رقصنده با کد
782 subscribers
1.69K photos
850 videos
207 files
666 links
Here are some interesting things I've come across during my learning process. That's it. Admin ID:
@alithecodeguy
Download Telegram
خیلی چیزا به ریکت ۱۸ اضافه شده از جمله هوک 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
فرق Debounce با Throttle توی جاوااسکریپت چیه؟
تکنیک Throttle یعنی اینکه یک فانکشن خاص توی تایم فریمی خاصی مثلا هر پنج ثانیه بیشتر از یکبار قابل اجرا نباشه.
تکنیک Debounce یعنی فانکشن خاصی بعد از تایم فریم خاصی اتفاق بیفته.
درظاهر یک هدف رو دارن ولی اگر دقت کنید کلا دو تا چیز مختلفن.
اینایی که گفتم برای جاوا اسکریپت بود و روی هر فریم ورکی میتونید پیادش کنید یا از کتابخونه‌های مختلف استفاده کنید. اگر هم از چیزی مثل ریکت استفاده میکنید به نظرم از هیچ کدوم استفاده نکنید و برید سراغ useDefferedValue
#react #debounce #throttle #hooks #js