I have the following React component that uses a custom Material UI theme
const getTheme = name => themes.filter(theme => theme.name === name)[0] || themes[0];
const Root = props => (
<MuiThemeProvider muiTheme={getMuiTheme(getTheme(props.theme).data)}>
<Router history={history}>
<Switch>
<Route component={AppContainer}/>
</Switch>
</Router>
</MuiThemeProvider>
);
It's fed by a container
const mapStateToProps = state => ({
theme: state.settings.theme
});
const RootContainer = connect(mapStateToProps, {})(Root);
When I update the theme name on a settings page the state is updated (confirmed via Redux logging), but the theme isn't updated. However, when I navigate away from the page, the new theme is applied.
Presumably the change in state isn't causing the Root component to re-render, or there's something I don't understand in the way this is applied
<MuiThemeProvider muiTheme={getMuiTheme(getTheme(props.theme).data)}>
Any idea how I can get the theme to update the instance it's changed in the state?
