UNPKG

@hello-pangea/dnd

Version:

Beautiful and accessible drag and drop for lists with React

16 lines (12 loc) 307 B
import { useRef, useEffect } from 'react'; export default function usePrevious<T>(current: T): { current: T; } { const ref = useRef<T>(current); // will be updated on the next render useEffect(() => { ref.current = current; }); // return the existing current (pre render) return ref; }