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:
764 bytes
|
Rev | Line | |
---|
[d565449] | 1 | import useCustomCompareEffect from './useCustomCompareEffect';
|
---|
| 2 | import isDeepEqual from './misc/isDeepEqual';
|
---|
| 3 | var isPrimitive = function (val) { return val !== Object(val); };
|
---|
| 4 | var useDeepCompareEffect = function (effect, deps) {
|
---|
| 5 | if (process.env.NODE_ENV !== 'production') {
|
---|
| 6 | if (!(deps instanceof Array) || !deps.length) {
|
---|
| 7 | console.warn('`useDeepCompareEffect` should not be used with no dependencies. Use React.useEffect instead.');
|
---|
| 8 | }
|
---|
| 9 | if (deps.every(isPrimitive)) {
|
---|
| 10 | console.warn('`useDeepCompareEffect` should not be used with dependencies that are all primitive values. Use React.useEffect instead.');
|
---|
| 11 | }
|
---|
| 12 | }
|
---|
| 13 | useCustomCompareEffect(effect, deps, isDeepEqual);
|
---|
| 14 | };
|
---|
| 15 | export default useDeepCompareEffect;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.