Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose a useStore hook. #130

Open
fallaciousreasoning opened this issue Jul 8, 2020 · 1 comment
Open

Expose a useStore hook. #130

fallaciousreasoning opened this issue Jul 8, 2020 · 1 comment
Labels
enhancement New feature or request

Comments

@fallaciousreasoning
Copy link

Is your feature request related to a problem? Please describe.
It would be convenient to be able use recollect through the React hooks API, to avoid wrapping components in a HOC

Describe the solution you'd like
Ideally, a useStore hook would work something like this:

export default (props) => {
    const store = useStore();
    const name = store.name; // Recollect will now rerender this component when name is updated
    
    return <div>
        Hello, {store.name}
    </div>;
}

Describe alternatives you've considered
Currently this is possible using the HOC pattern. However, many libraries are providing a way to consume them via hooks, and the syntax is a little more concise.

@fallaciousreasoning fallaciousreasoning added the enhancement New feature or request label Jul 8, 2020
@serchavalos
Copy link

Personally, I'm happy keeping the HOC pattern. I'm afraid adding alternatives syntax can create confusion or increase the complexity unnecessarily

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants