Closed Shivamycodee closed 1 year ago
Which version are you using? Please provide codesandbox and please follow the template.
here is my whole code...
I'm getting error : TypeError: makeStore is not a function
Sandbox is broken:
Which version of wrapper are you using?
export const wrapper = createWrapper(store, { debug: true });
This is wrong, you should supply not the store, but a function that will make a store:
export const wrapper = createWrapper(() => configureStore({
reducer: counterSlice.reducer,
}), { debug: true });
Please read the docs!
I don't understand why I'm getting this error:
TypeError: (0 , next_redux_wrapper__WEBPACK_IMPORTED_MODULE_4__.withRedux) is not a function
I'm just trying to use redux in next.js,
app.js file:
import '@/styles/globals.css' import { Provider } from "react-redux"; import {store} from "./store"; import { withRedux } from "next-redux-wrapper";
function App({ Component, pageProps }) { return <>
<Component {...pageProps} />
</> }
export default withRedux(store)(App);
store file:-
import { configureStore, createSlice } from "@reduxjs/toolkit"; const counterSlice = createSlice({ name: "counter", initialState: { value: 0, }, reducers: { increment: (state) => { state.value += 1; }, decrement: (state) => { state.value -= 1; }, }, });
export const { increment, decrement } = counterSlice.actions;
export const store = configureStore({ reducer: counterSlice.reducer, });