I'm getting error after upgrading to Material UI 4 - withStyles

后端 未结 2 1721
無奈伤痛
無奈伤痛 2021-01-18 07:09

I\'m getting the following error after upgrading to MUI v4.0.2 from v3.9.x:

You must pass a component to the function returned by connect. Instead rec

2条回答
  •  盖世英雄少女心
    2021-01-18 07:48

    This is how I do it:

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

    Define your styles object: look at the material-ui examples for guidance

    const styles => ({
      root: {
        display: 'flex',
      }
    });
    

    Then export the component using your styles:

    export default withStyles(styles)(YourComponent);
    

提交回复
热议问题