1 | "use strict";
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports["default"] = void 0;
|
7 | var _react = require("react");
|
8 | var defaultShouldUpdate = function defaultShouldUpdate(a, b) {
|
9 | return !Object.is(a, b);
|
10 | };
|
11 | function usePrevious(state, shouldUpdate) {
|
12 | if (shouldUpdate === void 0) {
|
13 | shouldUpdate = defaultShouldUpdate;
|
14 | }
|
15 | var prevRef = (0, _react.useRef)();
|
16 | var curRef = (0, _react.useRef)();
|
17 | if (shouldUpdate(curRef.current, state)) {
|
18 | prevRef.current = curRef.current;
|
19 | curRef.current = state;
|
20 | }
|
21 | return prevRef.current;
|
22 | }
|
23 | var _default = usePrevious;
|
24 | exports["default"] = _default; |
\ | No newline at end of file |