Im currently using material-ui for my web app and would like to add themes to it so Im using the MuiThemeProvider it comes with to theme it.
The documentation contains instructions on how to use custom components with themes but it unfortunately lacks instruction on how to use it from within a render function.
For example, in the the code they use is:
import React from 'react';
import muiThemeable from 'material-ui/styles/muiThemeable';
const DeepDownTheTree = (props) => (
<span style={{color: props.muiTheme.palette.textColor}}>
Hello World!
</span>
);
export default muiThemeable()(DeepDownTheTree);
Which is fine, but if you need the render function, this wont do. How would I achieve something similar to this? (This wouldnt work, just an example):
import React from 'react';
import muiThemeable from 'material-ui/styles/muiThemeable';
class MyComponent extends React.Component{
render(){
return muiThemeable()(
<span style={{color: props.muiTheme.palette.textColor}}>
Hello World!
</span>
)
}
}
export default muiThemeable()(DeepDownTheTree);
This is critical for my application as I manipulate bits of my DOM in the render function before returning the final DOM.
this.props.muiTheme.palette.textColorinstead?muiThemeableso it can switch colors in realtime when you switch themes.