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

Development issue #7

Open
entrptaher opened this issue Mar 3, 2019 · 3 comments
Open

Development issue #7

entrptaher opened this issue Mar 3, 2019 · 3 comments

Comments

@entrptaher
Copy link

entrptaher commented Mar 3, 2019

Using the package on development mode from the git repo does not work.

  • Works: yarn run dev. It does not throw any error on console.
  • Works: yarn run test. It does not throw any error on console.
    It means it's built properly, right?

But,

  • Works: import createPersistedState from 'use-persisted-state'.
  • Doesn't Work: import createPersistedState from './use-persisted-state'. It throws the following error,
Hooks can only be called inside the body of a function component. (https://fb.me/react-invalid-hook-call)
  1 | import createPersistedState from './use-persisted-state';
  2 | const useCounterState = createPersistedState('count');
  3 | 
> 4 | const useCounter = initialCount => {
    |                                   ^  5 |   const [count, setCount] = useCounterState(initialCount);
  6 | 
  7 |   return {

I found no contribution guide so maybe I did not do it the right way.

@donavon
Copy link
Owner

donavon commented Mar 3, 2019

I guess I'm not sure exactly what you are trying to do. What happens if you replace useCounterState above with setState? If it's producing the same error (it should) then you are calling the useCounter hook from outside of a component.

@entrptaher
Copy link
Author

entrptaher commented Mar 3, 2019

I cloned your repo, built it and simply changed,

import createPersistedState from 'use-persisted-state'; 

to

import createPersistedState from './use-persisted-state';

and the error happens. It works perfectly fine if I use the NPM version.

It only happens when I git clone your repo.

How do I contribute if I cannot run it off of npm? :D

@mungojam
Copy link
Contributor

mungojam commented Sep 4, 2019

sounds like you need to correct the path you are using to match the repository structure (which looks standard):

import createPersistedState from './use-persisted-state/src'

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

3 participants