React · Exercise 1 of 5Next
Beginner
Show comments as text, not HTML
This comment list renders each comment with dangerouslySetInnerHTML, so a comment containing HTML becomes real elements. One comment proves it: it logs this would have run (a harmless stand-in for an attacker's code).
Change Comment so the text is shown exactly as typed, as plain text, with no raw HTML anywhere. Keep the <p className="comment"> element for each comment and keep the author in a <strong>.
What Check tests
- All three comments are shown
- No element was created from a comment's HTML
- The HTML shows as typed text
- Nothing ran from a comment
- No
dangerouslySetInnerHTMLleft
Stuck? One hint at a time
The solution unlocks after your first Check. Try first: that is where the learning happens.
Runs in your browser. Your code is saved here.
Your page
Press Run to see the page.
Console
Nothing logged yet.