Why setState() in React.js is not immediate? Can we make it to update the state instantly?
Deep dive into how useState() works and how we can write our own better version.
My newsletter recommendation: (not sponsored)
⚛️ This Week in React
https://thisweekinreact.com/
⏱️ Timestamps:
00:00 - StackOverflow question
00:24 - useSyncState() hook
00:48 - Disclaimer
01:03 - Why setState is not SYNC?
01:34 - Why the result of setState is not immediate?
02:47 - Role of setState()
03:25 - Batching
04:12 - Splitting setState()
04:38 - How to implement useSyncState()
05:42 - The problem with .current
07:41 - Refactoring useSyncState()
08:04 - Solving .current problem
09:04 - Discussing drawbacks
📖 Acknowledgments & Further Reading:
StackOverflow question: https://stackoverflow.com/questions/5...
React Docs: https://react.dev/learn/state-as-a-sn...
En esta página del sitio puede ver el video en línea Making setState() instant de Duración hora minuto segunda en buena calidad , que subió el usuario UI Engineering 12 septiembre 2024, comparta el enlace con amigos y conocidos, en youtube este video ya ha sido visto 7,696 veces y le gustó 422 a los espectadores. Disfruta viendo!