Learn React 19 useActionState Hook from scratch with a real practical example! 🚀 In this React 19 tutorial, we will understand what useActionState is, why React introduced it, how it simplifies async Actions and forms, and how it compares with the old React approach.
We will start with an interesting history of useActionState, understand the old vs new syntax, and then build the same functionality first using the traditional React approach and finally using the new React 19 useActionState Hook.
✅ What is useActionState in React 19? ✅ Why do we need useActionState? ✅ React old approach vs React 19 approach ✅ state, dispatchAction and isPending ✅ reducerAction and initialState ✅ How prevState works ✅ How FormData reaches an Action ✅ Async API requests with useActionState ✅ Error and pending state handling ✅ Real signup form example ✅ Frontend + backend data flow ✅ Running the complete React 19 application ✅ Why useActionState reduces manual state-management code
React officially describes useActionState as a Hook for updating state using Actions, and the current API exposes the latest state, an Action dispatcher, and pending status.
If you're learning React.js in 2026 or want to understand the latest React 19 features and hooks, this video will help you understand useActionState practically instead of only memorizing the syntax.
💬 What React 19 feature should I cover next? If any React 19 topic is confusing you, comment below. I'll try to cover it in an upcoming video.
⌛TIMELINE⏳ 00:00 Interesting Fact About useActionState 02:10 Must-Watch React 19 New Feature 02:25 Old vs New useActionState Syntax 03:50 React 18 Approach Explained – The Hard Way 07:00 Understanding the Data in the Older React Approach 07:50 useActionState in React 19 09:20 Understanding useActionState Syntax with console.log() 14:20 useActionState Explained with Real Code 22:05 Running the useActionState App & Seeing the Final Data
AI Generated·May contain errors
Video Summary
AI Generated
This video explores the `useActionState` hook in React 19, highlighting how it streamlines form handling and state management compared to React 18. By consolidating state, pending status, and action dispatching, the hook reduces boilerplate code and simplifies the developer workflow for handling asynchronous side effects.
Let's start with something interesting.
I would like to tell you that
In ReactJS stable version 18
You don't get to see
UseFormState and
UseActionState
It means that
Official hook for React version 19
Is your UseActionState
Which we are going to see today
Now, an important thing
React does not release any version
Directly as stable
Before becoming stable
First, they release it in
Canary version
After that, your release candidate
RCStage arrives
And then your stable version
Now, the story is
In React's Canary version
Finally, you get to see
UseFormState
Where? In the ReactDOM package
Basically, ReactDOM.useFormState
You have to see
In React version 19's
Canary version
And what was it returning?
It was returning your state
And a form action
At this point, if you see
You don't see any value in IsPending
Basically, it shows
Your action
Then comes
Your React version 19 release candidate
RCStage
Or Development Stage
Before reaching this stage
What did the React team do?
They renamed it.
To Use Action State
And their package
Was in ReactDOM
They moved it.
To React package
Now, the return value
You can see
State, form action
And finally, IsPending
And finally, when React 19
The stable version was released.
You can import
UseActionState
Inside your React package
And the return value
State, form action, and IsPending
You can see it like this
So guys, this was the journey
How a hook
Was renamed
Even the package
From ReactDOM to React
And an important property
Pending
So today
We are going to see this.
But before that
I uploaded a video
Two days ago
Where I discussed a new feature
Of React version 19.2
If you haven't checked it out
I thought about bringing a series
Where can I share
The new feature of React version 19
And the best part
I made a video about UseActionState
One year ago
And if you see here
This is the syntax
This is the UseActionState
Look carefully
What has changed in a year
This is the syntax from a year ago
But the current syntax
You can see
Something like this
Where the form action was written
Now they have changed.
They have changed it to dispatch action.
Which is correct
And then
If you see here
We have a simple function
But now they have named it
Reducer Action
InitialState and Permalink
So basically they've changed
The name of two things
There is no change in the inner part.
Once again
If you see
You can see the dispatch action
Then here
You can see a simple function
It's an action only
What is the reducer action?
So today
We have to see this.
Why do we need this?
Let me tell you
You can see here
I have not compromised.
I have built a full-stack website.
Where we have a login form
Registration form
Connected to the database
We have this backend
And version 18
I have submitted the same application.
Through versions 18 and 19
So
In version 18
If you create a sign-up form
And user sign up
What is the process?
To obtain the data
Filled by the user
If you see
We have created a state.
Then
If there is an error
We have taken a state
You can see
And one more thing
It's pending
You must display the loading animation.
When you submit the form
For a few milliseconds
You must demonstrate the action.
For that
We have to take 3 states
Then
This is my backend
API
Where are we forwarding the data?
Through the POST method
If everything is done
You have to use set error
In case there is an error
Otherwise
You must keep the data in set user
Don't worry, you'll get the idea of React widths 19
Then
Catch
We have a try catch
And finally
You have to use
Button stock forever
Finally, you have to use
Set error
And the set is pending
We have falsified
Why falsified?
If someone is submitting the form
In that function
We have kept the set pending
True
Yes.
To submit the data
And UI
To enhance the user experience
There was a way.
You had to use three states.
try, catch, block, and finally
If you forgot
There was a problem.
In normal form
The Name attribute is very important.
And you submitted the handle
In this way
You show the error at the end
In case everything is correct
You can show it
I will do one thing.
I will close it
I will go to React version 18
CD
Is there anything else?
NPM
Run and Deb
I will run version 18
It opens in VS Code.
I don't need it
I will paste it
I have pasted it.
You can see
I have entered the data.
I am signing up
Creating account
Is on hold for some time
You can see
In version 18
It worked like this
Where you had to use three states
This data
Is saved in my database
Don't worry
I thought I'd show you the data.
Then you will understand
If I refresh it
I have to describe it
Table
Users
I will enter it
See
I have written
Vinod 18
Today is the 14th.
11.11
My data is in version 18
With the help of React version 18
I have stored it.
You won't see any difference in the user interface.
User experience and UI
There is no difference.
The problem is when we were coding
See the way
How much we had to do
Now comes
React version 19
Where we will use
Use action state
I will show you
Reducer action
Initial state
Permalink
Unique URL
Let it be
It is returning an array.
With 3 elements
Current state
Dispatch action
Pending
Story
Pending
Change name
React version 18
Use form state
Where did it come from?
I will show you.
How to use it
Funda is very simple.
Initial state
You may assume
Its value
Initial state
Reducer action
This is a function
Like useReducer
We took action.
Whenever you call a dispatch action
It will trigger
This action
And finally
Inside this action
React provides form data
It provides form data
Important for us
How did it come about?
I will show you.
I have closed version 18.
I am going to
Version 19
This is my version 19
I am closing everything.
I am closing version 18
I am going to version 19
Here I have
A simple sum
And I have
Use action state
10
I want to show you
If I console this function
If I console
What I am getting
This will clear our doubt.
I am saving controller
This is yours
React version 19
I am going to console.
I am refreshing
If you see
You can see
Can you see?
Yes
Perfect
You can see
Use action state
If you console
You can see
It is returning an array.
With 3 elements
It is returning an array.
With 3 elements
You can see a value
10 and that's your initial state
Current state
This is not a
Normal function
This is not a function
This is an action
Form action
You can call it a dispatch action.
This is not a function
This is an action
You have to trigger it
So that you can obtain the form data
These are yours
IsPending value
Means
Is your action
Running or not
Now you know
Why in our syntax
Whenever we see
Use action state
You can see
These three values
Inside the array
If I console
I am getting
What was written in our syntax
Current state
Dispatch function
Or form action
You can call it
IsPending value
Current state dispatch action
Pending
State
Initial
Pending
Current state
Dispatch action
Pending
Now there is no doubt.
Clear
Where did this come from?
Come from
console.log
Now it's clear
How to use it
Very simple
Side by side comparison
So that you can understand
How easy it was
Before
Now
How it was before
Now
Respect
Our ancestors
Made this
Life is easy
We didn't see that.
Here as well
Version 18
If I show you
It was like
If I show you
Basically
I had to take three states.
I was using it three times.
But here
You must use only one hook.
And all the work
Will be done through this hook
Use action state
I told you
State dispatch action
Reducer action
Initial state
There is no need for a permalink
Here you can see
Form action and fn
Which is the dispatch action?
And reducer action
Only name change
Because
People thought
Use action state
Due to form action
They thought
It is designed to handle forms.
Later React Team
They thought
People only use it in form.
But it can manage side effects.
Like reducer
So
Make it general-purpose
Not only in one place
You can use it in multiple places
They changed the name.
How easy it is
Before
Now
You can see
You will get everything
How to use it
It is very simple
Comment it
We don't need this code
You have to write
Only one line
And your work will be done
We have one input.
Another input
The name attribute is important
And we have this button
On button
Disable is pending
How easy it is
Button
Pending
To make it
The set is pending
False
True
Nothing here
Nothing
I used it directly.
In button
If the action is running
Value is true
If true, the button is disabled.
You can see
Text for creating an account
You can add a loading animation.
If
Action completed
You can see the sign-up text
How easy it is
Then
We are not doing anything on submit
We are using the action attribute
Dispatch action
This action
Dispatch action
We passed it
When the button is submitted
What will happen
The dispatch action will call it
If the dispatch action is triggered
Use action state
Inside it
Reducer action
It will call it.
One thing
Reducer action
Outside my component
You can create it.
I said
Inside it
You will receive form data
Inside it
First
With the help of object.formentries
I got it.
Properly
I put it in the payload
I have already uploaded the video on it.
One thing
I made the world's best
JavaScript course
32 hours
Basic part
Advanced section
E-commerce website
Object part
Advanced
Go to object.formentries
You will know
Don't worry
Do not doubt
For you
Form data
Why I wrote it
In object.formentries
If I wrote
What I am getting
In payload
I know
I'm clearing it.
I entered both values.
In console.log
In payload
In object
Name, email, password
You are receiving data
When you have data
Pass backend
It will be stored in the database.
This is our
URL
Retrieve
API / sign up
If I go here
I will show you.
Our API
In backend
Server.js
I will show you.
You can brush up
If you alreadyposal
This is my URL
I'm calling it.
Method is
POST
Synchronous function
RequestResponse
Hold it
So you can see
Loading state
Request.body
Name, email, password
We're getting it.
In case
If anyone is missing
If they left empty
We will return it.
We are checking the password.
The password should be
More than 6 characters
If not
Password must be
Passing message
By the way
I am adding normal text
In the password field
In reality
You don't have to do it
You can use any
Password
Don't do it
I'm just showing you.
Finally
My data
I am inserting it.
In my database
In table
My connection is complete.
You can see
Normally
I am using a prepared statement.
Or procedure
We call it
SQL Injection
I don't have it
You can use it
If everything is done
I am returning an object
In which user
Has a property
ID, name, email
In case
If error
Caught
Most important
Email
If someone
Trying to
Register with the same email
We'll get it.
In this way
This email has already been sent.
Registered
If the email ID was new
But there is still some error.
Something went wrong
I am sending this message
This is it
This is my React version 19
We passed the data
Data in payload
Was in object form
But we need it in string format
So that we can send further
That's the reason why JSON.stringify
Not a string means JSON format
We converted it.
Whatever response I received
I got it in the data
If my response is not satisfactory
We have a NOT operator here
You can see the return error
I will get the data. message
Users is null קצת לא ברור, האם תוכל לספק עוד הקשר או לתקן את המשפט? (הערה: התרגום של "Users is null" הוא "משתמשים הם null", אך זה לא מדויק דקדוקית. הנכון הוא "Users are null" או "The users are null".)
Attempts is null
By the way
If you notice
This part
I will show youTheory of the firm
This is our initial state
Over here
Error, user
Attempts is already defined
In initial state
I am updating it
OK
If there is no problem
Everything is correct
Error is null
Users field
Data.users
Attempts is zero
Finally, we have a catch.
In the previous one
try, catch, finally
There is nothing.
Same content
Catch, server not reachable
Null
Attempts are showing
We will play on attempts
More than 3
That's it
Your work is done
In case states.attempt
More than 3
State.error
If state.user is correct
We will show welcome user
I have already shown you.
Spending by default
You can do it like this
This is yours
Use action state
I have told you
When you submit the form
Dispatch action
This will trigger
In use action state
Reducer action
You will receive form data
You will receive data
Remember one thing
In reducer action
You are receiving 2 parameters
Previous state and form data
React is providing
The previous state is important
For that reason
When you are defining
Use action state
You have to pass two values.
Reducer action is
Form data
A reducer action is a reducer action.
Initial state
For the very first time
The previous state will be obtained
In case you don't give
A problem will arise
Remember this
Rest is nothing.
I have shown you
I have run it.
I am going.
I have entered the data.
If you haven't seen
Payload and form data
I will sign up
This is it
Welcome binod19
This is your form data
You can see it like this
Form data
You can see it like this
Tell me
Do you know
What was my data
You can use form data.get
To get individually
.name, .email
You can use form entry
This is what I was talking about
If you see
In payload
You are receiving an object.
With name, email, and password
By the way
When you interact with any API
You don't pass an object
You pass JSON
In JSON
You need code
Both property and value
You need code in both
That's the reason
For that
JSON.stringify
I hope there is no doubt.
What you are receiving in the form data
I have shown you.
Why did I write it as object.form?
Due to which
I have stored its data in the payload.
What I'm getting there
We have seen
Form data and payload
In use action state
These three elements
Why am I writing this
I have shown you.
In console
Current state, dispatch action
Spending
By default
My data has been inserted.
I am going to
My workbench
If I refresh
See
React version 18
I have told you
In UI and user experience
There is no change.
They are the same.
But in React version 19
It is simplified.
Manual steps are reduced
In React version 19
How was today's video?
If you want
I am going to
In React version 19
All latest features
One by one
Detailed video
Why I have brought it
What was before
If you want a detailed video
Like this video
Like target is 500 likes
Share with friends
Comment
In your mind
Which topic
Difficult
Want to understand
New feature
Upload video
Comment
I will be happy
Share with friends
Tag
On social media
I want this
You can tell
This video
Check out
Version 19.2
Check out
Yes
Like
Share
Subscribe
See you
Until then
Thank you