Files
30-seconds-of-code/node_modules/shallow-compare/lib/index.js
2019-08-20 15:52:05 +02:00

18 lines
545 B
JavaScript

"use strict";
exports.__esModule = true;
// Pulled from react-compat
// https://github.com/developit/preact-compat/blob/7c5de00e7c85e2ffd011bf3af02899b63f699d3a/src/index.js#L349
function shallowDiffers(a, b) {
for (var i in a) {
if (!(i in b)) return true;
}for (var _i in b) {
if (a[_i] !== b[_i]) return true;
}return false;
}
exports.default = function (instance, nextProps, nextState) {
return shallowDiffers(instance.props, nextProps) || shallowDiffers(instance.state, nextState);
};
module.exports = exports["default"];