DEV Community

Discussion on: Basic React Component Layout

Collapse
 
marzelin profile image
Marc Ziel

The main advantage of function components over class components is code collocation. You can have all code for a given feature in one block of code and not spreaded over different lifecycle methods. When you need to use a feature in more than one component, you can just create a custom hook with all the code needed for a given feature.

The easiest way to differentiate between the two is that class components use classes and function components use functions (the hint is in the name ;).