-
-
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
bindActionCreators expected a function actionCreator for key 'SET_STRING', instead received type 'string'. #2458
Comments
See #2279 |
@Florian-R I see what they explain there but I'm not sure how to fix it in my container I have this import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import * as demoActions from '!/actions/demoActions';
...
function mapStateToProps(state) {
return {
demoString: state.demoString
};
}
function mapDispatchToProps(dispatch) {
return bindActionCreators(demoActions, dispatch);
}
export default connect(mapStateToProps, mapDispatchToProps)(Home); |
@johhansantana Seems you have stuff Try importing only the action creators from the file like:
Here is a similar question I asked on SO. |
@elrumordelaluz oh I see, so instead of Right? a big app would be annoying to fix, maybe change it to a |
Try this
|
This is a legit warning. You're attempting to pass in non-functions to bindActionCreators, which can have unexpected results. It's akin to React's change to not accept any unknown props on DOM-backed elements (e.g., You'll need to be more explicit about your imports and input to the function. This is a good practice regardless, as you're not expecting Redux to clean up after you. Also, most type systems (TS, Flow) should catch this for you already (prior to this version too). It's just a good practice. |
I take issue with the attitude that "best practice" recommendations can just be changed willy nilly with no regard to backwards compatibility or what the tool is advertising as best practice in its own documentation. We've locked to 3.6.0 but this has just created a lot of needless work without much warning. I do get the reasoning behind the change, but I don't think this was handled in a consumer friendly way. |
Reverted and pushed out in 3.7.1. Thanks for the feedback everyone! |
I haven't got this error but I think since the new
3.7.0
release this is poping up.This seems a pretty regular redux action no? What I'm doing wrong?
The text was updated successfully, but these errors were encountered: