mapRef not being updated on load #2438
Unanswered
nareshbhatia
asked this question in
Q&A
Replies: 1 comment
-
|
I would suggest using a ref callback function instead of a ref created by import { Map, type MapRef } from 'react-map-gl';
const handleRef = (ref: MapRef | null) => {
if (ref) {
// ...
}
};
const CustomMap = () => {
return (
<Map ref={handleRef}>
// ...
</Map>
);
}; |
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
Uh oh!
There was an error while loading. Please reload this page.
-
Hello react-map-gl community,
I am trying to use a
mapRefas a dependency in myuseEffectto install geocoders. My code follows this example in the docs. Unfortunately, themapRefis not being updated even after the map is loaded and hence theuseEffectis not triggered. Here's the console output (note that there is nomapRefchange after the map is loaded):What am I missing? My code is shown below (the full repository is here):
Package versions:
Beta Was this translation helpful? Give feedback.
All reactions