-
Notifications
You must be signed in to change notification settings - Fork 46.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Component Lifecycle Error Handling #9865
Comments
Hi @matthew-rister, Version 15 introduced a new experimental error boundary feature (basically a try/catch for the component tree). That feature has been improved significantly for the upcoming version 16 (currently available as an alpha if you're interested in trying it). If an error occurs in render or a component lifecycle method, React looks up the tree for the nearest ancestor (component) that define a method The test code for this feature is here if you're interested in learning more about how it works. I'm going to close this issue for now since it seems to overlap highly with this existing feature. 😄 |
Thanks @bvaughn, It's great to see that there is already work going on in this space and kudos for writing entertaining test cases :) Matt |
I would add that those tests are pretty old and describe the feature as it's supported in 15 (only a few cases work). The support in React 16 is much more comprehensive and is described in these tests: https://github.com/facebook/react/blob/master/src/renderers/__tests__/ReactErrorBoundaries-test.js |
Whoops. Thanks Dan. I didn't mean to link to the version of the test in 15-stable. |
Greetings React team,
Let me start off by saying that I am a big fan of the work your team is doing and keep up the good work. With that said, one of the major disadvantages of React is that it sort of throws up when an exception is thrown in one of the lifecycle methods (i.e. null or undefined reference). Although this is ultimately up to the developer to ensure proper error handling, I was wondering if you would consider adding some additional component lifecycle method for catching unhandled exceptions (i.e. componentDidFail). From a developer perspective, this would make my life so much easier and really help to improve the quality of the applications I produce.
Matt
The text was updated successfully, but these errors were encountered: