DianaSuvorova / eslint-plugin-react-redux

Enforcing best practices for react-redux

Home Page:https://www.npmjs.com/package/eslint-plugin-react-redux

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Allow `bindActionCreators` in `mapDispatchToProps`

lextoc opened this issue · comments

The code below gives an eslint message:

function mapDispatchToProps(dispatch) {
  return bindActionCreators({
    homeAction,
  }, dispatch);
}

It says "mapDispatchToProps should return object". While this is true, the convenience method bindActionCreators should be allowed too:

Turns an object whose values are action creators, into an object with the
same keys, but with every function wrapped into a dispatch call so they
may be invoked directly. This is just a convenience method, as you can call
store.dispatch(MyActionCreators.doSomething()) yourself just fine.

is this still in consideration? are there any known workarounds?

the syntax i am having an issue with is

const mapDispatchToProps = dispatch => {
  return bindActionCreators(
    {
      actionName: action
    },
    dispatch,
  );
};

is there a refactor to this is will pass linting?