MapViewCallbacks keep old references for variables #235
Labels
priority: p2
Moderately-important priority. Fix may not be included in next release.
type: bug
Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
SDK Version: 0.4.3
The MapViewCallbacks are not getting recreated when a state value changes. If I define local state variable and I use that variable inside a callback then the callback always has the initial value of the variable even if the variable gets updated. This happens even when the mapViewCallback is defined using
useCallback
and the the variable is listed as a dependency.You can see that there is a console.log with appointmentMarkers inside
onMarkerClick
and there is one outside. The outside one has the correct value of the appointmentMarkers and is updated. The one inside theonMarkerClick
callback always has value[]
and never gets updated. This same code existed in version 0.3.4 and worked perfectly.I've tried putting
onMarkerClick
in auseCallback
, defined it outside then referenced, I've removed theuseMemo
frommapViewCallbacks
and it doesn't make any difference. The value of the state var inside any of mapViewCallbacks always stays the same and never updates.The text was updated successfully, but these errors were encountered: