UNPKG

272 BJavaScriptView Raw
1import { useCallback } from 'react';
2import useCommittedRef from './useCommittedRef';
3export default function useEventCallback(fn) {
4 const ref = useCommittedRef(fn);
5 return useCallback(function (...args) {
6 return ref.current && ref.current(...args);
7 }, [ref]);
8}
\No newline at end of file