What is state
📖 Scenario: You want to build a simple React component that shows a number on the screen. This number can change when you click a button. To do this, you need to keep track of the number inside the component. This is called state.
🎯 Goal: Create a React functional component that uses state to store a number. Add a button that, when clicked, increases the number by 1. The number should update on the screen each time you click the button.
📋 What You'll Learn
Use React functional component
Use the useState hook to create a state variable called
countInitialize
count to 0Add a button with an
onClick event that increases count by 1Display the current value of
count in a <div>💡 Why This Matters
🌍 Real World
Tracking user interactions like clicks, form inputs, or toggles in a web app.
💼 Career
Understanding state is essential for building interactive React applications used in many web development jobs.
Progress0 / 4 steps