1 | "use strict";
|
2 |
|
3 | var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
4 | Object.defineProperty(exports, "__esModule", {
|
5 | value: true
|
6 | });
|
7 | exports.default = useMemo;
|
8 | var React = _interopRequireWildcard(require("react"));
|
9 | function 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 |