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

Error from component causes error to be thrown twice #10779

Closed
guyfedwards opened this issue Sep 22, 2017 · 3 comments
Closed

Error from component causes error to be thrown twice #10779

guyfedwards opened this issue Sep 22, 2017 · 3 comments

Comments

@guyfedwards
Copy link

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

What is the current behavior?
If a component throws not in render, for example in a click handler, the error is thrown twice instead of once. Error boundaries stop the double reporting, but only handle errors thrown in render, not errors in handlers etc.

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem via https://jsfiddle.net or similar (template: https://jsfiddle.net/ebsrpraL/).
https://codepen.io/anon/pen/GMjEpx?editors=0010

What is the expected behavior?
Just one error thrown

Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?
16.0.0-rc.2

@gaearon
Copy link
Collaborator

gaearon commented Sep 22, 2017

Error boundaries don’t (currently) catch errors coming from event handlers. The blog post goes into more detail about this:

Error boundaries catch errors during rendering, in lifecycle methods, and in constructors of the whole tree below them.

@guyfedwards
Copy link
Author

Thats ok but the error still seems to be rethrown resulting in two errors being caught in window.onerror

@gaearon
Copy link
Collaborator

gaearon commented Sep 22, 2017

This seems like the same discussion as #10474.

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