InterviewHubPRO
Section Overview
Q118

Question 118 of 445

Part 5: React Redux State Management (101 - 134)

27%
React & Modern Frontend (445 Qs)•Part 5: React Redux State Management (101 - 134)

What are the different ways to write mapDispatchToProps()?

There are a few ways of binding action creators to dispatch() in mapDispatchToProps().

Below are the possible options:

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

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