GoScrobble/web/node_modules/@restart/hooks/esm/useUpdatedRef.js

13 lines
283 B
JavaScript
Raw Normal View History

2022-04-25 02:47:15 +00:00
import { useRef } from 'react';
/**
* Returns a ref that is immediately updated with the new value
*
* @param value The Ref value
* @category refs
*/
export default function useUpdatedRef(value) {
var valueRef = useRef(value);
valueRef.current = value;
return valueRef;
}