File tree 3 files changed +17
-17
lines changed
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 {
14
14
15
15
componentDidMount ( ) {
16
16
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 ;
18
18
}
19
19
20
20
componentWillReceiveProps ( nextProps ) {
@@ -23,6 +23,12 @@ class App extends React.Component {
23
23
}
24
24
}
25
25
26
+ componentDidUpdate ( prevProps ) {
27
+ if ( this . props . theme !== prevProps . theme ) {
28
+ document . body . className = this . props . theme ;
29
+ }
30
+ }
31
+
26
32
render ( ) {
27
33
return (
28
34
< div className = "app" >
@@ -39,10 +45,18 @@ App.propTypes = {
39
45
pathname : PropTypes . string
40
46
} ) . isRequired ,
41
47
setPreviousPath : PropTypes . func . isRequired ,
48
+ theme : PropTypes . string ,
42
49
} ;
43
50
44
51
App . defaultProps = {
45
- children : null
52
+ children : null ,
53
+ theme : 'light'
46
54
} ;
47
55
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';
11
11
class FullView extends React . Component {
12
12
componentDidMount ( ) {
13
13
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
- }
21
14
}
22
15
23
16
ident = ( ) => { }
@@ -62,7 +55,6 @@ class FullView extends React.Component {
62
55
}
63
56
64
57
FullView . propTypes = {
65
- theme : PropTypes . string . isRequired ,
66
58
params : PropTypes . shape ( {
67
59
project_id : PropTypes . string
68
60
} ) . isRequired ,
@@ -98,7 +90,6 @@ FullView.propTypes = {
98
90
function mapStateToProps ( state ) {
99
91
return {
100
92
user : state . user ,
101
- theme : state . preferences . theme ,
102
93
htmlFile : getHTMLFile ( state . files ) ,
103
94
jsFiles : getJSFiles ( state . files ) ,
104
95
cssFiles : getCSSFiles ( state . files ) ,
Original file line number Diff line number Diff line change @@ -66,7 +66,6 @@ class IDEView extends React.Component {
66
66
67
67
window . onbeforeunload = ( ) => this . warnIfUnsavedChanges ( ) ;
68
68
69
- document . body . className = this . props . preferences . theme ;
70
69
this . autosaveInterval = null ;
71
70
}
72
71
@@ -90,10 +89,6 @@ class IDEView extends React.Component {
90
89
this . props . getProject ( nextProps . params . project_id ) ;
91
90
}
92
91
}
93
-
94
- if ( nextProps . preferences . theme !== this . props . preferences . theme ) {
95
- document . body . className = nextProps . preferences . theme ;
96
- }
97
92
}
98
93
99
94
componentDidUpdate ( prevProps ) {
You can’t perform that action at this time.
0 commit comments