Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issues (onRegionChangeComplete|restProps.mapRef) is not a function #205

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ja-ka
Copy link

@ja-ka ja-ka commented Jan 20, 2021

After I added react-native-map-clustering to my app I and simply exchanged import MapView from 'react-native-maps' with import MapView from 'react-native-map-clustering', I experienced these two issues when running my app:

TypeError: restProps.mapRef is not a function. (In 'restProps.mapRef(map)', 'restProps.mapRef' is undefined)

and

TypeError: onRegionChangeComplete is not a function. (In 'onRegionChangeComplete(region)', 'onRegionChangeComplete' is undefined)

I wasn't providing any functions for mapRef and onRegionChangeComplete since these props are optional and I don't require them in my app. I fixed these errors for now by doing this:

const dummy = () => {};

<MapView
  ref={map}
  mapRef={dummy}
  onRegionChangeComplete={dummy}
  ...
>
  {...}
</MapView>

Cheers!

@benallfree
Copy link

@ja-ka I think this fix is incomplete.

const mapRef = useRef<MapView>(null)

<ClusteredMapView mapRef={mapRef} />

still fails with the error.

@jacquesdev
Copy link

@benallfree - you will need to call something like this.mapRef.map iirc. Basically, it's an child of mapRef.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants