Blog
首页
文档
收藏
关于
  • 在线转换时间戳 (opens new window)
  • 在线压缩图片 (opens new window)
  • Float-Double转二进制 (opens new window)
  • 文件转Hex字符串 (opens new window)

HiuZing

🍑
首页
文档
收藏
关于
  • 在线转换时间戳 (opens new window)
  • 在线压缩图片 (opens new window)
  • Float-Double转二进制 (opens new window)
  • 文件转Hex字符串 (opens new window)
  • 前端面试题

  • JavaScript

  • Vue2

  • port

  • CSS

  • Node.js

  • JavaScript优化

  • uniapp

  • Mini Program

  • TypeScript

  • 面向对象编程

  • UI组件

  • Plugin

  • Vue3

  • 性能优化

  • Axios

  • 状态管理

  • React

  • Mock

  • Icon

  • Template

  • 构建工具

  • 项目规范配置

  • Taro

  • SVG

  • React Native

    • 沙盒环境-Expo

    • 原生环境

    • 生态

      • React Navigation
        • 安装
        • 基础使用
          • 常见API
          • useNavigation
          • useFocusEffect
    • 第三方库
  • 前端
  • React Native
  • 生态
HiuZing
2026-07-26
目录

React Navigation

# 安装

基础依赖:

npm install @react-navigation/native
1

安装 RN 依赖:

npm install react-native-screens react-native-safe-area-context
1

Stack:

npm install @react-navigation/native-stack
1

Tab:

npm install @react-navigation/bottom-tabs
1

# 基础使用

# 常见API

API 用途
navigate 跳转
goBack 返回
replace 替换当前页面
reset 重置导航
push 新增页面
pop 返回
setParams 修改参数
setOptions 修改标题
useNavigation 获取导航
useRoute 获取参数
useFocusEffect 页面生命周期

# useNavigation

获取导航

如果组件不是 Screen,可以这样使用

import {
 useNavigation
}
from "@react-navigation/native";


const navigation =useNavigation();


navigation.navigate("Detail")
1
2
3
4
5
6
7
8
9
10

# useFocusEffect

页面生命周期

import {
useFocusEffect
}
from "@react-navigation/native";


useFocusEffect(

React.useCallback(()=>{

 console.log(  "页面显示" )

 return ()=>{ console.log(  "离开页面" ) }

},[])

)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
上次更新: 2026/07/26, 06:36:59
CodePush
第三方库

← CodePush 第三方库→

最近更新
01
TanStack Query
07-23
02
软路由
04-06
03
基础知识
04-06
更多文章>
Theme by Vdoing | Copyright © 2021-2026 WeiXiaojing | 友情链接
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式