useState is a built-in React Hook that lets you add and manage state in functional components.
It returns a pair: the current state value and a function to update it.
Stateful Value & Setter
Initial State
The argument you pass to useState becomes the initial state on the first render.
You can also pass a function to lazily compute a heavy initial value:
Immutable Updates & Batching
Functional Updates
If the new state depends on the previous one, pass a function to the setter:
Ensures you always update based on the latest value, avoiding stale closures.
Multiple State Variables