react-google-maps-api: useLoadScript() throws "invariant requires an error message argument"
Please provide an explanation
Your Environment
os:
mac
node --version
v10.15.3
react version
16.8.7
webpack version
4.28.3
@babel version
@babel/core@7.2.2
@react-google-maps/api version
1.3.0
How is it behave?
When trying to use useLoadScript() hook, I get following error:
browser.js:22 Uncaught Error: invariant requires an error message argument
at invariant (browser.js:22)
at reactgooglemapsapi.es.production.js:331
at commitHookEffectList (react-dom.development.js:18059)
at commitPassiveHookEffects (react-dom.development.js:18086)
at HTMLUnknownElement.callCallback (react-dom.development.js:147)
at Object.invokeGuardedCallbackDev (react-dom.development.js:196)
at invokeGuardedCallback (react-dom.development.js:250)
at commitPassiveEffects (react-dom.development.js:19712)
at wrapped (scheduler-tracing.development.js:177)
at flushFirstCallback (scheduler.development.js:99)
at flushWork (scheduler.development.js:216)
at MessagePort.push../node_modules/scheduler/cjs/scheduler.development.js.channel.port1.onmessage (scheduler.development.js:619)
The code is simple:
export default function Map( props ) {
const { isLoaded, loadError } = useLoadScript( {
googleMapsApiKey: googleConfig.apiKey,
id: props.id + '-script-loader',
} );
if ( loadError ) {
return <div>Map cannot be loaded right now, sorry.</div>
}
return (
<>{ isLoaded ? <GoogleMap {...props} /> : <LoadingAnimation /> }</>
)
}
How should it behave correctly?
It should not throw the error 😃
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 18 (5 by maintainers)
@JustFly1984 I have the libraries prop
const libs = ['places', 'visualization', 'drawing', 'geometry'];Yes use onLoad with GoogleMap component and you’ll get the map instance Defiantly you can pass to parent with callback.
On Thu, 27 Jun 2019 at 12:22 PM, Sergey Segeda notifications@github.com wrote: