react中state應該注意的點

正確的使用State 不要直接修改state 此代碼不會渲染組件java // Wrong this.state.comment = 'Hello'; 而是應該使用setState()react // Correct this.setState({comment: 'Hello'}); 構造函數是惟一能夠給this.state賦值的地方web state的更新多是異步的 出於性能考慮,react可
相關文章
相關標籤/搜索