minishouyin/node_modules/rc-util/es/hooks/useMemo.js
2025-11-12 11:35:57 +08:00

9 lines
354 B
JavaScript

import * as React from 'react';
export default function useMemo(getValue, condition, shouldUpdate) {
var cacheRef = React.useRef({});
if (!('value' in cacheRef.current) || shouldUpdate(cacheRef.current.condition, condition)) {
cacheRef.current.value = getValue();
cacheRef.current.condition = condition;
}
return cacheRef.current.value;
}