The useState hook lets you add state to functional components.
π Example:
const [count, setCount] = useState(0);
πͺ Update state easily:
<button onClick={() => setCount(count + 1)}>
Count: {count}
</button>
β¨ Key Points:
β’ Returns [value, setter]
β’ Re-renders component when state changes
β’ Use callback form β setCount(prev => prev + 1)
useState = Simplicity + Power πͺ
Top comments (0)