問題描述使用react開發過程中,用ES6語法寫組件如下const Name = (props) => { this.state = { data: null, visible: false
};
const open = (data) => { this.setState({
data, visible: true
});
}
return ( <div>content</div>
);
}當執行open()時提示Unhandled Rejection (TypeError): _this.setState is not a function嘗試過const that = this;that.setState({})抱一樣的錯誤,求大佬解答。
ES6寫react組件 _this.setState is not a function
慕尼黑8549860
2018-08-03 18:59:39