"Hooks embrace JavaScript closures and avoid introducing React-specific APIs where JavaScript already provides a solution."
- React website
In the previous sections, we covered different concepts of React, but we only provided examples for class components. While doing so, we kept repeating that hooks are enablers for the same functionality in function components. But what exactly are hooks and what is their purpose? Let's find out!
In the past, React class components were comparatively more powerful than function components: they could have an internal state, could hook into the lifecycle, and so on. Function components on the other hand, did not have equivalent APIs. The only way to use some features was to convert the concerned function components into class-based ones. This was clearly not ideal.
React hooks were introduced to fill that...