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";
|
---|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
---|
3 | var tslib_1 = require("tslib");
|
---|
4 | var fast_shallow_equal_1 = require("fast-shallow-equal");
|
---|
5 | var useCustomCompareEffect_1 = tslib_1.__importDefault(require("./useCustomCompareEffect"));
|
---|
6 | var isPrimitive = function (val) { return val !== Object(val); };
|
---|
7 | var shallowEqualDepsList = function (prevDeps, nextDeps) {
|
---|
8 | return prevDeps.every(function (dep, index) { return fast_shallow_equal_1.equal(dep, nextDeps[index]); });
|
---|
9 | };
|
---|
10 | var 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 | };
|
---|
21 | exports.default = useShallowCompareEffect;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.