Commit 555fee2
committed
fix(scatterlab): make StatusBar.currentHeight a lazy getter
As a class field the native constant is read while the module is being loaded. Under the
New Architecture the TurboModule constants are only valid once the module instance
exists, so on Android that read fails during startup and takes the app down with
TypeError: Cannot read property 'HEIGHT' of undefined
`import {StatusBar} from 'react-native'` alone is enough to trigger it — that is how
@react-navigation/native-stack uses it, so an app crashes before its first screen even
though it never touches StatusBar itself. Upstream closed the same report as not planned
(react#41663).
A getter defers the read to the point where the value is used. The JS spec wrapper does
not cache a failed lookup, so a later read still returns the real height.1 parent 291b330 commit 555fee2
3 files changed
Lines changed: 25 additions & 4 deletions
File tree
- .github/scatterlab
- packages/react-native
- Libraries/Components/StatusBar
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
Lines changed: 14 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
249 | 249 | | |
250 | 250 | | |
251 | 251 | | |
252 | | - | |
253 | | - | |
254 | | - | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
255 | 265 | | |
| 266 | + | |
256 | 267 | | |
257 | 268 | | |
258 | 269 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
| 4 | + | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| |||
0 commit comments