A framework for building native applications using React
Fix KotlinNullableVariableCastToNonnullType in DefaultReactHost.kt (#55406)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/55406 Refactored getDefaultReactHost to prove that reactHost is never null at return time, eliminating the need for checkNotNull. The original code used `checkNotNull(reactHost)` which was a runtime assertion. The refactored code uses a pattern that proves null-safety at compile time: 1. Early return with `?.let` if reactHost is already initialized 2. Create the new ReactHostImpl in a local `val newReactHost` (which compiler knows is non-null) 3. Assign to the class field and return the local variable directly This approach eliminates the runtime check while maintaining the same singleton behavior. changelog: [internal] internal Reviewed By: javache Differential Revision: D91820164 fbshipit-source-id: 4e550569e8473b549ba0debb701991a260a8dd04
D
David Vacca committed
905fa243c5e31cf018b9a5b98f7846c507728ff6
Parent: 9bd72e7
Committed by meta-codesync[bot] <215208954+meta-codesync[bot]@users.noreply.github.com>
on 2/5/2026, 5:55:13 AM