material-ui icon indicating copy to clipboard operation
material-ui copied to clipboard

The "Usage" on the readme file doesn't contain the latest requirements

Open MickCoelho opened this issue 11 years ago • 3 comments

It's missing a few lines into the "Usage" part of the readme file to get started:

var React = require('react');
var mui = require('mui');
var ThemeManager = new mui.Styles.ThemeManager();

var OuterMostParentComponent = React.createClass ({
  // Important!
  childContextTypes: {
    muiTheme: React.PropTypes.object
  },

  // Important!
  getChildContext: function() { 
    return {
      muiTheme: ThemeManager.getCurrentTheme()
    };
  }
});

module.exports = OuterMostParentComponent;

MickCoelho avatar Jun 10 '15 14:06 MickCoelho

Thanks for bringing that up, added a pull request to address this #815

Zadielerick avatar Jun 10 '15 21:06 Zadielerick

I am writing in this way according to ES6 standards

import React from "react";
import Mui from "material-ui";
let ThemeManager = new Mui.Styles.ThemeManager();

class BaseComponent extends React.Component {
    getChildContext() {
        return {
            muiTheme: ThemeManager.getCurrentTheme()
        };
    }
}

BaseComponent.childContextTypes = {
    muiTheme: React.PropTypes.object
};

module.exports = BaseComponent;

Afterwards, I am extending all the react components from this common BaseComponent

mairh avatar Jun 12 '15 10:06 mairh

Thanks @Zadielerick @mairh

hai-cea avatar Jun 19 '15 16:06 hai-cea