0

I'm trying to remove an item inside the _state[] by comparing the id of the item to be removed. I used filter but when trying to call this action throw the store all the values are still showing.

export const bookReducer = createReducer(
  initialCtion,
  on(book.retrievedBook, (_state, { book } ) => book),
  on(book.removeBook., (_state, { book } ) =>  _state.filter((id) => id.id != book) || [])
);

Below is showing the book object that is passed down to the book arg shown above.

book: Book= {
id: "2342342",
name: "case1"
}

onRemove(_action: Book){
  const book= _book.id;
  this.store.dispatch(ApiBooks.removeBook({book}))
}

0 Answers0