Question · JavaScript and React course · Module 16: Error Handling and Suspense

try/catch in React

Why doesn't a standard try/catch catch rendering errors in child components?

Answer options

  • Because React intentionally blocks the use of try/catch in components
  • Because try/catch doesn't work in JavaScript ES6+
  • Because try/catch only works in Node.js, not in the browser
  • Because React renders components declaratively - JSX creates a UI description processed later, not executing code in place

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