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

Error "TypeError r is not a function" occurs when calling store with argument #92

Closed
kayrules opened this issue Feb 13, 2020 · 1 comment

Comments

@kayrules
Copy link

I'm not sure if this is a known limitation of this library or a bug. I couldn't find any reference on this.

Reproduce

https://codesandbox.io/s/shy-fast-c1v73

Additional Info

Declare store with initialValue:

export const useCounter = createStore(initialValue => {
  useState(initialValue);
});

Calling hooks with initial value as argument:

const [counter] = useCounter(0);
@kayrules kayrules changed the title Error "TypeError r is not a function" occurs when calling hooks with argument Error "TypeError r is not a function" occurs when calling store with argument Feb 13, 2020
@adamkleingit
Copy link
Collaborator

Hi @kayrules, this is not how Reusable works.
The first parameter to useCounter is a selector function that selects things from the store.
The store can't receive a parameter since it is initialised before you even use it

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

No branches or pull requests

2 participants