【问题标题】:Why is TypeScript not parsing my `react-native-web` code? (NOT using `create-react-native-app`)为什么 TypeScript 不解析我的“react-native-web”代码? (不使用`create-react-native-app`)
【发布时间】:2019-08-09 09:51:33
【问题描述】:
Already tried https://github.com/necolas/react-native-web/issues/832

得到:

为:

我认为问题可能是我得到了 react-native-webreact-native 别名的 b/c 的 linter 错误(由于某种原因,TypeScript 无法弄清楚......)。能够通过npm i -D react-native @types/react-native 解决这个问题。

但是,仍然出现同样的错误。

接下来,我尝试将我的 SFC(无状态功能组件)转换为类组件。还是得到了:

所以我想知道为什么即使I've configured TypeScript 也会收到此错误消息。

【问题讨论】:

    标签: reactjs typescript react-native-web


    【解决方案1】:

    This 是我的问题: 在我的 tsconfig.json 中,我有 "jsx": "preserve"。切换到"jsx": "react" 修复它!

    【讨论】:

      猜你喜欢
      • 2020-04-27
      • 2018-10-27
      • 1970-01-01
      • 2018-11-18
      • 2019-01-23
      • 2021-04-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多