diff --git a/packages/react-native-web/src/exports/ScrollView/__tests__/index-test.js b/packages/react-native-web/src/exports/ScrollView/__tests__/index-test.js index 76c388c2..c12de3b2 100644 --- a/packages/react-native-web/src/exports/ScrollView/__tests__/index-test.js +++ b/packages/react-native-web/src/exports/ScrollView/__tests__/index-test.js @@ -3,6 +3,7 @@ import React from 'react'; import ScrollView from '..'; import StyleSheet from '../../StyleSheet'; +import View from '../../View'; import { mount, shallow } from 'enzyme'; describe('components/ScrollView', () => { @@ -13,6 +14,21 @@ describe('components/ScrollView', () => { }).not.toThrow(); }); + test('"children" prop', () => { + const component = shallow( + + + + ); + expect(component.find({ testID: 'child' }).length).toBe(1); + + component.setProps({ stickyHeaderIndices: [4] }); + expect(component.find({ testID: 'child' }).length).toBe(1); + + component.setProps({ pagingEnabled: true }); + expect(component.find({ testID: 'child' }).length).toBe(1); + }); + test('"pagingEnabled" prop', () => { const getStyleProp = (component, prop) => StyleSheet.flatten(component.prop('style'))[prop]; diff --git a/packages/react-native-web/src/exports/ScrollView/index.js b/packages/react-native-web/src/exports/ScrollView/index.js index 7fa8bea5..b4847660 100644 --- a/packages/react-native-web/src/exports/ScrollView/index.js +++ b/packages/react-native-web/src/exports/ScrollView/index.js @@ -168,20 +168,18 @@ const ScrollView = createReactClass({ const children = hasStickyHeaderIndices || pagingEnabled ? React.Children.map(this.props.children, (child, i) => { - if (child != null) { - const isSticky = hasStickyHeaderIndices && stickyHeaderIndices.indexOf(i) > -1; - if (isSticky || pagingEnabled) { - return ( - - {child} - - ); - } + const isSticky = hasStickyHeaderIndices && stickyHeaderIndices.indexOf(i) > -1; + if (child != null && (isSticky || pagingEnabled)) { + return ( + + {child} + + ); } else { return child; }