I'm struggling to get material-ui's theming to work with react-router-dom in Typescript. When accessing classes.root in render(), I get TypeError: Cannot read property 'root' of undefined, but I can't figure out how I'm merging/passing props incorrectly. Can anyone see what I'm doing wrong? Many thanks in advance.
Relevant code below:
const styles = (theme: Theme) =>
createStyles({
root: {
maxWidth: 345,
},
});
interface HomeProps extends RouteComponentProps, WithStyles<typeof styles> {
classes: any;
}
export class Home extends React.Component<HomeProps, HomeState> {
constructor(props: HomeProps) {
super(props);
}
render() {
const { classes } = this.props;
// classes.root is undefined...
}
}
export default withRouter(withStyles(styles)(Home));
Edit to add: the answer to this question did not resolve this issue: Typescript error when using withRouter(withStyles(styles)(ComponentName))