我在使用 expo 和 typescript 的 react-native 应用程序中遇到了问题。我已经使用 npm 安装了这些库,它们在 node_modules
文件夹中可用,请参见图片。
同样的问题发生在 '@react-navigation/stack'
当我运行程序时出现此错误:
Error: Looks like you have nested a 'NavigationContainer' inside another. Normally you need only one container at the root of the app, so this was probably an error. If this was intentional, pass 'independent={true}' explicitely. Note that this will make the child navigators disconnected from the parent and you won't be able to navigate between them.
但是我的程序只有一个 NavigationContainer。这里似乎有什么问题? P.S:我尝试重新安装软件包,但仍然没有进展。
答案 0 :(得分:1)
要解决这些错误:Cannot find module X or its corresponding type declarations
运行:
yarn add @types/X -D
就您而言:yarn add @types/@react-navigation/native @types/react-query -D
这将为这些库安装类型定义(如果可用)。