为什么TypeScript无法解析我的`react-native-web`代码? (不使用`create-react-native-app`) [英] Why is TypeScript not parsing my `react-native-web` code? (NOT using `create-react-native-app`)
问题描述
Already tried https://github.com/necolas/react-native-web/issues/832
知道:
针对:
我认为问题可能是我得到react-native-web
的react-native
别名的b/c的短绒毛错误(由于某种原因,TypeScript无法弄清楚...).能够通过npm i -D react-native @types/react-native
解决该问题.
I thought the issue might be the linter error I was getting b/c of the react-native
aliasing of react-native-web
(which for some reason, TypeScript can't figure out...). Was able to resolve that via npm i -D react-native @types/react-native
.
但是,仍然出现相同的错误.
However, still got the same error.
接下来,我尝试将SFC(无状态功能组件)转换为类组件.仍然得到:
Next, I tried converting my SFC (stateless functional component) to a class component. Still got:
所以我想知道为什么即使我已经配置了,为什么仍然收到此错误消息TypeScript .
So I'm wondering why I'm getting this error message even though I've configured TypeScript.
推荐答案
This was my issue: In my tsconfig.json
, I had "jsx": "preserve"
. Switching to "jsx": "react"
fixed it!
这篇关于为什么TypeScript无法解析我的`react-native-web`代码? (不使用`create-react-native-app`)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!