Read latest values in an effect event without re-triggering the effect.
Section: Effect Hooks
useEffectEvent for non-reactive effect logic
tsx
tsx
const onVisit = useEffectEvent((visitedUrl: string) => {
logVisit(visitedUrl, cart.length);
});
useEffect(() => {
onVisit(url);
}, [url]);Explanation
Use for event-like logic called from effects that should see fresh values.
Learn the surrounding workflow
Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.
Related commands
Same sheet · prioritizing Effect Hooks
useLayoutEffect before paint
Run a layout-sensitive effect before the browser paints.
Fetch inside an effect
Fetch client-side data in an effect with cleanup guard.