3 ms·
Short version: React already knows what component instance it's rendering. Whenever a hook is called, React looks up the right data from a linked list stored in
by acemarke 6y ago
Short version: React already knows what component instance it's rendering. Whenever a hook is called, React looks up the right data from a linked list stored in the internal component metadata objects.
For more details, see:
- Shawn Wang's talk "Getting Closure on Hooks": https://www.swyx.io/getting-closure-on-hooks/ https://www.swyx.io/getting-closure-on-hooks/
- React Hooks Demystified: https://dev.to/kayis/react-hooks-demystified-2af6 https://dev.to/kayis/react-hooks-demystified-2af6
- React Hooks - Not Magic, Just Arrays: https://medium.com/@ryardley/react-hooks-not-magic-just-arrays-cd4f1857236e https://medium.com/@ryardley/react-hooks-not-magic-just-arra...
- additional articles: https://github.com/markerikson/react-redux-links/blob/master/react-hooks.md#understanding-hooks-concepts https://github.com/markerikson/react-redux-links/blob/master...