There are two ways to create React components, using functions or classes. A common question when learning React is often “When do I use which?” Luckily, this is a question that might eventually become obsolete with the release of React version 16.8 as it includes hooks.
Hooks provide a way to use functionality such as state and context that could only be achieved through classes previously to be easily done with functional components.
In this blog, we’ll introduce React hooks and show some code examples of those hooks in action. Specifically, we will take a simple class component and convert it to a function with hooks, have an in-depth look at hooks useState and useEffect, and create a custom hook. Let’s get started!