-
-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
React invalid hook call in library mode #11069
Comments
Same problem |
Maybe not the issue of Vite... Package import { ... } from '@react-spring/web'
// It imports { unstable_batchedUpdates } from 'react-dom' I saw Vite bundled a large copy for And also, TSX, JSX are also supported out of the box(JSX Features). So if the repo is library only, the plugin // vite.config.ts
export default defineConfig({
plugins: [
- react(),
],
build: {
rollupOptions: {
+ external: ['react', 'react-dom'],
output: {
globals: {
react: 'React',
+ 'react-dom': 'reactdom'
},
},
},
}
}) |
@luo3house thank for your guess, but it doesn't help. I've updated the repo with your suggestions but the exact same problem still remains |
The only workaround i've found by far is switching to plain rollup (letoxyz/swipeout#1) |
I am sorry I ignored an important operation. And I don't think it is the issue of Vite. The repo uses Rollup instead also causes the problem "Invalid hook call" if I follow steps of reproduction wrote above. Please visit my repo related this issue if you are still in this problem, and try following |
Looks like the issue happens because of linking the local version of a library in playground project to speed up the development. It leads to "duplicate version of React" because of a symlink to a library directory which has Thank you for your time, there is really no problem here |
Describe the bug
I have a React component that is built using vite library mode. But when i import this component in app created by
create-react-app
i get the following error:Though it works fine in an app created by Vite
Reproduction
https://github.com/letoxyz/swipeout
Steps to reproduce
Insert the following code to
swipeout-test/src/App.tsx
:System Info
Used Package Manager
npm
Validations
The text was updated successfully, but these errors were encountered: