MCPcopy Index your code
hub / github.com/adobe/react-spectrum / useEffectEvent

Function useEffectEvent

packages/react-aria/src/utils/useEffectEvent.ts:20–30  ·  view source on GitHub ↗
(fn?: T)

Source from the content-addressed store, hash-verified

18const useEarlyEffect = React['useInsertionEffect'] ?? useLayoutEffect;
19
20export function useEffectEvent<T extends Function>(fn?: T): T {
21 const ref = useRef<T | null | undefined>(null);
22 useEarlyEffect(() => {
23 ref.current = fn;
24 }, [fn]);
25 // @ts-ignore
26 return useCallback<T>((...args) => {
27 const f = ref.current!;
28 return f?.(...args);
29 }, []);
30}

Callers 15

useInteractOutsideFunction · 0.90
usePressFunction · 0.90
useMoveFunction · 0.90
useUpdateEffectFunction · 0.90
useFormResetFunction · 0.90
useEventFunction · 0.90
useLoadMoreSentinelFunction · 0.90
useResizeObserverFunction · 0.90
useActionGroupItemFunction · 0.90
useFormValidationFunction · 0.90
useSpinButtonFunction · 0.90
useTableColumnResizeFunction · 0.90

Calls

no outgoing calls

Tested by 2

EditableTableFunction · 0.72
ActionEditableTableFunction · 0.72