Skip to content

Connect could listen to the used state automatically #901

Closed
@SkoomaCowboy

Description

@SkoomaCowboy

Hey, I was trying to reduce the redux boilerplate in my project and came up with a connect that instead of requiring mapStateToProps, automatically detects the state that was used in render. https://github.com/SkoomaCowboy/connect-redux Basically:

import { autoConnect } from "react-redux";

const ComponentName = (redux, props, context) => <div>{redux.count}</div>;

// no more mapStateToProps, listens only to the state that was used in the component
export default autoConnect(ComponentName);

It was more or less inspired by @acdlite https://twitter.com/acdlite/status/971598256454098944

I know it's a fat chance that you would consider expanding the API with autoConnect or changing the default connect behaviour, but I see very few drawbacks to this approach, so I had to ask. Feel free to close this issue :)

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