React Native Cursor Rules

Mindrally/skills/react-native-cursor-rules

作者 Mindrally7682ca77710e0971eab4e0ae5dddfa281aea0ba5无许可证269 个星标收录于 2026年10月8日更新于 2026年10月9日仓库5周前更新

React Native development best practices for TypeScript, functional components, performance optimization, and styling guidelines.

AI 生成的概览

React Native 开发规范,涵盖 TypeScript、组件、性能优化、样式与最佳实践。

功能
该技能提供一套 React Native 开发规范,供 AI 代理在编写或审查移动应用代码时遵循。内容涵盖代码风格与文件结构、命名约定、TypeScript 用法、hooks 与 FlatList 的性能优化、UI 样式,以及导航和 Expo 工具等通用最佳实践。它产出的是指导原则和约定,而非可运行代码或文件。
适用场景
适用于开发 React Native 项目,并希望获得一致、类型安全的 TypeScript 代码和注重性能的组件模式时。适合编写、重构或审查 React Native 组件、hooks、样式和列表渲染。
运行要求
无需任何工具、软件包或凭据;仅为说明性指令,不包含脚本。

React Native Cursor Rules

Expert guidelines for React Native development by Will Sims, focusing on type-safe TypeScript code, performance optimization, and maintainable component architecture.

Code Style and Structure

  • Write concise, type-safe TypeScript code
  • Use functional components and hooks instead of class components
  • Ensure components are modular, reusable, and maintainable
  • Organize files by feature, grouping related components, hooks, and styles

Naming Conventions

  • Use camelCase for variables and functions (e.g., isFetchingData, handleUserInput)
  • Use PascalCase for components (e.g., UserProfile, ChatScreen)
  • Directory names should be lowercase and hyphenated (e.g., user-profile, chat-screen)

TypeScript Usage

  • Use TypeScript for all components, favoring interfaces for props and state
  • Enable strict typing in tsconfig.json
  • Avoid any type; strive for precise types
  • Utilize React.FC for defining functional components with props

Performance Optimization

  • Minimize useEffect, useState, and heavy computations in render methods
  • Use React.memo() for components with static props to prevent unnecessary re-renders
  • Optimize FlatLists with the following props:
    • removeClippedSubviews
    • maxToRenderPerBatch
    • windowSize
  • Use getItemLayout for consistent-sized FlatList items
  • Avoid anonymous functions in renderItem or event handlers

UI and Styling

  • Use consistent styling via StyleSheet.create() or Styled Components
  • Ensure responsive design for different screen sizes and orientations
  • Optimize images using react-native-fast-image

Best Practices

  • Follow React Native's threading model for smooth performance
  • Utilize Expo's EAS Build and Over-The-Air updates
  • Use React Navigation for navigation and deep linking

来源与署名

来源:Mindrally/skills位于react-native-cursor-rules提交7682ca7

许可证: 无许可证

内容归原作者所有。SourceWeft 从公开仓库中收录这些内容。

举报或申请下架