title: Redux: what is the correct way to filter a data array in reducer?
body: <p>i want to filter an array on search SEARCH_TEXT is an on change action
  what I'm confused with is how i return the state when the delete key is pressed and the text now becomes empty, i figure i could use initial state in the else statement but my inclination is this is wrong? when i return just state it has all ready been manipulated in the if statement.</p>
  
  <p>simple example.</p>
  
  <p>thanks in advance.</p>
  
  <pre><code>const initialState =  ['hello', 'wahhh', 'yo'];
  
  export default function searchSimple(state = initialState, action) {
    switch (action.type) {
      case SEARCH_TEXT:
        if(action.text.length &gt; 0){
          return state.filter(item =&gt;
            item.startsWith(action.text)
          )
        }
        else {
          return state
        }
  </code></pre>