UNPKG

565 BJavaScriptView Raw
1"use strict";
2
3var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
4Object.defineProperty(exports, "__esModule", {
5 value: true
6});
7exports.default = useMemo;
8var React = _interopRequireWildcard(require("react"));
9function useMemo(getValue, condition, shouldUpdate) {
10 var cacheRef = React.useRef({});
11 if (!('value' in cacheRef.current) || shouldUpdate(cacheRef.current.condition, condition)) {
12 cacheRef.current.value = getValue();
13 cacheRef.current.condition = condition;
14 }
15 return cacheRef.current.value;
16}
\No newline at end of file