title: useDispatch() throwing error from reducer
body: <p>I'm building an app that loads in Trump's tweets and visualizes them. Right now, I have the tweets in a .json file, but eventually I want to call an API asynchronously to fetch the tweets. However, my reducer keeps throwing a new error from the <code>default</code> clause in the <code>switch</code> statement, and I can't figure out why! The goal is to achieve <code>FETCH_TWEETS_SUCCESS</code>, which should be guaranteed since I'm just importing a .json file.</p>
  
  <p>EDIT: The repo is here: <a href="https://github.com/inspectordanno/trump_tweets" rel="nofollow noreferrer">https://github.com/inspectordanno/trump_tweets</a></p>
  
  <p>I built out a <code>useEffect()</code> hook which will fetch data. Again, right now I'm just passing an .json file so the whole exercise is a bit overkill. Anyway, here is my app with the actions dispatched from the <code>useDispatch()</code> hook, a new hook from react-redux:</p>
  
  <pre><code>import React, { useEffect } from 'react';
  import tweets from '../../trump_r/tweets_cleaned.json';
  import { useDispatch } from 'react-redux';
  
  const TrumpApp = () =&gt; {
    const dispatch = useDispatch();
  
    useEffect(() =&gt; {  
      let didCancel = false;
  
      const fetchData = () =&gt; {
        dispatch({ type: 'FETCH_TWEETS_INIT' });
        try {
          if (!didCancel) {
            dispatch({ type: 'FETCH_TWEETS_SUCCESS', payload: tweets });
          }
        } catch (error) {
          if (!didCancel) {
            dispatch({ type: 'FETCH_TWEETS_FAILURE' });
          } 
        }
      }
      fetchData();
  
      return () =&gt; {
        didCancel = true;
      };
  
    }, []);
  
    return (
        &lt;h1&gt;hello world&lt;/h1&gt;
    );
  }
  
  export default TrumpApp;
  </code></pre>
  
  <p>This is my reducer:</p>
  
  <pre><code>const fetchTweetsReducerDefaultState = {
    isLoading: false,
    isError: false,
    data: 'data not loaded'
  };
  
  const fetchTweetsReducer = (state = fetchTweetsReducerDefaultState, action) =&gt; {
    switch (action.type) {
      case 'FETCH_TWEETS_INIT':
        return {
          ...state,
          isLoading: true,
          isError: false
        };
      case 'FETCH_TWEETS_SUCCESS':
        return {
          ...state,
          isLoading: false,
          isError: false,
          data: action.payload
        };
      case 'FETCH_TWEETS_FAILURE':
        return {
          ...state,
          isLoading: false,
          isError: true
        };
      default:
        throw new Error();
    }
  }
  
  export default fetchTweetsReducer;
  </code></pre>
  
  <p>Store is here:</p>
  
  <pre><code>import { createStore, combineReducers } from 'redux';
  import fetchTweetsReducer from '../reducers/fetchTweetsReducer';
  
  export default () =&gt; {
    const store = createStore(
      combineReducers({
        tweets: fetchTweetsReducer,
      }),
      window.__REDUX_DEVTOOLS_EXTENSION__ &amp;&amp; window.__REDUX_DEVTOOLS_EXTENSION__()
    );
    return store;
  }
  </code></pre>
  
  <p>And finally for good measure, app.js:</p>
  
  <pre><code>import React from 'react';
  import ReactDOM from 'react-dom';
  import { Provider } from 'react-redux';
  import configureStore from './store/configureStore';
  import TrumpApp from './components/TrumpApp';
  // import 'normalize.css/normalize.css';
  // import './styles/styles.scss';
  
  const store = configureStore();
  
  const jsx = (
    &lt;Provider store={store}&gt;
      &lt;TrumpApp /&gt;
    &lt;/Provider&gt;
  );
  
  ReactDOM.render(jsx, document.getElementById('root'));
  </code></pre>
  
  <p>I have the @next latest version of react-redux installed, and the latest version of everything. I even tried commenting out the <code>try/catch</code> block and just dispatching a <code>'FETCH_TWEETS_SUCCESS'</code> action, but I'm still getting the same error from my reducer. I'm assuming that there is some faulty logic in my reducer but I can't figure out what is going on.</p>