react中state应该注意的点

正确的使用State 不要直接修改state 此代码不会渲染组件java // Wrong this.state.comment = 'Hello'; 而是应该使用setState()react // Correct this.setState({comment: 'Hello'}); 构造函数是惟一能够给this.state赋值的地方web state的更新多是异步的 出于性能考虑,react可
相关文章
相关标签/搜索