-
-
Notifications
You must be signed in to change notification settings - Fork 15.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Warn when reducer is not a function #3026
Warn when reducer is not a function #3026
Conversation
baibhavx
commented
Jun 15, 2018
•
edited
Loading
edited
- If the object supplied to combineReducers has a key whose value is not a function, it simply ignores it. With this fix, it gives a warning, letting the user know that each key in the object must point to a function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs at least one test case to go with the change.
4b6047c
to
4e31693
Compare
@timdorr I added the tests to my commit but the build fails at `npm ci` with `zlib: unexpected end of file` and I have no idea why that is happening. If possible, please suggest how to make this pass. Thanks! |
src/combineReducers.js
Outdated
@@ -121,6 +121,8 @@ export default function combineReducers(reducers) { | |||
if (process.env.NODE_ENV !== 'production') { | |||
if (typeof reducers[key] === 'undefined') { | |||
warning(`No reducer provided for key "${key}"`) | |||
} else if (typeof reducers[key] !== 'function') { | |||
warning(`"${key}" is not a function`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will probably be confusing by itself. I'd add more context to the message: The reducer for "${key}" is not a function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea! I've updated the error message to The reducer for "${key}" is not a function
format.
Yeah, something is up with Travis. Not your fault, though! I'll see if I can figure it out... |
4e31693
to
a410afd
Compare