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
The type definitions for `react-native-web` are available on [DefinitelyTyped](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/react-native-web).
16
+
17
+
---
18
+
19
+
## Installation
20
+
21
+
Simply install the following dependency in your project.
22
+
23
+
```shell
24
+
npm install --save-dev @types/react-native-web
25
+
```
26
+
27
+
The package comes with the `react-native-web` declaration types, so you can use it normally in your project.
28
+
29
+
```ts
30
+
import { AppRegistry } from'react-native-web';
31
+
```
32
+
33
+
---
34
+
35
+
## Using it in React Native projects
36
+
37
+
To extend the `react-native` types, you have to supply `react-native-web` as a member of the `types` compiler option in the `tsconfig.json` file.
38
+
39
+
```json
40
+
{
41
+
...
42
+
"compilerOptions": {
43
+
"types": ["react-native-web"]
44
+
}
45
+
}
46
+
```
47
+
48
+
Now you can use `react-native` components in your project with TS support to `react-native-web` props and styles :tada:
49
+
50
+
```jsx
51
+
import { View, ViewStyle } from'react-native';
52
+
53
+
const style:ViewStyle= {
54
+
position:"fixed", // RN style properties are augmented with Web-only options e.g. 'fixed'
55
+
marginBlock:"auto", // All Web CSS style properties are also available to use
0 commit comments