Created
August 31, 2022 15:32
-
-
Save everdimension/7cc3fc1c90978a9176245bb825f90356 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// just a reminder of a nice API for a <Script /> component, | |
// reference: https://nextjs.org/docs/basic-features/script#executing-code-after-mounting-onready | |
import { useRef } from 'react' | |
import Script from 'next/script' | |
export function Home() { | |
const mapRef = useRef() | |
return ( | |
<> | |
<div ref={mapRef}></div> | |
<Script | |
id="google-maps" | |
src="https://maps.googleapis.com/maps/api/js" | |
onReady={() => { | |
new google.maps.Map(mapRef.current, { | |
center: { lat: -34.397, lng: 150.644 }, | |
zoom: 8, | |
}) | |
}} | |
/> | |
</> | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment