question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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:

  1. Go to ‘https://codepen.io/Lucas-HMS/pen/vYeajrr?editors=1010’ with the Dev Tools open
  2. 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:closed
  • Created 2 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
JoviDeCroockcommented, Jan 20, 2022

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

0reactions
Lucas-HMScommented, Jan 20, 2022

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!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Switching to Preact (from React)
There are two different approaches to switch from React to Preact: ... If you're not using a build system or want to permanently...
Read more >
Error with JSX in my React Library when Switching to Preact
The issue was running the library through a compiler. The library should have been written as a just a Higher Order Component and...
Read more >
@mui/icons-material | Yarn - Package Manager
@mui/icons-material. This package provides the Google Material Icons converted to SvgIcon components. Installation. Install the package in your project ...
Read more >
cannot read properties of undefined usestate - You.com
The tutorial appears to be older and using react-router-dom version 5 whereas you are using version 6. In version 6 there were many...
Read more >
Minimizing bundle size - Material UI - MUI
⚠️ The following instructions are only needed if you want to optimize your development startup times or if you are using an older...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found