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

New rule: react-no-throw-in-lifecycle #48

Closed
adidahiya opened this issue Dec 15, 2016 · 2 comments
Closed

New rule: react-no-throw-in-lifecycle #48

adidahiya opened this issue Dec 15, 2016 · 2 comments

Comments

@adidahiya
Copy link
Contributor

some good advice from @crazytoucan (abridged):

Sometimes your whole app crashes, because of a single React component that threw: maybe render() tried to map an array that was undefined, or WillMount() tried to talk to a service that threw internally
...
there’s ultimately no reliable way to recover from a crashed component as a library or utility.
...
Simply put, you should never throw inside your React lifecycle methods. If this means a little bit of extra defensive programming, I think component resilience is a worthwhile cost. Don’t litter code with unnecessary invariant checks ...

We should look into a lint rule that can enforce this.

@OzairP
Copy link

OzairP commented Dec 10, 2018

Not needed in React 16 due to Error Boundary

@adidahiya
Copy link
Contributor Author

Closing due to old age and deprecation timeline #210

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

No branches or pull requests

2 participants