useState
A Hook that lets you add React state to function components.
Before the
useState
hook was introduced, state management is used to handle through the class components.
Now, the useState hook can be used in functional components which serves the same purpose as
this.state
/this.setState
in class components as shown above.
using the useState hook, any type of state variable can be declared.
the hook can also be used multiple times in a single component.
Last updated