是否有人在NEXT JS组件内使用useGoogleMap() ?它给出了Unhandled Runtime Error Invariant Violation: useGoogleMap needs a GoogleMap available up in the tree
误差。我只需要在Next JS中引用谷歌地图的地图。
你必须用GoogleMap组件包装使用这个钩子的组件如文档所述:
GoogleMap组件在内部使用React Context来传递地图实例。为了方便,这个值是通过钩子useGoogleMap暴露的(需要React 16.8+)。