react-google-maps icon indicating copy to clipboard operation
react-google-maps copied to clipboard

withScriptjs is undefined

Open thanhacun opened this issue 9 years ago • 9 comments

Both of the following still makes withScriptjs undefine:

import { withScriptjs } from 'react-google-maps import { withScriptjs } from 'react-google-maps/lib/withScriptjs

thanhacun avatar Sep 14 '17 03:09 thanhacun

@thanhacun which version are you using now?

https://github.com/tomchentw/react-google-maps/blob/77a5f4ffead3f818a7a3c86f54dbcbbd852ba912/lib/index.js#L7-L14

tomchentw avatar Sep 14 '17 04:09 tomchentw

I am using version 8.0.0, temporary I have to use import * as withScriptjs from ... and use withScriptjs.default as a fucntion

thanhacun avatar Sep 14 '17 04:09 thanhacun

Are u using webpack/babel?

Does this only happen to withScriptjs? Or other components as well?

tomchentw avatar Sep 14 '17 04:09 tomchentw

  • I do use webpack/babel (create-react-app)
  • It only happens with withScriptjs

Working code sample:

import  * as withScriptjs from 'react-google-maps/lib/withScriptjs';
import { withGoogleMap, GoogleMap, Marker } from 'react-google-maps';

const MapWithAMarker = compose(
  withScriptjs.default,
  withGoogleMap
)(props =>
  <GoogleMap
    defaultZoom = {8}
    defaultCenter = {{ lat: -34.397, lng: 150.644 }}
  >
    <Marker position={{ lat: -34.397, lng: 150.644 }} />
  </GoogleMap>
);

thanhacun avatar Sep 14 '17 04:09 thanhacun

Oh, read the Changlog. WithScriptjs is now exported by root(but I don't know why you can't use it) For explicit import, just use default import:

import withScriptjs from lib/...

tomchentw avatar Sep 14 '17 04:09 tomchentw

Yes as I mention in the first post: if import as the changelog, withScriptjs will be undefined. I have tried both root import and explicit import as well

thanhacun avatar Sep 14 '17 05:09 thanhacun

It is working now! May be when upgrading to v8.0.0, it is not successful!

Very sorry to bother you!

thanhacun avatar Sep 14 '17 05:09 thanhacun

LOL good to hear that!!

tomchentw avatar Sep 14 '17 05:09 tomchentw

Released v8.1.0

tomchentw avatar Sep 15 '17 00:09 tomchentw