Skip to content

Commit e21f8ec

Browse files
cortinicofacebook-github-bot
authored andcommitted
Fix crash on ReactEditText with AppCompat 1.4.0
Summary: This Diff fixes a crash happening as the user uses AppCompat 1.4.0 as a dependency in their App and uses a `TextInput` component. The crash happens as `mFabricViewStateManager` is accessed during the ctor of the superclass, and is not yet initialized. Fixes #31572 Changelog: [Android] [Fixed] - Fix crash on ReactEditText with AppCompat 1.4.0 Reviewed By: ShikaSD Differential Revision: D32674975 fbshipit-source-id: efa413f5e33527a29fbcfa729e8b006ecb235978
1 parent e89d494 commit e21f8ec

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java

+6-3
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,8 @@ public class ReactEditText extends AppCompatEditText
114114

115115
private ReactViewBackgroundManager mReactBackgroundManager;
116116

117-
private final FabricViewStateManager mFabricViewStateManager = new FabricViewStateManager();
117+
private final @Nullable FabricViewStateManager mFabricViewStateManager =
118+
new FabricViewStateManager();
118119
protected boolean mDisableTextDiffing = false;
119120

120121
protected boolean mIsSettingTextFromState = false;
@@ -746,7 +747,9 @@ private void setIntrinsicContentSize() {
746747
// view, we don't need to construct one or apply it at all - it provides no use in Fabric.
747748
ReactContext reactContext = getReactContext(this);
748749

749-
if (!mFabricViewStateManager.hasStateWrapper() && !reactContext.isBridgeless()) {
750+
if (mFabricViewStateManager != null
751+
&& !mFabricViewStateManager.hasStateWrapper()
752+
&& !reactContext.isBridgeless()) {
750753
final ReactTextInputLocalData localData = new ReactTextInputLocalData(this);
751754
UIManagerModule uiManager = reactContext.getNativeModule(UIManagerModule.class);
752755
if (uiManager != null) {
@@ -978,7 +981,7 @@ public FabricViewStateManager getFabricViewStateManager() {
978981
*/
979982
private void updateCachedSpannable(boolean resetStyles) {
980983
// Noops in non-Fabric
981-
if (!mFabricViewStateManager.hasStateWrapper()) {
984+
if (mFabricViewStateManager != null && !mFabricViewStateManager.hasStateWrapper()) {
982985
return;
983986
}
984987
// If this view doesn't have an ID yet, we don't have a cache key, so bail here

0 commit comments

Comments
 (0)