`import { ThemeProvider, createMuiTheme } from '@material-ui/core'` not work
See original GitHub issueThis may be a type related issue.
import { ThemeProvider, createMuiTheme } from '@material-ui/core'
cause this error:
ERROR in ./src/app.tsx
Module not found: Error: Can't resolve '@material-ui/core/esm/ThemeProvider' in '\path\to\myproject\packages\bbs\src'
@ ./src/app.tsx 1:0-65 16:150-164
@ ./src/index.tsx
ERROR in ./src/app.tsx
Module not found: Error: Can't resolve '@material-ui/core/esm/createMuiTheme' in '\path\to\myproject\packages\bbs\src'
@ ./src/app.tsx 3:0-67 9:12-27
@ ./src/index.tsx
And I dig into the source code of @material-ui/core/index.js, I found ThemeProvider
and createMuiTheme
are not exported. But they are listed in the type file.
- The issue is present in the latest release.
- I have searched the issues of this repository and believe that this is not a duplicate.
Current Behavior 😯
import { ThemeProvider, createMuiTheme } from '@material-ui/core'
not work
Expected Behavior 🤔
import { ThemeProvider, createMuiTheme } from '@material-ui/core'
works
Steps to Reproduce 🕹
Steps:
- code like title.
- compile.
Context 🔦
Your Environment 🌎
Tech | Version |
---|---|
Material-UI | v4.10.2 |
TypeScript | 3.9.5 |
Issue Analytics
- State:
- Created 3 years ago
- Comments:5
Top Results From Across the Web
import { ThemeProvider, createMuiTheme } from '@material-ui ...
And I dig into the source code of @material-ui/core/index.js, I found ThemeProvider and createMuiTheme are not exported. But they are listed in ...
Read more >Not able to create theme using Material UI's ThemeProvider ...
There is no function createtheme in material-ui/core/style Instead use import {createMuiTheme} from '@material-ui/core'; const theme ...
Read more >Troubleshooting - Material UI - MUI
To check this, run npm ls @material-ui/core (or yarn why @material-ui/core ). ... createTheme } from '@mui/material/styles'; import { ThemeProvider as ...
Read more >Why is ThemeProvider (Material UI) not working for me here?
[Solved]-Why is ThemeProvider (Material UI) not working for me here?-Reactjs ... import { useTheme, createMuiTheme } from '@material-ui/core/styles';.
Read more >How to use the @material-ui/core/styles.createMuiTheme ...
To help you get started, we've selected a few @material-ui/core examples, based on popular ways it is used in public projects. ; import...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@yellowspaceboots @AyemunHossain Yes, if I have in code
import { MuiThemeProvider, createMuiTheme } from '@material-ui/core/styles';
it works npm -v 8.1.0 node -v v16.13.0Use import { createTheme } from ‘@material-ui/core/styles’ instead. And this will solve the issue; Here is a pieces of code of my project:
import { ThemeProvider } from '@material-ui/core/styles'; import { createMuiTheme } from '@material-ui/core/styles';
const customTheme = createTheme({ palette:{ secondary:purple } })
And i think this issue can be closed now.