react navigation 多页面路由

1.安装集成 react navigation

1.项目初始化后,集成React Navigation在项目根目录运行命令:

expo install react-navigation

react-native-gesture-handler

react-native-reanimated

react-native-screens

2.在已创建的项目中安装 React Navigation ,在项目根目录下运行命令:

yarn add react-navigation
yarn add react-native-reanimated
yarn add react-native-gesture-handler
yarn add react-native-screens @'1.0.0-aipha.23'

2.为了完成 react-native-screens在Andriod上的安装,请在android/app/build.gradle中dependencies选项中添加下面这两行:

implementation 'androidx.appcompat:appcompat:1.1.0-rc01'
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0-alpha02'

3. 添加栈 

yarn add react-navigation-stack

 

上一篇:react-native导航


下一篇:React Native三端同构实践