Harry Potter author J.K. Rowling on Monday hit out at the “bunch of racists” who criticized the decision to cast Swaziland-born actress Noma Dumezweni as Hermione in the eagerly-awaited play “Harry Potter and the Cursed Child.” Hermione, described in the books as “the brightest witch of her age,” was portrayed by British actress Emma Watson in the eight Harry Potter movies.

“I had a bunch of racists telling me that because Hermione ‘turned white’ — that is, lost colour from her face after a shock — that she must be a white woman, which I have a great deal of difficulty with. But 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,” Rowling told the Observer.

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

The Observer article also quoted the play’s director John Tiffany as saying he was “shocked” that “people couldn't visualise a non-white person as the hero of a story.”

“I am not as Twitter-familiar as Jo ... so I hadn’t encountered its dark side, which is just awful,” Tiffany said.

Last year, after Dumezweni’s casting was announced, it triggered a fierce debate over Granger’s ethnicity, with many accusing the play’s creators of deviating from the books in the interest of “political correctness.”

At the time, Rowling gave her stamp of approval to the choice of casting, stating that the canon never specified that Granger had white skin.

The two-part play, based on an original new story by Rowling, Tiffany and Jack Thorne, will be the first official Harry Potter story be presented on stage when it begins previews at London’s Palace Theatre on Tuesday. The story picks up the plot years after the events in the seventh book “Harry Potter and the Deathly Hallows” unfold, and follows Potter — who is now “an overworked employee of the Ministry of Magic, a husband and father of three school-age children” — and his friends Ron and Hermione.