Commit 3cfa201
committed
fix(TextInput): fall back to theme fontWeight when style doesn't provide one
Both TextInputOutlined and TextInputFlat destructure `fontWeight` from the
user's `style` prop and spread it after the theme font object:
const { fontWeight } = StyleSheet.flatten(style) || {};
textStyle: { ...font, fontWeight }
When the user doesn't set `fontWeight` in their style, the destructured
value is `undefined`. Spreading `{ ...font, fontWeight: undefined }` then
overrides `font.fontWeight` (e.g. '400' from the theme) with `undefined`.
On React Native's Fabric renderer (New Architecture), this `undefined`
flows through as nil to the native `RCTGetFontWeight` function, which
passes it to `CFStringFind` → `CFStringGetLength` on a NULL pointer →
EXC_BAD_ACCESS (SIGSEGV).
The fix renames the destructured variable to `fontWeightStyle` and uses
nullish coalescing to fall back to the theme font's fontWeight:
const fontWeight = fontWeightStyle ?? font.fontWeight;
This preserves the existing behavior when `fontWeight` IS provided in the
style prop, while preventing the nil crash when it isn't.1 parent ad744ff commit 3cfa201
2 files changed
Lines changed: 4 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
88 | 88 | | |
89 | 89 | | |
90 | 90 | | |
91 | | - | |
| 91 | + | |
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
95 | 95 | | |
96 | 96 | | |
| 97 | + | |
97 | 98 | | |
98 | 99 | | |
99 | 100 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
90 | 90 | | |
91 | 91 | | |
92 | 92 | | |
93 | | - | |
| 93 | + | |
94 | 94 | | |
95 | 95 | | |
96 | 96 | | |
97 | 97 | | |
98 | 98 | | |
99 | 99 | | |
| 100 | + | |
100 | 101 | | |
101 | 102 | | |
102 | 103 | | |
| |||
0 commit comments