9 lines
279 B
TypeScript
9 lines
279 B
TypeScript
import { useRef } from 'react';
|
|
|
|
/** Hook that allows using useState values in event handlers. */
|
|
// https://stackoverflow.com/a/64770671/8811886
|
|
export const useRefEventHandler = (fn: (...params: any) => void) => {
|
|
const ref = useRef(fn);
|
|
ref.current = fn;
|
|
return ref;
|
|
};
|