With react-jss
it's possible to do:
const styles = props => ({
appContent: {
position: 'absolute',
left: props.sidebarOpen ? 240 : 0,
}
})
const App = () => {...}
const mapStateToProps = createStructuredSelector({
sidebarOpen: state => state.sidebar.open,
})
export default connect(mapStateToProps)(injectSheet(styles)(App))
It doesn't look like there's any way to pass the props to the styles
using withStyles
; all I can pass is the theme
using withTheme
. But in some components I may want to have the best of both worlds: props from state and the Material-UI theme
. Why not support both in withStyles
?
Sigh, this is a nightmare so far. When I try to use dynamic styles with injectSheet
it's SNAFU, generating class names with spaces in them like App- Unthemed- Dynamic-appFrame-4 App- Unthemed- Static-appFrame-1
Please ask JSS questions via the appropriate channels. Thanks!