this is my state:
class table extends Component {
state = {
arr: [],
numofSub: 1
};
I wish to push an object to the arr with set state through fetch from my database, the fetch works great I console logged it, I just cant seem to push the object inside the array:
componentWillMount() {
fetch('/api/items')
.then(data => data.json())
.then(inputs => this.setState({ arr: [...inputs] }));
}
this.setState({ arr: [...this.state.arr, ...inputs] })