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() {
77}
88
99export default class HelmetData {
10+ instances = [ ] ;
11+
1012 value = {
1113 setHelmet : serverState => {
1214 this . context . helmet = serverState ;
1315 } ,
1416 helmetInstances : {
15- get : ( ) => instances ,
17+ get : ( ) => ( this . canUseDOM ? instances : this . instances ) ,
1618 add : instance => {
17- instances . push ( instance ) ;
19+ ( this . canUseDOM ? instances : this . instances ) . push ( instance ) ;
1820 } ,
1921 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 ) ;
2224 } ,
2325 } ,
2426 } ;
2527
26- constructor ( context ) {
28+ constructor ( context , canUseDOM = typeof document !== 'undefined' ) {
2729 this . context = context ;
30+ this . canUseDOM = canUseDOM ;
2831
29- if ( ! HelmetData . canUseDOM ) {
32+ if ( ! canUseDOM ) {
3033 context . helmet = mapStateOnServer ( {
3134 baseTag : [ ] ,
3235 bodyAttributes : { } ,
Original file line number Diff line number Diff line change @@ -36,7 +36,7 @@ export default class Provider extends Component {
3636 constructor ( props ) {
3737 super ( props ) ;
3838
39- this . helmetData = new HelmetData ( this . props . context ) ;
39+ this . helmetData = new HelmetData ( this . props . context , Provider . canUseDOM ) ;
4040 }
4141
4242 render ( ) {
You can’t perform that action at this time.
0 commit comments