Learn React Hooks: useTransition - Simply Explained!

  Рет қаралды 19,834

Cosden Solutions

Cosden Solutions

8 ай бұрын

Join The Discord! → discord.cosdensolutions.io
Source Code → github.com/cosdensolutions/co...
In this video we will learn about React hooks, starting with useTransition. This powerful React hook will allow you to have interruptible state updates that you can configure to priorities some updates over others. This is an optimisation React hook which you will use to give users a better experience on your app. You will learn how to use the useTransition hook, how to start a transition with startTransition, and how to use the isPending flag to show some UI as the transition is happening.
In this new React world, hooks are here to stay, so it's best to learn them! In this tutorial I demonstrate the useTransition React hook, and I explain it very simply and in a way that is easy to understand. Enjoy!

Пікірлер: 50
@cosdensolutions
@cosdensolutions 2 ай бұрын
Hey everyone! I just launched 🚀 Project React, which is a course that teaches you React by building a real-world project. It goes way beyond what you see in these videos and walks you through step-by-step on how to build a big and complex application with React! You can check it out here: cosden.solutions/project-react
@sumitdubey8695
@sumitdubey8695 8 күн бұрын
What you say "This is the last video you are ever going to watch", is actually 100% true. Just amazing explanation 👌🏻
@jacobwwarner
@jacobwwarner Күн бұрын
Beautiful. I didn't think you could have such a refined control of rendering by using hooks like this.
@AnuragSingh-ev8qd
@AnuragSingh-ev8qd 3 ай бұрын
I had to watch few parts of the video twice, but got it at the end. Amazing explanation, you got one more subscriber 👍
@mikewski4410
@mikewski4410 8 ай бұрын
Pretty clean explanation. Easy to understand. Thank you
@prakashbanjade4374
@prakashbanjade4374 8 ай бұрын
Cool, now I understand useTransition and I won't need to look at other videos and solutions for this. Great explanation.
@cosdensolutions
@cosdensolutions 8 ай бұрын
happy to hear it!
@tusharghildiyal6814
@tusharghildiyal6814 8 ай бұрын
That was very clear and helpful brother. Thanks, much appreciated 🙌👏
@cosdensolutions
@cosdensolutions 8 ай бұрын
Glad you enjoyed it!
@IAmRC1
@IAmRC1 4 ай бұрын
Nice explanation buddy!
@garudaphoenix5479
@garudaphoenix5479 8 ай бұрын
Thanks, man, clearly explained 💖💖
@michaelm8044
@michaelm8044 8 ай бұрын
Sick video. Pretty advanced stuff.
@irradev
@irradev 2 ай бұрын
Amazing! I will refactor my code. Thanks so much!
@abeercodes
@abeercodes 8 ай бұрын
whoever has found this video on KZbin is lucky
@adembenabdallah9678
@adembenabdallah9678 8 ай бұрын
I appreciate your work this helped a lot ❤❤. Your are the best who explain the hooks it is true the last video you need to watch ❣❣
@cosdensolutions
@cosdensolutions 8 ай бұрын
thank you for the kind words!
@stepanostapuk4120
@stepanostapuk4120 8 ай бұрын
Thank you for the video!
@sudiptagogoi1431
@sudiptagogoi1431 8 ай бұрын
Thanks a lot cosden
@EmmanuelOdii80
@EmmanuelOdii80 6 ай бұрын
Much simplified than the info from the docs :)
@ankurparchani3230
@ankurparchani3230 8 ай бұрын
I really don't have to go to another video for this topic ever again 👏🏻
@cosdensolutions
@cosdensolutions 8 ай бұрын
There you go ☺️
@vuongal1658
@vuongal1658 8 ай бұрын
Thank you so much!!!
@Shaheer-xs5os
@Shaheer-xs5os 8 ай бұрын
Bro that was helpful 😄😊
@gmjitendra
@gmjitendra 7 ай бұрын
Excellent.
@vinothkumarv9722
@vinothkumarv9722 22 күн бұрын
Awesome :)
@jerry_codes
@jerry_codes Ай бұрын
Quick Question? Can I use the useTransition to put the loading state for side effects functions For e.g. if I have to update the user and I'll wrap the start transition on update function. I can use the isPending state to show that is updating or likewise.
@StingSting844
@StingSting844 8 ай бұрын
Neat. So what happens to components that render direct from manipulations like chart libraries or canvas libraries? They don't work because react has no way to stop them right?
@cosdensolutions
@cosdensolutions 8 ай бұрын
depends, if they are driven by state, this will control when that state gets interrupted or not
@Herxh428
@Herxh428 8 ай бұрын
Clean
@robertomolinasilvera4863
@robertomolinasilvera4863 4 ай бұрын
React sends one rerender with currentState and isPending:true to component to tell it will start transition. Then it will rerender component with newState if during this rerender (probably slow) another update is raised, async rerender will be stopped
@dominggusoctovianus4915
@dominggusoctovianus4915 8 ай бұрын
Simple but so juice... hehe
@rockstarshahid
@rockstarshahid Ай бұрын
Awesome. Simple and clear explanation. But I have a question regarding POSTS page. How can we resolve the UI freezing issue for Posts page? Or how can we load Posts page content faster? Can you help me with this? Thanks.
@cosdensolutions
@cosdensolutions Ай бұрын
only render a few at a time. So either use virtualization, or paginate them and load them 20 at time
@bibahbibah5108
@bibahbibah5108 8 ай бұрын
u are right i don't need to read or see another thing
@user-mr8rv8yb8v
@user-mr8rv8yb8v 4 ай бұрын
your a goat
@tnarra
@tnarra 7 ай бұрын
Why does my script to animate in page router doesn't work in app router of nextjs
@fullstackprojects5615
@fullstackprojects5615 6 ай бұрын
hello, Can you explain this one please - while (performance.now() - startTime < 1) { console.log("entered while...", performance.now()); // Do nothing for 1 ms per item to emulate extremely slow code } performance.now() - startTime < 1 should always be greater than 1 isn't it? I don't know why is it going inside the while loop and what does 1ms delay is derived. Would be great if you can please explain.
@cosdensolutions
@cosdensolutions 6 ай бұрын
this code just forces the component to wait 1ms before continuing the render. It comes from the React docs in their examples! It just simulates slowness so that you can actually see the effects of what you are doing
@deliotablang823
@deliotablang823 8 ай бұрын
seems like same with the suspense lazy load what are the difference between them?
@cosdensolutions
@cosdensolutions 8 ай бұрын
suspense is for delaying the loading of something and this is for interrupting it and prioritising other renders first
@deliotablang823
@deliotablang823 8 ай бұрын
Many thanks. Is this working also using next/link?
@veerasamysevagen9533
@veerasamysevagen9533 5 ай бұрын
Hello, Loved your explanation but it does not seem to work with this piece of code. const buttonClick = (type: string) => { startTransition(() => { if(type === "fast") { setCounter(25); } else { setCounter(() => { let sum = 0; for(let i =0; i
@cosdensolutions
@cosdensolutions 5 ай бұрын
because startTransition works by interrupting renders that take too long after being set, not the actual setting of a new value. In your case, you're just taking a while to set the new value to trigger a re-render, but the actual re-render is super fast as it will just update the counter with one value
@veerasamysevagen9533
@veerasamysevagen9533 5 ай бұрын
@@cosdensolutions makes sense yeah. Thanks a lot for responding.
@user-js1ym3xs9q
@user-js1ym3xs9q 7 ай бұрын
why not use loading instead
@jivkojelev3744
@jivkojelev3744 8 ай бұрын
Its look like debounce or throthle
@cosdensolutions
@cosdensolutions 8 ай бұрын
It does
@agustind
@agustind 8 ай бұрын
I promess you after reading this comment you wont have to read any other comment again
@cosdensolutions
@cosdensolutions 8 ай бұрын
Thanks you saved me
@bq_wang
@bq_wang 8 ай бұрын
Learn React Hooks: useDeferredValue - Simply Explained!
12:02
Cosden Solutions
Рет қаралды 11 М.
Learn React Hooks: useImperativeHandle - Simply Explained!
9:54
Cosden Solutions
Рет қаралды 15 М.
Why? 😭 #shorts by Leisi Crazy
00:16
Leisi Crazy
Рет қаралды 45 МЛН
How I prepare to meet the brothers Mbappé.. 🙈 @KylianMbappe
00:17
Celine Dept
Рет қаралды 49 МЛН
BRUSH ONE’S TEETH WITH A CARDBOARD TOOTHBRUSH!#asmr
00:35
HAYATAKU はやたく
Рет қаралды 20 МЛН
The correct way to optimise React
11:29
Cosden Solutions
Рет қаралды 28 М.
Why didn't the Angular team just use RxJS instead of Signals?
8:15
Joshua Morony
Рет қаралды 84 М.
Micro-Frontends in Just 10 Minutes
11:00
Jack Herrington
Рет қаралды 214 М.
Learn React Hooks: useLayoutEffect - Simply Explained!
9:17
Cosden Solutions
Рет қаралды 15 М.
Learn React Hooks: useRef - Simply Explained!
12:42
Cosden Solutions
Рет қаралды 75 М.
Новые хуки useTransition и useDeferredValue в React 18
22:17
Михаил Непомнящий
Рет қаралды 21 М.
Speed Up Your React Apps With Code Splitting
16:50
Web Dev Simplified
Рет қаралды 365 М.
Why? 😭 #shorts by Leisi Crazy
00:16
Leisi Crazy
Рет қаралды 45 МЛН