Abhishek Ganotra
Abhishek Ganotra

Reputation: 58

How to perform Error Boundary using React Hooks

I am trying to look for some predefined hooks that could be used for Error Boundary for my React Application. I don't want to use any external library support, so is there any way out for that since useEffect does not replace componentDidCatch.

Upvotes: 2

Views: 3149

Answers (1)

It's not yet possible to create Error Boundary components with hooks: https://reactjs.org/docs/hooks-faq.html#do-hooks-cover-all-use-cases-for-classes.

You'll have to write your Error Boundary component using an old-fashioned class component.

Upvotes: 4

Related Questions