You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Returns an object which contains all available common and specific constants related to the platform.
@@ -84,8 +91,8 @@ Returns an object which contains all available common and specific constants rel
84
91
85
92
### `isPad` <divclass="label ios">iOS</div>
86
93
87
-
```jsx
88
-
Platform.isPad;
94
+
```tsx
95
+
staticisPad: boolean;
89
96
```
90
97
91
98
Returns a boolean which defines if device is an iPad.
@@ -98,8 +105,8 @@ Returns a boolean which defines if device is an iPad.
98
105
99
106
### `isTV`
100
107
101
-
```jsx
102
-
Platform.isTV;
108
+
```tsx
109
+
staticisTV: boolean;
103
110
```
104
111
105
112
Returns a boolean which defines if device is a TV.
@@ -110,10 +117,24 @@ Returns a boolean which defines if device is a TV.
110
117
111
118
---
112
119
120
+
### `isVision`
121
+
122
+
```tsx
123
+
staticisVision: boolean;
124
+
```
125
+
126
+
Returns a boolean which defines if device is an Apple Vision. _If you are using [Apple Vision Pro (Designed for iPad)](https://developer.apple.com/documentation/visionos/checking-whether-your-app-is-compatible-with-visionos)`isVision` will be `false` but `isPad` will be `true`_
127
+
128
+
| Type |
129
+
| ------- |
130
+
| boolean |
131
+
132
+
---
133
+
113
134
### `isTesting`
114
135
115
-
```jsx
116
-
Platform.isTesting;
136
+
```tsx
137
+
staticisTesting: boolean;
117
138
```
118
139
119
140
Returns a boolean which defines if application is running in Developer Mode with testing flag set.
@@ -126,8 +147,8 @@ Returns a boolean which defines if application is running in Developer Mode with
126
147
127
148
### `OS`
128
149
129
-
```jsx
130
-
staticPlatform.OS
150
+
```tsx
151
+
staticOS: 'android'|'ios';
131
152
```
132
153
133
154
Returns string value representing the current OS.
@@ -140,8 +161,8 @@ Returns string value representing the current OS.
140
161
141
162
### `Version`
142
163
143
-
```jsx
144
-
Platform.Version;
164
+
```tsx
165
+
staticVersion: 'number'|'string';
145
166
```
146
167
147
168
Returns the version of the OS.
@@ -154,8 +175,8 @@ Returns the version of the OS.
154
175
155
176
### `select()`
156
177
157
-
```jsx
158
-
staticselect(config:object):any
178
+
```tsx
179
+
staticselect(config: Record<string, T>): T;
159
180
```
160
181
161
182
Returns the most fitting value for the platform you are currently running on.
@@ -177,45 +198,45 @@ The `config` parameter is an object with the following keys:
177
198
178
199
**Example usage:**
179
200
180
-
```jsx
181
-
import {Platform, StyleSheet} from'react-native';
201
+
```tsx
202
+
import {Platform, StyleSheet} from'react-native';
182
203
183
204
const styles =StyleSheet.create({
184
205
container: {
185
206
flex: 1,
186
207
...Platform.select({
187
208
android: {
188
-
backgroundColor:'green'
209
+
backgroundColor: 'green',
189
210
},
190
211
ios: {
191
-
backgroundColor:'red'
212
+
backgroundColor: 'red',
192
213
},
193
214
default: {
194
215
// other platforms, web for example
195
-
backgroundColor:'blue'
196
-
}
197
-
})
198
-
}
216
+
backgroundColor: 'blue',
217
+
},
218
+
}),
219
+
},
199
220
});
200
221
```
201
222
202
223
This will result in a container having `flex: 1` on all platforms, a green background color on Android, a red background color on iOS, and a blue background color on other platforms.
203
224
204
225
Since the value of the corresponding platform key can be of type `any`, [`select`](platform.md#select) method can also be used to return platform-specific components, like below:
0 commit comments