-
Beta Was this translation helpful? Give feedback.
Answered by
nonoumasy
Nov 11, 2021
Replies: 2 comments
-
So I was able to resolve the issue using the Script tag inside a useEffect inside the component.
However I'm still unable to use the asynchronous script loading. |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
nonoumasy
-
I ran into a number of issues and decided on this dirty pattern for now: import type { AppProps } from "next/app";
import Script from "next/script";
import { useState } from "react";
export default function App({ Component, pageProps }: AppProps) {
const [googleApiLoaded, setGoogleApiLoaded] = useState(false);
return (
<>
<Script
src="https://maps.googleapis.com/maps/api/js?key=MY_KEY&libraries=places"
onLoad={() => setGoogleApiLoaded(true)}
></Script>
{googleApiLoaded && <Component {...pageProps} />}
</>
);
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
So I was able to resolve the issue using the Script tag inside a useEffect inside the component.
However I'm still unable to use the asynchronous script loading.