epicweb-dev / react-hooks

Learn React Hooks! 🎣 ⚛
https://hooks.epicreact.dev
Other
2.78k stars 1.91k forks source link

ErrorBoundary seems to not work with development mode #146

Closed minhnguyen-paidy closed 3 years ago

minhnguyen-paidy commented 3 years ago

I'm working on exercise 6 with error boundary and even though my code is exactly the same as yours, it doesn't work. I still see a crashing error.

Screen Shot 2021-08-22 at 20 26 16

I did a little research and seems like ErrorBoundary only works in production mode. In development mode, the red screen will still be shown for easier debugging.

If this is correct then I think it would be great if you can adjust the code template for exercise 6 or adding some notes there.

kentcdodds commented 3 years ago

The view that you're looking at there is not the error boundary. It's a special iframe that Create React App adds during development. If you press the little x at the top right of the page, you'll see what the app would look like in production.

If you want to make a pull request to add a link to this issue and explanation, then that would be welcome :)