@atlaskit/pragmatic-drag-and-drop-react-beautiful-dnd-migration
Version:
An optional Pragmatic drag and drop package that enables rapid migration from react-beautiful-dnd to Pragmatic drag and drop
15 lines (14 loc) • 336 B
JavaScript
import { useCallback, useEffect, useRef } from 'react';
/**
* Allows access to a changing value in a stable way.
*/
export function useStable(value) {
const ref = useRef(value);
useEffect(() => {
ref.current = value;
}, [value]);
const getValue = useCallback(() => {
return ref.current;
}, []);
return getValue;
}