S
S
Sergey Yaroshuk2017-10-12 17:57:43
JavaScript
Sergey Yaroshuk, 2017-10-12 17:57:43

What's the point of bindActionCreators?

After reading the documentation, I did not understand the sacred meaning of this function.
Why write like this?

function mapDispatchToProps(dispatch) {
  return bindActionCreators({ selectBook: selectBook }, dispatch);
}
export default connect(mapStateToProps, mapDispatchToProps)(BookList);

If code like this works fine too:
let mapDispatchToProps = {selectBook};
export default connect(mapStateToProps, mapDispatchToProps)(BookList);

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Mikhail Osher, 2017-10-12
@miraage

bindActionCreators is in the redux module , while shorthand mapDispatchToProps is in the react-redux module .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question