Command Palette

Search for a command to run...

Hectal
Phase 21: Security in React Apps
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

  1. All three comments are shown
  2. No element was created from a comment's HTML
  3. The HTML shows as typed text
  4. Nothing ran from a comment
  5. No dangerouslySetInnerHTML left

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.