UNPKG

reactshouldupdate

Version:

Simple util to compare props and state in shouldComponentUpdate

37 lines (25 loc) 728 B
'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _lodash = require('lodash.isequal'); var _lodash2 = _interopRequireDefault(_lodash); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var check = function check(obj) { if (!obj) { return false; } for (var i = 0; i < obj.checks.length; i++) { var property = obj.checks[i]; if (!(0, _lodash2.default)(obj.current[property], obj.next[property])) { return true; } } return false; }; exports.default = function (options) { var props = options.props; var state = options.state; return check(props) || check(state); }; module.exports = exports['default'];