source: imaps-frontend/node_modules/react-use/lib/useShallowCompareEffect.js

main
Last change on this file 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 tslib_1 = require("tslib");
4var fast_shallow_equal_1 = require("fast-shallow-equal");
5var useCustomCompareEffect_1 = tslib_1.__importDefault(require("./useCustomCompareEffect"));
6var isPrimitive = function (val) { return val !== Object(val); };
7var shallowEqualDepsList = function (prevDeps, nextDeps) {
8 return prevDeps.every(function (dep, index) { return fast_shallow_equal_1.equal(dep, nextDeps[index]); });
9};
10var useShallowCompareEffect = function (effect, deps) {
11 if (process.env.NODE_ENV !== 'production') {
12 if (!(deps instanceof Array) || !deps.length) {
13 console.warn('`useShallowCompareEffect` should not be used with no dependencies. Use React.useEffect instead.');
14 }
15 if (deps.every(isPrimitive)) {
16 console.warn('`useShallowCompareEffect` should not be used with dependencies that are all primitive values. Use React.useEffect instead.');
17 }
18 }
19 useCustomCompareEffect_1.default(effect, deps, shallowEqualDepsList);
20};
21exports.default = useShallowCompareEffect;
Note: See TracBrowser for help on using the repository browser.