Are React class components going away?

 by Robin Wieruch
 - Edit this Post

After I rewrote my book The Road to React with React Hooks using instead of class components, aspiring React beginners always ask me whether React class components are going away. I always give them the same short answer, however, I thought it would be good to have this brief explanation here as well.

Yes, React class components will fade away in the future. If you want to embrace modern React, then you should use function components with . That's why you will find most tutorials out there teaching modern React and no class components anymore.

However, if your "legacy" React project still uses , there is no need to panic. Class components are not going really away -- as team members from the React team stated -- because they are still widely used in many React projects. The project with the largest usage of React class components may be Facebook itself. So until there is some kind of codemod to automatically, there will be support for class components. What may be happening though is that React class components will get extracted into their own library eventually.

In conclusion, if you are favoring class components over function components with hooks, you are still good to use them. However, keep in mind that using .

Keep reading about 

React Hooks were introduced to React to make state and side-effects available in React Function Components. Before it was only possible to have these in React Class Components; but since React's way…

React Hooks were introduced at React Conf October 2018 as a way to use state and side-effects (see lifecycle methods in class components) in React function components. Whereas function components…

The Road to React

Learn React by building real world applications. No setup configuration. No tooling. Plain React in 200+ pages of learning material. Learn React like 50.000+ readers.

Get it on Amazon.