File tree Expand file tree Collapse file tree 3 files changed +17
-17
lines changed Expand file tree Collapse file tree 3 files changed +17
-17
lines changed Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ class App extends React.Component {
1414
1515 componentDidMount ( ) {
1616 this . setState ( { isMounted : true } ) ; // eslint-disable-line react/no-did-mount-set-state
17- document . body . className = 'light' ;
17+ document . body . className = this . props . theme ;
1818 }
1919
2020 componentWillReceiveProps ( nextProps ) {
@@ -23,6 +23,12 @@ class App extends React.Component {
2323 }
2424 }
2525
26+ componentDidUpdate ( prevProps ) {
27+ if ( this . props . theme !== prevProps . theme ) {
28+ document . body . className = this . props . theme ;
29+ }
30+ }
31+
2632 render ( ) {
2733 return (
2834 < div className = "app" >
@@ -39,10 +45,18 @@ App.propTypes = {
3945 pathname : PropTypes . string
4046 } ) . isRequired ,
4147 setPreviousPath : PropTypes . func . isRequired ,
48+ theme : PropTypes . string ,
4249} ;
4350
4451App . defaultProps = {
45- children : null
52+ children : null ,
53+ theme : 'light'
4654} ;
4755
48- export default connect ( ( ) => ( { } ) , { setPreviousPath } ) ( App ) ;
56+ const mapStateToProps = state => ( {
57+ theme : state . preferences . theme ,
58+ } ) ;
59+
60+ const mapDispatchToProps = { setPreviousPath } ;
61+
62+ export default connect ( mapStateToProps , mapDispatchToProps ) ( App ) ;
Original file line number Diff line number Diff line change @@ -11,13 +11,6 @@ import * as ProjectActions from '../actions/project';
1111class FullView extends React . Component {
1212 componentDidMount ( ) {
1313 this . props . getProject ( this . props . params . project_id ) ;
14- document . body . className = this . props . theme ;
15- }
16-
17- componentWillUpdate ( nextProps ) {
18- if ( nextProps . theme !== this . props . theme ) {
19- document . body . className = nextProps . theme ;
20- }
2114 }
2215
2316 ident = ( ) => { }
@@ -62,7 +55,6 @@ class FullView extends React.Component {
6255}
6356
6457FullView . propTypes = {
65- theme : PropTypes . string . isRequired ,
6658 params : PropTypes . shape ( {
6759 project_id : PropTypes . string
6860 } ) . isRequired ,
@@ -98,7 +90,6 @@ FullView.propTypes = {
9890function mapStateToProps ( state ) {
9991 return {
10092 user : state . user ,
101- theme : state . preferences . theme ,
10293 htmlFile : getHTMLFile ( state . files ) ,
10394 jsFiles : getJSFiles ( state . files ) ,
10495 cssFiles : getCSSFiles ( state . files ) ,
Original file line number Diff line number Diff line change @@ -66,7 +66,6 @@ class IDEView extends React.Component {
6666
6767 window . onbeforeunload = ( ) => this . warnIfUnsavedChanges ( ) ;
6868
69- document . body . className = this . props . preferences . theme ;
7069 this . autosaveInterval = null ;
7170 }
7271
@@ -90,10 +89,6 @@ class IDEView extends React.Component {
9089 this . props . getProject ( nextProps . params . project_id ) ;
9190 }
9291 }
93-
94- if ( nextProps . preferences . theme !== this . props . preferences . theme ) {
95- document . body . className = nextProps . preferences . theme ;
96- }
9792 }
9893
9994 componentDidUpdate ( prevProps ) {
You can’t perform that action at this time.
0 commit comments