source: imaps-frontend/node_modules/react-use/lib/useCustomCompareEffect.js@ d565449

main
Last change on this file since d565449 was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

  • Property mode set to 100644
File size: 1.1 KB
Line 
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3var react_1 = require("react");
4var isPrimitive = function (val) { return val !== Object(val); };
5var useCustomCompareEffect = function (effect, deps, depsEqual) {
6 if (process.env.NODE_ENV !== 'production') {
7 if (!(deps instanceof Array) || !deps.length) {
8 console.warn('`useCustomCompareEffect` should not be used with no dependencies. Use React.useEffect instead.');
9 }
10 if (deps.every(isPrimitive)) {
11 console.warn('`useCustomCompareEffect` should not be used with dependencies that are all primitive values. Use React.useEffect instead.');
12 }
13 if (typeof depsEqual !== 'function') {
14 console.warn('`useCustomCompareEffect` should be used with depsEqual callback for comparing deps list');
15 }
16 }
17 var ref = react_1.useRef(undefined);
18 if (!ref.current || !depsEqual(deps, ref.current)) {
19 ref.current = deps;
20 }
21 react_1.useEffect(effect, ref.current);
22};
23exports.default = useCustomCompareEffect;
Note: See TracBrowser for help on using the repository browser.