title: Returning array react-redux
body: <p>I am trying to return an array in react-redux, but I get undefined when I try to get them in my react component.</p>
  
  <p>How do I return an array, using the "GET_TODO", "GET_FINISHED", "GET_LATER" cases.</p>
  
  <h1>Reducer, ( GET_ is the one that should return an array )</h1>
  
  <pre><code>const initialState = {
    today: [1, 2, 3],
    finished: [3, 2, 1, 3],
    later: [2, 3, 1, 4, 2, 5]
  };
  
  export default (state = initialState, action) =&gt; {
  
    switch (action.type) {
  
      case 'ADD_TODO':
        return [...state.today, action.payload]
      case 'DELETE_TODO':
        return state.today.filter((item, index) =&gt; index !== action.payload)
      case 'GET_TODO':
        return state.today
      case 'ADD_LATER':
        return [...state, action.payload]
      case 'DELETE_LATER':
        return state.filter((item, index) =&gt; index !== action.payload)
      case 'GET_LATER':
        return [...state.later]
      case 'ADD_FINISHED':
        return [...state, action.payload]
      case 'DELETE_FINISHED':
        return state.filter((item, index) =&gt; index !== action.payload)
      case 'GET_FINISHED':
        return [...state.finished]
      default:
        return state;
    }
  }
  </code></pre>
  
  <h1>React component</h1>
  
  <pre><code>componentDidMount() {
      this.props.get();
    }
  </code></pre>
  
  <h2>mapStateToProps &amp; mapDispatchToProps</h2>
  
  <pre><code>function mapStateToProps(state) {
    return {
      today: state.important.today ? state.important.today : [],
      finished: state.important.finished ? state.important.finished : [],
      later: state.important.later ? state.important.later : [],
  
    }
  }
  </code></pre>
  
  <pre><code>function mapDispatchToProps(dispatch) {
    return {
      add: (value) =&gt; {
        dispatch({ type: 'ADD_TODO', payload: value })
      },
      remove: (index) =&gt; {
        dispatch({ type: 'DELETE_TODO', payload: index })
      },
      get: () =&gt; {
        dispatch({type:'GET_TODO'})
      },
      addToFinished: (value) =&gt; {
        dispatch({ type: 'ADD_FINISHED', payload: value })
      },
      removeFinished: (index) =&gt; {
        dispatch({ type: 'DELETE_FINISHED', payload: index })
      },
      addToLater: (value) =&gt; {
        dispatch({ type: 'ADD_LATER', payload: value })
      },
      removeLater: (index) =&gt; {
        dispatch({ type: 'DELETE_LATER', payload: index })
      }
    }
  }
  </code></pre>