Engineering practice

Subscription debugging exercise

Use a functional updater for increments and unsubscribe when source changes.

Formal Syntax & Structure

react syntaxreact
useEffect(setup,[clock])

Working Example

Example Snippetreact
return clock.subscribe(()=>setTicks(n=>n+1))
React Reference