Skip to content

Latest commit

 

History

History
41 lines (29 loc) · 993 Bytes

mapDispatchToProps-prefer-parameters-names.md

File metadata and controls

41 lines (29 loc) · 993 Bytes

Enforces that all mapDispatchToProps parameters have specific names. (react-redux/mapDispatchToProps-prefer-parameters-names)

react-redux mapStateToProps function has 2 optional arguments:

  • state
  • ownProps

This rule enforces that all of the provided parameters should follow the above naming conventions.

Rule details

The following pattern is considered incorrect:

const mapDispatchToProps = (anyOtherName) => {}
connect((state) => state, (anyOtherName) => {})(App)

The following patterns are considered correct:

const mapDispatchToProps = () => {}
const mapDispatchToProps = (dispatch, ownProps) => {}
const mapDispatchToProps = (dispatch, {prop1, prop2}) => {}
const mapDispatchToProps = (dispatch) => {}
connect((state) => state, (dispatch, ownProps, moreArgs) => {})(App)