Skip to content

Commit 2f8328d

Browse files
dratwasfacebook-github-bot
authored andcommitted
Remove max depth parameter while measuring layout of shadow view (#26986)
Summary: Searching for the ancestor view while measuring a shadow view layout relative to the ancestor is limited to `30`. I couldn't find the reason nor commit where it was introduced (because I have no access to internal facebook commits). I think we should keep looking for an ancestor view until the shadow view has the superview property. ## Changelog [iOS] [Fixed] - Remove maximum searching depth while measuring layout. Pull Request resolved: #26986 Test Plan: - Tested if RNTester works as expected. - Tested in app with a lot of nested flatlists where sometimes I was facing this redbox because of the max depth limit. <img width="297" alt="Screenshot 2019-10-24 at 14 40 11" src="https://user-images.githubusercontent.com/16336501/67486474-6309d380-f66c-11e9-9eab-15e8fb8372a5.png"> Differential Revision: D18175568 Pulled By: shergin fbshipit-source-id: cd59a18032d10bc6dd5707981e69813810f65b5a
1 parent 6c177d8 commit 2f8328d

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

React/Views/RCTShadowView.m

+2-6
Original file line numberDiff line numberDiff line change
@@ -156,13 +156,11 @@ static void RCTProcessMetaPropsBorder(const YGValue metaProps[META_PROP_COUNT],
156156
- (CGRect)measureLayoutRelativeToAncestor:(RCTShadowView *)ancestor
157157
{
158158
CGPoint offset = CGPointZero;
159-
NSInteger depth = 30; // max depth to search
160159
RCTShadowView *shadowView = self;
161-
while (depth && shadowView && shadowView != ancestor) {
160+
while (shadowView && shadowView != ancestor) {
162161
offset.x += shadowView.layoutMetrics.frame.origin.x;
163162
offset.y += shadowView.layoutMetrics.frame.origin.y;
164163
shadowView = shadowView->_superview;
165-
depth--;
166164
}
167165
if (ancestor != shadowView) {
168166
return CGRectNull;
@@ -172,11 +170,9 @@ - (CGRect)measureLayoutRelativeToAncestor:(RCTShadowView *)ancestor
172170

173171
- (BOOL)viewIsDescendantOf:(RCTShadowView *)ancestor
174172
{
175-
NSInteger depth = 30; // max depth to search
176173
RCTShadowView *shadowView = self;
177-
while (depth && shadowView && shadowView != ancestor) {
174+
while (shadowView && shadowView != ancestor) {
178175
shadowView = shadowView->_superview;
179-
depth--;
180176
}
181177
return ancestor == shadowView;
182178
}

0 commit comments

Comments
 (0)