title: prevent duplicate objects being added to state react redux
body: <p>I have a question regarding preventing duplicates from being added to my redux store.</p>
  
  <p>It should be straight forward but for some reason nothing I try is working.</p>
  
  <pre><code>export const eventReducer = (state = [], action) =&gt; {
  
      switch(action.type) {
  
          case "ADD_EVENT":
  
              return [...state, action.event].filter(ev =&gt; {
                  if(ev.event_id !== action.event.event_id){
                     return ev;
                  }
              });
  
  
          default:
              return state;
  
      }
  
  };
  </code></pre>
  
  <p>The <code>action</code> looks something like the below:</p>
  
  <pre><code>{
     type: "ADD_EVENT",
     event: { event_id: 1, name: "Chelsea v Arsenal" }
  }
  </code></pre>
  
  <p>The issue is that on occasions the API I am working with is sending over identical messages through a websocket, which means that two identical events are getting added to my store.</p>
  
  <p>I have taken many approaches but cannot figure out how to get this to work. I have tried many SO answers, </p>