Fix NPE on RN-Tester due to null mFabricViewStateManager (#33910)

Summary:
RN-Tester is currently crashing at startup time due to an NPE.
This PR fixes it.

## Changelog

[Android] [Fixed] - Fix NPE on `ReactEditText` due to null mFabricViewStateManager

Pull Request resolved: https://github.com/facebook/react-native/pull/33910

Test Plan: Tested locally that RN Tester runs both in Debug and in Release

Reviewed By: cipolleschi

Differential Revision: D36666440

Pulled By: cortinico

fbshipit-source-id: f004ff228fb4f9ff339aac606858d47de3706426
This commit is contained in:
Nicola Corti
2022-05-25 10:10:35 -07:00
committed by Facebook GitHub Bot
parent d315e9c743
commit ba6bf5a3ce
@@ -747,7 +747,10 @@ public class ReactEditText extends AppCompatEditText
// view, we don't need to construct one or apply it at all - it provides no use in Fabric.
ReactContext reactContext = getReactContext(this);
if (!mFabricViewStateManager.hasStateWrapper() && !reactContext.isBridgeless()) {
if (mFabricViewStateManager != null
&& !mFabricViewStateManager.hasStateWrapper()
&& !reactContext.isBridgeless()) {
final ReactTextInputLocalData localData = new ReactTextInputLocalData(this);
UIManagerModule uiManager = reactContext.getNativeModule(UIManagerModule.class);
if (uiManager != null) {
@@ -983,7 +986,7 @@ public class ReactEditText extends AppCompatEditText
*/
private void updateCachedSpannable(boolean resetStyles) {
// Noops in non-Fabric
if (!mFabricViewStateManager.hasStateWrapper()) {
if (mFabricViewStateManager == null || !mFabricViewStateManager.hasStateWrapper()) {
return;
}
// If this view doesn't have an ID yet, we don't have a cache key, so bail here