Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Makestyles hook is not working in Material Ui

I’m totally new to React and I’m trying to use makeStyles. I’m using it as they use it in the docs, but It’s not working for me and my page just went to blank white page after using it.

    import {makeStyles} from "@mui/material";
    
    const useStyles = makeStyles({
      field: {
        marginTop: 20,
        marginBottom: 20,
        display: "block",
      },
    });
    
export default function Create() {
  const classes = useStyles();
       return (   <TextField
            className={classes.field}
            label="Note Title"
            variant="outlined"
            color="secondary"
            fullWidth
            required
          /> );
}

am I doing anything wrong?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Did you install all you dependencies? See a copy of your version here.

import { makeStyles } from "@mui/styles";
import TextField from "@mui/material/TextField";

const useStyles = makeStyles({
  field: {
    marginTop: 20,
    marginBottom: 20,
    display: "block"
  }
});

export default function App() {
  const classes = useStyles();
  return (
    <TextField
      className={classes.field}
      label="Note Title"
      variant="outlined"
      color="secondary"
      fullWidth
      required
    />
  );
}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading