News for hackers. Stuff that matters.
Re:Error Handling in React 16 by hungerstrike on Wednesday July 26, 2017 @10:10PM (#14862134)
Why not let components catch their own errors?
Re:Error Handling in React 16 by danabramov on Thursday July 27, 2017 @06:12AM (#14863955)
* It's not very useful to write error handling code in every component. The thinking about the feature is you'll put it in a few strategic places: https://facebook.github.io/react/blog/2017/07/26/error-handl...

* If error boundary could catch its own errors, what happened if it tried to render error message and threw then? It would get into an infinite loop, trying to handle its own error and failing again. Thanks to the restriction, this can never happen.

Re:Error Handling in React 16 by mattashii on Thursday July 27, 2017 @03:37AM (#14863358)
When a component throws, it means the user's code has encountered an unexpected error. That means the component is in an unexpected state, and you cannot reasonably say that that component can rebuild it's (internal) state to a stable (and renderable) state.
Re:Error Handling in React 16 by rtpg on Thursday July 27, 2017 @04:10AM (#14863489)
but in theory at that point in the operation, we're still in the process of building a new DOM (hence the old DOM is still around)? So you could replace the component with an error node and during the diffing process replace with the old node?

Not great but if you hit a fatal error you hit a fatal error

Re:Error Handling in React 16 by beaconstudios on Thursday July 27, 2017 @05:46AM (#14863821)
personally I would rather a website tell me that an error occurred using the new mechanism than fall back to a previous version of the DOM and have me wondering why clicking that button isn't doing anything.
Re:Error Handling in React 16 by acjohnson55 on Thursday July 27, 2017 @03:20AM (#14863278)
If you package this up as a higher-order component, you basically get this behavior. It would be pretty easy to do. But I think the way they designed it is smart. You want components that account for very granular concerns, and then compose them together to get more complex behavior.