React 19 changed the way we can handle data fetching in React. But does that mean we no longer need useEffect and multiple useState hooks for fetching data?
🎁 BONUS OFFER — Full Stack Live Classes Batch 1 Recordings Get access to my recorded Full Stack Live Online Classes. 👉 https://kodyfier.com/video-courses.php
In this video, we’ll understand the new React 19 use() API with Suspense and see how it can make async data handling much cleaner.
We’ll first compare the traditional useState + useEffect data fetching approach with the new use() + Suspense approach.
Then we’ll build a practical example where we fetch user data and understand exactly what happens when a Promise is pending and when it is resolved.
You’ll also understand an extremely important concept when using use() with Promises inside Client Components:
👉 Why does the Promise need to be cached? 👉 Why do we use new Map()? 👉 What are cache.has(), cache.set() and cache.get() doing? 👉 What exactly is a cache? 👉 Where is this cache stored? 👉 Why does the cache disappear after a page refresh? 👉 How does use() finally read and render the resolved Promise data?
By the end of this video, the complete flow will be clear:
Fetch Data → Promise → Cache → use() → Suspense → Fallback UI → Promise Resolved → Render Data ✅
If you're learning React 19, this is one of those concepts you should understand properly instead of simply memorizing the syntax.
💬 Comment “Notes” if you want the notes for this video.
⏱️ TIMELINE
0:00 React 19 Data Fetching Is Easier 1:10 Before React 19 – useState + useEffect 2:30 After React 19 – use() + Suspense 3:30 Must-Watch React 19 Videos 4:45 Fetching & Showing User Data 5:20 What Is React Suspense? 6:30 Complete Data Fetching Code Flow 7:25 Why Do We Need new Map()? 8:40 What Is Cache? 9:30 Fetch Data & Store Promise in Cache 13:40 How use() Reads Promise Data 15:10 Must-Watch React 19 Video 16:05 Comment “Notes” to Get Notes
AI Generated·May contain errors
Video Summary
AI Generated
This video explains how data fetching has been simplified in React version 19 using the new `use` API combined with `Suspense`. The instructor demonstrates a transition from the traditional manual state management (using `useState` and `useEffect`) to a more streamlined approach that eliminates the need for manual loading and error states.
Data fetching has become simple now.
If you still don't know
How has it become?
So today in this video, I'll clarify this dot for you.
And the SIP images are thur
I will not explain it to you.
I will show you live practical demonstration.
Is this exactly it or not?
You can see for yourself here by speaking
This is my user ID 1 in the database.
It's a stored procedure because it's a full-stack application.
So, from the backend, I am fetching the data.
Alright, whoever has user ID 1
Show me his data here
You will see when I refresh
Both of these components of both
That first one, the loading state
It is appearing.
And to achieve that state, guys, I don't have any motivation to do anything.
in React version 18
The suspense you were given
His thumb and this one here, this API usage
With the help of these two, you can obtain the data from Araham.
You can catch him.
Loading status also automatically
It will happen here with the help of use
Plus, suspense—how can I tell you?
First, let's go to the image
What used to happen before?
First, Gai, if you have any questions about...
We all know how to make an API call.
with the help of useState and then useEffect
We used to do it like a component from Araha.
First of all, the vaccine has an effect.
Inside, we were calling the API
Right, now look at this
I am calling the API now, as long as
We aren't getting the data; we're just waiting.
The vaccine is right there in the middle of it.
The state comes now, say it so we can hear
They seemed to be some kind of data state basically
Your const
data, set data
Whatever actual data we have
We used to store it inside him.
Back then, we used to create a loading state.
To handle an error
These three used to create an error state
individual use state
We thought it was a use effect
Inside it, we were making API calls to retrieve data.
I put the data inside the data state.
This is the loading state before the data arrives
Show loading, data
If any problem arises
Put the error in the error state
Show me how much there used to be
First, say yes or no, please
So in this way, your guys are these three
We had to manually manage the state.
and once the data was obtained
Re-render from the dashboard, and you'll get your data
So here, this was your manual work.
First but now after
Use API plus suspense
component render I mean
You have the page like I have for the first time
Do not load the page
The component has to render there, use it
Inside the API, we pass a promise, okay?
Now it will happen.
as long as this promise remains in the pending stage
Pending means I received the visa
Until the data arrives
Show the loading animation to the user.
As your promised result comes into being
Then show me the actual data.
So here, no state has
I don't need to manually manage it
Here you go, guys, your cleaner
Code and these are now yours
Easily do this in React version 19
I hope at least you've figured this out by now
Where previously we had to manually handle the state
use effect and use state two two hooks
Here, suspense and then
You can easily do it with the help of the API.
Alright, so guys, if I tell you
Tell me the code, then for the past few days
React version 19's latest feature
Then we have no more manual loading.
Why would I have said such a thing? You'll see for yourself.
Alright, then let's continue with him today.
And among all these, I have one project
I'm continuing so that you all can
None of these are separate; they are all connected.
Here it is, exactly right from the other one.
I sign up quickly through WhatsApp
You can see, Gais
I have filled in the data, and I'm letting you know.
that right now I'mjumlah live javascript onlinequisites
I'm teaching myself classes
If you want to enroll every night at 9 o'clock
You can see the link at the top; you'll enroll there.
And seven seven, even full stack classes are here
Started as it started, if you
I want to learn full stack live online classes from you.
So, the link is below in the description and comment section.
I have provided it; you can enroll.
My work is being done.
I'm going back to the bag; I'll refresh it once.
So, look, this is coming from this thirike, how is this happening?
Now I will tell you, look closely
So first of all, how does it happen
This is my actual app component
Inside which there is suspense
The sign of form
This is my second suspense.
The simple job of suspense is this
As long as the data does not arrive
Whatever you have inside this fallback component
Whatever text you pass to me
Render it on the screen.
As soon as the data arrives, user profile
And here is the sign of the component
We will show you that data.
So if the promise gets resolved
I will get the data.
So there, user profile
I am calling that component.
And seven seven in this component
I'm passing a prop.
the one I wrote under the name of user ID
So this User ID one means
I am the current user ID one.
I want to fetch his data.
How will we fetch it?
with the help of the API
Look at this
User promise
Inside it, fetch user, I have another function
I'm creating here
Inside which I am passing the user ID
If I run this function
So his job is just that.
Now in this function
My API is
I'm fetching him here.
We do it this way.
This URL is the same.
If you were also using the use effect hook
So even you fetch
You'll have to write it the same way anyway.
Now the difference is
To call this
To call this API
I am no longer using the use effect hook
If you look, you'll immediately go to the end.
Look here, inside the user, the user's promise
I mean, just look how easy this will be
This fetch user here
Whatever data he has will be in the user promise.
I mean, do it.
And I have passed him inside the user.
So, Philal, now you see it
So, the fetch that is
I called dot then
I need a response from you.
Now, let us carefully look here
If the response is not equal, throw a new error
And if everything is needed
So I need the original format of it
That's why we do dot json
It's not a big deal.
You knew that.
But here, there's an extra thing that's becoming visible to you.
new map object
What is this? Let me tell you—listen carefully.
Alright, this is very important.
If you are on React version 19
And if you use the API
And if you are a client component
But you're working
If you're working on pure React
So, the page you have by default is
client component
If you use the API
You are using it in a client component
then make sure whatever promise you have
It will be data, here you will have it
Keep the cash or should settle
Settle, by default, proceeds with the promise you make to yourself.
But keep it in cash for him.
so that if next time
The same API, I mean
Whatever ID you want to call
The data you just spilled, you had it earlier
If you call him again after he's already received it
If you want, this time
You won't have to make the call
Give me the cash data you've collected and hand it over here.
What will happen if you
You will avoid an infinite loop
So we just need to avoid that infinite loop.
That's what I mean.
In the client component, you
Cash creation will have to be done.
Now, what is cash here? Cash is temporary.
Memory data is over
Now a question will arise in your mind
that is temporary memory data
So, this store is located on my local system
On my browser
Where on my database?
Look, this is on your VSCode editor, not on yours
on your local system, not on your server
Its data loads on your browser
even then, as long as you are with her
On the tab, the moment page you have
Refresh this or from another tab
Those data over here and there
You will go, that's what it means.
Your cache data is on your browser.
It stays in the store. I mean, the one for your browser
There is memory, and within that memory, a slight haze
temporary memory keeps this on hand
Alright, so the map is yours.
A constructor is and the moment you have
Now, if this is an object, then its
I am providing the reference.
The user cache is a constant variable.
Me him I have my this
I have provided the reference to the map object.
Now, regarding this our
It is an object; it has something.
method is your get method, set
getter and setter then has
They have a method, that's right.
So here's the twist
You're thinking, dude, fetch user, huh?
How many are easily calling the API there?
there were side effects and all those things
In the case of using effect, here it's quite comfortable
I did it, but how did it happen inside the function?
Look here, I've put this here
Cache created, okay.
and gave you the reference to my object
Now inside it, if you go into the if condition
If you look closely, I'm asking you.
Inside my cache
This ID right now of whom
I need to fetch the data
Is this present?
Is its data already present in my cache?
Look, there is a not operator here
If not present
If not then
Then he used this API
Calls
A call will be made to this API
The call will come.
This ID that we wrote there as one
What will happen if this one happens?
My ID in the workbench
Number one, it must be fetching its data.
Now on-the-spot data
Promises mean nothing in themselves.
In the future, a result will come to you
So long as that result has not reached you
I can't find you. What are you?
Look at this one here.
It will soon become known that Abi
The promise that I made has not been fulfilled for me.
This is still in the pending stage; the data is still pending.
It's coming, so burst it.
use what is yours component
Pauses or suspends
And whichever is the nearest fallback
will be
Whoever is the nearest fallback
I'll show you here, look here
whatever is the nearest fallback inside the user profile
So its parent will be this one.
So the UI he has, this one here
It's a part; it renders it right away.
So you need to load the user like this
fetch user data that is
It appears to be showing.
You can see this data.
As long as it remains in the pending stage
As soon as
Data has been obtained here.
And there's no problem with it.
And when this returns
What are we doing then?
When is the data inside Kai's?
Checking in here, storing it
You might also have a question in your mind.
If that data is present
No, I promise.
I make an API call.
And the data is being returned here.
Where are we storing whatever is being returned?
promise inside this constant variable
Here, my promise is being stored
Basically, the data will be there
Please carefully look at this promise.
Now here is the same as my what is it like
In it, we have one more method
set
Inside the set
Whatever my current ID was, like this ID
Number one is Philal, ID number is still pending
One is ID number one.
What is it? Finally, now I
I'm setting it inside my case.
Adding, storing
So whatever data is in ID one
I set it up in this way.
Now next time next render
If same me
You are this touru's
What is a note?
You are that inside this condition
It won't go anyway.
You see, this is automatic.
It looks like it's blanked out, disabled kind of appearance to you
It won't go inside it.
Where will Siddha go?
Here it goes, take a look here
usercache.get
Understood in this way
So we have a .has method
.set and then
If false, then .get
ID, I got it, I'll return it to whom?
This function of mine
Whoever has made the fetch user call
Here we had called, now
Where did he go, to the user's promise?
Where is it? It's inside him.
Just finished data like that
As long as that data is not obtained
The promise is pending stage.
By then, your
The nearest suspense
The fallback UI that is shown to you
It means simple, you see.
You promised, basically
Call a data point
Until the data arrives
Whatever loading animation for suspense
Show me the rotate one
What will it do as soon as the data arrives?
The data that was received, put it on that UI
I will render it completely.
with the help of suspense
plus use this way now you
Easily in React version 19
Data that you can fetch
Just keep in mind that you need to data
It will have to be stored in the cache in this manner.
Because if you don't keep it in the cache
Then it is not correct either.
Your infinite loop might be causing the problem.
It will keep going back into suspense again and again.
That's why this cache is important.
If you are working with server components
So in the server component
There's no tension about it, because
Something is going to render on the server
You call it, and your work gets done.
It will be fine, relax then.
In React version 19, if you need to fetch data
So in this way, comfortably
You can fetch the data.
Your suspense is with you for loading
suspense If you still don't quite understand it
So don't worry.
Look at this
React can render the UI before
Here, I've left a lot of suspense.düğü
I have told you well
This API, one of its kind
I have also shown this in the use case here
I'm just now handling the promise data.
I was using the API to get it.
But you use the API's context
To obtain the data that exists
for suspense
You must have liked today's video
You now have a complete idea.
What does the React team say about React version 19?
If you are using an API-oriented component
If I have to use it
Nothing to do, nothing to be done
As usual, from Aram
They were fetching data here too, it's the same thing here.
If you have
React version 19 has some more features like this
What you still haven't understood clearly yet
I want you to understand this; let me explain it to you in a better way.
Be sure to let us know by commenting below
Mine too, and help will be available. Is this also a new feature?
Did I fall or didn't I fall?
I will definitely make a video about him.
So, Gais, please come to the video and like it
Keep 500 likes from the target
Share it fully with your friends
And our next target is 8 lakh subscribers
And if any of you are live online
You want to learn, you want to study.
Then you will enroll in the course.
Only ₹699 until 9 PM tonight
You will get this, then it will become 999
It's fine after 9 o'clock
See you in the next video
Until then, guys, thank you so much
Take care.