我是 React.js 库的新手,我正在阅读一些教程,我遇到了:
this.setStatethis.replaceState
给出的描述不是很清楚(IMO)。
setState is done to 'set' the state of a value, even if its already set 
in the 'getInitialState' function.
相似地,
The replaceState() method is for when you want to clear out the values 
already in state, and add new ones.
我尝试this.setState({data: someArray});了this.replaceState({test: someArray});follow 和 console.logged 它们,我发现state现在有data和test。
然后,我尝试this.setState({data: someArray});了this.setState({test: someArray});follow 和 console.logged 它们,我发现它又state同时具有data和test。
那么,两者究竟有什么区别呢?