Skip to content

Could mapStateToProps be an object? #1048

Closed
@selbekk

Description

@selbekk

I'm playing around with selectors, and most of my mapStateToProps functions look like this:

const mapStateToProps = state => ({
  isAuthenticated: selectors.isAuthenticated(state),
  isSomethingElse: selectors.isSomethingElse(state),
});

Since I always pass on the state, would it be okay to do the same thing as mapDispatchToProps does, and just allow sending an object of functions? Like so:

const mapStateToProps = {
  isAuthenticated: selectors.isAuthenticated,
  isSomethingElse: selectors.isSomethingElse,
};

Then, connect could do the work required to call each of these with the state.

I'd be happy to submit a PR doing this - but what are your thoughts? I'm sure there's a reason the API is the way it is :)

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