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

How to yarn link swr? Error: Invalid hook call #210

Closed
addstar34 opened this issue Dec 22, 2019 · 1 comment
Closed

How to yarn link swr? Error: Invalid hook call #210

addstar34 opened this issue Dec 22, 2019 · 1 comment
Labels
help wanted Extra attention is needed

Comments

@addstar34
Copy link
Contributor

Hey,

Sorry for the noob question, how do I yarn link swr?

I'm getting the following?

Error: 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'm using next js and have tried setting an alias as suggested here: facebook/react#14257 but no luck.

const path = require('path')

module.exports = {
  webpack(config, options) {
    config.resolve.alias['react'] = path.join(__dirname, 'node_modules/react')
    return config
  },
}
@addstar34
Copy link
Contributor Author

I was able to get things working by yarn linking react and react-dom from my app into swr.

eg:
my-app/node_modules/react> yarn link
my-app/node_modules/react-dom> yarn link
swr> yarn link react
swr> yarn link react-dom

A little bit fiddly so I'd be curious if someone has a better solution.

@shuding shuding added the help wanted Extra attention is needed label Dec 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants