react-native-maps: Callout does not update after props change on Android
I’m having an issue on Android where the content of the tooltip does not update after its props have changed.
I am fetching data from an API as a result of the onPress event for a custom marker. After the data is returned, I am updating the state of the component, and the relevant attributes are passed down as props to the content component for the custom callout. On iOS the custom content re-renders after the state is updated. However, on android, the content does not re-render.
<MapView.Marker
onPress={() => this.fetchData(item.id)}
key={key}
coordinate={{latitude, longitude}}
>
<MapView.Callout
style={{width: 200}}>
<CustomTooltipContent text={this.state.text} isLoading={this.state.isLoading} />
</MapView.Callout>
</MapView.Marker>
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 20 (3 by maintainers)
I got same issue in iOS with Google Map. After looking at API of Marker, I found the reason: Callouts only renders 1 time at first because of this prop tracksInfoWindowChanges (default is false)
So there we have 2 solutions for it:
More information: https://github.com/react-native-community/react-native-maps/blob/master/docs/marker.md
Hope can help someone.
Here is a simple working example. The increment button increments the count variable. However, on android you need to dismiss the tooltip and reopen it to see the changed. On iOS you see the counter increment like a normal react component.
I have the same problem. I’m showing a callout with the distance between the user and the marker but the callout is not updating when the user’s position changes. The callout always shows the same value unless it is closed and reopened.
I have same problem, and I do these to solve:
same issue here. Marker Callout does not update unless you close and open it again. Any solutions ?