Does anyone use useGoogleMap() inside NEXT JS component? It gives Unhandled Runtime Error Invariant Violation: useGoogleMap needs a GoogleMap available up in the tree
error. I just need to refer to map of google Map inside Next JS.
Asked
Active
Viewed 402 times
0

sam
- 23
- 5
-
did you wrap the component that are use this hook by `GoogleMap` – Mohssine Oussama Apr 01 '23 at 13:08
-
what do you mean to wrap it? it is a hook! example: https://unpkg.com/browse/@react-google-maps/api@1.8.1/src/useGoogleMap.md – sam Apr 02 '23 at 01:29
1 Answers
0
you have to wrap the component that are using this hook by GoogleMap component as the documentation say:
The GoogleMap component uses React Context internally to pass the map instance around. For the convenience the value is exposed with hook useGoogleMap (requires React 16.8+).

Mohssine Oussama
- 103
- 1
- 9