Closed jgarplind closed 4 months ago
Can you create a CodeSandbox that reproduces your issue?
Can you create a CodeSandbox that reproduces your issue?
It didn't reproduce, and I could in fact not even reproduce it in our own repository now that I tried again.
I will close this as "can't repro", and re-open only if I can reproduce it consistently in a place where you too can observe it.
Thanks for taking the time to respond!
I am also seeing this behavior in our project. If I can find some time, I will look into creating a CodeSandbox. For now, the steps are:
<Map reuseMaps={true} />
onLoad
fires and mapRef.current
is defined)onLoad
fires, mapRef.current === null
)The behavior is quite reproducible for us, and goes away when disabling reuseMaps
First time digging to this codebase here, but it looks like the ref's value (contextValue.map
) set set after the call to Mapbox.reuse
, where the "load"
event is fired: https://github.com/visgl/react-map-gl/blob/master/src/components/map.tsx#L86
Description
Using a simple implementation inspired by @Pessimistress in https://github.com/visgl/react-map-gl/discussions/1983#discussioncomment-3615365, I find that the
mapRef
isnull
at the timeonLoad
is called.Doing something like this:
current event
logs the map objectcurrent
logs nullcurrent later
logs the non-null map referenceExpected Behavior
mapRef.current
should be non-null by the timeonLoad
is called.Steps to Reproduce
See above.
Environment
Logs
No response