Stable handlers and reactions
useEvent(handler) returns a function with the same arguments and result that always runs the handler untracked.
useEvent(handler) returns a function with the same arguments and result that always runs the handler untracked.
Components run once and props are read through getters, so the handler already sees the latest values. The untracked
call is the part that matters: an effect that calls the handler does not subscribe to the signals the handler reads.
This is the ShadowJS form of React's useEffectEvent. There is no dependency array to keep correct.
useReaction(onInvalidate) returns track(fn). track runs fn at once and records what it reads. The first change
of any of those values calls onInvalidate once, untracked; nothing is observed again until track is called. This is
the ShadowJS form of Solid's createReaction.
Two React idioms have no ShadowJS counterpart because components run once. useCallback is a plain function written
once in the component body. useLayoutEffect and useInsertionEffect are useRenderEffect: it runs in the render
phase, before user effects in the same flush.