Guest User

Untitled

a guest
Oct 15th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.36 KB | None | 0 0
  1. deleteBook = (id) => {
  2. const newBooks = {...this.state.books};
  3. if(newBooks.hasOwnProperty(id)){
  4. //удаляем объект из Dom
  5. delete newBooks[id];
  6. //перезаписываем его в localStorage
  7. localStorage.setItem("SAVED_BOOK", JSON.stringify(newBooks[id]));
  8. this.setState({books: newBooks});
  9. }
  10. };
Add Comment
Please, Sign In to add comment