Skip to content

Commit 87aac33

Browse files
authored
feat: Add missing ReactNativeVersion API (#5238)
commit: react/react-native@ec5638a
1 parent de255a6 commit 87aac33

21 files changed

Lines changed: 630 additions & 0 deletions

docs/components-and-apis.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,12 @@ These components may be useful for certain applications. For an exhaustive list
198198
<p>Provides access to the device pixel density.</p>
199199
</a>
200200
</div>
201+
<div className="component">
202+
<a href="./reactnativeversion">
203+
<h3>ReactNativeVersion</h3>
204+
<p>Exposes the resolved React Native package version on the JS side.</p>
205+
</a>
206+
</div>
201207
<div className="component">
202208
<a href="./refreshcontrol">
203209
<h3>RefreshControl</h3>

docs/reactnativeversion.md

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
---
2+
id: reactnativeversion
3+
title: ReactNativeVersion
4+
---
5+
6+
```tsx
7+
import {ReactNativeVersion} from 'react-native';
8+
```
9+
10+
The `ReactNativeVersion` API exposes the version of the resolved `react-native` package on JS side. Apps and libraries can use it to check compatibility or enable version-specific behavior.
11+
12+
:::note
13+
14+
Also, we have [`Platform.constants.reactNativeVersion`](platform#constants) in our public API already. **However**, this is the per-platform _**native-reported**_ React Native version.
15+
16+
:::
17+
18+
## Example
19+
20+
```tsx
21+
import {ReactNativeVersion} from 'react-native';
22+
23+
const version = ReactNativeVersion.getVersionString(); // 0.88.1
24+
const {major, minor, patch, prerelease} = ReactNativeVersion;
25+
major; // 0
26+
minor; // 88
27+
patch; // 1
28+
prerelease; // null
29+
```
30+
31+
---
32+
33+
# Reference
34+
35+
## Properties
36+
37+
### `major`
38+
39+
```tsx
40+
static major: number;
41+
```
42+
43+
The major version number of the resolved `react-native` package.
44+
45+
---
46+
47+
### `minor`
48+
49+
```tsx
50+
static minor: number;
51+
```
52+
53+
The minor version number of the resolved `react-native` package.
54+
55+
---
56+
57+
### `patch`
58+
59+
```tsx
60+
static patch: number;
61+
```
62+
63+
The patch version number of the resolved `react-native` package.
64+
65+
---
66+
67+
### `prerelease`
68+
69+
```tsx
70+
static prerelease: string | null;
71+
```
72+
73+
The prerelease tag for the resolved `react-native` package, or `null` for stable releases.
74+
75+
## Methods
76+
77+
### `getVersionString()`
78+
79+
```tsx
80+
static getVersionString(): string;
81+
```
82+
83+
Returns the full version string in the format `major.minor.patch` or `major.minor.patch-prerelease`.

website/sidebars.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ export default {
214214
'pixelratio',
215215
'platform',
216216
'platformcolor',
217+
'reactnativeversion',
217218
'roottag',
218219
'share',
219220
'stylesheet',

website/versioned_docs/version-0.82/components-and-apis.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,12 @@ These components may be useful for certain applications. For an exhaustive list
198198
<p>Provides access to the device pixel density.</p>
199199
</a>
200200
</div>
201+
<div className="component">
202+
<a href="./reactnativeversion">
203+
<h3>ReactNativeVersion</h3>
204+
<p>Exposes the resolved React Native package version on the JS side.</p>
205+
</a>
206+
</div>
201207
<div className="component">
202208
<a href="./refreshcontrol">
203209
<h3>RefreshControl</h3>
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
---
2+
id: reactnativeversion
3+
title: ReactNativeVersion
4+
---
5+
6+
```tsx
7+
import {ReactNativeVersion} from 'react-native';
8+
```
9+
10+
The `ReactNativeVersion` API exposes the version of the resolved `react-native` package on JS side. Apps and libraries can use it to check compatibility or enable version-specific behavior.
11+
12+
:::note
13+
14+
Also, we have [`Platform.constants.reactNativeVersion`](platform#constants) in our public API already. **However**, this is the per-platform _**native-reported**_ React Native version.
15+
16+
:::
17+
18+
## Example
19+
20+
```tsx
21+
import {ReactNativeVersion} from 'react-native';
22+
23+
const version = ReactNativeVersion.getVersionString(); // 0.82.1
24+
const {major, minor, patch, prerelease} = ReactNativeVersion;
25+
major; // 0
26+
minor; // 82
27+
patch; // 1
28+
prerelease; // null
29+
```
30+
31+
---
32+
33+
# Reference
34+
35+
## Properties
36+
37+
### `major`
38+
39+
```tsx
40+
static major: number;
41+
```
42+
43+
The major version number of the resolved `react-native` package.
44+
45+
---
46+
47+
### `minor`
48+
49+
```tsx
50+
static minor: number;
51+
```
52+
53+
The minor version number of the resolved `react-native` package.
54+
55+
---
56+
57+
### `patch`
58+
59+
```tsx
60+
static patch: number;
61+
```
62+
63+
The patch version number of the resolved `react-native` package.
64+
65+
---
66+
67+
### `prerelease`
68+
69+
```tsx
70+
static prerelease: string | null;
71+
```
72+
73+
The prerelease tag for the resolved `react-native` package, or `null` for stable releases.
74+
75+
## Methods
76+
77+
### `getVersionString()`
78+
79+
```tsx
80+
static getVersionString(): string;
81+
```
82+
83+
Returns the full version string in the format `major.minor.patch` or `major.minor.patch-prerelease`.

website/versioned_docs/version-0.83/components-and-apis.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,12 @@ These components may be useful for certain applications. For an exhaustive list
198198
<p>Provides access to the device pixel density.</p>
199199
</a>
200200
</div>
201+
<div className="component">
202+
<a href="./reactnativeversion">
203+
<h3>ReactNativeVersion</h3>
204+
<p>Exposes the resolved React Native package version on the JS side.</p>
205+
</a>
206+
</div>
201207
<div className="component">
202208
<a href="./refreshcontrol">
203209
<h3>RefreshControl</h3>
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
---
2+
id: reactnativeversion
3+
title: ReactNativeVersion
4+
---
5+
6+
```tsx
7+
import {ReactNativeVersion} from 'react-native';
8+
```
9+
10+
The `ReactNativeVersion` API exposes the version of the resolved `react-native` package on JS side. Apps and libraries can use it to check compatibility or enable version-specific behavior.
11+
12+
:::note
13+
14+
Also, we have [`Platform.constants.reactNativeVersion`](platform#constants) in our public API already. **However**, this is the per-platform _**native-reported**_ React Native version.
15+
16+
:::
17+
18+
## Example
19+
20+
```tsx
21+
import {ReactNativeVersion} from 'react-native';
22+
23+
const version = ReactNativeVersion.getVersionString(); // 0.83.10
24+
const {major, minor, patch, prerelease} = ReactNativeVersion;
25+
major; // 0
26+
minor; // 83
27+
patch; // 10
28+
prerelease; // null
29+
```
30+
31+
---
32+
33+
# Reference
34+
35+
## Properties
36+
37+
### `major`
38+
39+
```tsx
40+
static major: number;
41+
```
42+
43+
The major version number of the resolved `react-native` package.
44+
45+
---
46+
47+
### `minor`
48+
49+
```tsx
50+
static minor: number;
51+
```
52+
53+
The minor version number of the resolved `react-native` package.
54+
55+
---
56+
57+
### `patch`
58+
59+
```tsx
60+
static patch: number;
61+
```
62+
63+
The patch version number of the resolved `react-native` package.
64+
65+
---
66+
67+
### `prerelease`
68+
69+
```tsx
70+
static prerelease: string | null;
71+
```
72+
73+
The prerelease tag for the resolved `react-native` package, or `null` for stable releases.
74+
75+
## Methods
76+
77+
### `getVersionString()`
78+
79+
```tsx
80+
static getVersionString(): string;
81+
```
82+
83+
Returns the full version string in the format `major.minor.patch` or `major.minor.patch-prerelease`.

website/versioned_docs/version-0.84/components-and-apis.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,12 @@ These components may be useful for certain applications. For an exhaustive list
198198
<p>Provides access to the device pixel density.</p>
199199
</a>
200200
</div>
201+
<div className="component">
202+
<a href="./reactnativeversion">
203+
<h3>ReactNativeVersion</h3>
204+
<p>Exposes the resolved React Native package version on the JS side.</p>
205+
</a>
206+
</div>
201207
<div className="component">
202208
<a href="./refreshcontrol">
203209
<h3>RefreshControl</h3>
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
---
2+
id: reactnativeversion
3+
title: ReactNativeVersion
4+
---
5+
6+
```tsx
7+
import {ReactNativeVersion} from 'react-native';
8+
```
9+
10+
The `ReactNativeVersion` API exposes the version of the resolved `react-native` package on JS side. Apps and libraries can use it to check compatibility or enable version-specific behavior.
11+
12+
:::note
13+
14+
Also, we have [`Platform.constants.reactNativeVersion`](platform#constants) in our public API already. **However**, this is the per-platform _**native-reported**_ React Native version.
15+
16+
:::
17+
18+
## Example
19+
20+
```tsx
21+
import {ReactNativeVersion} from 'react-native';
22+
23+
const version = ReactNativeVersion.getVersionString(); // 0.84.1
24+
const {major, minor, patch, prerelease} = ReactNativeVersion;
25+
major; // 0
26+
minor; // 84
27+
patch; // 1
28+
prerelease; // null
29+
```
30+
31+
---
32+
33+
# Reference
34+
35+
## Properties
36+
37+
### `major`
38+
39+
```tsx
40+
static major: number;
41+
```
42+
43+
The major version number of the resolved `react-native` package.
44+
45+
---
46+
47+
### `minor`
48+
49+
```tsx
50+
static minor: number;
51+
```
52+
53+
The minor version number of the resolved `react-native` package.
54+
55+
---
56+
57+
### `patch`
58+
59+
```tsx
60+
static patch: number;
61+
```
62+
63+
The patch version number of the resolved `react-native` package.
64+
65+
---
66+
67+
### `prerelease`
68+
69+
```tsx
70+
static prerelease: string | null;
71+
```
72+
73+
The prerelease tag for the resolved `react-native` package, or `null` for stable releases.
74+
75+
## Methods
76+
77+
### `getVersionString()`
78+
79+
```tsx
80+
static getVersionString(): string;
81+
```
82+
83+
Returns the full version string in the format `major.minor.patch` or `major.minor.patch-prerelease`.

0 commit comments

Comments
 (0)