Skip to content
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 unhandled? #12262

Closed
TanninOne opened this issue Feb 21, 2018 · 2 comments
Closed

componentDidCatch unhandled? #12262

TanninOne opened this issue Feb 21, 2018 · 2 comments

Comments

@TanninOne
Copy link

Do you want to request a feature or report a bug?

Not sure tbh.

What is the current behavior?

I have global handler for unhandled errors:
window.addEventListener('error', (evt) => ...)

Now when I use the componentDidCatch function it gets called correctly when render throws an exception but that global error event is also triggered - and before the componentDidCatch call.

What is the expected behavior?

Since componentDidCatch handles the error I'd prefer if the global event wasn't triggered, same as with a usual try-catch block.

Or is there at least some way to figure out from the evt object in the event handler that the exception is caught by react?

I hope this made sense...

@gaearon
Copy link
Collaborator

gaearon commented Feb 21, 2018

I think this is a duplicate of #10474.

@gaearon gaearon closed this as completed Feb 21, 2018
@TanninOne
Copy link
Author

You are right and the suggestion there worked as well. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants