Error: Expected the reducer to be a function - MERN app

Error: Expected the reducer to be a function - MERN app

我正在开发 MERN 应用程序,代码部署在 Heroku 上并且运行良好。但是自从我在 store.js 中为生产构建添加了三元运算符后,它就停止了在开发中的工作。

store.js

import { createStore, applyMiddleware, compose } from "redux"
import thunk from "redux-thunk"
import rootReducer from "./reducers/Layout"

const initialState = {}

const middleware = [thunk]

const store = createStore(
    rootReducer, 
    initialState, 
    compose(
        applyMiddleware(...middleware),
        (
            (process.env.NODE_ENV === 'production') ? 
             compose : 
            (window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose)
        )
    )
)

export default store

我从我的 Layout.js(index.js 替换)导入了我的 rootReducer,但它工作正常,直到我添加了三元运算符。但以防万一这里是我的 Layout.js.

中的 combineReducers 函数

Layout.js(index.js替换)

import { combineReducers } from "redux"
import RuleReducer from "./RuleReducer"
import ErrorReducer from "./ErrorReducer"
import AuthReducer from "./AuthReducer"

export default combineReducers({
    rule: RuleReducer,
    error: ErrorReducer,
    auth: AuthReducer
})

好吧,我不是瞎了就是傻了,但多亏了安德烈亚斯,他对我的问题发表了评论,我刚刚为遇到同样问题的任何人修改了我的三元运算符,这里是修改:

import { createStore, applyMiddleware, compose } from "redux"
import thunk from "redux-thunk"
import rootReducer from "./reducers/Layout"

const initialState = {}

const middleware = [thunk]

const stage = (process.env.NODE_ENV === 'production') ? compose : (window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__())

const store = createStore(
    rootReducer, 
    initialState, 
    compose(
        applyMiddleware(...middleware),
        stage
    )
)

export default store