Cindy Ord/Getty Images J.K. Rowling has defended the decision to cast Noma Dumezweni as Hermione in the upcoming "Harry Potter" play.

"Harry Potter" author J.K. Rowling has a strong message for the “bunch of racists” who’ve criticized the decision to cast a black woman to play the character of Hermione Granger: Back off.

In an interview with The Observer, Rowling said Noma Dumezweni, who will play the beloved character in the upcoming West End play “Harry Potter and the Cursed Child,” was chosen for the role because of her talent.

“With my experience of social media, I thought that idiots were going to idiot,” Rowling said. “But what can you say? That’s the way the world is. Noma was chosen because she was the best actress for the job.”

We’re thrilled to confirm Jamie Parker, Noma Dumezweni & Paul Thornley will play Harry, Hermione & Ron #CursedChild pic.twitter.com/s1rsDbrXMO — Harry Potter Play (@HPPlayLDN) December 21, 2015

The casting decision was first announced in December. At the time, the news prompted criticism from some fans who asked why “white Hermione” was going to be played be a black actress.

@HPPlayLDN Not being racist but how can a black woman play Hermione? This play has lost all credibility. — Agent S(ean Bassett) (@WhoPotterVian) December 21, 2015

i'm offended by the casting of #CURSEDCHILD hermione is a white character. we may not make poc characters white so white should not be poc — michelle (@1006michelle) December 20, 2015

@Hypable why would they make Hermione black?! So damn stupid — Daisy Ann The Only (@DawsonTheCanoe) December 21, 2015

British actress Emma Watson, who is white, played the role of Hermione in the “Harry Potter” films. However, as Rowling herself stressed, Hermione’s race and skin color were never actually specified in the books.

Canon: brown eyes, frizzy hair and very clever. White skin was never specified. Rowling loves black Hermione 😘 https://t.co/5fKX4InjTH — J.K. Rowling (@jk_rowling) December 21, 2015

Speaking with The Observer, Rowling responded to critics who claimed Hermione must be white because she “turned white from shock” in one of the books.

“I had a bunch of racists telling me that because Hermione ‘turned white’ -- that is, lost color from her face after a shock -- that she must be a white woman, that I have a great deal of difficulty with,” Rowling said. “I decided not to get too agitated about it and simply state quite firmly that Hermione can be a black woman with my absolute blessing and enthusiasm.”

“Harry Potter and the Cursed Child,” directed by Tony Award winner John Tiffany, is set 19 years after Harry defeated Voldemort as a teenager. The show will open at the Palace Theater in London at the end of July. Previews for the play begin on Tuesday.