State is a built-in React object that allows components to hold and manage their own dynamic data. Unlike props, which are passed down and read-only, state can change within the component over time.
State makes your components interactive. For example, a button click can update the state, causing the component to re-render with new data — all without refreshing the page.
Here, the useState
hook initializes count
at 0. Clicking the button calls setCount
to update the state, which triggers a UI update.
useState
for simple state management, and explore useReducer
or external libraries for complex states.
Help others discover Technorank Learning by sharing your honest experience.
Your support inspires us to keep building!