Skip to content

Commit 3281c90

Browse files
authored
[Android] Fix array conversion for snapshots
Android crashes when trying to send back an array due to trying to use putMap with an array (incompatible types)
1 parent 4a9eea8 commit 3281c90

File tree

1 file changed

+7
-2
lines changed
  • android/src/main/java/io/fullstack/firestack

1 file changed

+7
-2
lines changed

android/src/main/java/io/fullstack/firestack/Utils.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import com.facebook.react.bridge.ReadableMap;
1414
import com.facebook.react.bridge.ReactContext;
1515
import com.facebook.react.bridge.WritableArray;
16+
import com.facebook.react.bridge.WritableNativeArray;
1617
import com.facebook.react.modules.core.DeviceEventManagerModule;
1718

1819
import com.facebook.react.bridge.ReadableType;
@@ -82,8 +83,12 @@ public static WritableMap dataSnapshotToMap(
8283
data.putString("value", null);
8384
}
8485
} else {
85-
WritableMap valueMap = Utils.castSnapshotValue(dataSnapshot);
86-
data.putMap("value", valueMap);
86+
Object value = Utils.castSnapshotValue(dataSnapshot);
87+
if (value instanceof WritableNativeArray) {
88+
data.putArray("value", (WritableArray) value);
89+
} else {
90+
data.putMap("value", (WritableMap) value);
91+
}
8792
}
8893

8994
// Child keys

0 commit comments

Comments
 (0)