2

Before React 16, class components were used over function components whenever there is a need to use state or lifecycle methods in your component.

In the latest release react introduced Hooks and Effects using which we can use state and lifecycle methods inside our function components.

So is there any reason why still the class components exist? Is there any cases we still have to choose class components over function components?

0

1 Answer 1

4

Here you can see the cases where you will need class components

The most common case where you will need class components is if you want to make an ErrorBoundary, you will need a class component because you can't implement componentDidCatch with hooks... yet!

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.