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...
In questa pagina del sito puoi guardare il video online Making setState() instant della durata di ore minuti seconda in buona qualità , che l'utente ha caricato UI Engineering 12 settembre 2024, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 7,696 volte e gli è piaciuto 422 spettatori. Buona visione!