typescript - 如何在 Typescript 中使用 react-native-web

标签 typescript react-native react-native-web

我使用 create-react-native-app 创建了应用程序。我用来运行和进行生产构建的命令是:

"scripts": {
  "web": "react-scripts start",
  "build": "react-scripts build"
}

对于 React Native,我可以使用 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') });

关于typescript - 如何在 Typescript 中使用 react-native-web,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51580389/

相关文章:

javascript - React-Native .js 变量未找到错误

react-native - 专注于react-native-web(expo)时更改TextInput的边框颜色

react-native build android failed mismatch react-native模块编译版本和运行时版本错误

reactjs - react-admin 登录页面中的背景图片

reactjs - React 抽屉导航内容 Prop 类型定义

typescript - 我应该如何在 TypeScript 中扩展 WebSocket 类型?

javascript - 从 React Native 上传到 Firebase 存储

javascript - 如何动态决定是否将 Prop 传递给 react 组件?

javascript - Flexbox 生成器在我的 React 应用程序中显示不佳

angular - 尽管应用程序按预期运行,但无法读取未定义错误的属性