, array.push() . .
: array.concat[]
newArray = oldArray.concat[newItem];
.concat[] .push().
, React state :
selectedBook.shelf = newShelf;
this.setState((prevState) => (
{books: prevState.books
.filter((book) => (book.id !== selectedBook.id))
.concat(selectedBook)
}
));
state books, book.
book - id shelf ( ).
setState() , state
selectedBook books, shelf .
setState .
, , .
, books .
filter, selectedBook.
concat selectedBook , shelf.
push.
concat.
:
array.push() ( ).
array.concat[] .