File tree Expand file tree Collapse file tree 2 files changed +31
-8
lines changed Expand file tree Collapse file tree 2 files changed +31
-8
lines changed Original file line number Diff line number Diff line change @@ -3,11 +3,10 @@ import { render } from 'react-dom';
33import { hot } from 'react-hot-loader/root' ;
44import { Provider } from 'react-redux' ;
55import { Router , browserHistory } from 'react-router' ;
6- import { ThemeProvider } from 'styled-components' ;
76
87import configureStore from './store' ;
98import routes from './routes' ;
10- import theme , { Theme } from './theme ' ;
9+ import ThemeProvider from './modules/App/components/ThemeProvider ' ;
1110
1211require ( './styles/main.scss' ) ;
1312
@@ -19,14 +18,12 @@ const initialState = window.__INITIAL_STATE__;
1918
2019const store = configureStore ( initialState ) ;
2120
22- const currentTheme = Theme . light ;
23-
2421const App = ( ) => (
25- < ThemeProvider theme = { { ... theme [ currentTheme ] } } >
26- < Provider store = { store } >
22+ < Provider store = { store } >
23+ < ThemeProvider >
2724 < Router history = { history } routes = { routes ( store ) } />
28- </ Provider >
29- </ ThemeProvider >
25+ </ ThemeProvider >
26+ </ Provider >
3027) ;
3128
3229const HotApp = hot ( App ) ;
Original file line number Diff line number Diff line change 1+ import React from 'react' ;
2+ import PropTypes from 'prop-types' ;
3+ import { connect } from 'react-redux' ;
4+ import { ThemeProvider } from 'styled-components' ;
5+
6+ import theme , { Theme } from '../../../theme' ;
7+
8+ const Provider = ( { children, currentTheme } ) => (
9+ < ThemeProvider theme = { { ...theme [ currentTheme ] } } >
10+ { children }
11+ </ ThemeProvider >
12+ ) ;
13+
14+ Provider . propTypes = {
15+ children : PropTypes . node . isRequired ,
16+ currentTheme : PropTypes . oneOf ( Object . keys ( Theme ) ) . isRequired ,
17+ } ;
18+
19+ function mapStateToProps ( state ) {
20+ return {
21+ currentTheme : state . preferences . theme ,
22+ } ;
23+ }
24+
25+
26+ export default connect ( mapStateToProps ) ( Provider ) ;
You can’t perform that action at this time.
0 commit comments