React-redux-starter-kit: do I HAVE to use the name REDUCER?! I don't understand this at all..

Created on 7 Nov 2016  路  6Comments  路  Source: davezuko/react-redux-starter-kit

so i'm trying to hack my way into learning react-redux. I already have done some systems using angular and then moved to react. but never used react-redux before. Also I find webpack to be very challenging. I really do not understand that at all. This is far far removed from the old days where I could get things done by just downloading a few js libraries. anyways...

I created a new thingy based on the Counter thingy. I called it Edit bcuz its the name it will have in the final system.

In edit/index.js I have this:

require.ensure([], (require) => { /* Webpack - use require callback to define dependencies for bundling */ const Edit = require('./containers/EditContainer').default const reducer = require('./modules/edit').default //const formStepReducer = require('./modules/formStep').default injectReducer( store, { key: 'edit', reducer } ) /* Return getComponent */ cb(null, Edit) /* Webpack named bundle */ }, 'edit')

when I try to change the const reducer name to something else, like for instance:

const somethingelse = require('./modules/edit').default //const formStepReducer = require('./modules/formStep').default injectReducer( store, { key: 'edit', somethingelse } )

it throws error: No reducer provided for key "edit"

can anyone help me?!

Most helpful comment

The function injectReducer needs the reducer as object key reducer. So you HAVE to set it like this:

injectReducer( store, { key: 'edit', reducer: somethingelse } ) // New JavaScript Syntax

ECMAScript 2015 Property definitions

All 6 comments

It sounds like somethingelse is undefined. Have you confirmed that ./modules/edit has a default export defined?

You do not have to use the name reducer at all, it plays no part. As @DillonGray it sounds like a bad import. If you dig into it further and discover that that's not the issue, please post and we can reopen. Thanks!

I had this exact same issue. Anytime I tried to change the name from reducer to something else I got the same No reducer provided for key "edit" error. This tripped me up for a long time until I changed the name of the constant to 'reducer' like in the example. Why would the name of the variable in injectReducer matter?

same thing here. any solutions?

The function injectReducer needs the reducer as object key reducer. So you HAVE to set it like this:

injectReducer( store, { key: 'edit', reducer: somethingelse } ) // New JavaScript Syntax

ECMAScript 2015 Property definitions

Thanks @piu130 !

Was this page helpful?
0 / 5 - 0 ratings

Related issues

liubko picture liubko  路  4Comments

marcelloromanelli picture marcelloromanelli  路  5Comments

rpribadi-ds picture rpribadi-ds  路  5Comments

gilesbradshaw picture gilesbradshaw  路  5Comments

zeroc picture zeroc  路  4Comments