fix: failed eslint checks (#1616)

This commit is contained in:
João Nuno Mota 2023-05-01 01:38:35 +01:00 committed by GitHub
parent f12163bc94
commit 3314fe8b0e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -15,11 +15,9 @@ function useLatestValue<T>(value: T) {
}
// TODO: Add React.useEvent ?? once the useEvent hook is available
function useEvent<F extends (...args: any[]) => any, P extends any[] = Parameters<F>, R = ReturnType<F>>(
cb: (...args: P) => R
) {
function useEvent<F extends (...args: any[]) => any, P extends any[] = Parameters<F>, R = ReturnType<F>>(cb: (...args: P) => R) {
const cache = useLatestValue(cb);
return React.useCallback((...args: P) => cache.current(...args), [cache]);
};
}
export default useEvent;