为什么TypeScript无法解析我的`react-native-web`代码? (不使用`create-react-native-app`) [英] Why is TypeScript not parsing my `react-native-web` code? (NOT using `create-react-native-app`)

查看:89
本文介绍了为什么TypeScript无法解析我的`react-native-web`代码? (不使用`create-react-native-app`)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Already tried https://github.com/necolas/react-native-web/issues/832

知道:

针对:

我认为问题可能是我得到react-native-webreact-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.

推荐答案

.切换到"jsx": "react"可以解决问题!

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屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆