Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change React Native Version import to the one from Platform #3949

Merged
merged 8 commits into from
Aug 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

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

### Dependencies

Expand Down
5 changes: 2 additions & 3 deletions src/js/utils/rnlibraries.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/* eslint-disable @typescript-eslint/no-var-requires */

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

import type * as ReactNative from '../vendor/react-native';
import type { ReactNativeLibrariesInterface } from './rnlibrariesinterface';
Expand Down Expand Up @@ -32,7 +31,7 @@ export const ReactNativeLibraries: Required<ReactNativeLibrariesInterface> = {
},
},
ReactNativeVersion: {
version: RNV,
version: Platform.constants?.reactNativeVersion,
},
TurboModuleRegistry,
};
6 changes: 1 addition & 5 deletions src/js/utils/rnlibrariesinterface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
// that don't have all the internals available. For example react-native-web.
//

import type { version as RNV } from 'react-native/Libraries/Core/ReactNativeVersion';

import type * as ReactNative from '../vendor/react-native';

export type { UnsafeObject } from 'react-native/Libraries/Types/CodegenTypes';
Expand All @@ -25,8 +23,6 @@ export interface ReactNativeLibrariesInterface {
polyfillGlobal: <T>(name: string, getValue: () => T) => void;
};
Promise?: typeof Promise;
ReactNativeVersion?: {
version: typeof RNV;
};
ReactNativeVersion?: ReactNative.ReactNativeVersion;
TurboModuleRegistry?: ReactNative.TurboModuleRegistry;
}
10 changes: 10 additions & 0 deletions src/js/vendor/react-native/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,13 @@ export type TurboModuleRegistry = {
get<T extends TurboModule>(name: string): T | null;
getEnforcing<T extends TurboModule>(name: string): T;
};

// Adapted from https://github.com/facebook/react-native/blob/575ab7862553d7ad7bc753951ed19dcd50d59b95/packages/react-native/Libraries/Utilities/Platform.d.ts#L23-L28
export type ReactNativeVersion = {
version: {
major: number;
minor: number;
patch: number;
prerelease?: number | null | undefined;
};
};
8 changes: 0 additions & 8 deletions typings/react-native.d.ts

This file was deleted.

Loading