Answers for "how to add new object in arrat using setstate"

CSS
-1

add object to array setstate

To push to the beginning of the array do it this way

   this.setState( prevState => ({
     userFavorites: [{id: 3, title: 'C'}, ...prevState.userFavourites]
  }));
Posted by: Guest on October-06-2020

Code answers related to "how to add new object in arrat using setstate"

Browse Popular Code Answers by Language