Enabling followUserLocation
with other follow
props on Camera
is non-deterministic
#530
Milestone
followUserLocation
with other follow
props on Camera
is non-deterministic
#530
The
followUserLocation
and otherfollow
props of theCamera
are currently non-deterministic and don't work as expected.Reproduction is possible with the following example. It basically switches between normal map browsing into a "navigation mode", by following the user and applying pitch:
Expected behavior on both platforms when enabling navigation for the first and following times:
Camera.Follow.Android.mp4
Camera.Follow.iOS.mp4
I suspect the migration to function components to be still faulty for the
Camera
component. Lets review the code at the latest point before migration to FC.The component was never re-rendered, the props were only initially passed via
render
for the first ever render cycle. Afterwards it was blocked by:maplibre-react-native/javascript/components/Camera.tsx
Lines 212 to 214 in 31bdad0
This is the
render
method which initially passes the native props:maplibre-react-native/javascript/components/Camera.tsx
Lines 651 to 676 in 31bdad0
Now looking into how the props were updated within the Class Component we see this
UNSAFE_componentWillReceiveProps
. It was the reason, why the migration was done as this is deprecated.maplibre-react-native/javascript/components/Camera.tsx
Lines 208 to 210 in 31bdad0
And this called the
_handleCameraChange
function:maplibre-react-native/javascript/components/Camera.tsx
Lines 216 to 304 in 31bdad0
This one calls
setNativeProps
in specific order. E.g. it setsfollowUserLocation
first, then otherfollow
props and only then restrictions/controlled camera position. This might be the culprit for the now rather unclear behavior. It looks like it's native props are updated in a random order, when just rendering theNativeComponent
and passing the props.To be honest I'm not 100 % sure how to fix this. I couldn't find any docs around native props order during updating. I have some ideas:
useEffect
and maybe storing old props within aref
maplibre-react-native/javascript/components/Camera.tsx
Lines 383 to 391 in a45fc55
useEffects
but without theNativeComponent
getting the props passed?The text was updated successfully, but these errors were encountered: