this.setState( prevState => ({
userFavorites: [...prevState.userFavourites, {id: 3, title: 'C'}]
}));
const handleAdd = (todo) => {
const newTodos = [...todos];
newTodos.push(todo);
setTodos(newTodos);
}
this.setState(prevState => ({
arrayvar: [...prevState.arrayvar, newelement]
}))
To push to the beginning of the array do it this way
this.setState( prevState => ({
userFavorites: [{id: 3, title: 'C'}, ...prevState.userFavourites]
}));
var joined = this.state.myArray.concat('new value');
this.setState({ myArray: joined })