Introduction

Let's have a look at how to use the state and lifecycle methods inside function components.

Hooks are a completely new and novel concept introduced in React 16.8.0. Many React Core developers have already described Hooks as one of the most exciting and fundamental shifts in React. Indeed, Hooks were making waves at the 2018 React Conf where they were first announced—before their introduction in the React 16.7 alpha release. Other frameworks have even followed suit and implemented their own version of Hooks. But what are Hooks exactly?



What are Hooks?

Hooks allow us to use certain mechanisms in function components that were only available to class components in the past. Features such as setState or lifecycle methods such as componentDidMount() or componentDidUpdate()—which used to be reserved entirely for ...