Skip to main content

Component Architecture

The Launch mobile app uses a well-organized component system that promotes reusability, consistency, and maintainability.

Prerequisites

  • Familiarity with apps/mobile/components
  • AppText and base components available

Steps

Common Components

Components live in a flat components/ folder. Here are a few real examples from the codebase:

Creating New Components

Component Template

Troubleshooting

  • Styles not applied: verify NativeWind classes and theme tokens
  • Component not found: check exports and import paths

Next Steps

Import Pattern

Components are imported directly from their files:

TypeScript Best Practices

Styling Guidelines

NativeWind Classes

Use Tailwind CSS classes through NativeWind:

Theme Integration

Components should respect the theme system:

Responsive Design

Handle different screen sizes and form factors:

Copy Organization

Launch does not ship with a centralized copy system. Keep copy close to the component or feature module it belongs to, and extract shared strings into constants when needed.

Testing Components

Component Testing

Visual Testing

Use Storybook or component galleries for visual testing:

Performance Considerations

Memoization

Use React.memo for expensive components:

Lazy Loading

Use lazy loading for heavy components:

Best Practices

Component Design

  1. Single Responsibility - Each component should have one clear purpose
  2. Composition over Inheritance - Build complex components from simpler ones
  3. Props Interface - Always define TypeScript interfaces for props
  4. Default Props - Provide sensible defaults for optional props
  5. Error Boundaries - Handle errors gracefully

Code Organization

  1. Logical Grouping - Place components in appropriate category folders
  2. Index Exports - Always export from folder index files
  3. Consistent Naming - Use PascalCase for components, camelCase for props
  4. File Naming - Use kebab-case for file names

Documentation

  1. Props Documentation - Document complex props with JSDoc
  2. Usage Examples - Provide clear usage examples
  3. Component Stories - Create Storybook stories for visual components
  4. README Updates - Keep component documentation current
This component system ensures consistency, reusability, and maintainability across the entire mobile application.