just at the beginning of learning react, I would like to ask, with an add button, below is a ul, and then every click of button, adds li, to the following ul. How does the following code report an error? the error is this.state.listitem.push is not a function
.const numbers = [1, 2, 3, 4, 5];
var index=0;
class App extends React.Component{
constructor(props){
super(props);
this.state={listitem:[]};
this.handleClick = this.handleClick.bind(this);
}
handleClick() {
this.setState(
listitem: this.state.listitem.push(<li>{numbers[0]}</li>);
);
}
render(){
return (
<div>
<button onClick={this.handleClick}>
Add
</button>
<ul>{this.state.listitem}</ul>
</div>
)
}
}
ReactDOM.render(
<App />,
document.getElementById("root")
);