Component Architecture
The Launch mobile app uses a well-organized component system that promotes reusability, consistency, and maintainability.Prerequisites
- Familiarity with
apps/mobile/components AppTextand base components available
Steps
Common Components
Components live in a flatcomponents/ 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
- Single Responsibility - Each component should have one clear purpose
- Composition over Inheritance - Build complex components from simpler ones
- Props Interface - Always define TypeScript interfaces for props
- Default Props - Provide sensible defaults for optional props
- Error Boundaries - Handle errors gracefully
Code Organization
- Logical Grouping - Place components in appropriate category folders
- Index Exports - Always export from folder index files
- Consistent Naming - Use PascalCase for components, camelCase for props
- File Naming - Use kebab-case for file names
Documentation
- Props Documentation - Document complex props with JSDoc
- Usage Examples - Provide clear usage examples
- Component Stories - Create Storybook stories for visual components
- README Updates - Keep component documentation current