`

shallowCompare

 
阅读更多

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;

 

0
0
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics