Skip to content

Commit bef845f

Browse files
Emily Janzerfacebook-github-bot
Emily Janzer
authored andcommitted
Save a copy of DisplayMetrics native map in DeviceInfoModule
Summary: After some more testing, I discovered a problem in D19395326 because the native map that DeviceInfoModule was storing in `mPreviousDisplayMetrics` had been consumed when the event was emitted to JS. This caused the comparison to fail, so it would emit the event again when the dimensions hadn't changed. In this diff, I'm storing a Java-only copy of the native map before emitting the event to JS so this shouldn't happen. Changelog: [Android][Fixed] Fix bug in updating dimensions in JS Reviewed By: mdvacca Differential Revision: D19462861 fbshipit-source-id: 2e47479df93377b85fe87f255972dd31e874e3a8
1 parent cc3e27d commit bef845f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

ReactAndroid/src/main/java/com/facebook/react/modules/deviceinfo/DeviceInfoModule.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,10 @@ public void emitUpdateDimensionsEvent() {
9090
WritableNativeMap displayMetrics =
9191
DisplayMetricsHolder.getDisplayMetricsNativeMap(mFontScale);
9292
if (!displayMetrics.equals(mPreviousDisplayMetrics)) {
93+
mPreviousDisplayMetrics = displayMetrics.copy();
9394
mReactApplicationContext
9495
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
9596
.emit("didUpdateDimensions", displayMetrics);
96-
mPreviousDisplayMetrics = displayMetrics;
9797
}
9898
} else {
9999
ReactSoftException.logSoftException(

0 commit comments

Comments
 (0)