React 19 · State and effects

Run an effect

Run code after render, here when the id changes, and clean up before the next run.

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

Official React 19 documentation

More state and effects commands

All state and effects commands · React 19 cheatsheet

Was this page helpful?