如何在 Typescript 中使用 react-native-web
How to use react-native-web with Typescript
我使用 create-react-native-app
创建了应用程序。我用来 运行 并进行生产构建的命令是:
"scripts": {
"web": "react-scripts start",
"build": "react-scripts build"
}
对于本机反应,我可以使用 react-native-scripts-ts
,但是如何使用 react-native-web 配置 Typescript 管道?
所以解决方案是使用:
"scripts": {
"test": "jest",
"web": "react-scripts-ts start",
"build": "react-native-scripts-ts build",
"test:web": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
},
和运行App.tsx
与:
AppRegistry.registerComponent("root", () => App);
AppRegistry.runApplication('root', { rootTag: document.getElementById('root') });
我使用 create-react-native-app
创建了应用程序。我用来 运行 并进行生产构建的命令是:
"scripts": {
"web": "react-scripts start",
"build": "react-scripts build"
}
对于本机反应,我可以使用 react-native-scripts-ts
,但是如何使用 react-native-web 配置 Typescript 管道?
所以解决方案是使用:
"scripts": {
"test": "jest",
"web": "react-scripts-ts start",
"build": "react-native-scripts-ts build",
"test:web": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
},
和运行App.tsx
与:
AppRegistry.registerComponent("root", () => App);
AppRegistry.runApplication('root', { rootTag: document.getElementById('root') });