useTransition() Hook Example ReactJs

useTransition() Hook Example Reactjs

useTransition() hook returns array of 2 elements. First one isPending element. second one startTransition.

isPending: it's Boolean variable that returns true when the second element startTransition function executes and returns false when the execution of the startTransition() function is Done.


variable


reactjs-declare


render

When you execute above code then you will notice that as soon as you try to write in search box then UI gets hand for sometime which is bed user experience.

useTransition() Hook




useTransition() Hook implementation

When you execute above code, notice that the issue which we were facing in the previous code will be gone. 










Previous Post Next Post