ydeshayes / googlePlaceAutocomplete

Wrapper on top of the material-ui AutoComplete component that use google place api
https://ydeshayes.github.io/googlePlaceAutocomplete/
26 stars 12 forks source link

Server side rendering: google is not defined #10

Open jwamsterdam opened 7 years ago

jwamsterdam commented 7 years ago

Hi, Your npm works great running locally, but using SSR with node I get the following error:

ReferenceError: google is not defined at new t (C:\tripnew\node_modules\material-ui-places\lib\material-ui-places.min.js:1:2370)

any change to fix this?

Thanks a lot!

jwamsterdam commented 7 years ago

Hi @ydeshayes,

Do you think you can help out here? I love your npm and would really like to keep using it!

ydeshayes commented 7 years ago

Hello!

When is your error firing, at run time or bundle time ?

Do you have the ability to load the google script in the HTML that you return to the browser ?

Sorry for the delay...

ydeshayes commented 7 years ago

Can you try to add google as external on window.google ?

jwamsterdam commented 7 years ago

Hi,

Will check if the error is on runtime or buildtime, I do have the script in my html. Do not completely undertsand your second answer.. how do I configure that?

jwamsterdam commented 7 years ago

The error is on runtime, building goes oke. Below is the more detailed error:

C:\Tripscanner2\node_modules\material-ui-places\lib\material-ui-places.min.js:1 (function (exports, require, module, filename, dirname) { !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("material-ui"),require("prop-types"),require("react")):"function"==typeof define&&define.amd?define("material-ui-places",["material-ui","prop-types","react"],t):"object"==typeof exports?exports["material-ui-places"]=t(require("material-ui"),require("prop-types"),require("react")):e["material-ui-places"]=t(e["material-ui"],e["prop-types"],e.react)}(this,function(e,t,r){return function(e){function t(o){if(r[o])return r[o].exports;var n=r[o]={i:o,l:!1,exports:{}};return e[o].call(n.exports,n,n.exports,t),n.l=!0,n.exports}var r={};return t.m=e,t.c=r,t.i=function(e){return e},t.d=function(e,r,o){t.o(e,r)||Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:o})},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=f