I took a look a this question, but still did manage to get this to work.
The intention is to separate the styles from the component file in order to have a cleaner setup.
It works fine when there is no theme involved.
I did try several iterations, with or without wrapping withStyles in the
styles.js files.
The particular example below will of course throw error
TypeError: "theme.spacing is not a function"
So I have created a file for the css as follows
styles.js
import { withStyles } from '@material-ui/core/styles';
export default theme => ({
...
textField: {
marginLeft: theme.spacing(1),
marginRight: theme.spacing(1),
}
...
});
Then on the component file:
login.js
import styles from './styles';
...
render() {
const { classes } = this.props;
}
...
export default withCookies(withRouter(connect(mapStateToProps, mapDispatchToProps)(withStyles(styles, { withTheme: true })(Login))));