File tree Expand file tree Collapse file tree 2 files changed +10
-7
lines changed Expand file tree Collapse file tree 2 files changed +10
-7
lines changed Original file line number Diff line number Diff line change @@ -7,26 +7,29 @@ export function clearInstances() {
7
7
}
8
8
9
9
export default class HelmetData {
10
+ instances = [ ] ;
11
+
10
12
value = {
11
13
setHelmet : serverState => {
12
14
this . context . helmet = serverState ;
13
15
} ,
14
16
helmetInstances : {
15
- get : ( ) => instances ,
17
+ get : ( ) => ( this . canUseDOM ? instances : this . instances ) ,
16
18
add : instance => {
17
- instances . push ( instance ) ;
19
+ ( this . canUseDOM ? instances : this . instances ) . push ( instance ) ;
18
20
} ,
19
21
remove : instance => {
20
- const index = instances . indexOf ( instance ) ;
21
- instances . splice ( index , 1 ) ;
22
+ const index = ( this . canUseDOM ? instances : this . instances ) . indexOf ( instance ) ;
23
+ ( this . canUseDOM ? instances : this . instances ) . splice ( index , 1 ) ;
22
24
} ,
23
25
} ,
24
26
} ;
25
27
26
- constructor ( context ) {
28
+ constructor ( context , canUseDOM = typeof document !== 'undefined' ) {
27
29
this . context = context ;
30
+ this . canUseDOM = canUseDOM ;
28
31
29
- if ( ! HelmetData . canUseDOM ) {
32
+ if ( ! canUseDOM ) {
30
33
context . helmet = mapStateOnServer ( {
31
34
baseTag : [ ] ,
32
35
bodyAttributes : { } ,
Original file line number Diff line number Diff line change @@ -36,7 +36,7 @@ export default class Provider extends Component {
36
36
constructor ( props ) {
37
37
super ( props ) ;
38
38
39
- this . helmetData = new HelmetData ( this . props . context ) ;
39
+ this . helmetData = new HelmetData ( this . props . context , Provider . canUseDOM ) ;
40
40
}
41
41
42
42
render ( ) {
You can’t perform that action at this time.
0 commit comments