File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed
packages/@react-aria/utils/src Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -17,7 +17,10 @@ import {useLayoutEffect} from './useLayoutEffect';
1717// before all layout effects, but is available only in React 18 and later.
1818const useEarlyEffect = React [ 'useInsertionEffect' ] ?? useLayoutEffect ;
1919
20- export function useEffectEvent < T extends Function > ( fn ?: T ) : T {
20+ // Starting with React 19.2, this hook has been internalized.
21+ const useModernEffectEvent = React [ 'useEffectEvent' ] ?? useLegacyEffectEvent ;
22+
23+ function useLegacyEffectEvent < T extends Function > ( fn ?: T ) : T {
2124 const ref = useRef < T | null | undefined > ( null ) ;
2225 useEarlyEffect ( ( ) => {
2326 ref . current = fn ;
@@ -28,3 +31,8 @@ export function useEffectEvent<T extends Function>(fn?: T): T {
2831 return f ?.( ...args ) ;
2932 } , [ ] ) ;
3033}
34+
35+ export function useEffectEvent < T extends Function > ( fn ?: T ) : T {
36+ let noop = useCallback ( ( ) => { } , [ ] ) ;
37+ return useModernEffectEvent ( fn ?? noop ) ;
38+ }
You can’t perform that action at this time.
0 commit comments