我怎样才能shouldComponentUpdate用于州?
我可以查一下:
shouldComponentUpdate(nextProps, nextState) {
return this.state.value != nextState.value;
}
Run Code Online (Sandbox Code Playgroud)
但它对国家没有任何意义.因为如果我改变state(this.setState({value: 'newValue'}))this.state将是平等的 nextState.
例如,onClick事件:
handleClick() {
this.setState({value: 'newValue'});
}
Run Code Online (Sandbox Code Playgroud) reactjs ×1