Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Build performant React Native and Expo apps with best practices for lists, animations, and navigation
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
rules/ui-native-modals.md
1---2title: Use Native Modals Over JS-Based Bottom Sheets3impact: HIGH4impactDescription: native performance, gestures, accessibility5tags: modals, bottom-sheet, native, react-navigation6---78## Use Native Modals Over JS-Based Bottom Sheets910Use native `<Modal>` with `presentationStyle="formSheet"` or React Navigation11v7's native form sheet instead of JS-based bottom sheet libraries. Native modals12have built-in gestures, accessibility, and better performance. Rely on native UI13for low-level primitives.1415**Incorrect (JS-based bottom sheet):**1617```tsx18import BottomSheet from 'custom-js-bottom-sheet'1920function MyScreen() {21const sheetRef = useRef<BottomSheet>(null)2223return (24<View style={{ flex: 1 }}>25<Button onPress={() => sheetRef.current?.expand()} title='Open' />26<BottomSheet ref={sheetRef} snapPoints={['50%', '90%']}>27<View>28<Text>Sheet content</Text>29</View>30</BottomSheet>31</View>32)33}34```3536**Correct (native Modal with formSheet):**3738```tsx39import { Modal, View, Text, Button } from 'react-native'4041function MyScreen() {42const [visible, setVisible] = useState(false)4344return (45<View style={{ flex: 1 }}>46<Button onPress={() => setVisible(true)} title='Open' />47<Modal48visible={visible}49presentationStyle='formSheet'50animationType='slide'51onRequestClose={() => setVisible(false)}52>53<View>54<Text>Sheet content</Text>55</View>56</Modal>57</View>58)59}60```6162**Correct (React Navigation v7 native form sheet):**6364```tsx65// In your navigator66<Stack.Screen67name='Details'68component={DetailsScreen}69options={{70presentation: 'formSheet',71sheetAllowedDetents: 'fitToContents',72}}73/>74```7576Native modals provide swipe-to-dismiss, proper keyboard avoidance, and77accessibility out of the box.78