Where should I put following line to get my component ready?
const classes = useStyles();
Try to use Material-UI
MenuList
component, but need to use in my existing MainPage
code, what is slightly different from Material-UI
code example.
Where should I put following line to get my component ready?
const classes = useStyles();
Try to use Material-UI
MenuList
component, but need to use in my existing MainPage
code, what is slightly different from Material-UI
code example.
Could you try to call it inside render lifecycle ? If i'm not wrong, u can't create const directly inside class, the order should be class > function > const or let var Or you can try to put it inside constructor
Constructor(props) {
super(props)
this.classes = useStyles()
}
Or you can do it like seanplwong suggest
constants are not supported at class level.
You have two options.
This thread has some more information. Declaring static constants in ES6 classes?
I think for class properties, the syntax should be something like
class Foo {
classes = useStyle();
}