Searchbox dosen't work when the input is erased react redux

Viewed 30
1 Answers

Try to change to:

case "SEARCH_DATA": {
  const { event } = action.payload;
  let res = [];
  if (event)  {
   res = state.data.filter( el => el.name.toLowerCase().includes(event));
  }
  return {
    ...state,
    data : res, // here is pass the result of the filter fn
    loading: true
  };
}
Related