Jennifer Lopez is sharing the real importance of sleep.

In the latest edition of her On The JLo newsletter, the “Marry Me” star opens up about her struggles with getting enough sleep early in her career, leading to panic attacks.

“There was a time in my life where I used to sleep three to five hours a night. I’d be on set all day and in the studio all night and doing junkets and filming videos on the weekends,” she said. “I was in my late 20s and I thought I was invincible.”

READ MORE: Jennifer Lopez Details Why Her And Ben Affleck’s Relationship Was ‘Destroyed’ In 2004

Things changed for her, though, when the stress and exhaustion from that lack of sleep led her to have a terrible panic attack.

“I was sitting in a trailer, and all the work and the stress it brought with it, coupled with not enough sleep to recuperate mentally, caught up with me,” Lopez recalled. “I went from feeling totally normal, to thinking about what I needed to do that day and all of a sudden I felt as if I couldn’t move.”

Describing being “completely frozen,” Lopez wrote, “I couldn’t see clearly, and then the physical symptoms I was having started to scare me, and the fear compounded itself. Now I know it was a classic panic attack brought on by exhaustion, but I had never even heard the term at the time.”

Eventually she had her security guard drive her to a doctor.

“I thought I was losing my mind. I asked the doctor if I was going crazy,” she said, and the doctor gave her advice that changed her life: she needed seven to ten hours of sleep each night, and should avoid drinking caffeine while making sure to work out.

READ MORE: Jennifer Lopez Gives Fans A Look At Some Of The Highs And Lows Of Her Career In New Trailer For Netflix Doc ‘Halftime’

“I realized how serious the consequences could be of ignoring what my body and mind needed to be healthy — and that’s where my journey to wellness began,” Lopez said of that straightforward advice.

“I think of sleep like a little time machine,” she added. “You lay down and you go into a space where you preserve yourself and then you come out a new, younger person than you were before.”

Finally, Lopez said, “Sometimes I wake up and say, ‘Wow! I just lost 10 years off my face!’ That’s what a good night’s sleep can do for you, and it accumulates over time.”