JJ Kim
JJ Kim

Reputation: 15

material ui v1 default theme not defined

I'm trying to use the default theme in a react app using material ui v1, and it's a little weird. Some projects the default theme will load up just fine, but then on others it won't.

I've got this so far:

import {withStyles} from '@material-ui/core/styles';

const styles = theme = ({
    paper: {

    }
});

class Topbar extends Component {
    render() {
        const {classes} = this.props;

        return (
            <Paper className={classes.paper}>
        )
    }
}

export default withStyles(styles)(Topbar);

And when it runs, it throws an error: 'theme' is not defined no-undef

What is throwing me for a loop is that I have something almost exactly the same in another project and that one is working perfectly fine. I'm not sure what I'm missing, and there aren't much support on the matter.

Any help is appreciated!

Upvotes: 1

Views: 3588

Answers (1)

sn42
sn42

Reputation: 2444

There is a typo in your styles declaration, it should be an arrow function using => instead of =:

const styles = theme => ({
    paper: { }
});

Upvotes: 5

Related Questions