Summary
Importing ScreenCornerRadius crashes the app on the iOS simulator with:
TypeError: Cannot read property 'cornerRadius' of null
The crash happens at module-load time, so it takes down the whole app rather than degrading gracefully.
Root cause
In src/index.tsx:
export const ScreenCornerRadius =
NativeModules.ScreenCornerRadius.cornerRadius ?? 0;
The ?? 0 only guards .cornerRadius being null/undefined — it does not guard NativeModules.ScreenCornerRadius itself being null. When the native module isn't available (iOS simulator, or module not registered), NativeModules.ScreenCornerRadius is null, so accessing .cornerRadius throws before the ?? 0 fallback can apply.
Steps to reproduce
- Add
react-native-screen-corner-radius to an app.
import { ScreenCornerRadius } from 'react-native-screen-corner-radius'.
- Run on an iOS simulator.
- App crashes on load.
Expected behavior
When the native module is unavailable, ScreenCornerRadius should fall back to 0 (and IsScreenRounded to false) rather than throwing.
Suggested fix
Optional-chain the module access too:
export const ScreenCornerRadius =
NativeModules.ScreenCornerRadius?.cornerRadius ?? 0;
Environment
react-native-screen-corner-radius: 0.2.3
react-native: 0.83.2
- Platform: iOS simulator
Summary
Importing
ScreenCornerRadiuscrashes the app on the iOS simulator with:The crash happens at module-load time, so it takes down the whole app rather than degrading gracefully.
Root cause
In
src/index.tsx:The
?? 0only guards.cornerRadiusbeing null/undefined — it does not guardNativeModules.ScreenCornerRadiusitself beingnull. When the native module isn't available (iOS simulator, or module not registered),NativeModules.ScreenCornerRadiusisnull, so accessing.cornerRadiusthrows before the?? 0fallback can apply.Steps to reproduce
react-native-screen-corner-radiusto an app.import { ScreenCornerRadius } from 'react-native-screen-corner-radius'.Expected behavior
When the native module is unavailable,
ScreenCornerRadiusshould fall back to0(andIsScreenRoundedtofalse) rather than throwing.Suggested fix
Optional-chain the module access too:
Environment
react-native-screen-corner-radius: 0.2.3react-native: 0.83.2