🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: XSS: all 10 questions

Quiz: XSS · Question 3 of 10

In React, which is dangerous with user input?

In React, which is dangerous with user input?

  1. A.{comment.text}
  2. B.dangerouslySetInnerHTML={{ __html: comment.text }}
  3. C.<p>{comment.author}</p>
  4. D.useState(comment.text)
Answer & explanation

Correct answer: dangerouslySetInnerHTML={{ __html: comment.text }}

React escapes {...} automatically; dangerouslySetInnerHTML inserts raw HTML.

Can you get the rest right without peeking?

Take the timed Quiz: XSS quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →