DEV Community

Discussion on: React: class components vs function components

Collapse
 
mrmannu profile image
mrmannu

In class components, the render method will be called, whenever the state of the components changes. On the other hand, the Functional components render the UI based on the props. Class Components should be preferred whenever we have the requirement with the state of the component. best regards upflixapk.com/
First of all, the clear difference is the syntax. Just like in their names, a functional component is just a plain JavaScript function that returns JSX. A class component is a JavaScript class that extends React. Component which has a render method.

Collapse
 
standelethan profile image
Ethan Standel

Have you not heard of the React hooks model? React apps haven't needed classes for stateful components since mid 2017.