英文:
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
答案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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论