[material-ui] recommended babel-plugin-import causes type and runtime mismatch for useTheme
location
#41597
Labels
customization: theme
Centered around the theming features
package: material-ui
Specific to @mui/material
status: waiting for author
Issue with insufficient information
Steps to reproduce
I'm sorry not to include this, but I really struggled to find a way to get either CodeSandbox or StackBlitz to support a custom babelrc and typescript.
Current behavior
I tried setting up the
babel-plugin-import
optimization described here.After doing that, I'm importing
useTheme
like soAnd my typescript compiler shows no errors.
However at runtime I get the following error
If I remove the plugin, both type checking and the runtime are fine, which leads me to think this is a problem with the babel setup.
I see that it's possible to change my import to this
But I feel like it would be preferable to change my babel set up.
Any ideas how I could configure it differently?
Expected behavior
Importing
useTheme
at runtime should find the correct functionContext
My full babelrc
Your environment
Search keywords: useTheme, type, module, babel-plugin-import
The text was updated successfully, but these errors were encountered: