Expo React Native Javascript Best Practices

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

Expo React Native JavaScript best practices for clean code, functional components, performance optimization, and Expo Router navigation.

AI 生成的概览

用于编写整洁、高性能的 Expo React Native JavaScript 应用并使用 Expo Router 导航的指南。

功能
该技能提供一套用 JavaScript 构建 Expo React Native 应用的编码指南。内容涵盖代码风格与结构、命名约定、JavaScript 用法、性能优化、UI 与样式以及通用最佳实践。它还建议使用 Expo Router 实现基于文件的路由,并使用 Expo EAS Build 与 OTA 更新进行部署。它产出的是指导而非代码或文件。
适用场景
当你编写、审查或组织 Expo React Native JavaScript 代码并希望保持一致的约定时使用。它也适用于优化组件性能,或为 Expo 应用设置导航与部署实践。
运行要求
无需任何工具、软件包或凭据;它仅为说明性内容,不附带脚本。

Expo React Native JavaScript Best Practices

Guidelines for building high-quality Expo React Native applications with JavaScript, focusing on clean code, modularity, and performance.

Code Style and Structure

  • Clean, Readable Code: Ensure your code is easy to read and understand. Use descriptive names for variables and functions.
  • Functional Components: Prefer functional components with hooks (useState, useEffect) over class components
  • Component Modularity: Break components into smaller, reusable pieces with single responsibility
  • Feature-Based Organization: Group related components, hooks, and styles into feature directories (e.g., user-profile, chat-screen)

Naming Conventions

  • Variables and Functions: Use camelCase (e.g., isFetchingData, handleUserInput)
  • Components: Use PascalCase (e.g., UserProfile, ChatScreen)
  • Directories: Use lowercase hyphenated names (e.g., user-profile, chat-screen)

JavaScript Usage

  • Minimize global variables to prevent unintended side effects
  • Leverage ES6+ features like arrow functions, destructuring, and template literals to write concise code
  • Use PropTypes for type checking if not using TypeScript

Performance Optimization

  • Avoid unnecessary state updates; use local state when needed
  • Apply React.memo() to prevent unnecessary re-renders
  • Optimize FlatList with the following props:
    • removeClippedSubviews
    • maxToRenderPerBatch
    • windowSize
  • Avoid anonymous functions in renderItem or event handlers

UI and Styling

  • Use StyleSheet.create() for consistent styling or Styled Components for dynamic styles
  • Ensure responsive design across screen sizes and orientations
  • Use optimized image libraries like react-native-fast-image

Best Practices

  • Follow React Native's threading model for smooth UI performance
  • Use Expo's EAS Build and OTA updates for deployment
  • Expo Router: Use Expo Router for file-based routing in your React Native app. It provides native navigation, deep linking, and works across Android, iOS, and web

来源与署名

来源:mindrally/skills位于expo-react-native-javascript-best-practices提交9718410

许可证: 无许可证

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

举报或申请下架