TLDR Web Dev · OPINIONS & ADVICE
USESTATE SHOULD REQUIRE A DEPENDENCY ARRAY
Summary from the TLDR Web Dev newsletter
React's `useState` hook should require a dependency array to prevent a common bug where state initialized from props doesn't update when those props change, creating un-reactive code. Current workarounds like using the `key` prop or `useEffect` to sync state are clunky and error-prone, and instead `useState` should work like `useState(initialValue, [dependencies])` where state resets when dependencies change.