DEV Community

Ushahemba Shir
Ushahemba Shir

Posted on

React. Functional vs class components

0

Is it possible to use both Functional and Class Components in a single React App?. I am building a website UI with React, back end has been build with NodeJS. The templates I am using was build with Class Components where they new Components I am introducing are Functional with Context API's. Can they work together or is it necessary I convert all the Class Components to Functions?.
https://stackoverflow.com/questions/63359346/react-functional-vs-class-components

Top comments (1)

Collapse
 
mehtanilay10 profile image
Nilay Mehta • Edited

Yes, you can!
I was using functional components when there is no state/context requirements in components. If required then use class components.
But with introduction of Hook, We can use functional components for both requirements.