@@ -48,6 +48,10 @@ public class ReactTextView extends AppCompatTextView implements ReactCompoundVie
48
48
private static final ViewGroup .LayoutParams EMPTY_LAYOUT_PARAMS =
49
49
new ViewGroup .LayoutParams (0 , 0 );
50
50
51
+ private static final ViewGroup .LayoutParams WRAP_CONTENT_LAYOUT_PARAMS =
52
+ new ViewGroup .LayoutParams (
53
+ ViewGroup .LayoutParams .WRAP_CONTENT , ViewGroup .LayoutParams .WRAP_CONTENT );
54
+
51
55
private boolean mContainsImages ;
52
56
private int mDefaultGravityHorizontal ;
53
57
private int mDefaultGravityVertical ;
@@ -266,12 +270,14 @@ public int compare(Object o1, Object o2) {
266
270
267
271
public void setText (ReactTextUpdate update ) {
268
272
mContainsImages = update .containsImages ();
269
- if ( ReactFeatureFlags . enableSettingEmptyLayoutParams ) {
270
- // Android's TextView crashes when it tries to relayout if LayoutParams are
271
- // null; explicitly set the LayoutParams to prevent this crash. See:
272
- // https://github.com/facebook/react-native/pull/7011
273
- if (getLayoutParams () == null ) {
273
+ // Android's TextView crashes when it tries to relayout if LayoutParams are
274
+ // null; explicitly set the LayoutParams to prevent this crash. See:
275
+ // https://github.com/facebook/react-native/pull/7011
276
+ if ( getLayoutParams () == null ) {
277
+ if (ReactFeatureFlags . enableSettingEmptyLayoutParams ) {
274
278
setLayoutParams (EMPTY_LAYOUT_PARAMS );
279
+ } else {
280
+ setLayoutParams (WRAP_CONTENT_LAYOUT_PARAMS );
275
281
}
276
282
}
277
283
Spannable spannable = update .getText ();
0 commit comments