Getting the following error while using @materail-ui/core library
Module not found: Can't resolve '@material-ui/core/styles/ThemeProvider' in 'Z:\\module-builder\\web\\src\\Components'.
Below is the code I am using, have installed @material-ui/core in node modules
import React, { createContext, useContext, useState } from 'react';
import createMuiTheme from '@material-ui/core/styles/createMuiTheme';
import UploadIcon from '@material-ui/icons/CloudUpload';
import WarningIcon from '@material-ui/icons/Warning';
import MuiThemeProvider from '@material-ui/core/styles/ThemeProvider';
import Snackbar from '@material-ui/core/Snackbar';
import { TRASH_ICON } from '../Assets/Images/svg';
import Slide from '@material-ui/core/Slide';
interface Options {
message: string;
variant: number;
timeout?: number;
}
function createTheme(backgroundColor: string) {
return createMuiTheme({
overrides: {
MuiSnackbarContent: {
root: { backgroundColor }
}
}
});
}
const errorSnack = createTheme('#cc5200');
const infoSnack = createTheme('#0088cc');
const successSnack = createTheme('#00a14f');
createMuiTheme is now deprecated in newer @material-ui/core . Try use createTheme instead.
use this code added alias name to get your usages working correctly .
import {createTheme as createMuiTheme,ThemeProvider as MuiThemeProvider} from '@material-ui/core/styles';
using the above will solve your issue.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.