Answers for "redux if already exist item dont add to array"

0

redux if already exist item dont add to array

Element won't be duplicated and always at 0 index,

return {
    ...state,
    data: {
      ...state.data,
      list: [].concat(action.payload.list, state.data.list.filter(val=>val.id==action.payload.list.id))
    }
  }
Posted by: Guest on March-07-2021

Code answers related to "redux if already exist item dont add to array"

Code answers related to "Javascript"

Browse Popular Code Answers by Language