material-ui
material-ui copied to clipboard
The "Usage" on the readme file doesn't contain the latest requirements
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;
Thanks for bringing that up, added a pull request to address this #815
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
Thanks @Zadielerick @mairh