title: Redux-toolkit: Store does not have a valid reducer
body: <p>I am completely lost on redux and next.js. I can't seem to figure out how to just simply connect the two after many frustrating hours. My site returns an error &quot;TypeError: Cannot read property 'getState' of undefined&quot;. For some reason the store doesn't seem to have a valid reducer.</p>
  <p>The following is the code that seems to be the problem.
  _app.js</p>
  <pre><code>import &quot;../styles/globals.css&quot;;
  import { SessionProvider } from &quot;next-auth/react&quot;;
  import store from &quot;../store&quot;;
  import { Provider as ReduxProvider } from &quot;react-redux&quot;;
  
  function MyApp({ Component, pageProps: { session, ...pageProps } }) {
    return (
      &lt;ReduxProvider store={store}&gt;
        &lt;SessionProvider session={session}&gt;
          &lt;Component {...pageProps} /&gt;
        &lt;/SessionProvider&gt;
      &lt;/ReduxProvider&gt;
    );
  }
  
  export default MyApp;
  
  </code></pre>
  <p>store.js</p>
  <pre><code>import { configureStore } from &quot;@reduxjs/toolkit&quot;;
  import counterReducer from &quot;./slices/counterSlice&quot;;
  
  export const store = configureStore({
    reducer: { counter: counterReducer },
  });
  
  </code></pre>
  <p>counterSlice.js</p>
  <pre><code>import { createSlice } from &quot;@reduxjs/toolkit&quot;;
  
  const initialState = {
    value: 0,
  };
  
  export const counterSlice = createSlice({
    name: &quot;counter&quot;,
    initialState,
    reducers: {
      increment: (state) =&gt; {
        state.value += 1;
      },
  
      decrement: (state) =&gt; {
        state.value -= 1;
      },
  
      incrementByAmount: (state, action) =&gt; {
        state.value = action.payload;
      },
    },
  });
  
  export const { increment, decrement, incrementByAmount } = counterSlice.actions;
  export default counterSlice.reducer;
  
  </code></pre>
  <p>all I am looking for is the site to not break. I just want to be able to play around with global state to change one variable from true to false and vice versa across different components.</p>