Skip to content

fix: resolves react snapshot undefined warning#2903

Merged
rborn merged 1 commit intoreact-native-maps:masterfrom
jxeeno:fix/shapshot-warning
Jun 13, 2019
Merged

fix: resolves react snapshot undefined warning#2903
rborn merged 1 commit intoreact-native-maps:masterfrom
jxeeno:fix/shapshot-warning

Conversation

@jxeeno
Copy link
Copy Markdown
Contributor

@jxeeno jxeeno commented Jun 9, 2019

Does any other open PR do the same thing?

No

What issue is this PR fixing?

Resolves React warning being displayed when the region prop in MapView is undefined. React requires a snapshot value (or null) to be provided (see warning message below). This PR modifies getSnapshotBeforeUpdate in MapView to return null if props.region is undefined.

How did you test this PR?

Change is JS only and only affects library's interaction with React. However, the change was also tested on Android (on device) and iOS (device and simulator) to confirm warning is no longer triggered.

Steps to recreate and test for change:

  1. Create MapView without region prop defined, e.g.:
<MapView style={{flex: 1, width: '100%'}} />
  1. Run react native app and observe React warning in debug mode.
    image

  2. Now test with changes in this PR, warning should disappear.

@rborn rborn merged commit 99492e9 into react-native-maps:master Jun 13, 2019
@jxeeno jxeeno deleted the fix/shapshot-warning branch June 13, 2019 15:32
pohnean pushed a commit to pohnean/react-native-maps that referenced this pull request Jul 28, 2020
pinpong pushed a commit to pinpong/react-native-maps that referenced this pull request Feb 28, 2025
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.

2 participants