UNPKG

354 BJavaScriptView Raw
1import * as React from 'react';
2export default function useMemo(getValue, condition, shouldUpdate) {
3 var cacheRef = React.useRef({});
4 if (!('value' in cacheRef.current) || shouldUpdate(cacheRef.current.condition, condition)) {
5 cacheRef.current.value = getValue();
6 cacheRef.current.condition = condition;
7 }
8 return cacheRef.current.value;
9}
\No newline at end of file