Question · JavaScript and React course · Module 10: React Ecosystem and Future

Input Data Sanitization

When in React do you NEED to sanitize user input using a library like DOMPurify?

Answer options

  • Never - React automatically sanitizes all data
  • Always, for every input field in a form
  • Only for login and registration forms
  • When using dangerouslySetInnerHTML or displaying HTML from an untrusted source

You can check the correct answer by solving this task in the CodeWorlds game.