Problem Statement
What is useState() and how does it work?
Explanation
useState() is a Hook that allows you to add state to functional components. It returns an array with the current state and a function to update it. When you call the setter function, React re-renders the component.
Code Solution
SolutionRead Only
const [name, setName] = useState('Guest');
setName('John'); // updates state and re-renders component