Error when trying to use preact X with MUI via UMD
See original GitHub issue- Check if updating to the latest Preact version resolves the issue The example is using the latest version (10.6.4)
Describe the bug
We are using preact X for our frontend (browser-side) via UMD (and requireJS), and are trying to get MUI running.
It seems to me that preact/compat
does not add compatibility for ReactCurrentOwner
from the secret internals (__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED
), which MUI tries to use and then runs into the following error:
material-ui.development.js:4510 Uncaught TypeError: Cannot read properties of undefined (reading 'current')
To Reproduce
Steps to reproduce the behavior:
- Go to ‘https://codepen.io/Lucas-HMS/pen/vYeajrr?editors=1010’ with the Dev Tools open
- See the error in the browser console/debugger
The error happens at the following location:
return ReactElement(type, key, ref, self, source, ReactCurrentOwner.current, props);
(line 4510 in material-ui.development.js for example)
We are using one of the latest chrome versions “96.0.4664.110”.
I tried to create a hack to define the missing internal. The error goes away, but no MUI components are rendered afterwards. Preact components work still fine.
You can enable the hack on line 73 (//"ReactCompatHack",
)
Expected behavior MUI should work with Preact X via UMD
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (3 by maintainers)
Hey, sorry about the late response. I haven’t found time yet to look at this but I’ll try my best to take a peek tonight
I just saw that the UMD version of MUI is only meant for prototyping, maybe that’s why React is inlined then, bummer… 😦
Thank you for your aid anyway!