How do I prevent adding duplicate values to an array using Redux?

I want the user to tap on an item from a list and add it to their favorites page. The problem I’m having is that if the user taps on the same item twice it will be added to their favorites page twice and create issues because two children have the same key.

I’m updating the state this way in reducer:

const initialState = {
  selectedFavorites: [],
};

addFavorite: (state, action) => {
  return {
    ...state,
    selectedFavorites: [...state.selectedFavorites, action.payload],
  };
},

When user taps on item to be added to favorites:

  const handlePress = () => {
    favorite === true ? setFavorite(false) : setFavorite(true);


dispatch(
  addFavorite({
    id: currentIndex,
    title: getIds[currentIndex].title,
    liked: 'true',
  }),
);
setTimeout(() => {
  setFavorite(false);
}, 500);
  };

I’ve tried using new Set() but was unable to make this work. What is a good way to copy and render the state without any duplicate values?