The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
Rocket.Chat/client/hooks/useEventCallback.js

13 lines
342 B

import { useCallback, useLayoutEffect, useRef } from 'react';
export const useEventCallback = (fn, ...deps) => {
const fnRef = useRef(fn);
const depsRef = useRef(deps);
useLayoutEffect(() => {
fnRef.current = fn;
depsRef.current = deps;
});
return useCallback((...args) => (0, fnRef.current)(...depsRef.current, ...args), []);
};