Habilidades rn-navigation
📦

rn-navigation

Baixo Risco

构建 Expo Router 导航

React Native 应用需要适当的导航架构来支持标签栏、模态框和深度链接。本技能提供经过验证的 Expo Router 生产应用模式。

Suporta: Claude Codex Code(CC)
📊 69 Adequado
1

Baixar o ZIP da skill

2

Upload no Claude

Vá em Configurações → Capacidades → Skills → Upload skill

3

Ative e comece a usar

Testar

A utilizar "rn-navigation". Create an app with bottom tabs for Feed, Search, and Profile. Add a FAB button in the center that opens a Compose modal.

Resultado esperado:

Use the Expo Router directory structure:

app/
├── _layout.tsx # Root layout with providers
├── (app)/
│ └── _layout.tsx # Tab layout with tabBar
├── (app)/_layout.tsx:

export default function AppLayout() {
return (
<Tabs
screenOptions={{
tabBarActiveTintColor: '#007AFF',
headerShown: false,
}}>
<Tabs.Screen name="feed" />
<Tabs.Screen name="search" />
<Tabs.Screen
name="compose"
href={{ pathname: '/compose', params: { modal: true } }}
listeners={{ tabPress: (e) => e.preventDefault() }}
/>
<Tabs.Screen name="profile" />
</Tabs>
)
}

A utilizar "rn-navigation". Set up deep links so that myapp://messages/123 opens the chat screen for conversation 123

Resultado esperado:

In app.json:

{
"expo": {
"scheme": "myapp",
"plugins": [
[
"expo-router",
{ "origin": "myapp://" }
]
]
}
}

In app/_layout.tsx or index.tsx:

const linking = {
prefixes: ['myapp://', 'https://myapp.com'],
config: {
screens: {
'(app)': {
screens: {
messages: {
path: 'messages/:conversationId',
parse: {
conversationId: (conversationId) => conversationId
}
}
}
}
}
}
}

export default function RootLayout() {
return (
<GestureHandlerRootView>
<SafeAreaProvider>
<NavigationContainer linking={linking}>
<Stack />
</NavigationContainer>
</SafeAreaProvider>
</GestureHandlerRootView>
)
}

Auditoria de Segurança

Baixo Risco
v5 • 1/21/2026

Documentation-only skill for React Native navigation patterns. Static findings are false positives: backtick patterns are markdown code formatting, cryptographic alerts are scanner noise on text patterns, and URLs are legitimate metadata. No executable code or security concerns detected.

2
Arquivos analisados
1,097
Linhas analisadas
0
achados
5
Total de auditorias
Nenhum problema de segurança encontrado
Auditado por: claude Ver Histórico de Auditoria →

Pontuação de qualidade

38
Arquitetura
100
Manutenibilidade
87
Conteúdo
30
Comunidade
90
Segurança
91
Conformidade com especificações

O Que Você Pode Construir

构建新应用的移动开发者

按照生产模式为新的 Expo 应用设置导航结构,包括标签栏、栈和深度链接。

添加复杂导航的团队

重构现有导航以支持模态框、嵌套路由和适当的深度链接配置。

调试导航问题的开发者

诊断导航状态问题、深度链接处理失败或标签栏渲染问题。

Tente Estes Prompts

基础导航设置
为 React Native 应用创建 Expo Router 导航结构,包含带有主屏、个人资料和设置屏幕的标签栏。为设置添加带有通知和隐私选项的嵌套栈。
深度链接配置
为 Expo 应用配置深度链接,使自定义 URL scheme://profile/settings 打开设置栈到隐私屏幕。显示 app.json 中的必要配置和链接钩子实现。
模态导航模式
使用 Expo Router 实现模态框展示模式,模态框从底部滑动出现并带有背景模糊。包含手势支持的正确关闭功能。
导航状态持久化
使用 AsyncStorage 实现导航状态持久化,使用户在应用重启后返回到完全相同的屏幕位置。处理嵌套导航状态的恢复逻辑。

Melhores Práticas

  • 使用 (group) 文件夹约定来组织导航栈和管理共享布局
  • 尽早配置深度链接前缀以避免生产中的路径解析问题
  • 在 iOS 和 Android 上测试导航,因为手势行为在不同平台之间有所不同

Evitar

  • 避免在同一应用中混合使用 React Navigation 和 Expo Router
  • 不要在组件中硬编码深度链接 URL;使用动态路径生成
  • 避免在没有适当错误边界的情况下进行深度导航状态变更

Perguntas Frequentes

如何使用 Expo Router 处理身份验证守卫?
根据身份验证状态在根布局中使用条件渲染。使用 router.replace() 在需要时将未身份验证用户重定向到专用的身份验证流程。
我可以将 Expo Router 与 React Native Fabric 组件一起使用吗?
是的,Expo Router 3.0+ 支持 Fabric。将应用包装在 GestureHandlerRootView 中,以确保在经典组件和 Fabric 组件中都能正确处理手势。
如何在 Expo Router 的屏幕之间传递参数?
在 href prop 中使用 params 对象:href={{ pathname: '/profile', params: { userId: '123' } }}。通过 useLocalSearchParams() 钩子访问参数。
栈和标签栏组件之间有什么区别?
栈管理用于下钻流程的层次导航。标签栏提供底部栏用于切换顶级视图。通过将栈嵌套在标签栏内或反之来组合它们。
如何在 Expo Router 中处理 Android 返回按钮?
Expo Router 自动处理大多数情况下的 Android 返回按钮。使用 useBackButtonHook() 获取自定义行为,或使用 router.canGoBack() 检查导航状态。
我可以在 Expo Router 中为屏幕过渡添加动画吗?
是的,在 Stack.Screen 上使用 animation prop。可用选项包括 'default'、'fade'、'slide_from_right'、'slide_from_left'、'fade_from_bottom' 和 'none'。

Detalhes do Desenvolvedor

Estrutura de arquivos

📄 SKILL.md