umi-preset-react-navigation
针对 react-navigation 的 umi 插件集。
支持在 RN 应用中替换 umi 默认的 react-router。
内置react-navigation 5.x
版本,需要 react-native 0.60.0 及以上版本(>=0.60.x)。
了解如何使用umi开发 RN 应用,请移步至:umi-react-native
目录
安装
在 RN 工程根目录下,使用 yarn 安装umi-preset-react-navigation:
yarn add umi-preset-react-navigation --dev
接下来,安装react-navigation的依赖:
- react-native-reanimated
- react-native-gesture-handler
- react-native-screens
- react-native-safe-area-context
- @react-native-community/masked-view
根据你所使用的 RN 开发工具:
React Native CLI
使用yarn
安装react-navigation的依赖:
yarn add react-native-reanimated react-native-gesture-handler react-native-screens react-native-safe-area-context @react-native-community/masked-view
RN 0.60.0 及以上版本有自动链接功能,Android 会自动搞定这些react-navigation的原生依赖,但对于iOS,待 yarn 安装完成后,还需要进到 ios 目录,使用 pod 安装:
cd ios && pod install
注意:因为添加了原生依赖,需要执行:yarn ios
和yarn android
重新编译和启动 iOS 和 Android 工程。
expo
使用expo
安装react-navigation的依赖:
expo install react-native-gesture-handler react-native-reanimated react-native-screens react-native-safe-area-context @react-native-community/masked-view