title: Best way to clean an array and insert a new element
body: <p>I want to know what the best way to clean an array would be, write a new element.
  My array, selectedUser, will be nurtured with the information I send as payload, after clicking on a row in the table.
  You should always have only one element in the array, so I must delete the information it contains when selecting another element. I am currently doing it as follows, but I don't think it's the right one.</p>
  
  <pre><code>import * as actionTypes from "../actions/userModuleActions";
  const initialState = {
    selectedUser: []
  };
  const reducer = (state = initialState, action) =&gt; {
    state.selectedUser = [];
    switch (action.type) {
      case actionTypes.UPDATE_USER_MODULE_SELECTED_USER:
        return {
          ...state,
          selectedUser: state.selectedUser.concat(action.payload)
        };
      default:
        return state;
    }
  };
  export default reducer;
  </code></pre>