shallowCompare浅比较,判断组件是否需要重绘。
'use strict'; var shallowEqual = require('fbjs/lib/shallowEqual'); // 比较更新前后的props、state,值不等、对象不包含相同的属性或其属性值不等时,返回true进行组件重绘 function shallowCompare(instance, nextProps, nextState) { return !shallowEqual(instance.props, nextProps) || !shallowEqual(instance.state, nextState); } module.exports = shallowCompare;