初次加载组件的时候,会调用一次render函数
如果不是前两种,还希望组件发生更新,可以使用 this.forceUpdate()
this.forceUpdate()
注意: <button onClick={() => this.forceUpdate()}>强制渲染 不可以写为<button onClick={this.forceUpdate}>强制渲染</button>
<button onClick={() => this.forceUpdate()}>
<button onClick={this.forceUpdate}>强制渲染</button>
React触发页面渲染的几种方式
原文:https://www.cnblogs.com/sunhang32/p/12724134.html