Skip to content

Commit

Permalink
docs(readme): onRegionChangeComplete called infinitely (#4574)
Browse files Browse the repository at this point in the history
  • Loading branch information
Bilal-Abdeen committed Apr 21, 2023
1 parent 5f8510f commit 1b2a6aa
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions README.md
Expand Up @@ -607,6 +607,25 @@ Source: https://github.com/react-native-maps/react-native-maps/issues/1901

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

#### onRegionChangeComplete() callback is called infinitely

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.

```javascript
onRegionChangeComplete={ (region, gesture) => {
// This fix only works on Google Maps because isGesture is NOT available on Apple Maps
if (!gesture.isGesture) {
return;
}

// You can use
dispatch({ type: "map_region", payload: { mapRegion: region }}); // if using useReducer
// setMapRegionState(region); // if using useState
}}
```

Source: https://github.com/react-native-maps/react-native-maps/issues/846#issuecomment-1210079461

## License

Copyright (c) 2017 Airbnb
Expand Down

0 comments on commit 1b2a6aa

Please sign in to comment.