react-native-maps: Animate to region crash on Android

Hi

I’m running RN 0.35.0 and RN maps 0.11.0 and I’m getting a null pointer with the following stack trace:

image

I’ve created a component which wraps the MapView Component. There is a componentWillUpdate() class with the following code:

     this.refs.map.animateToRegion({
       latitude: this.props.location.latitude,
       longitude: this.props.location.longitude,
       latitudeDelta: this.state.latitudeDelta,
       longitudeDelta: this.state.longitudeDelta
     })

Anyone got a fix for this crash?

Thanks

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 6
  • Comments: 16 (2 by maintainers)

Most upvoted comments

This is extremely hard to debug, but i managed to find that MapView “ref” a.k.a this.map could be null even when called inside onMapReady. Not only that it only randomly happens on some android devices that i couldn’t reproduce on my test devices.

My workaround is to use repeat loop timer to wait until this.map shows up!

I’m having this problem too. But only on the first run. I’m getting : ExceptionsManager.js:65 Cannot read property ‘animateToRegion’ of null

@alvelig I’m already using onMapReady … but this problem still persists. Worst still i can’t seem to reproduce it in all my three Android test devices (5.1, 6.0 & 7.0). But it persists in Android console crash reporting.

I even put a if(this.map) checking for all occurrences of animateToRegion() function … but still receive crash reports.

Has someone solved this ? I’m having the same issue Is there any onMapReady function ?