@geneui/components
Version:
The Gene UI components library designed for BI tools
15 lines (12 loc) • 392 B
JavaScript
import { useRef, useCallback } from 'react';
import useForceUpdate from './useForceUpdate.js';
const useUpdatableRef = initial => {
const ref = useRef(initial);
const forceUpdate = useForceUpdate();
const update = useCallback(value => {
if (ref.current !== value) forceUpdate();
ref.current = value;
}, []);
return [ref, update];
};
export { useUpdatableRef as default };