Deciding between Class and Functional Components

Functional Component:

These can be thought of as pure functions, as they always behave the same (with the same props).

Class Component:

Since this is a class, you will need a this in front of props each time you implement props, or state.
There is a way to fetch data from an api with useEffect and other React Hooks, but for the purposes of this post I provided a simpler example. Refer to this post if you want to understand how.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store