Can I stop using classes in my React App now?
For the most part, yes.
While React Hooks simplified component development, there are a couple of component methods that are not fully replaceable. These relate to Error Boundaries
Error Boundaries
Error Boundaries are Container components that prevent any errors from affecting anything outside its children’s scope. Without this, an uncaught exception in a component can propagate all the way up your component tree and produce an ugly error state on the browser. Error Boundaries are very useful to isolate problems inside a certain scope in your application.
The two lifecycle methods that are related to Error Boundaries are:
- componentDidCatch(error)
- getDerivedStateFromError(error)
There are no hooks equivalents to these methods. Error boundaries are very useful and essential in large apps. The good news is that ErrorBoundaries are far and few and you can develop them as very generic class components and reuse them in your app. According to this, React team is already working on it.