Skip to content

Commit

Permalink
Handle possible null exception on ReactEditText with AppCompat 1.4.0 (#…
Browse files Browse the repository at this point in the history
…33769)

Summary:
This Change fixes a possible null exception as the user uses AppCompat 1.4.0
as a dependency in their App and uses a `TextInput` component.

The exception may happen as `mFabricViewStateManager` is accessed during
the constructor of the superclass, and is not yet initialized.
- For reference, commit #e21f8ec34984551f87a306672160cc88e67e4793 fixes the crash which was already happening.

<!-- Explain the **motivation** for making this change. What existing problem does the pull request solve? -->
Possible null exception as `mFabricViewStateManager` is accessed during
the constructor of the superclass, white it is not yet initialized.
This commit #e21f8ec34984551f87a306672160cc88e67e4793 fixes the crash which was already happening, accessing of mFabricViewStateManager before initialization, and left another one of the call of the same nature.
## Changelog
<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://github.com/facebook/react-native/wiki/Changelog
-->
Fix: accessing `mFabricViewStateManager` before initialization.

[JavaScript] [Fixed] - accessing `mFabricViewStateManager` before initialization.

Pull Request resolved: #33769

Test Plan: no external tool was used.

Reviewed By: javache

Differential Revision: D36205441

Pulled By: cortinico

fbshipit-source-id: f3fca69224c7794757514f026a5293b213986186
  • Loading branch information
mikemasam authored and facebook-github-bot committed May 9, 2022
1 parent 2a274c1 commit 24a1f5c
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,7 @@ private static boolean sameTextForSpan(
// This is hacked in for Fabric. When we delete non-Fabric code, we might be able to simplify or
// clean this up a bit.
private void addSpansForMeasurement(Spannable spannable) {
if (!mFabricViewStateManager.hasStateWrapper()) {
if (mFabricViewStateManager != null && !mFabricViewStateManager.hasStateWrapper()) {
return;
}

Expand Down

0 comments on commit 24a1f5c

Please sign in to comment.