Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

add object to array setstate


 this.setState( prevState => ({
     userFavorites: [...prevState.userFavourites,  {id: 3, title: 'C'}]
 }));

Source by nullorempty.org #
 
PREVIOUS NEXT
Tagged: #add #object #array #setstate
ADD COMMENT
Topic
Name
4+8 =