1 | export function getReactNativeVersionWithModules(nativeModules: any): string | null {
|
2 | try {
|
3 |
|
4 | if (!nativeModules.PlatformConstants) return null
|
5 | if (!nativeModules.PlatformConstants.reactNativeVersion) return null
|
6 |
|
7 |
|
8 | const major = nativeModules.PlatformConstants.reactNativeVersion.major
|
9 | const minor = nativeModules.PlatformConstants.reactNativeVersion.minor
|
10 | const patch = nativeModules.PlatformConstants.reactNativeVersion.patch
|
11 | const prerelease = nativeModules.PlatformConstants.reactNativeVersion.prerelease
|
12 |
|
13 |
|
14 | if (typeof major !== "number") return null
|
15 |
|
16 |
|
17 | const vParts = []
|
18 | vParts.push(`${major}.${minor}.${patch}`)
|
19 | if (prerelease) vParts.push(`-${prerelease}`)
|
20 | return vParts.join("")
|
21 | } catch {}
|
22 |
|
23 | return null
|
24 | }
|