Skip to content

Commit eb06659

Browse files
author
Alex Akers
committed
[React Native] Update code comments about layout-only view
1 parent 875ab07 commit eb06659

3 files changed

Lines changed: 14 additions & 1 deletion

File tree

Libraries/Components/View/View.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,12 @@ var AccessibilityTraits = [
4444
'pageTurn',
4545
];
4646

47+
// <<<<< WARNING >>>>>
48+
// If adding any properties to View that could change the way layout-only status
49+
// works on iOS, make sure to update ReactNativeViewAttributes.js and
50+
// RCTShadowView.m (in the -[RCTShadowView isLayoutOnly] method).
51+
// <<<<< WARNING >>>>>
52+
4753
/**
4854
* The most fundamental component for building UI, `View` is a
4955
* container that supports layout with flexbox, style, some touch handling, and

Libraries/ReactNative/ReactNativeViewAttributes.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,11 @@ ReactNativeViewAttributes.UIView = {
2626
onMagicTap: true,
2727
collapsible: true,
2828

29-
// If any below are set, view should not be collapsible!
29+
// If editing layout-only view attributes, make sure
30+
// -[RCTShadowView isLayoutOnly] in RCTShadowView.m
31+
// is up-to-date! If any property below is set, the
32+
// view should not be collapsible, but this is done
33+
// on the native side.
3034
onMoveShouldSetResponder: true,
3135
onResponderGrant: true,
3236
onResponderMove: true,

React/Views/RCTShadowView.m

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,12 +439,15 @@ - (BOOL)isLayoutOnly
439439
@"flex",
440440
};
441441
layoutKeys = [NSSet setWithObjects:layoutKeyStrings count:sizeof(layoutKeyStrings)/sizeof(*layoutKeyStrings)];
442+
// layoutKeys are the only keys whose presence does not reject layout-only status.
442443

443444
static NSString *const specialKeyStrings[] = {
444445
@"accessible",
445446
@"collapsible",
446447
};
447448
specialKeys = [NSSet setWithObjects:specialKeyStrings count:sizeof(specialKeyStrings)/sizeof(*specialKeyStrings)];
449+
// specialKeys are keys whose presence does not indicate whether layout-only or not
450+
// their values must be tested below
448451
}
449452

450453
NSNumber *collapsible = self.allProps[@"collapsible"];

0 commit comments

Comments
 (0)