-
Notifications
You must be signed in to change notification settings - Fork 63
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
Invalid hook call when using react-colorful package #184
Comments
I did |
@ArnaudBarre So I'm on Windows and I did In my original post, I was using HexColorPicker from a separate local package, so I'm not sure if this is the issue. but I tried to reproduce with the following, and I began to see errors. (using yarn btw) Local Package: {
"name": "test-color",
"private": true,
"version": "0.0.0",
"main": "index.ts",
"dependencies": {
"react-colorful": "^5.6.1"
},
"devDependencies": {
"@types/react": "^18.2.43",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"peerDependencies": {
"react": "^18.2.0",
"react-dom": "^18.2.0"
}
} import * as React from 'react';
import { HexColorPicker } from "react-colorful";
export const Color = () => {
return <HexColorPicker></HexColorPicker>;
}; export * from './Color'; Test Project: "dependencies": {
"react": "^18.2.0",
"react-dom": "^18.2.0",
"test-color": "../test-color"
}, import { Color } from "test-color"; Strangely the error did disappear after removing the local package, adding react-colorful directly, then adding back the local package and removing react-colorful. Not sure if something is being cached but that's what I noticed. However, after removing node_modules and lock file, error reappeared again. |
So yeah probably you're hitting the reason number 3.: |
We faced a similar issue with nested packages, the two things that helped:
It's weird that this error shows up for one plugin, but not the other. I can provide a minimal repro if that will be helpful. |
Yeah this is because this plugin doesn't dedupe. I think this is better this way but I don't want to break people that really on this. You should use a workspace package manager to ensure you have only one version of React used across your packages that are used together. Not every tool will to the dedupe so it's better to avoid depending on Vite to do this (and worse not being sure which version you're running) |
I'm closing the issue for now. |
I am seeing an Uncaught TypeError and getting Invalid hook call warnings when using plugin-react-swc and react-colorful package.
This happens when rendering
<HexColorPicker></HexColorPicker>
No issue after replacing with plugin-react.
The text was updated successfully, but these errors were encountered: