react-native-elements-best-practices
Original:🇺🇸 English
Translated
React Native Elements UI component library best practices for performance, theming, and proper component usage. Use when building React Native apps with RNE, configuring themes, optimizing lists with ListItem, or reviewing RNE component code.
1installs
Sourcepproenca/dot-skills
Added on
NPX Install
npx skill4agent add pproenca/dot-skills react-native-elements-best-practicesTags
Translated version includes tags in frontmatterSKILL.md Content
View Translation Comparison →Community React Native Elements Best Practices
Comprehensive best practices guide for React Native Elements applications. Contains 45 rules across 8 categories, prioritized by impact to guide component usage, theming, and performance optimization.
When to Apply
Reference these guidelines when:
- Setting up React Native Elements in a new project
- Configuring ThemeProvider and createTheme
- Building lists with ListItem components
- Implementing form inputs with Input and SearchBar
- Optimizing FlatList performance with RNE components
- Reviewing code using React Native Elements
Rule Categories by Priority
| Priority | Category | Impact | Prefix |
|---|---|---|---|
| 1 | Import & Setup | CRITICAL | |
| 2 | Theme Architecture | CRITICAL | |
| 3 | Component Selection | HIGH | |
| 4 | List Performance | HIGH | |
| 5 | Props & Configuration | MEDIUM-HIGH | |
| 6 | Styling Patterns | MEDIUM | |
| 7 | Callbacks & Events | MEDIUM | |
| 8 | Advanced Patterns | LOW | |
Quick Reference
1. Import & Setup (CRITICAL)
- - Wrap app with ThemeProvider for consistent theming
setup-themeprovider - - Use @rneui/themed vs @rneui/base correctly
setup-imports - - Type-safe theme configuration with createTheme
setup-createtheme - - Enable proper tree-shaking for bundle size
setup-tree-shaking - - Configure SafeAreaProvider for notched devices
setup-safe-area
2. Theme Architecture (CRITICAL)
- - Access theme reactively with useTheme
theme-usetheme-hook - - Configure light/dark mode with createTheme
theme-dark-mode - - Set component defaults in theme
theme-component-defaults - - Runtime theme updates without remount
theme-updatetheme - - Sync with system color scheme
theme-color-scheme - - Extend theme with custom colors safely
theme-custom-colors
3. Component Selection (HIGH)
- - Use ListItem for list rows
comp-listitem-over-view - - Use Input for form fields
comp-input-over-textinput - - Platform-specific SearchBar variants
comp-searchbar-platform - - Use Button type prop for variants
comp-button-type - - Choose Icon type wisely for bundle size
comp-icon-source - - Use Avatar for profile images
comp-avatar-vs-image
4. List Performance (HIGH)
- - Memoize ListItem in FlatList
list-memo-items - - Always provide keyExtractor
list-keyextractor - - Use getItemLayout for fixed heights
list-getitemlayout - - Extract renderItem with useCallback
list-renderitem-callback - - Configure windowSize for memory balance
list-windowsize - - Use FlatList over ScrollView
list-virtualized - - Configure removeClippedSubviews carefully
list-removeClipped
5. Props & Configuration (MEDIUM-HIGH)
- - Use loading prop for async operations
props-loading-state - - Configure disabledStyle for feedback
props-disabled-styling - - Use errorMessage for validation
props-input-validation - - Configure Icon props correctly
props-icon-configuration - - Show loading state in SearchBar
props-searchbar-loading - - Use color prop for semantic colors
props-button-color
6. Styling Patterns (MEDIUM)
- - Use StyleSheet.create over inline objects
style-stylesheet - - Use containerStyle for wrappers
style-containerStyle - - Memoize dynamic styles
style-usememo-dynamic - - Use theme colors over hardcoded values
style-theme-colors - - Prefer component-specific style props
style-component-props
7. Callbacks & Events (MEDIUM)
- - Wrap handlers in useCallback
event-usecallback - - Debounce SearchBar onChangeText
event-debounce-search - - Pass item data correctly
event-listitem-onpress - - Avoid anonymous functions in renders
event-avoid-anonymous - - Configure Input handlers efficiently
event-input-handlers
8. Advanced Patterns (LOW)
- - Wrap RNE components correctly
adv-custom-component - - Handle platform-specific props
adv-platform-specific - - Use makeStyles for theme-aware styles
adv-makeStyles - - Choose Overlay vs Modal correctly
adv-overlay-modal - - Configure Avatar ImageComponent for caching
adv-image-component
How to Use
Read individual reference files for detailed explanations and code examples:
- Section definitions - Category structure and impact levels
- Rule template - Template for adding new rules
Reference Files
| File | Description |
|---|---|
| references/_sections.md | Category definitions and ordering |
| assets/templates/_template.md | Template for new rules |
| metadata.json | Version and reference information |