Extra HTML CSS being added upon theme change in Material UI

Viewed 34

I mightve framed my question wrong but when I change my theme on material UI again and again, a few lines of HTML and Css are being added upon every change. My code to change theme is

const [darkMode, setdarkMode] = useState(true);

  const theme = createMuiTheme({
    palette: {
      type: darkMode ? "dark" : "light",
    },
  });
  const handleThemeChange = () => {
    setdarkMode(!darkMode);
  };
 <ThemeProvider theme={theme}>
      <CssBaseline />
   <Typography
          className={classes.mainTitle}
          variant="h2"
          onClick={handleThemeChange}
        >
          Some text
        </Typography>
    </ThemeProvider>

This is what happens when I change theme

Extra HTML add

0 Answers
Related