What is the purpose of the `useState` hook in React?
useState is a React Hook that lets you add a state variable to your component.
The `useState` hook allows functional components to add stateful behaviour by providing a way to declare and update state variables.
It returns a state variable and a function to update it, enabling components to re-render when the state changes.
initialState: The value you want the state to be initially.
It can be a value of any type, but there is a special behaviour for functions.
This argument is ignored after the initial render.
If you pass a function as initialState, it will be treated as an initializer function. It should be pure, should take no arguments, and should return a value of any type.
React will call your initializer function when initializing the component, and store its return value as the initial state.
useState returns an array with exactly two values:
The current state. During the first render, it will match the initialState
The set function lets us update the state and trigger a re-render. set functions do not have a return value.