title: React Native Redux : "Undefined is not an object (evaluating 'action.type')"
body: <p>I'm use Redux with ReactNative,I'd like to create a store with reducer</p>
  
  <p>And,I got error below, point to line 'switch (action.type)' in function toggleFavorite() in favoriteReducer.js. I found a similar topic but it didn't fix it...</p>
  
  <blockquote>
    <p>undefined is not an object(evaluating 'action.type')</p>
  </blockquote>
  
  <p>favoriteReducer.js :</p>
  
  <pre><code>const initialState = { favoriteQuotes: [] }
  
  function toggleFavorite(state = initialState, action) {
    let nextState
    switch (action.type) {
      case 'TOGGLE_FAVORITE':
        const favoriteQuoteIndex = state.favoriteQuotes.findIndex(item =&gt; item.id === action.value.id)
        if (favoriteQuoteIndex !== -1) {
          // La citation est déjà dans les favoris, on la supprime de la liste
          nextState = {
            ...state,
            favoriteQuotes: state.favoriteQuotes.filter( (item, index) =&gt; index !== favoriteQuoteIndex)
          }
        }
        else {
          // La citation n'est pas dans les favoris, on l'ajoute à la liste
          nextState = {
            ...state,
            favoriteQuotes: [...state.favoriteQuotes, action.value]
          }
        }
        return nextState || state
    default:
      return state
    }
  }
  
  export default toggleFavorite()
  </code></pre>
  
  <p>configureStore.js :</p>
  
  <pre><code>import { createStore } from 'redux';
  import toggleFavorite from './Reducers/favoriteReducer'
  
  export default createStore(toggleFavorite)
  </code></pre>
  
  <p>Here is where I use "dispatch":</p>
  
  <pre><code>import React from 'react'
  ...
  import { connect } from 'react-redux'
  
  class QuoteDetail extends React.Component {
  
  ...
  
    _toggleFavorite() {
      const action = { type: "TOGGLE_FAVORITE", value: this.state.quote }
      this.props.dispatch(action)
    }
  
  ...
  
  &lt;Button title="Favoris" onPress={() =&gt; this._toggleFavorite()}/&gt;
  
  ...
  
  const mapStateToProps = (state) =&gt; {
    return {
      favoriteQuotes: state.favoriteQuotes
    }
  }
  export default connect(mapStateToProps)(QuoteDetail)
  </code></pre>
  
  <p>Anyone have an idea ??</p>