React Learning Journey — Understanding useState
As I continue learning React, one of the first concepts that made React feel truly interactive was the useState Hook.

React Learning Journey — Understanding useState
As I continue learning React, one of the first concepts that made React feel truly interactive was the useState Hook.
Before learning React, I was used to displaying static data on a webpage. But modern web applications constantly change based on user actions. Counters increase, forms update, notifications appear, and data changes dynamically. This is where state management becomes important.
What is useState?
The useState Hook allows React components to store and manage data that can change over time.
When the state changes, React automatically updates the user interface to reflect the new data.
A simple example looks like this:
import { useState } from "react";
function Counter() {
const [count, setCount] = useState(0);
return (
<div>
<h2>{count}</h2>
<button onClick={() => setCount(count + 1)}>
Increase
</button>
</div>
);
}
export default Counter;
Understanding the Syntax
const [count, setCount] = useState(0);
Here:
countis the current state value.setCountis the function used to update the state.0is the initial value.
Whenever setCount() is called, React updates the state and re-renders the component.
Building a Simple Counter
The counter example helped me understand how React responds to user interactions.
When the button is clicked:
setCount(count + 1);
The state value increases by one.
React then automatically updates the displayed value on the screen without manually changing the DOM.
This felt very different from traditional JavaScript approaches and showed me why React is so popular for building interactive user interfaces.
Why useState is Important
The useState Hook is useful whenever data needs to change during the lifetime of a component.
Some common examples include:
- Counter applications
- Form inputs
- Toggle buttons
- Theme switching
- Showing or hiding elements
- Managing fetched data
Without state, applications would remain mostly static.
My Learning Reflection
Learning useState was an important step in my React journey because it helped me understand how React handles dynamic data and UI updates.
At first, the syntax looked a little confusing, but after building a few simple examples, the concept became much clearer. Seeing the UI update automatically whenever the state changes was one of those moments where React started to make sense.
There is still a lot more to learn, but understanding useState has given me a stronger foundation for building interactive React applications.
Conclusion
The useState Hook is one of the most fundamental concepts in React. It allows components to remember information, respond to user actions, and update the interface dynamically.
For beginners learning React, building small projects like counters is a great way to understand how state works before moving on to more advanced topics.
Every small concept learned today becomes part of a bigger React journey tomorrow.
메타데이터
- post_id
- 907fcbf89a86
- slug
- react-learning-journey-understanding-usestate-907fcbf89a86
- url
- https://medium.com/@jm.dilusha.lakshan/react-learning-journey-understanding-usestate-907fcbf89a86
- canonical_url
- https://medium.com/@jm.dilusha.lakshan/react-learning-journey-understanding-usestate-907fcbf89a86
- author_url
- https://medium.com/@jm.dilusha.lakshan
- status
- ok
- fetched_at
- 2026-06-09 15:37:30