alexandrecanuto
7/26/2019 - 1:48 PM

New React Component

import React, { Component } from 'react';
import PropTypes from 'prop-types';
// Styles
import { withStyles } from '@material-ui/core/styles';
import styles from './styles';

class Teste extends Component {

  state = {

  };

  componentDidMount() {
    this._isMounted = true;
  }

  componentWillUnmount() {
    this._isMounted = false;
  }

  /**
   * Applies the state if screen is mounted, preventing errors.
   */
  applyState(obj, callback) {
    this._isMounted && this.setState(obj, callback);
  }

  render() {
    const { classes } = this.props;

    return (
      <div className={classes.root}>
        
      </div>
    );
  }
}

let component = withStyles(styles)(Teste);
component.displayName = 'Teste';
component.propTypes = {};
export default component;