I'm following the official tutorial to create global theme for my app.
My root component is supposed to provide global theme:
const themeInstance = {
backgroundColor: 'cadetblue'
}
render (
<ThemeProvider theme={themeInstance}>
<ChildComponent />
</ThemeProvider>,
rootNode
)
But I can't seem to get my child component to apply the theme:
const useStyles = makeStyles(theme => {
childComp: {
backgroundColor: theme.backgroundColor
}
})
const ChildComponent: FC = () => {
const classes = useStyles()
return (
<div className={classes.childComp}>I'm a div</div>
)
}
<ChildComponent /> is getting rendered un-styled.
It looks to be a types mismatch issue of some sort as when I started to play around with types of theme parameter, the browser has rendered the expected output (<ChildComponent /> div with background-color: cadetblue) for split second than failed with error.
Any help to figure out where did I go wrong way are quite appreciated.
Live sandbox can be found over here.