Repository navigation
fix(native): apply className on SafeAreaView from the safe-area-context shim - #468
Merged
danstepanov merged 1 commit intoNov 20, 2026
Merged
Conversation
sammoore
approved these changes
Nov 20, 2026
sammoore
left a comment
Contributor
There was a problem hiding this comment.
Thanks for your contribution! This is clean; approved on my end.
…xt shim The native safe-area-context shim re-exported SafeAreaView from react-native-safe-area-context unwrapped, so className on it was a silent no-op: the CSS compiled, but never reached the component. After moving from v4 to v5 every `<SafeAreaView className="flex-1">` screen root lost its styles. Wrap SafeAreaView with useCssElement the way View is wrapped, mapping className to style and keeping the original component's static properties. The shim's own SafeAreaView export takes precedence over the `export *`, as SafeAreaProvider already does. Fixes nativewind#386 Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
danstepanov
force-pushed
the
fix/safe-area-view-classname
branch
from
November 20, 2026 22:20
fc6b65c to
08d7204
Compare
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.
Fixes #386
Thanks to @Thomas-athletics for the report and the clear diagnosis. If you would rather open your own PR for this, say so and I will close mine.
Problem
The native
react-native-safe-area-contextshim wrappedSafeAreaProvider(to expose the inset CSS variables) but re-exported everything else, includingSafeAreaView, unwrapped throughexport *. SoclassNameonSafeAreaViewwas a silent no-op: the CSS compiled fine but never reached the component.<SafeAreaView className="flex-1">is a very common screen root, so after a v4 to v5 migration screens collapsed to their content height.Change
src/components/react-native-safe-area-context.native.tsxnow exports a wrappedSafeAreaView, built the same way asView(useCssElementwithclassNamemapped tostyle, andcopyComponentPropertiesto keep the original component's static properties). The shim's own export takes precedence overexport *, asSafeAreaProvideralready does.classNameis typed throughViewProps, whichSafeAreaViewPropsextends, so no type changes were needed.I did not change the web shim (
react-native-safe-area-context.tsx), which is a bare re-export; this issue is about native.Testing
src/__tests__/native/safe-area-view.test.tsx(3 tests):classNameis applied as style (compiledflex: 1and a color); the component's own props (edges) reach the native component exactly as they do without the shim, and an inlinestyleis merged withclassName; and rendering without aclassNamestill works. Without the change, 2 of the 3 fail (the style isundefined); with it all 3 pass.yarn typecheckandeslinton the changed files pass, and the repo's pre-commit and commit-msg hooks passed.yarn test: 1334 tests pass and 4 fail insrc/__tests__/babel. The same 4 fail on an unmodifiedmainon my Windows machine, so I left them alone.Generated with Claude Code