Skip to content
This repository has been archived by the owner on Feb 18, 2019. It is now read-only.

Commit

Permalink
Fix empty ScrollView warnings
Browse files Browse the repository at this point in the history
Summary:Currently, an empty `<ScrollView />` on iOS always throws the warning "Sticky header index 0 was outside the range {0, 0}".

This is because the error-reporting code relies on the assumption that `stickyHeaderIndices` exists, and when it doesn't the error check thinks there's an index when there really isn't.

Note that this only changes error reporting and won't affect apps out of debug mode.

**Test plan**
I created a sample app and included an empty `<ScrollView />`. Without this change the "Sticky header..." warning was displayed on every run through. With this change implemented, the warning went away.
Closes facebook#6417

Differential Revision: D3042178

Pulled By: nicklockwood

fb-gh-sync-id: 7afefd428a5fcb03867bcb69e46c46fe1ae9151e
shipit-source-id: 7afefd428a5fcb03867bcb69e46c46fe1ae9151e
  • Loading branch information
corbt authored and Facebook Github Bot 9 committed Mar 11, 2016
1 parent 6f7a305 commit 299cd4c
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion React/Views/RCTScrollView.m
Original file line number Diff line number Diff line change
Expand Up @@ -838,7 +838,10 @@ - (void)reactBridgeDidFinishTransaction
if (RCT_DEBUG) {
// Validate that sticky headers are not out of range.
NSUInteger subviewCount = _scrollView.contentView.reactSubviews.count;
NSUInteger lastIndex = _scrollView.stickyHeaderIndices.lastIndex;
NSUInteger lastIndex = NSNotFound;
if (_scrollView.stickyHeaderIndices != nil) {
lastIndex = _scrollView.stickyHeaderIndices.lastIndex;
}
if (lastIndex != NSNotFound && lastIndex >= subviewCount) {
RCTLogWarn(@"Sticky header index %zd was outside the range {0, %zd}",
lastIndex, subviewCount);
Expand Down

0 comments on commit 299cd4c

Please sign in to comment.