title: Remove first element from array in reducer state
body: <p>I want to keep maximum array count to 10. When new object is added to reducer state, if the array count exceeds 10 I want to remove first object. How can I do this ?</p>
  
  <p>This is my code:</p>
  
  <pre><code>switch(action.type) {
      case types.RECENTLY_VIEWED_ITEM:
          return Object.assign({}, state, {
          data: [
              ...(state.data.filter(item =&gt; (item.id !== action.payload.id))), 
              action.payload
              ]
          });
  
      case types.REMOVE_RECENTLY_VIEWED_ITEM:
          return Object.assign({}, state, {
          data: [
              ...(state.data.splice(0, 1))
          ]});
  
          default:
          return state;
  }
  </code></pre>
  
  <p>Thank you</p>