使用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({})
抱一样的错误,求大佬解答。
繁星淼淼
精慕HU