I want to use a theme in parts of my own components that are class based. I cannot get anything to work, all examples in the documentation is for functional components. Basically the theme is defined and I want to use it to style my own components so I can avoid repeating myself and change the code at the higher level and it change everywhere.
My App.js
import { ThemeProvider } from '@material-ui/styles';
import { createMuiTheme } from '@material-ui/core/styles';
const theme = createMuiTheme({
palette: {
primary: {
light: '#757ce8',
main: '#3f50b5',
dark: '#002884',
contrastText: '#fff',
},
},
overrides: {
MuiOutlinedInput: {
disabled: true,
input: {
color: 'red'
}
}
}
});
export default class App extends React.Component {
render() {
return (
<ThemeProvider theme={theme}>
<Nav />
</ThemeProvider>
);
}
}
My Problem file, Nav.js
import React from 'react';
import SearchBar from './SearchBar';
import { makeStyles } from '@material-ui/styles';
const styles = makeStyles(theme => ({
root: {
background: theme.background,
},
}));
class Nav extends React.Component {
render() {
const classes = styles();
return(
<div className={classes.root}>
<SearchBar />
</div>
)
}
}
export default Nav;