// copied from https://github.com/jaredLunde/react-hook/blob/master/packages/latest/src/index.tsx import * as React from 'react'; const useLatest = (current: T) => { const storedValue = React.useRef(current); React.useEffect(() => { storedValue.current = current; }); return storedValue; }; export default useLatest;