Skip to main content
Journey Uncommon Logo
JourneyUncommon
mediumReactuseEffect dependency arraysSingle-choice MCQ

An effect subscribes to a store and lists `[count]` in its deps, where `count` is read inside the subscription callback. The effect's cleanup unsubscribes. When `count` goes from 2 to 3, in what order do the cleanup and setup run?

useEffect(() => { const sub = store.subscribe(() => use(count)); return () => sub.unsubscribe(); }, [count]);