klng
klng

Reputation: 3

Server Error Error: middleware is not a function WHEN I use Redux in NEXTJS

When I run program, it appears error "Server Error Error: middleware is not a function". I don't know why it happened. How can I fix this error? This is my code in store.js

import { createStore, combineReducers, applyMiddleware } from 'redux'
import thunk from 'redux-thunk'
import { composeWithDevTools } from '@redux-devtools/extension'

const reducer = combineReducers({})

const initialState = {}

const middleware = [thunk]

const store = createStore(
    reducer,
    initialState,
    composeWithDevTools(applyMiddleware(...middleware))
)

export default store

I want to know why it appears that error and How I can fix it

Upvotes: -1

Views: 129

Answers (1)

timotgl
timotgl

Reputation: 2925

You can't have a global store server-side with next.js. Please read (and try to follow) https://redux.js.org/usage/nextjs

Upvotes: 0

Related Questions