software-mansion / software-mansion/react-native-screens
SafeAreaProvider returns device-only insets for pre-rendered tabs in NativeTabs
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 3.7k
- Forks
- 713
- Avg merge
- 2d 23h
- Merged PRs (30d)
- 71
Description
Context
When using expo-router's NativeTabs (which uses react-native-screens), all tabs are pre-rendered before the tab bar is measured. This causes nested SafeAreaProviders to return device-only insets (~34px) instead of bounded insets (~83px including tab bar).
Related issues:
- expo/expo#42486
- AppAndFlow/react-native-safe-area-context#689
The Problem
- NativeTabs pre-renders all tabs simultaneously on app load
- Pre-rendered tab content doesn't appear to be positioned as a child of the tab bar layout in the native view hierarchy
- When a nested SafeAreaProvider measures, it gets device-only insets (container to screen edge)
- When user visits the tab, insets jump from 34px to 83px = visible layout flash
Question
Is there a mechanism in react-native-screens (or could there be) to:
- Ensure pre-rendered screens in a tab navigator are positioned relative to the tab bar from the start?
- Provide bounded insets for inactive/pre-rendered screens?
- Defer SafeAreaProvider measurement until the screen is correctly positioned?
Or is this purely an expo-router concern in how they use react-native-screens?
Workaround
We're currently sharing insets via React context across tab screens and caching the largest bottom value (which includes the tab bar). First tab visited still flashes, subsequent tabs use cached correct insets.
Environment
- expo-router: 6.0.21
- react-native-screens: (via expo)
- react-native: 0.81.5
- iOS 18
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing NativeTabs pre-rendering and SafeAreaProvider measurement in the react-native-screens integration, using the linked expo-router and safe-area-context issues for context. Determine whether positioning, bounded insets, or deferred measurement is owned here or by expo-router; done means an agreed fix direction or a documented ownership decision.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react-native, typescript
- Domain
- mobile
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100