Summary
nativeStyleMapping() in src/native/styles/index.ts assumes every mapping value is a dot-path string and calls path.split("."). However, the NativeStyleMapping type — and the built-in components shipped by this package — allow the value to be the boolean shorthand true (meaning "map onto a native prop with the same name"). When such a mapped style is actually present, (true).split throws TypeError: undefined is not a function during render.
Same root cause as #232 / #288 — filing with a precise root-cause trace and a one-line fix that I've verified locally via a patch.
Affected built-in components
Components that ship a boolean-shorthand nativeStyleMapping crash as soon as the mapped style is applied:
components/TextInput.tsx → { textAlign: true } — triggered by text-right / text-center / text-left
components/ImageBackground.tsx → { backgroundColor: true } — triggered by any bg-*
(ActivityIndicator / Button use { color: "color" }, a string path, so they don't hit this.)
Reproduction
import { TextInput } from "react-native-css/components"; // or via nativewind v5
<TextInput className="text-right" value="x" onChangeText={() => {}} />
Render → TypeError: undefined is not a function.
Note it only crashes when the mapped style is actually present: when textAlign is absent, styleValue === undefined short-circuits via continue, which is why text-left-less inputs render fine and the crash looks intermittent.
Root cause
src/native/styles/index.ts:
for (const [key, path] of Object.entries(config.nativeStyleMapping)) {
const styleValue = source[key];
delete source[key];
if (styleValue === undefined) {
continue;
}
let target = props;
const tokens = path.split("."); // path === true -> true.split is not a function
...
}
useNativeCss.ts casts value.nativeStyleMapping as Record<string, string>, but the runtime value is { textAlign: true }, so path is the boolean true.
Suggested fix
Treat true as the same-name shorthand (target prop named key), matching the true | DotNotation type:
const tokens = (typeof path === "string" ? path : key).split(".");
Environment
- react-native-css 3.0.7 (latest)
- nativewind 5.0.0-preview.3
- react-native 0.85.3 / React 19.2.3
- Hermes, iOS
Related: #232, #288, #251
Summary
nativeStyleMapping()insrc/native/styles/index.tsassumes every mapping value is a dot-path string and callspath.split("."). However, theNativeStyleMappingtype — and the built-in components shipped by this package — allow the value to be the boolean shorthandtrue(meaning "map onto a native prop with the same name"). When such a mapped style is actually present,(true).splitthrowsTypeError: undefined is not a functionduring render.Same root cause as #232 / #288 — filing with a precise root-cause trace and a one-line fix that I've verified locally via a patch.
Affected built-in components
Components that ship a boolean-shorthand
nativeStyleMappingcrash as soon as the mapped style is applied:components/TextInput.tsx→{ textAlign: true }— triggered bytext-right/text-center/text-leftcomponents/ImageBackground.tsx→{ backgroundColor: true }— triggered by anybg-*(
ActivityIndicator/Buttonuse{ color: "color" }, a string path, so they don't hit this.)Reproduction
Render →
TypeError: undefined is not a function.Note it only crashes when the mapped style is actually present: when
textAlignis absent,styleValue === undefinedshort-circuits viacontinue, which is whytext-left-less inputs render fine and the crash looks intermittent.Root cause
src/native/styles/index.ts:useNativeCss.tscastsvalue.nativeStyleMapping as Record<string, string>, but the runtime value is{ textAlign: true }, sopathis the booleantrue.Suggested fix
Treat
trueas the same-name shorthand (target prop namedkey), matching thetrue | DotNotationtype:Environment
Related: #232, #288, #251