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.

`import { ThemeProvider, createMuiTheme } from '@material-ui/core'` not work

See original GitHub issue

This 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:

  1. code like title.
  2. compile.

Context 🔦

Your Environment 🌎

Tech Version
Material-UI v4.10.2
TypeScript 3.9.5

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
JaneMaxcommented, Nov 3, 2021

@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.0

1reaction
AyemunHossaincommented, Jul 11, 2021

Use import { createTheme } from ‘@material-ui/core/styles’ instead. And this will solve the issue; Here is a pieces of code of my project:

  • Import them

import { ThemeProvider } from '@material-ui/core/styles'; import { createMuiTheme } from '@material-ui/core/styles';

  • Use createTheme()

const customTheme = createTheme({ palette:{ secondary:purple } })

And i think this issue can be closed now.

Read more comments on GitHub >

github_iconTop 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 >

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