خیلی چیزا به ریکت ۱۸ اضافه شده از جمله هوک useTransition و هوک useDefferedValue.
هر دوش برای این به کار میره که اولویت render یک state به خصوص رو از بقیه stateها بیارن پایینتر.
ولی اینکه چه فرقی با هم دارن رو سخت میشه از روی داکیومنت اصلی متوجه شد.
این لینک خیلی کوتاه و مشروح و عملی این تفاوت رو شرح داده.
https://academind.com/tutorials/react-usetransition-vs-usedeferredvalue#:~:text=As%20mentioned%20above%2C%20the%20difference,same%20goal%20in%20the%20end.
——————
useTransition() gives you full control since you decide which code should be wrapped and treated as "low priority". Sometimes though, you might not have access to the actual state updating code (e.g., because it's performed by some third-party library). Or, for some reason, you can't use useTransition().
In such cases, you could use useDeferredValue() instead.
With useDeferredValue(), you don't wrap the state updating code but instead the value that's in the end generated or changed because of the state update (either the state value itself or some value that's computed based on the state value
——————
#react #react18 #hooks
هر دوش برای این به کار میره که اولویت render یک state به خصوص رو از بقیه stateها بیارن پایینتر.
ولی اینکه چه فرقی با هم دارن رو سخت میشه از روی داکیومنت اصلی متوجه شد.
این لینک خیلی کوتاه و مشروح و عملی این تفاوت رو شرح داده.
https://academind.com/tutorials/react-usetransition-vs-usedeferredvalue#:~:text=As%20mentioned%20above%2C%20the%20difference,same%20goal%20in%20the%20end.
——————
useTransition() gives you full control since you decide which code should be wrapped and treated as "low priority". Sometimes though, you might not have access to the actual state updating code (e.g., because it's performed by some third-party library). Or, for some reason, you can't use useTransition().
In such cases, you could use useDeferredValue() instead.
With useDeferredValue(), you don't wrap the state updating code but instead the value that's in the end generated or changed because of the state update (either the state value itself or some value that's computed based on the state value
——————
#react #react18 #hooks
هر چی بیشتر ریکت میخونم بیشتر متوجه میشم چه قدر این صفحه رو درک نکردم.
https://raw.githubusercontent.com/reactjs/reactjs.org/main/static/html/single-file-example.html
#ract #react18
https://raw.githubusercontent.com/reactjs/reactjs.org/main/static/html/single-file-example.html
#ract #react18