Hooks were brought out to allow programmers to use state — amongst other things — within a functional component, doing away with traditional class based components. As a side — bonus it also made React more accessible to learn.

Hooks are great, they’re backwards compatible, really easy to use and they speed up development. Below i’ve given an example of a class based component that uses a counter to update the state. You can see that it’s quite a lot of code for what is effectively, a component that add’s or subtracts 1 to the counter object in state.


Nathan Leadill

CTO at Templar Payments, but really I'm just a glorified Javascript developer.

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