我的handleClick箭头功能出现意外错误我不知道为什么,无法发现任何错误。
class HelloWidget extends React.Component {
constructor(props) {
super(props);
this.names_holder = [];
this.state = {
name: []
};
}
handleClick = () => { //error here
let random = this.names_holder.concat(Math.ceil(Math.random() * 10) + 3);
this.setState({
name: random
});
}
render() {
return <div className = "widget" >
< button onClick = {
this.handleClick
} > Random concat < /button> {
JSON.stringify(this.state.name)
} < /div>;
}
}