File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -99,6 +99,32 @@ exports[`grid list renders correctly 1`] = `
9999/>
100100` ;
101101
102+ exports [` grid list renders empty list 1` ] = `
103+ <FlatList
104+ ItemSeparatorComponent = { [Function ]}
105+ animationDuration = { 500 }
106+ animationInitialBackgroundColor = " #FFFFFF"
107+ contentContainerStyle = { false }
108+ data = { Array []}
109+ disableVirtualization = { false }
110+ horizontal = { false }
111+ initialNumToRender = { 10 }
112+ itemStyle = { Object {}}
113+ keyExtractor = { [Function ]}
114+ maxToRenderPerBatch = { 10 }
115+ numColumns = { 3 }
116+ onEndReachedThreshold = { 2 }
117+ renderItem = { [Function ]}
118+ scrollEventThrottle = { 50 }
119+ separatorBorderColor = " #FFFFFF"
120+ separatorBorderWidth = { 0 }
121+ showAnimation = { false }
122+ showsVerticalScrollIndicator = { false }
123+ updateCellsBatchingPeriod = { 50 }
124+ windowSize = { 21 }
125+ />
126+ ` ;
127+
102128exports [` grid list renders showAnimation 1` ] = `
103129<FlatList
104130 ItemSeparatorComponent = { [Function ]}
Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ export default class GridList extends PureComponent {
2222 // Only is allowed children or data not both
2323 children ( props , propName ) {
2424 const { data } = props ;
25- if ( ! props [ propName ] && data && data . length === 0 ) {
25+ if ( ! props [ propName ] && ! data ) {
2626 return new Error ( 'Invalid props, `data` or `children` is required' ) ;
2727 }
2828 if ( data && data . length !== 0 && ! props . renderItem ) {
@@ -34,6 +34,7 @@ export default class GridList extends PureComponent {
3434
3535 static defaultProps = {
3636 numColumns : 3 ,
37+ data : [ ] ,
3738 itemStyle : { } ,
3839 showSeparator : false ,
3940 showAnimation : false ,
Original file line number Diff line number Diff line change @@ -17,6 +17,16 @@ describe('grid list', () => {
1717 ) ;
1818 expect ( wrapper ) . toMatchSnapshot ( ) ;
1919 } ) ;
20+
21+ it ( 'renders empty list' , ( ) => {
22+ const wrapper = shallow (
23+ < GridList
24+ data = { [ ] }
25+ renderItem = { ( { item } ) => < Image source = { item . thumbnail } /> }
26+ /> ,
27+ ) ;
28+ expect ( wrapper ) . toMatchSnapshot ( ) ;
29+ } ) ;
2030
2131 it ( 'renders showSeparator' , ( ) => {
2232 const wrapper = shallow (
You can’t perform that action at this time.
0 commit comments