In my experience this is a fairly common source of confusion. People have a tendency to write things like:
useEffect(() => {
const unsub = subscribeToThing(thing => handleThing(props.id, thing))
return () => unsub()
}, [])
This looks pretty good except it's broken if props.id changes. handleThing() will always be called with the first props.id.I'm the defacto React tutor at my company and issues like this make me pause before recommending new React devs to use hooks. useState is awesome and feels more natural to people than setState(). useEffect seems similarly simple but the subtleties can catch you.