useState is a hook that returns a state variable and a state setter. The state is initialized with the argument passed to the useState hook.
const [count, setCount] = useState(0);
In the above example useState returns 2 things setCount which can only be used to set the count state variable. The count variable cannot be set directly, that’s why we need to use the setter. The setter won’t set the state if the new state is identical to the old state, therefore, skipping rerendering of the component.