DEV Community

Discussion on: When React Hooks "just clicked" in my head 💡🤩

Collapse
 
lexlohr profile image
Alex Lohr

It clicked with me when I researched the internals of the new fiber architecture, which is basically tree-walking over fiber nodes, which can be elements or hooks.

The whole architecture is based on memoization (call caching) and tree-walking during different cycles (mount, render, layout, unmount).

useRef(value) is basically useState(value)[0].
useCallback(fn, deps) is a shorthand for useMemo(() => fn, deps).
So you're left with useState, useMemo, useEffect and useLayoutEffect, the latter just being evaluated during different cycles.