title: Accessing state in middleware in Redux
body: <p>I have a middleware in my React/Redux app that looks like this:</p>
  
  <pre><code>export const myMiddleware = (store) =&gt; (next) =&gt; async (action) =&gt; {
  
     switch (action.type) {
        case types.SOME_ACTION:
        // Some logic here...
        break;
     }
  }
  </code></pre>
  
  <p>I need to access the state here so that I can execute my logic this middleware is  designed to handle.</p>
  
  <p>I thought, because store is being passed into the middleware, I could access it but when I inspect store, I don't see the state at all. I do see a <code>getState()</code> function but when I used it, looks like it's getting me the initial state, not the current state with data in it.</p>
  
  <p>Here's the <code>store</code> object I see when I inspect it:
  <a href="https://i.stack.imgur.com/k2zg5.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/k2zg5.jpg" alt="enter image description here"></a></p>
  
  <p>Here's my store and how I include the middleware in it:</p>
  
  <pre><code>import { createStore, applyMiddleware } from 'redux';
  import thunk from 'redux-thunk';
  import rootReducer from '../reducers/root-reducer';
  import { myMiddleware } from '../middleware/my-middleware';
  
  export default function configureStore(initialState) {
  
      const store = createStore(
          rootReducer,
          initialState,
          applyMiddleware(thunk, myMiddleware)
      );
  
      return store;
  }
  </code></pre>
  
  <p>How do I access state in my middleware?</p>