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
ErrorBoundary rendering multiple copies of itself when ref assignment fails #16365
Comments
Is this a new bug? |
Flipping through the versions on that sandbox, it first appears in |
Is this issue still opened ? If so I'll have a try. |
@gaearon Mind if I take this up? |
Shouldn't you be using class ErrorBoundary extends React.Component {
state = { err: null };
static getDerivedStateFromProps(err) {
return { err };
}
// componentDidCatch = err => this.setState({ err });
// ^ This should only be used for side effects. E.g logging errors etc
render() {
return (
<div className="boundary">
{this.state.err ? <span>error</span> : this.props.children}
</div>
);
}
} |
Ideally both should work but I just tested See https://codesandbox.io/s/recursing-dawn-l029b for the |
Do you want to request a feature or report a bug?
bug
What is the current behavior?
When a error occurs during the assignment of a
ref
(and maybe other conditions), a error boundary wrapping that error may get confused and it renders itself multiple times inside the same parent. See https://codesandbox.io/s/stoic-fermi-6etqb which renders:What is the expected behavior?
The text was updated successfully, but these errors were encountered: