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 從公開儲存庫中收錄這些內容。

檢舉或申請下架