I have developed a React / Material UI application using the CssBaseline component and jss component styling like:
const styles = (theme: Theme) => ({
"appBar": {
"zIndex": theme.zIndex.appBar,
},
"buttonContainer": {
"marginRight": theme.spacing.unit
},
"leftBar": {
"alignItems": "center",
"display": "flex",
"flexGrow": 1,
},
"logo": {
"display": "inline-block",
"height": 30,
"marginRight": theme.spacing.unit,
"width": 30,
},
"rightBar": {
"alignItems": "center",
"display": "flex",
"flexGrow": 1,
"justifyContent": "flex-end",
},
});
and withStyles() which I thought made the application styling be self-contained (i.e. would ignore any other styling on the app hosting page).
However now that I've been tasked with embedding the new application into a page within an existing application, I have noticed that the existing application styles sometimes penetrate into the new React / Material UI application (i.e. a tag colors being the existing app color rather than the Material UI color).
- Are these bugs in the CssBaseline component?
- How do I update the new application to keep the old styles from affecting it?
For reference my App component looks like this:
export class App extends PureComponent {
public render(): JSX.Element {
return (
<Provider store={ReduxStore}>
<OidcProvider store={ReduxStore} userManager={AuthUserManager}>
<BrowserRouter basename={AppConfig.pageUrl}>
<MuiThemeProvider theme={theme}>
<MuiPickersUtilsProvider utils={LuxonUtils}>
<CssBaseline />
<AppLayout />
</MuiPickersUtilsProvider>
</MuiThemeProvider>
</BrowserRouter>
</OidcProvider>
</Provider>
);
}
}