使用 JSON.stringify 字符串化 props,再对比,有什么弊端吗?

#1

这里不想用不可变数据。

只是想在 shouldComponentUpdate 里面:


shouldComponentUpdate(nextProps, nextState) {
  return JSON.stringify(this.props) !== JSON.stringify(nextProps);
}

#2

数据量多的时候性能会出问题, 毕竟 JSON.stringify 也是要时间的. 从根节点一路下来都要执行一遍.

#3

也是,没必要每个地方都做

#4

没仔细研究, 搜了一下貌似问题不小, 需要留一下 http://stackoverflow.com/questions/1068834/object-comparison-in-javascript

#5

多了不适合,少了没必要…