Can you assign setState to ref attribute?

Pubblicato il: 25 febbraio 2024
sul canale di: UI Engineering
875
78

What setState and refCallback have in common?
Unintuitive React Pattern that can help synchronize DOM Elements with Render Cycle.

⏱️Timestamps:
00:00 - Why assigning setState in ref is unintuitive
01:00 - Example from Popper.js
02:27 - How does it work?
03:08 - Is it safe?
05:24 - Is it breaking React Rules?
06:57 - Why would you want to use it?
09:31 - Lessons learned: When to use it

📖 Acknowledgments and further reading:
Popper Example: https://popper.js.org/react-popper/v2...
Popper, how it works explained: https://github.com/floating-ui/react-...
React's GitHub Discussion: https://github.com/facebook/react/iss...


In questa pagina del sito puoi guardare il video online Can you assign setState to ref attribute? della durata di ore minuti seconda in buona qualità , che l'utente ha caricato UI Engineering 25 febbraio 2024, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 875 volte e gli è piaciuto 78 spettatori. Buona visione!