The React useState
Hook allows us to track state in a function component.
State generally refers to data or properties that need to be tracking in an application.
Import useState
To use the useState
Hook, we first need to import
it into our component.
Example:
At the top of your component, import
the useState
Hook.
import { useState } from "react";
Notice that we are destructuring useState
from react
as it is a named export.
To learn more about destructuring, check out the ES6 section.