How to style components using makeStyles and still have lifecycle methods in Material UI?
167
I get the below error whenever I try to use makeStyles() with a component with lifecycle methods:
Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:
- You might have mismatching versions of React and the renderer (such as React DOM)
- You might be breaking the Rules of Hooks
- You might have more than one copy of React in the same app
Below is a small example of code that produces this error. Other examples assign classes to child items as well. I can't find anything in MUI's documentation that shows other ways to use makeStyles and have the ability to use lifecycle methods. 
import React, { Component } from 'react';
    import { Redirect } from 'react-router-dom';
    import { Container, makeStyles } from '@material-ui/core';
    import LogoButtonCard from '../molecules/Cards/LogoButtonCard';
    const useStyles = makeStyles(theme => ({
      root: {
        display: 'flex',
        alignItems: 'center',
        justifyContent: 'center',
      },
    }));
    const classes = useStyles();
    class Welcome extends Component {
      render() {
        if (this.props.auth.isAuthenticated()) {
          return <Redirect to="/" />;
        }
        return (
          <Container maxWidth={false} className={classes.root}>
            <LogoButtonCard
              buttonText="Enter"
              headerText="Welcome to PlatformX"
              buttonAction={this.props.auth.login}
            />
          </Container>
        );
      }
    }
    export default Welcome;