Skip to content

Commit 6e0fe2f

Browse files
Change React Native Version import to the one from Platform (#3949)
Co-authored-by: Krystof Woldrich <[email protected]>
1 parent a5a8f89 commit 6e0fe2f

File tree

5 files changed

+14
-16
lines changed

5 files changed

+14
-16
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
- Pass `sampleRate` option to the Android SDK ([#3979](https://github.com/getsentry/sentry-react-native/pull/3979))
88
- Drop app start data older than one minute ([#3974](https://github.com/getsentry/sentry-react-native/pull/3974))
9+
- Use `Platform.constants.reactNativeVersion` instead of `react-native` internal export ([#3949](https://github.com/getsentry/sentry-react-native/pull/3949))
910

1011
### Dependencies
1112

src/js/utils/rnlibraries.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
/* eslint-disable @typescript-eslint/no-var-requires */
22

3-
import { TurboModuleRegistry } from 'react-native';
4-
import { version as RNV } from 'react-native/Libraries/Core/ReactNativeVersion';
3+
import { Platform, TurboModuleRegistry } from 'react-native';
54

65
import type * as ReactNative from '../vendor/react-native';
76
import type { ReactNativeLibrariesInterface } from './rnlibrariesinterface';
@@ -32,7 +31,7 @@ export const ReactNativeLibraries: Required<ReactNativeLibrariesInterface> = {
3231
},
3332
},
3433
ReactNativeVersion: {
35-
version: RNV,
34+
version: Platform.constants?.reactNativeVersion,
3635
},
3736
TurboModuleRegistry,
3837
};

src/js/utils/rnlibrariesinterface.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
// that don't have all the internals available. For example react-native-web.
66
//
77

8-
import type { version as RNV } from 'react-native/Libraries/Core/ReactNativeVersion';
9-
108
import type * as ReactNative from '../vendor/react-native';
119

1210
export type { UnsafeObject } from 'react-native/Libraries/Types/CodegenTypes';
@@ -25,8 +23,6 @@ export interface ReactNativeLibrariesInterface {
2523
polyfillGlobal: <T>(name: string, getValue: () => T) => void;
2624
};
2725
Promise?: typeof Promise;
28-
ReactNativeVersion?: {
29-
version: typeof RNV;
30-
};
26+
ReactNativeVersion?: ReactNative.ReactNativeVersion;
3127
TurboModuleRegistry?: ReactNative.TurboModuleRegistry;
3228
}

src/js/vendor/react-native/index.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,13 @@ export type TurboModuleRegistry = {
6464
get<T extends TurboModule>(name: string): T | null;
6565
getEnforcing<T extends TurboModule>(name: string): T;
6666
};
67+
68+
// Adapted from https://github.com/facebook/react-native/blob/575ab7862553d7ad7bc753951ed19dcd50d59b95/packages/react-native/Libraries/Utilities/Platform.d.ts#L23-L28
69+
export type ReactNativeVersion = {
70+
version: {
71+
major: number;
72+
minor: number;
73+
patch: number;
74+
prerelease?: number | null | undefined;
75+
};
76+
};

typings/react-native.d.ts

Lines changed: 0 additions & 8 deletions
This file was deleted.

0 commit comments

Comments
 (0)