Token导航 LogoToken导航TokenDH.com
研究检索需要联网github未标认证来源可访问许可证需确认审计通过

react-native-patternsReact native 模式

Agent Skill

用于辅助前端页面、组件、样式和交互逻辑的开发与维护。它适合让 Agent 生成或审查 React、Next.js、Vue、Tailwind、CSS 等相关代码,整理组件结构,或定位布局和性能问题。使用时需要结合项目现有设计系统、路由和构建方式,避免只生成孤立片段;涉及页面改动时,应配合本地预览和构建检查确认视觉效果。

总安装

894

周安装

38

GitHub Stars

74

下载量

313
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:react-native-patterns(React native 模式)
来源仓库:https://github.com/dralgorhythm/claude-agentic-framework
仓库路径:skills/react-native-patterns
安装命令:
npx skills add https://github.com/dralgorhythm/claude-agentic-framework --skill react-native-patterns
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/dralgorhythm/claude-agentic-framework --skill react-native-patterns

简介

提供 React Native 组件开发的可维护模式参考,涵盖触摸交互、列表渲染和导航等核心场景。

  • 适用于移动端界面构建,支持 Pressable、FlashList 和模态框等原生组件的最佳实践。
  • 通过 SafeAreaView、触觉反馈和平台适配建议,帮助生成符合 RN 规范的交互逻辑。
  • 安装需指定 GitHub 仓库路径,使用时需结合项目路由与样式系统避免片段化代码。
  • react-native-patterns 属于研究检索类 Skill,可作为该场景下的辅助能力补充。

SKILL.md

React Native Patterns

Overview

Patterns for building maintainable React Native components. Covers touch interactions (Pressable), list rendering (FlashList), modal patterns (bottom sheets), accessibility, navigation, and RN-specific requirements that differ from web React.

For React web patterns (hooks, context, composition), see the react-patterns skill.

Workflows

Building an interactive screen:

  1. Set up SafeAreaView or apply safe area insets
  2. Use Pressable for all interactive elements (44pt minimum)
  3. Add haptic feedback on primary actions
  4. Use FlashList for lists, ScrollView for fixed content
  5. Implement bottom sheet for detail/modal views
  6. Add accessibility labels to all interactive elements
  7. Test on device for touch targets and scroll performance

Guidance

Pressable (not TouchableOpacity)

Pressable is the standard touch component. TouchableOpacity is deprecated.

Key principles:

  • 44pt minimum touch target on all interactive elements
  • Use hitSlop to expand touch area beyond visual bounds: hitSlop={{top: 8, bottom: 8, left: 8, right: 8}}
  • Style feedback via style function: style={({pressed}) => [pressed && {opacity: 0.7}]}
  • Or use NativeWind: className="active:opacity-70"
  • Add haptics on press for primary actions: onPress={() => {Haptics.impactAsync(); doAction();}}

Text-Only Strings Rule

React Native requires all visible text to be wrapped in <Text>:

✅ <View><Text>Hello</Text></View>
❌ <View>Hello</View>  // Crashes at runtime

This applies to conditional renders, string interpolation, and JSX expressions. Always wrap strings in Text.

ScrollView Patterns

Two className targets:

  • className — outer container (flex, background)
  • contentContainerClassName — inner content (padding, gap, alignment)

Use ScrollView for screens with fixed, non-dynamic content. Use FlashList for dynamic lists.

showsVerticalScrollIndicator={false} for cleaner visual when custom scroll indicators are used.

FlashList Patterns

High-performance list rendering:

  • estimatedItemSize is required — estimate average item height in points
  • renderItem receives {item, index} — keep render function pure
  • keyExtractor — use unique string ID from data
  • contentContainerClassName — NativeWind styling for inner content
  • ItemSeparatorComponent — consistent spacing between items
  • ListEmptyComponent — graceful empty state

Bottom Sheet as Modal

@gorhom/bottom-sheet replaces web modal dialogs:

  • Define snapPoints array: ['25%', '50%', '90%']
  • Use BottomSheetModal with BottomSheetModalProvider for imperative control
  • BottomSheetScrollView for scrollable sheet content
  • BottomSheetBackdrop for press-to-dismiss overlay
  • Present: bottomSheetRef.current?.present()
  • Dismiss: bottomSheetRef.current?.dismiss()

expo-image Patterns

Use for all image display:

  • Remote images: source={{uri: 'https://...'}}
  • Local images: source={require('../assets/image.png')}
  • Blurhash placeholder: placeholder="LKO2?U%2Tw=w]~RBVZRi}" for loading state
  • contentFit="cover" for card thumbnails, "contain" for full images
  • transition={300} for smooth fade-in on load

Accessibility

Required accessibility props for interactive elements:

PropPurposeExample
accessibilityRoleSemantic role"button", "link", "image"
accessibilityLabelScreen reader text"Open settings"
accessibilityHintAction description"Opens the settings screen"
accessibilityStateDynamic state{selected: true, disabled: false}
accessibleMarks as accessibleDefault true for Pressable

Guidelines:

  • All Pressable elements need accessibilityLabel
  • Images need accessibilityLabel describing content
  • Use accessibilityRole="header" for screen titles
  • Toggle/checkbox: set accessibilityState={{checked: isChecked}}
  • Disabled elements: accessibilityState={{disabled: true}}

Chat-Forward Component Patterns

Demos use a chat-forward interface where the conversation thread is the primary UI.

Chat Screen Layout

Three zones:

  • Header: Minimal — title, back nav, optional status. Uses safe area top inset.
  • Message stream: FlashList or inverted ScrollView for the conversation. Agent and user messages alternate. Rich content is embedded within agent message components.
  • Input bar: Text input pinned to bottom. Uses KeyboardAvoidingView (iOS) or android:windowSoftInputMode="adjustResize". Safe area bottom inset for home indicator. Optional quick-action chips above the text field.

Message Bubble

Agent and user bubbles have distinct styling (alignment, color, shape):

  • Agent bubble: Left-aligned, neutral background, can contain child components (cards, summaries, action buttons)
  • User bubble: Right-aligned, accent background, text only
  • Bubbles animate in with FadeInDown.duration(300) on append

Inline Rich Card

Compact data card rendered as a child of an agent message bubble:

  • Photo thumbnail (expo-image) + title + key metric + status badge
  • Tappable — opens bottom sheet with full detail
  • For card sets: horizontal ScrollView within the message, or vertical stack
  • Stagger animation: FadeInDown.delay(index * 50).duration(300)

Summary Card

Running totals/status that updates as the conversation progresses:

  • Shows aggregated state: Keep ($X), Sell ($Y), Donate ($Z), Progress (N%)
  • Can be rendered as a sticky element above the input bar for persistent visibility
  • Content crossfades on update (150ms timing)

Prompt Card

Agent suggestion with embedded action buttons:

  • Text prompt + 1-3 action buttons inline
  • Buttons are Pressable with 44pt targets, haptic on press
  • After tap, the prompt card updates to show the confirmed action
  • E.g., *"Want me to find pickup options?"* → [Yes] [Not now]

Comparison View

Before/after or side-by-side content within a message:

  • Two expo-image instances with labels (Before / After)
  • Optional delta annotation (e.g., "New scratch detected")

Timeline View

Chronological event list rendered inline within an agent message:

  • Compact: date + title + icon per event
  • Expandable: tap to show detail (inline expand or bottom sheet)
  • Vertical line connector between events

Notification Message

Proactive agent alert that appears as a new message in the thread:

  • Distinctive styling (icon + emphasis color) to differentiate from regular agent messages
  • Can contain inline action buttons
  • E.g., *"Storm season starts in 6 weeks. Your basement still shows moisture risk."*

Navigation from Components

Use Expo Router's useRouter() hook:

  • router.push('/path') — navigate forward (adds to stack)
  • router.replace('/path') — replace current screen
  • router.back() — go back
  • router.canGoBack() — check if back navigation possible
  • Pass params: router.push({pathname: '/detail/[id]', params: {id: '123'}})

Best Practices

  • Always use Pressable over TouchableOpacity or TouchableHighlight
  • Enforce 44pt minimum touch targets — use hitSlop when visual is smaller
  • Wrap every visible string in <Text> — no bare strings in JSX
  • Use expo-image for all images (never RN Image)
  • Add accessibilityLabel to every interactive element
  • Use FlashList with estimatedItemSize for any list with >10 items
  • Use contentContainerClassName for ScrollView/FlashList inner styling
  • Add haptic feedback sparingly — primary actions only
  • Test touch targets on real device (simulator touch is imprecise)

Anti-Patterns

  • Using TouchableOpacity (deprecated — use Pressable)
  • Touch targets smaller than 44pt without hitSlop compensation
  • Bare strings without <Text> wrapper (runtime crash)
  • Using RN Image instead of expo-image (no caching, no blurhash)
  • Forgetting estimatedItemSize on FlashList
  • Using FlatList for large datasets (FlashList is faster)
  • Missing accessibilityLabel on interactive elements
  • Using Alert.alert() for complex choices (use bottom sheet instead)
  • Padding on className of ScrollView (use contentContainerClassName)
  • Inline anonymous functions in FlashList renderItem (causes re-renders — extract component)

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

34.88%
按下载量换算109

Claude

32.1%
按下载量换算100

Cursor

18.1%
按下载量换算57

Gemini CLI

8.61%
按下载量换算27

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills