in React JS by
Q:

What are the different ways to write mapDispatchToProps()?

1 Answer

0 votes
by

There are a few ways of binding action creators to dispatch() in mapDispatchToProps(). Below are the possible options:

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

The third option is just a shorthand for the first one.

Click here to read more about React JS
Click here to read more about Insurance

Related questions

0 votes
asked Apr 18, 2020 by SakshiSharma
0 votes
asked Jul 26, 2020 in Spring by SakshiSharma
0 votes
asked Jun 25, 2019 in Dot Net by Venkatshastri
0 votes
asked Sep 23, 2020 in Artificial Intelligence by SakshiSharma
0 votes
asked Mar 30, 2020 in React JS by amita rallin
...