problem description
in the process of developing with react, write components with ES6 syntax as follows
const Name = (props) => {
this.state = {
data: null,
visible: false
};
const open = (data) => {
this.setState({
data,
visible: true
});
}
return (
<div>content</div>
);
}
prompt Unhandled Rejection (TypeError): _ this.setState is not a function
open ()
tried
const that = this;
that.setState({})
hold the same mistake and ask the boss for an answer.