SafeAreaView is re-exported unwrapped from the safe-area-context shim: className silently no-ops (breaks flex-1 screen roots after v4 -> v5 migration)
Maintainer antworten meist innerhalb von 3 Tagen
Bewertung
- Schwierigkeit
- 2/5
- Geschätzter Aufwand
- 1-3 Stunden
- Anfängerfreundlichkeit
- 28/100
- Issue-Typ
- Bug
- Klarheit
- Klar beschrieben
- Aktivitätsstatus
- Veraltet
- Tech-Stack
- react-native, typescript
Rechercherichtung
The bug is in the shim at src/components/react-native-safe-area-context.native.tsx, which re-exports SafeAreaView unwrapped, so className is dropped. Read how the other intercepted components are wrapped in that file, then check whether linked PR #468 already covers this before starting. Done means className on SafeAreaView maps to style, with a test or on-device check showing a flex-1 root fills the screen.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Summary
The react-native-safe-area-context shim wraps SafeAreaProvider (to expose the inset CSS variables) but re-exports everything else from the original package unwrapped:
// src/components/react-native-safe-area-context.native.tsx
export * from "react-native-safe-area-context";
export function SafeAreaProvider({ children, ...props }: SafeAreaProviderProps) { ... }
SafeAreaView is therefore the original component, and className on it is a silent no-op — no warning, no error.
Why this is painful
<SafeAreaView className="flex-1 ..."> is an extremely common screen-root pattern in NativeWind v4 apps (the v4 JSX transform made it work on any component). After migrating to NativeWind v5 / react-native-css, every such screen root silently loses flex: 1, the SafeAreaView collapses to content height, and ScrollViews inside shrink to zero — the entire screen body renders blank while headers/tab bars (styled via style objects) keep working.
Nothing catches it statically: tsc, jest, and expo export are all green (the CSS compiles fine; it just never reaches the component). We only found it via on-simulator UAT. In our app it affected 44 SafeAreaView className call sites, i.e. every screen.
Environment
react-native-css3.0.7,nativewind5.0.0-preview.4,tailwindcss4.3.3- Expo SDK 57, React Native 0.86, New Architecture enabled, pnpm monorepo (hoisted)
- Metro via
withNativewind(config, { inlineVariables: false }), defaultglobalClassNamePolyfill(true)
Repro
import { SafeAreaView } from "react-native-safe-area-context";
export default function Screen() {
return (
<SafeAreaView className="flex-1 bg-red-500">
<Text>never gets a red full-height background</Text>
</SafeAreaView>
);
}
<View className="flex-1 bg-red-500"> in the same tree styles correctly, confirming the CSS pipeline itself works.
Suggested fix
Wrap SafeAreaView in the shim like the other intercepted components, e.g.:
import { SafeAreaView as OriginalSafeAreaView } from "react-native-safe-area-context";
import { useCssElement } from "react-native-css";
export function SafeAreaView(props: SafeAreaViewProps & { className?: string }) {
return useCssElement(OriginalSafeAreaView, props, { className: "style" });
}
We are currently shipping exactly that as a local pnpm patch on dist/ (module + commonjs) and it fully restores v4 behavior — all screens render identically to our NativeWind 4 baseline.
More generally: a dev-mode warning when className is passed to a component that nothing intercepts would have turned a multi-hour debugging session into a one-line console message. Happy to open a PR for the SafeAreaView wrap if useful.
- Vorherrschende Sprache
- TypeScript
- Sterne
- 166
- Forks
- 45
- Ø Merge
- 13 T. 14 Std.
- Gemergte PRs (30 T.)
- 1
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Keine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus nativewind/react-native-css
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
nativewind/react-native-css#545 ·
Maintainer antworten meist innerhalb von 3 Tagen
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
nativewind/react-native-css#544 ·
Maintainer antworten meist innerhalb von 3 Tagen
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
nativewind/react-native-css#543 ·
Maintainer antworten meist innerhalb von 3 Tagen
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 84/100
nativewind/react-native-css#540 ·
Maintainer antworten meist innerhalb von 3 Tagen
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
nativewind/react-native-css#538 ·
Maintainer antworten meist innerhalb von 3 Tagen
Alle Issues in nativewind/react-native-css
Ähnliche Issues
-
Shell: serve the home app's Cookie Policy on a hard reloadEvtl. vergeben @2001anshkaushik hat das heute übernommen. Offenfeature module:ai
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 88/100
rocketride-org/rocketride-server#2899 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 2 Tagen
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
wazuh/wazuh-dashboard-plugins#9551 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
gofish-graphics/gofish-graphics#1252 ·
Maintainer antworten meist innerhalb von 1 Tag
-
optimization P3 size:XS
Schwierigkeit 1/5 1-3 Stunden Anfängerfreundlichkeit 88/100
josephfung/curia#2366 ·
Maintainer antworten meist innerhalb von 1 Tag
-
type:bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 65/100
nightgauge/nightgauge#2688 ·
Maintainer antworten meist innerhalb von 1 Tag