-
Notifications
You must be signed in to change notification settings - Fork 47.6k
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
componentDidCatch not fired as expected #11415
Comments
Please create a minimal reproducing example. We get new issues every day. If we had to spend an hour trying to reproduce every issue, we wouldn't have any time left for development. :-) Here's a good guide to doing just this: |
(To clarify, the published demo is helpful. I didn't notice the link at the top at first. But we would still appreciate if you could extract the part that doesn't work and show it in a simpler environment, without router / libs / TypeScript / etc) |
Thanks for fast response! Will try to do some additional research then, gradually removing libs and ts. Maybe some of them cause problem. |
You can also try in the opposite direction, starting with a fiddle and adding two or three minimal components there. |
All states working except componentDidCatch:
Package:
|
@felansu componenetDidCatch will trigger only on lifecycle methods and render , in your example you try to throw the exception inside an event handler "makeError" , here is the documentation: https://reactjs.org/docs/error-boundaries.html#how-about-event-handlers. |
what is wrong with the fiddle? , there the componenetDidCatch is triggered because the error happened in the render function not in an event handler. |
@idhard Yes, now is working. |
Few months ago i decided that it would be great idea to copy react.js and react-dom.js from node modules into dist folder so they'll be near index.html without ugly paths, safe and warm. Epic plan, except they didn't update since then 🤣 God i feel so stupid. Minimal example works, going to try update on source code. Conclusion: better not conserve libs in old-fashion manner, but pull them from node_modules like in TS guide for example. Thanks for your time @gaearon! Will try to be more careful next time 👍 |
hello guys! I try to build custom blog app and here is the branch with below mentioned issue.
The issue:
can't bring to live my ErrorBoundary though, doing everything like it is described in react 16 docs... Debugging shows that componentDidCatch is never called on errors (not synthetic new Error, nor real ui errors).
I use ErrorBoundary in my Navigation component
Here's ErrorBoundary component:
And Blog component that is bugged natural way 😃. Here's code that cause render bug in runtime:
Also i did try:
and every time exatly the same effect - componentDidCatch not fired 😞
Expected behavior:
componentDidCatch fired when any of child component can't render properly due to unhandled exception, like it described in docs.
Project technology stack:
My package.json.
The text was updated successfully, but these errors were encountered: