erikras / erikras/react-redux-universal-hot-example

"Expected the reducer to be a function"

Open
#1,070 1 comment 4 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
12.1k
Forks
2.5k
PR merge metrics
No merged PRs in 30d

Description

When running with `npm run dev` and loading the first page, I got:

```
[1] Error: Expected the reducer to be a function.
[1] at createStore (/somedir/node_modules/redux/lib/createStore.js:63:11)
[1] at /somedir/node_modules/redux/lib/applyMiddleware.js:37:19
[1] at createStore (create.js:25:17)
[1] at server.js:71:17
[1] at Layer.handle [as handle_request] (/somedir/node_modules/express/lib/router/layer.js:95:5)
[1] at trim_prefix (/somedir/node_modules/express/lib/router/index.js:312:13)
[1] at /somedir/node_modules/express/lib/router/index.js:280:7
[1] at Function.process_params (/somedir/node_modules/express/lib/router/index.js:330:12)
[1] at next (/somedir/node_modules/express/lib/router/index.js:271:10)
[1] at SendStream.error (/somedir/node_modules/serve-static/index.js:120:7)
```

This seems to be due to CommonJS require method in src/redux/create.js returning an object instead of the ES6 import's function:

```
const reducer = import reducer from './modules/reducer';
```

Instead, this fixed it for me:

```
import reducer from './modules/reducer';
```

Are there any unwanted side effects with this change? Should I issues a pull request?

Thanks

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.