diff --git a/CHANGELOG.md b/CHANGELOG.md index e9dbc06ecb..2313e1689d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,8 +5,7 @@ * All fields of a `Realm.Object` treated as optional by TypeScript when constructing a new class-based model, unless specified in the second type parameter [#5000](https://github.com/realm/realm-js/pull/5000) ### Fixed -* ([#????](https://github.com/realm/realm-js/issues/????), since v?.?.?) -* None +* Fixed an additional use of `globalThis` undefined issue, causing Realm to not load on iOS 11/12. ([#4655](https://github.com/realm/realm-js/pull/4655)) ### Compatibility * React Native >= v0.70.0 diff --git a/lib/react-native/index.js b/lib/react-native/index.js index 993a3da4bb..48ebd8b343 100644 --- a/lib/react-native/index.js +++ b/lib/react-native/index.js @@ -20,6 +20,7 @@ import { Platform, NativeModules } from "react-native"; import utils from "../utils"; import extend from "../extensions"; +import { safeGlobalThis } from "@realm/common"; //switch how babel transpiled code creates children objects. //Inheriting from Realm.Object with class syntax does not support using Reflect.construct the way babel transpiles it. @@ -42,8 +43,7 @@ if (Platform.OS === "android") { // TODO: Remove the need to store Realm as a global // @see https://github.com/realm/realm-js/issues/2126 -// eslint-disable-next-line no-restricted-globals -export const Realm = globalThis.Realm; +export const Realm = safeGlobalThis.Realm; // Otherwise, we must be in a "normal" react native situation. // In that case, the Realm type should have been injected by the native code.