fix: resolve native SafeAreaProvider via exports map#279
Merged
danstepanov merged 1 commit intomainfrom Feb 22, 2026
Merged
Conversation
The ./components/* wildcard in the exports map resolved env(safe-area-inset-*) to the web passthrough file (.tsx) instead of the native wrapper (.native.tsx) that injects CSS variables via SafeAreaEnv. Metro treats exports-resolved paths as final and does not apply platform-suffix resolution. Add an explicit exports entry for ./components/react-native-safe-area-context that maps the react-native condition to .native.tsx, and add a SafeAreaProvider convenience re-export consistent with the component naming pattern used by View, Text, etc. Enable the previously skipped env(safe-area-inset-*) test.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
env(safe-area-inset-*)values resolve to 0 on native when applied viaclassName(e.g.mb-safe,p-safe). TheSafeAreaEnvcomponent that injects CSS variables into theVariableContextis never loaded../components/*wildcard in theexportsmap resolves toreact-native-safe-area-context.tsx(the web passthrough) instead ofreact-native-safe-area-context.native.tsx(the native wrapper withSafeAreaEnv). Metro treats exports-resolved paths as final and does not apply platform-suffix resolution../components/react-native-safe-area-contextthat maps thereact-nativecondition directly to.native.tsx.Additionally:
SafeAreaProvider.tsxas a convenience re-export, consistent with the component naming pattern used byView,Text, etc.env(safe-area-inset-*)test.Closes #234
Test plan
env.test.ios.tsxpasses (previously skipped)npx jest src/__tests__/native/)SafeAreaEnvandreact-native-css-safe-area-inset-*variables are present in the iOS bundlemb-safeproduces visible bottom margin