Custom Hooks — Intermediate React challenge.
Dan Abramov's classic. Build a declarative `useInterval` hook that can be paused by passing `null` as the delay and always uses the latest callback.
function useInterval(callback: () => void, delay: number | null): void
useInterval(() => setCount(c => c + 1), running ? 1000 : null);