VSCode Intellisense要求我从react-native/type而不是react-native中导入View组件。

huangapple go评论65阅读模式
英文:

VScode intellisense wants me to import View component from react-native/type but not react-native

问题

我正在尝试从react-native导入View组件,在VScode中调用智能感知时,它要求我从react-native/types而不是react-native中导入它。

在我的旧项目中,这是有效的,但这次我创建了一个新的React Native应用程序v0.71.3。

英文:

I am trying to import View component from react-native, on invoking intellisense in VScode it wants me to import it from react-native/types but not react-native

It's working on my old projects, but this time I created a new react native application v0.71.3

VSCode Intellisense要求我从react-native/type而不是react-native中导入View组件。

答案1

得分: 1

你可以通过将@types/react-native添加到你的项目中来解决这个问题。如果你使用Yarn,具体操作是执行yarn add -D @types/react-native。如果你使用npm,可以执行npm install --save @types/react-native。这应该解决导入建议的问题。

英文:

Had the exact same problem recently.
You can resolve this by adding @types/react-native to your project.
Specifically doing yarn add -D @types/react-native if you're using Yarn.
If you're using npm install --save @types/react-native
This should address the bummed imports intelligence is recommending.

huangapple
  • 本文由 发表于 2023年2月23日 20:41:09
  • 转载请务必保留本文链接:https://go.coder-hub.com/75544980.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定