title: Redux action creator getting "TypeError: dispatch(...) is not a function" (code attached)?
body: <p>Any ideas why I am getting the following this "dispatch is not a function" error in my listEventsActionCreator function when it calls "dispatch(listEventsRequestedAction())" ???</p>
  
  <p>If I comment out the lines in this method <em>after</em> the dispatch it actually then works which is strange. </p>
  
  <p>Using react-create-app, with redux, typescript, thunk.</p>
  
  <p>ERROR:</p>
  
  <pre><code>TypeError: dispatch(...) is not a function
  </code></pre>
  
  <p>CODE:</p>
  
  <pre><code>export function listEventsRequestedAction() {
      return {
          type: PlannerEventTypes.LIST_EVENTS_REQUESTED
      }
  }
  
  export const listEventsReceivedAction = (events:PlannerEvent[]) =&gt; {
      return {
          type: PlannerEventTypes.LIST_EVENTS_RECEIVED,
          events
      }
  }
  
  export const listEventsErrorAction = (err:any) =&gt; {
      return {
          type: PlannerEventTypes.LIST_EVENTS_ERROR,
          error: err
      }
  }
  
  export const listEventsActionCreator = () =&gt; {
      return (dispatch: any) =&gt; {
          dispatch(listEventsRequestedAction())  // &lt;== ERROR: TypeError: dispatch(...) is not a function
          (API.graphql(graphqlOperation(listEvents)) as Promise&lt;any&gt;).then((results:any) =&gt; {
              const events = results.data.listEvents.items
              dispatch(listEventsReceivedAction(events))
          }).catch((err:any) =&gt; {
              // console.log("ERROR")
              dispatch(listEventsErrorAction(err))
          })
      }
  }
  </code></pre>
  
  <p>package.json</p>
  
  <pre><code>{
    "name": "planner",
    "version": "0.1.0",
    "private": true,
    "dependencies": {
      "@types/graphql": "^14.0.7",
      "@types/react-redux": "^6.0.10",
      "aws-amplify": "^1.1.19",
      "aws-amplify-react": "^2.3.0",
      "date-fns": "^1.30.1",
      "eslint": "^5.9.0",
      "konva": "^2.5.1",
      "moment": "^2.22.2",
      "moment-timezone": "^0.5.23",
      "react": "^16.6.3",
      "react-dom": "^16.6.3",
      "react-draggable": "^3.0.5",
      "react-konva": "^16.6.31",
      "react-moment": "^0.8.4",
      "react-redux": "^5.1.1",
      "react-scripts-ts": "3.1.0",
      "redux": "^4.0.1",
      "redux-logger": "^3.0.6",
      "redux-thunk": "^2.3.0"
    },
    "scripts": {
      "start": "react-scripts-ts start",
      "build": "react-scripts-ts build",
      "test": "react-scripts-ts test --env=jsdom",
      "eject": "react-scripts-ts eject"
    },
    "devDependencies": {
      "@types/jest": "^23.3.10",
      "@types/node": "^10.12.10",
      "@types/react": "^16.7.10",
      "@types/react-dom": "^16.0.11",
      "@types/redux-logger": "^3.0.7",
      "typescript": "^3.2.1"
    }
  }
  </code></pre>
  
  <p>index.tsx</p>
  
  <pre><code>import * as React from 'react'
  import { render } from 'react-dom'
  import { Provider } from 'react-redux'
  import { applyMiddleware, createStore } from 'redux'
  import App from './App'
  import './index.css'
  import rootReducer from './reducers/index'
  import registerServiceWorker from './registerServiceWorker'
  
  import { createLogger } from 'redux-logger'
  import thunkMiddleware from 'redux-thunk'
  
  const loggerMiddleware = createLogger()
  const store = createStore (
    rootReducer,
    applyMiddleware(
      thunkMiddleware, // lets us dispatch() functions
      loggerMiddleware // neat middleware that logs actions
    )
  )
  
  render(
    &lt;Provider store={store}&gt;
      &lt;App testStr='test' /&gt;
    &lt;/Provider&gt;
    ,document.getElementById('root') as HTMLElement
  );
  registerServiceWorker();
  </code></pre>