-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
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 importing a component library built on MUI #32357
Comments
How do you require your library exactly? Do you |
Since the issue is missing key information and has been inactive for 7 days, it has been automatically closed. If you wish to see the issue reopened, please provide the missing information. |
Did you ever figure out how to solve this? @sashafklein |
@OneTuskedMario - Yes, at least to my satisfaction. Documented on Stack Overflow. |
Duplicates
Latest version
Current behavior 😯
I've built a component library based on MUI. Following the pattern in MUI itself, the component library declares all dependencies (React, ReactDOM, MUI, Storybook, etc) as
devDependencies
, and the consuming application chooses which React version to run.However, when I import my component library and render the
Button
based off MUI's button, I see the following error:And:
This points to the MUI button component's use of
React.useContext
. Seems like this has to do with a mismatch of React version, but shouldn't the only React version be in the "consuming" application?I have seen this issue, but unlike its author, I am not using
npm link
; instead I'm requiring the library locally (to test it out prior to publication):"my-component-library": "file:../cl"
.I don't seem to have duplicate React versions:
Ongoing documentation of this issue here.
Expected behavior 🤔
MUI's use of React hooks shouldn't be causing a hooks error in an app consuming a component library based off of MUI.
Steps to reproduce 🕹
Steps:
Button
component.Context 🔦
No response
Your environment 🌎
`npx @mui/envinfo`
The text was updated successfully, but these errors were encountered: