import type React from 'react'; type UseMakeMutable = (referenceVar: T) => React.MutableRefObject; /** * For specific scenarios we need to be able to read the latest value of a variable at execution time without triggering dependency updates on useEffect/useCallback/useMemo * This is a custom hook that allows us to do that, with a performance overhead of a useEffect and a memory overhead of a ref. * @param {any} referenceVar - the value to be made "referentially stable", this works with primitive values and values by reference * @returns {object} - an object with a "current" property that holds the latest value of the variable passed as argument * @property {any} current - the latest value of the variable passed as argument * @example * const Comp = ({ value }) => { * const latestValueRef = useMakeMutable(value); * React.useEffect(() => { * console.log(latestValueRef.current); // this will log 'hola' at the time of execution * }, []); * latestValueRef.current = 'hola'; // this will update the latest value of "value" at the time of execution * ... * return
...
* } */ export declare const useMakeMutable: UseMakeMutable; /** * For specific scenarios we need to be able to read the latest value of a variable at execution time without triggering dependency updates on useEffect/useCallback/useMemo * This is a custom hook that allows us to do that, with a performance overhead of a useEffect and a memory overhead of a ref. * N.B. this is the same as useMakeMutable, but with a more explicit name. * @param {any} referenceVar - the value to be made "referentially stable", this works with primitive values and values by reference * @returns {object} - an object with a "current" property that holds the latest value of the variable passed as argument * @property {any} current - the latest value of the variable passed as argument * @example * const Comp = ({ value }) => { * const latestValueRef = useLatestValueReferenciallyStable(value); * React.useEffect(() => { * console.log(latestValueRef.current); // this will log 'hola' at the time of execution * }, []); * latestValueRef.current = 'hola'; // this will update the latest value of "value" at the time of execution * ... * return
...
* } */ export declare const useLatestValueReferenciallyStable: UseMakeMutable; export {};