From ba6bf5a3ce7039a7e407a6632ee41aa3d504f833 Mon Sep 17 00:00:00 2001 From: Nicola Corti Date: Wed, 25 May 2022 10:10:35 -0700 Subject: [PATCH] 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 --- .../com/facebook/react/views/textinput/ReactEditText.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java b/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java index d6ef3952e8d090..51deec2f262075 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java @@ -747,7 +747,10 @@ private void setIntrinsicContentSize() { // 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 FabricViewStateManager getFabricViewStateManager() { */ 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