Using modals and bottom sheets affects app performance mainly during animations and rendering. Smooth animations target 60 frames per second (fps) to feel natural. Poorly optimized modals can cause frame drops, making the UI feel slow or janky. Memory usage is usually low unless the modal loads heavy content like images or videos. Battery impact is minimal but can increase if animations run continuously or if modals keep background tasks alive.
Modal and bottom sheet in React Native - Build, Publish & Deploy
To keep modals and bottom sheets smooth at 60fps, limit the complexity of their content. Avoid heavy computations or large images inside the modal. Use React Native's Animated API or libraries like Reanimated for performant animations. Lazy load modal content only when needed. Also, avoid nesting multiple modals to reduce rendering overhead. Use native modal components when possible for better performance.
Modals and bottom sheets themselves add minimal size to the app bundle. However, including third-party libraries for advanced bottom sheets can increase bundle size by a few megabytes. Keep dependencies minimal and only include what you use. Large images or videos inside modals can increase app size if bundled. Startup time is usually unaffected unless modals preload heavy data on app launch.
On iOS, modals typically use UIKit components under the hood, supporting smooth native transitions and gestures. Bottom sheets follow iOS Human Interface Guidelines with swipe-to-dismiss gestures. Android uses Jetpack Compose or XML layouts with Material Design bottom sheets and modals. Android bottom sheets often support persistent and modal types. Gesture behavior and appearance differ slightly, so test on both platforms to ensure consistent user experience.
- Ensure modals do not block critical app functionality or trap users without a clear way to dismiss.
- Follow accessibility guidelines: provide proper labels, focus management, and support screen readers.
- Do not use modals for deceptive or disruptive ads, as this violates both Apple App Store and Google Play policies.
- Respect user privacy if modals request permissions or personal data.
- Test modal behavior on different device sizes and orientations to meet responsive design requirements.
If your modal takes 5 seconds to appear, likely causes include loading heavy images or data synchronously, running expensive computations on the main thread, or using non-optimized animations. To fix this, lazy load content after modal opens, move heavy work off the UI thread, and simplify animations.
Practice
Modal component in React Native?Solution
Step 1: Understand what a Modal does
A Modal appears on top of the current screen and blocks interaction with the background.Step 2: Compare options
Only To display content over the current screen and keep user focus describes this behavior correctly; others describe unrelated features.Final Answer:
To display content over the current screen and keep user focus -> Option AQuick Check:
Modal = Overlay content [OK]
- Confusing Modal with navigation
- Thinking Modal is a footer or background task
- Assuming Modal is always full screen
Modal in React Native?Solution
Step 1: Recall the correct prop for Modal visibility
The React Native Modal uses thevisibleprop to show or hide the modal.Step 2: Check each option
Only<Modal visible={true}>usesvisiblecorrectly; others use incorrect prop names.Final Answer:
<Modal visible={true}> -> Option BQuick Check:
Modal visibility prop = visible [OK]
- Using show or isVisible instead of visible
- Confusing display with visible
- Forgetting to pass boolean value
const [modalVisible, setModalVisible] = React.useState(false);
return (
<>
<Button title="Show Modal" onPress={() => setModalVisible(true)} />
<Modal visible={modalVisible} animationType="slide">
<View>
<Text>Hello Modal</Text>
<Button title="Close" onPress={() => setModalVisible(false)} />
</View>
</Modal>
</>
);Solution
Step 1: Understand state controlling Modal visibility
The state variablemodalVisiblestarts false, so modal is hidden initially.Step 2: Analyze button actions
Pressing 'Show Modal' setsmodalVisibleto true, showing modal with slide animation. 'Close' button sets it back to false, hiding modal.Final Answer:
The modal appears sliding up when 'Show Modal' is pressed and closes when 'Close' is pressed -> Option AQuick Check:
State controls visible with animation [OK]
- Assuming modal shows without pressing button
- Ignoring animationType effect
- Thinking modal cannot be closed
const [show, setShow] = React.useState(false);
return (
<Modal visible={show} animationType="fade" onRequestClose={() => setShow(false)}>
<View>
<Text>Modal Content</Text>
</View>
</Modal>
<Button title="Open" onPress={() => setShow(true)} />
);Solution
Step 1: Check JSX structure
The return statement has two sibling elements: Modal and Button, which is invalid JSX without a wrapper.Step 2: Identify correct fix
Wrapping Modal and Button inside a fragment or View fixes the error.Final Answer:
Modal must be wrapped inside a single parent element -> Option CQuick Check:
JSX requires one parent element [OK]
- Ignoring JSX syntax rules
- Thinking onRequestClose is optional on Android
- Confusing visible prop type
Solution
Step 1: Understand bottom sheet modal requirements
It must slide up (animationType="slide"), be transparent so background is visible, and detect taps outside to close.Step 2: Identify correct props and components
Usingtransparent={true}allows background taps. Wrapping background in TouchableWithoutFeedback lets you detect taps to close modal.Step 3: Eliminate wrong options
Options B, C, and D miss transparency, correct animation, or tap detection.Final Answer:
Use <Modal visible={true} animationType="slide" transparent={true}> with a TouchableWithoutFeedback wrapping the background to detect taps -> Option DQuick Check:
Slide + transparent + tap detection = bottom sheet [OK]
- Forgetting transparent prop for background tap
- Using fade animation instead of slide
- Not handling tap outside to close
Ready to prove it?
Pass the test and this pattern moves unknown
