-
|
Hello, I need help with the second example at https://visgl.github.io/react-map-gl/docs/api-reference/map-context. I'm trying to use <MapContext.Provider> as shown in the example but I get a typescript error: "Property 'value' is missing in type '{ children: Element; }' but required in type 'ProviderProps'". Do I have to pass something in the value prop? I was hoping that the map would somehow update the value of the MapContext.Provider. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
I struggled with this recently. This is what I have done: From outside, I made the ref for the const mapRef = createRef<MapRef>();
const mapContextValue: MapContextProps = {
map: mapRef,
container: null,
isDragging: false,
eventManager: undefined,
};
return (
<MapContext.Provider value={mapContextValue}>
...
<MapViewComponent />
...
<MapContext.Provider>
...Then in <ReactMapGL ref={forwardedRef} ...>
...
</ReactMapGL>So far the typescript stops complaining, but I DON'T KNOW is that correct way or not. I can't believe I can't find an example about this on github and/or google. Really appreciate if we can get more insightful comments from people have more experience on this. |
Beta Was this translation helpful? Give feedback.
I struggled with this recently. This is what I have done:
From outside, I made the ref for the
mapThen in
MapViewComponentI useforwardRefto put it into theReactMapGLSo far the typescript stops complaining, but I DON'T KNOW is that correct way or not. I can't believe I can't find an example about this on github a…