我正在使用react-navigation创建一个新的react native应用程序。
每次我做npm install --save react-navigation
时,我都会看到一组与react-native-gesture-handler相关的警告。我正在使用react-native init Test
创建一个全新的应用程序,下一步是安装react-navigation。
以下是警告和错误:
npm WARN [email protected] requires a peer of jest-haste-map@^24.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of jest-haste-map@^24.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of jest-haste-map@^24.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of react-native-gesture-handler@^1.0.12 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of react-native-gesture-handler@^1.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN @react-navigation/[email protected] requires a peer of react-native-gesture-handler@* but none is installed. You must install peer dependencies yourself.
在我的代码中导入库并在iOS模拟器上运行时,我收到如下错误:
Failed to load bundle(http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false) with error:(Unable to resolve module `react-native-gesture-handler` from `Documents/Code/Test/node_modules/@react-navigation/native/src/Scrollables.js`: Module `react-native-gesture-handler` does not exist in the Haste module map
我尝试在我的应用程序中删除node_modules文件夹并再次运行'npm install'和'npm install --save react-navigation',但这确实解决了这个问题。
请求建议。
创建新应用程序后,安装react-navigation
库,然后您需要安装react-native-gesture-handler
并链接库。
Step1 : react-native init test//your app name
Step2 : npm install --save react-navigation
Step3 : npm install --save react-native-gesture-handler
Step4 : react-native link react-native-gesture-handler
我遵循了Brijesh的建议,还必须在我的Xcode项目中手动导入库。以下是我遵循的步骤:
Step1:react-native init test //你的应用名称
第2步:npm install --save react-navigation
第3步:npm install --save react-native-gesture-handler
Step4:react-native link react-native-gesture-handler
步骤5:右键单击Xcode中的库“将文件添加到项目”
Step6:/node_modules/react-native-gesture-handlers/ios/RNGestureHandler.xcodeproj
Step7:转到构建阶段并添加libRNGestureHandler.a
这解决了它。