Skip to content
This repository was archived by the owner on Mar 20, 2024. It is now read-only.

Commit 1b2a6aa

Browse files
authored
docs(readme): onRegionChangeComplete called infinitely (react-native-maps#4574)
1 parent 5f8510f commit 1b2a6aa

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -607,6 +607,25 @@ Source: https://github.com/react-native-maps/react-native-maps/issues/1901
607607

608608
Source: https://github.com/react-native-maps/react-native-maps/issues/3957#issuecomment-924161121
609609

610+
#### onRegionChangeComplete() callback is called infinitely
611+
612+
If changing the state in `onRegionChangeComplete` is called infinitely, add a condition to limit these calls to occur only when the region change was done as a result of a user's action.
613+
614+
```javascript
615+
onRegionChangeComplete={ (region, gesture) => {
616+
// This fix only works on Google Maps because isGesture is NOT available on Apple Maps
617+
if (!gesture.isGesture) {
618+
return;
619+
}
620+
621+
// You can use
622+
dispatch({ type: "map_region", payload: { mapRegion: region }}); // if using useReducer
623+
// setMapRegionState(region); // if using useState
624+
}}
625+
```
626+
627+
Source: https://github.com/react-native-maps/react-native-maps/issues/846#issuecomment-1210079461
628+
610629
## License
611630

612631
Copyright (c) 2017 Airbnb

0 commit comments

Comments
 (0)