Skip to content

Question: bindActionCreators vs mapDispatchToProps #550

@prosanes

Description

@prosanes

Hello,

first of all, sorry if this is the wrong place for a question about design decision. But I didn't find a better place.

I'm starting to use React + Redux + React_on_rails. In my studies, I found that a common way to connect React to Redux is using connect(mapStateToProps, mapDispatchToProps)(Component).

Understanding the HelloWorldApp (created by the generator), I see that the connect() uses only the mapStateToProps(), in this case name as select(). This makes the dispatch be purely injected into the props, so the actions are connected to the dispatch by bindActionCreators() in the smart container and then passed as props for the dumb/view component.

Given the phrase bellow, found in the docs, I'd like to understand why this design decision was made.

The only use case for bindActionCreators is when you want to pass some action creators down to a component that isn't aware of Redux, and you don't want to pass dispatch or the Redux store to it.

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions