File tree Expand file tree Collapse file tree 2 files changed +25
-15
lines changed Expand file tree Collapse file tree 2 files changed +25
-15
lines changed Original file line number Diff line number Diff line change @@ -11,8 +11,28 @@ import Gitter from '../Gitter/Gitter';
11
11
import './Page.scss' ;
12
12
13
13
class Page extends React . Component {
14
- state = {
15
- content : this . props . content instanceof Promise ? 'Loading...' : this . props . content
14
+ constructor ( props ) {
15
+ super ( props ) ;
16
+
17
+ const { content } = props ;
18
+
19
+ this . state = {
20
+ content : content instanceof Promise ? 'Loading...' : content . default || content
21
+ } ;
22
+ }
23
+
24
+ componentDidMount ( ) {
25
+ const { content } = this . props ;
26
+
27
+ if ( content instanceof Promise ) {
28
+ content
29
+ . then ( module => this . setState ( {
30
+ content : module . default || module
31
+ } ) )
32
+ . catch ( error => this . setState ( {
33
+ content : 'Error loading content.'
34
+ } ) ) ;
35
+ }
16
36
}
17
37
18
38
render ( ) {
@@ -66,18 +86,6 @@ class Page extends React.Component {
66
86
</ section >
67
87
) ;
68
88
}
69
-
70
- componentDidMount ( ) {
71
- if ( this . props . content instanceof Promise ) {
72
- this . props . content
73
- . then ( module => this . setState ( {
74
- content : module . default || module
75
- } ) )
76
- . catch ( error => this . setState ( {
77
- content : 'Error loading content.'
78
- } ) ) ;
79
- }
80
- }
81
89
}
82
90
83
91
export default Page ;
Original file line number Diff line number Diff line change @@ -6,9 +6,11 @@ import Site from './components/Site/Site';
6
6
// TODO: Re-integrate <GoogleAnalytics analyticsId="UA-46921629-2" />
7
7
// Consider `react-g-analytics` package
8
8
9
+ const render = process . NODE_ENV === 'production' ? ReactDOM . hydrate : ReactDOM . render ;
10
+
9
11
// Client Side Rendering
10
12
if ( window . document !== undefined ) {
11
- ReactDOM . render ( (
13
+ render ( (
12
14
< BrowserRouter >
13
15
< Route
14
16
path = "/"
You can’t perform that action at this time.
0 commit comments