On Monday night's episode of Dancing With the Stars, Evanna Lynch, known for her role as Luna Lovegood in the Harry Potter franchise, opened up about how she battled an eating disorder while starring in the films.

During the episode, the 27-year-old shared with her dance partner, Keo Motsepe, that she struggled with an eating disorder from ages 11 to 12, just as she was cast as Luna.

Actors Evanna Lynch, (L) Rupert Grint, (...pinterest
SHAUN CURRY//Getty Images
From left: Evanna Lynch, Rupert Grint, Emma Watson, Daniel Radcliffe and Katie Leung.

"Anyone who's had an eating disorder knows it completely takes over your life, and the only thing that could actually take my attention apart from that was the Harry Potter series," Lynch said.

In 2016, Lynch first opened up to The Irish Times about her battles with anorexia nervosa, revealing she spent up to two years in clinics starting in 2006.

“I didn’t plan for an eating disorder," Lynch said at the time. "But I soon found that it was a way of getting attention that I could control. People would say, 'Aren’t you amazing that you exercise so much?' I was hungry all day, cold all day. But the punishment made me feel worthy.”

Harry Potter And The Order Of The Phoenixpinterest
Antony Jones//Getty Images

On Dancing With the Stars, Lynch told Motsepe just how much Harry Potter creator J.K. Rowling was involved in her recovery. She revealed that the author would write her letters while Lynch was in and out of the hospital.

"Her books and her kindness really made me want to live again," Lynch said. "I loved the feeling of creating and acting, more than I loved the feeling of being skinny or of being perfect."

Lumos Fundraising Event Hosted By J.K. Rowlingpinterest
David M. Benett//Getty Images

To pay tribute to her time in the iconic films, Lynch danced a Viennese Waltz to the Harry Potter theme song, "Hedwig's Theme" by John Williams. She scored an impressive 27 out of 30 for the performance.

RELATED VIDEO:

preview for These Cupcakes Can Tell You Which House You Belong In