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

Can't start the project #13

Closed
jerrygreen opened this issue May 6, 2019 · 6 comments · Fixed by #12
Closed

Can't start the project #13

jerrygreen opened this issue May 6, 2019 · 6 comments · Fixed by #12
Labels

Comments

@jerrygreen
Copy link
Contributor

jerrygreen commented May 6, 2019

I wanted to play a bit with these null/undefined, so I cloned the repo but after yarn && yarn start I've encountered two problems:

First problem

rollup v0.66.6
bundles src/index.ts → dist/index.js, dist/index.es.js...
rpt2: options error TS5053 Option 'declaration' cannot be specified with option 'isolatedModules'.
created dist/index.js, dist/index.es.js in 2.7s

[2019-05-06 18:16:37] waiting for changes...

However, by "waiting for changes" I suppose it's working anyway...

Second problem

I use the lib in my project - it's working ok. I managed to switch to my local react-request-hook with yarn link the lib, then yarn link react-request-hook in my project, but then I get this error in my app:

Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:
1. You might have mismatching versions of React and the renderer (such as React DOM)
2. You might be breaking the Rules of Hooks
3. You might have more than one copy of React in the same app
See https://fb.me/react-invalid-hook-call for tips about how to debug and fix this problem.

I tried to disable declaration and isolatedModules - it doesn't help, so it looks like these are different problems

Just a note

Also, you use allowSyntheticDefaultImports and esModuleInterop at the same time - but allowSyntheticDefaultImports may be disabled (here's why)

Additional thoughts

I may miss something. Maybe it's good idea to place some "How to contribute" section in readme

@jerrygreen
Copy link
Contributor Author

@schettino can you help with this? What am I missing?

@schettino
Copy link
Owner

I've seen this when there actually two versions of React being imported, but it happened in another library. Like, in the example folder, there's a CRA setup importing the library directly from NPM. Before, I was copying (though a rollup plugin) the files to the example folder, so I could use the most recent build.

The first warning you see is 'cause jest configure the option automatically and it was committed later on. #12 solves that. Thus, on the first problem, it generates the build just fine and as you used start, it will wait for changes to do the build again. The second problem is related to more than one React version in the same project. Let me dig into it to see if I can reproduce or, at least, have a minimal better setup. Thanks for raising that.

@jerrygreen
Copy link
Contributor Author

jerrygreen commented May 16, 2019

@schettino I've made a minimal repo on top of create-react-app, check it out:

https://github.com/JerryGreen/react-request-hook-issue13

Just copy-paste the instructions from there, you'll see the error. May help you start investigating

P.S. thanks for the lib, it's cool

@schettino
Copy link
Owner

I've had a week off, looking into it today. Thanks Jerry!

@schettino
Copy link
Owner

schettino commented May 23, 2019

@jerrygreen I looked into it and here's a quick summary: by doing yarn link (or npm) we end up with two react versions running side by side, one coming from CRA and another from the library's node_modules, which is expected somewhat. You can check that by running npm ls react (or react-dom).

I ran your repo and faced the same problem. It's not specific to react-request-hook though. I did the same step by step with this library and got this issue which has the same cause as the ours.

Not too surprisedly, if you run rm -rf node_modules from the library folder it'll fix that. But it's not a good solution. There's also yarn resolutions and some other solutions suggested by the community. However, I do think we should have a straightforward working setup to iterate during development. So, for that, I'm going to revert our examples folder to use the files built locally and set up another repo with the same examples, that we can run through codesandbox.

By the end, you'll be able to run yarn install followed by yarn start, which will listen for changes. From another terminal tab, cd examples && yarn start will use the latest build without having to link it. This for the development workflow. If you're testing on an actual project that uses CRA, the other approaches are still valid in this case. I haven't seen this happening before 'cause the projects I run for testing purposes don't use CRA, but I'm glad that you brought that up. Will put a PR up asap. Thanks.

@schettino
Copy link
Owner

🎉 This issue has been resolved in version 2.1.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging a pull request may close this issue.

2 participants