본문 바로가기

React/React - 잡동사니

@material-ui/core UI를 Class로 구현하기

https://github.com/mui-org/material-ui/issues/15820

 

@material-ui/styles: Usage in a Class Component? · Issue #15820 · mui-org/material-ui

How does one use the makeStyles API within a class component? The documentation only shows examples for function components. When I try to use this within a class component's render method, I g...

github.com

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

const useStyles = theme => ({
    fab: {
      position: 'fixed',
      bottom: theme.spacing(2),
      right: theme.spacing(2),
    },
  });

class LoginComponent extends Component {
       render() {
                const { classes } = this.props;
                {/** your UI components... */}
          }
} 

export default withStyles(useStyles)(LoginComponent)

'React > React - 잡동사니' 카테고리의 다른 글

Json Control 하기  (0) 2020.10.08
Arrow Function 및 전역객체의 의미  (0) 2019.08.03
Props vs State  (0) 2019.07.23
Bind Method  (0) 2019.07.03
Var, Let, Const 차이  (0) 2019.07.02