Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't resolve '@material-ui/styles/styled' in '@material-ui\core\Box'

Hi iam using react with material ui core.

I get the error you see in the title when iam trying to use the new box inside of typography component.

import Typography from "@material-ui/core/Typography";
import { unstable_Box as Box } from "@material-ui/core/Box";

 function sayHello() {
   return (
   <div >
     <Typography>
       <Box textAlign="left">Hello</Box>
     </Typography>
   </div>
  );}

I have updated material ui core to the new version 3.8.1. I have also updated material ui next but error still exists. Please help. How to use the new material ui component ? Please help.

like image 240
DealZg Avatar asked Jan 07 '19 16:01

DealZg


People also ask

Could not resolve mui material?

To solve the error "Module not found: Error: Can't resolve '@mui/material'", make sure to install the package by opening your terminal in your project's root directory and running the command npm i @mui/material @emotion/react @emotion/styled and restart your development server.

How do you use makeStyles in material UI?

In order to use makeStyles function in your application you will need to import it in the component in where you plan to access the css that results from your makeStyles function. This is assuming you have already installed Material Ui in your project. This is in order for react to recognize it as a styles file.

Does material UI support React 18?

@mui/styles v5 is not compatible with React 18 · Issue #32142 · mui/material-ui · GitHub.


1 Answers

you need to run yarn add @material-ui/styles@next or npm install @material-ui/styles@next

Did run into the same problem, and it seems that you need the alpha version of styled to run this.

This is going to be part of material ui core soon I believe :)

like image 132
Lino Rabolini Avatar answered Sep 24 '22 00:09

Lino Rabolini