File tree Expand file tree Collapse file tree 1 file changed +11
-7
lines changed
Expand file tree Collapse file tree 1 file changed +11
-7
lines changed Original file line number Diff line number Diff line change @@ -36,16 +36,18 @@ const CALLBACK_MAP = {
3636 'zoom_changed' : 'onZoomChange' ,
3737} ;
3838
39- window [ 'reactMapsGoogleInstances' ] = [ ] ;
40- window [ 'reactMapsGoogleInit' ] = ( ) => {
41- window [ 'reactMapsGoogleInstances' ] . forEach ( instance => instance ( ) ) ;
42- } ;
39+ if ( typeof window !== 'undefined' ) {
40+ window [ 'reactMapsGoogleInstances' ] = [ ] ;
41+ window [ 'reactMapsGoogleInit' ] = ( ) => {
42+ window [ 'reactMapsGoogleInstances' ] . forEach ( instance => instance ( ) ) ;
43+ } ;
44+ }
4345
4446class GoogleMap extends Component {
4547 constructor ( props ) {
4648 super ( props ) ;
4749
48- const scriptLoaded = window . google && window . google . maps && window . google . maps . Map
50+ const scriptLoaded = typeof window !== 'undefined' && window . google && window . google . maps && window . google . maps . Map
4951 ? true
5052 : false ;
5153
@@ -56,11 +58,13 @@ class GoogleMap extends Component {
5658
5759 this . onScriptLoad = this . onScriptLoad . bind ( this ) ;
5860 this . onScriptInit = this . onScriptInit . bind ( this ) ;
59-
60- window [ 'reactMapsGoogleInstances' ] . push ( this . onScriptInit ) ;
6161 }
6262
6363 componentDidMount ( ) {
64+ if ( typeof window !== 'undefined' ) {
65+ window [ 'reactMapsGoogleInstances' ] . push ( this . onScriptInit ) ;
66+ }
67+
6468 this . renderMap ( ) ;
6569 }
6670
You can’t perform that action at this time.
0 commit comments