This Ain’t Your Grandma’s React (Part 3)

How Hooks handle dependencies

Extremely loosely patterned after Dan Abramov’s original class lifecycle diagram on Twitter

Closures Are King

Dependencies Hold the Keys to the Kingdom

Closures are frozen. Dependencies aren’t.

Empty dependency arrays

Never Ignore react-hooks/exhaustive-deps.

useMemo: Reduce Calculation Time, Define Dependencies, Fix Object Literal References

useCallback: useMemo for functions

(I didn’t actually look at the code in React. It might be more complex than this, but this is the basic outcome.)

Beware Premature Optimization

tl;dr

Front-end web developer, React enthusiast, vagabond.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store