volleyball-dev-frontend/node_modules/react-pdf/dist/esm/shared/hooks/useCachedValue.js
2025-06-02 16:42:16 +00:00

16 lines
396 B
JavaScript

'use client';
import { useRef } from 'react';
import { isDefined } from '../utils.js';
export default function useCachedValue(getter) {
const ref = useRef(undefined);
const currentValue = ref.current;
if (isDefined(currentValue)) {
return () => currentValue;
}
return () => {
const value = getter();
ref.current = value;
return value;
};
}