Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

1.1K
Visualizações
MUI: The `styles` argument provided is invalid after upgrading from material v4 to v5

I recently upgraded from Material V4 to V5 and I'm now getting the following error:

MUI: The `styles` argument provided is invalid.
You are providing a function without a theme in the context.
One of the parent elements needs to use a ThemeProvider.

Within my App.js file, I have the following setup:

import { createTheme, ThemeProvider, StyledEngineProvider, adaptV4Theme } from '@mui/material/styles';
import makeStyles from '@mui/styles/makeStyles';
import { CssBaseline, Hidden } from '@mui/material';


let theme = createTheme(adaptV4Theme({
  palette: {
    primary: {
      light: '#63ccff',
      main: '#009be5',
      dark: '#006db3'
    }
  },
  typography: {
    h5: {
      fontWeight: 500,
      fontSize: 26,
      letterSpacing: 0.5
    }
  },
  shape: {
    borderRadius: 8
  },
  props: {
    MuiTab: {
      disableRipple: true
    }
  },
  mixins: {
    toolbar: {
      minHeight: 48
    }
  }
}));

theme = {
  ...theme,
  overrides: {
    MuiDrawer: {
      paper: {
        backgroundColor: '#18202c'
      }
    }
  }
};

and then have the following return within my App.js:

  const classes = useStyles();

  return (
    <NotifyProvider>
        <Routes>
          <Route path="/login" element={<Login />}></Route>
          <Route path="/logout" element={<Logout />}></Route>
        </Routes>
          <StyledEngineProvider injectFirst>
            <ThemeProvider theme={theme}>
              <div className={classes.root}>
                <CssBaseline />
                <nav className={classes.drawer}>
                </nav>
                <div className={classes.app}>
                  <Header
                    onDrawerToggle={handleDrawerToggle}
                  />
                  <main className={classes.main}>
                    <Routes>
                      <Route path="/" />
                    </Routes>
                  </main>
                </div>
              </div>
            </ThemeProvider>
          </StyledEngineProvider>
    </NotifyProvider>
  );

I'm not sure what the issue is and what I am missing but I also noticed that adaptV4Theme is depracated.

Any help would be great as the app is not starting at all.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

i am having the same issue. there is a thread here: https://github.com/mui/material-ui/issues/30092 with some troubleshooting suggestions. none of them worked for me but some others in the thread seem to have resolved the issue by deleting yarn.lock and rerunning yarn install, see thread for more details. if you do solve it please post here and let me know what fixed it, have been working at this for several days with no luck.

ETA -- I was able to solve this in my app by wrapping the components I was testing in a <ThemeProvider/>, as suggested here: https://github.com/mui/material-ui/issues/15528#issuecomment-487952731 (I was only getting the error message when testing)

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda