Error Boundaries with shouldComponentUpdate method?
See original GitHub issueI’m using this code from here: https://reactjs.org/blog/2017/07/26/error-handling-in-react-16.html
import React from "react";
class ErrorBoundary extends React.Component {
constructor(props) {
super(props);
this.state = { hasError: false };
}
componentDidCatch(error, info) {
// Display fallback UI
this.setState({ hasError: true });
// You can also log the error to an error reporting service
logErrorToMyService(error, info);
}
render() {
if (this.state.hasError) {
// You can render any custom fallback UI
return <h1>Something went wrong.</h1>;
}
return this.props.children;
}
}
and I got this error:
[eslint] Component is not optimized. Please add a shouldComponentUpdate method. (react/require-optimization).
What I should do?
I should add this?
shouldComponentUpdate() {
return true;
}
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Error Boundaries with shouldComponentUpdate method?
and I got this error: [eslint] Component is not optimized. Please add a shouldComponentUpdate method. (react/require-optimization).
Read more >Error Boundaries - React
Error boundaries are React components that catch JavaScript errors anywhere in their child component tree, log those errors, and display a fallback UI...
Read more >How Error Boundaries work in React? - eduCBA
In react js the React Error Boundary allows us to handle errors, it helps our components from getting corrupt because of error in...
Read more >ReactJS getDerivedStateFromError() Method - GeeksforGeeks
This method is used to implement the Error Boundaries for the React application. It is called during the render phase, so side-effects are...
Read more >Working with React Components - Simple Talk
The ShouldComponentUpdate() lifecycle method has the following signature: ... An error boundary has the following lifecycle methods:.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I’d just disable the rule; i don’t know why we included it in the first place.
The rule is still there…
It disappear only if I put this: