@@ -13,7 +13,6 @@ const InternalListViewType = require('InternalListViewType');
13
13
const ListViewDataSource = require ( 'ListViewDataSource' ) ;
14
14
const Platform = require ( 'Platform' ) ;
15
15
const React = require ( 'React' ) ;
16
- const PropTypes = require ( 'prop-types' ) ;
17
16
const ReactNative = require ( 'ReactNative' ) ;
18
17
const RCTScrollViewManager = require ( 'NativeModules' ) . ScrollViewManager ;
19
18
const ScrollView = require ( 'ScrollView' ) ;
@@ -37,22 +36,124 @@ const DEFAULT_SCROLL_CALLBACK_THROTTLE = 50;
37
36
type Props = $ReadOnly < { |
38
37
...ScrollViewProps ,
39
38
39
+ /**
40
+ * An instance of [ListView.DataSource](docs/listviewdatasource.html) to use
41
+ */
40
42
dataSource : ListViewDataSource ,
43
+ /**
44
+ * (sectionID, rowID, adjacentRowHighlighted) => renderable
45
+ *
46
+ * If provided, a renderable component to be rendered as the separator
47
+ * below each row but not the last row if there is a section header below.
48
+ * Take a sectionID and rowID of the row above and whether its adjacent row
49
+ * is highlighted.
50
+ */
41
51
renderSeparator ?: ?Function ,
52
+ /**
53
+ * (rowData, sectionID, rowID, highlightRow) => renderable
54
+ *
55
+ * Takes a data entry from the data source and its ids and should return
56
+ * a renderable component to be rendered as the row. By default the data
57
+ * is exactly what was put into the data source, but it's also possible to
58
+ * provide custom extractors. ListView can be notified when a row is
59
+ * being highlighted by calling `highlightRow(sectionID, rowID)`. This
60
+ * sets a boolean value of adjacentRowHighlighted in renderSeparator, allowing you
61
+ * to control the separators above and below the highlighted row. The highlighted
62
+ * state of a row can be reset by calling highlightRow(null).
63
+ */
42
64
renderRow : Function ,
65
+ /**
66
+ * How many rows to render on initial component mount. Use this to make
67
+ * it so that the first screen worth of data appears at one time instead of
68
+ * over the course of multiple frames.
69
+ */
43
70
initialListSize ?: ?number ,
71
+ /**
72
+ * Called when all rows have been rendered and the list has been scrolled
73
+ * to within onEndReachedThreshold of the bottom. The native scroll
74
+ * event is provided.
75
+ */
44
76
onEndReached ?: ?Function ,
77
+ /**
78
+ * Threshold in pixels (virtual, not physical) for calling onEndReached.
79
+ */
45
80
onEndReachedThreshold ?: ?number ,
81
+ /**
82
+ * Number of rows to render per event loop. Note: if your 'rows' are actually
83
+ * cells, i.e. they don't span the full width of your view (as in the
84
+ * ListViewGridLayoutExample), you should set the pageSize to be a multiple
85
+ * of the number of cells per row, otherwise you're likely to see gaps at
86
+ * the edge of the ListView as new pages are loaded.
87
+ */
46
88
pageSize ?: ?number ,
89
+ /**
90
+ * () => renderable
91
+ *
92
+ * The header and footer are always rendered (if these props are provided)
93
+ * on every render pass. If they are expensive to re-render, wrap them
94
+ * in StaticContainer or other mechanism as appropriate. Footer is always
95
+ * at the bottom of the list, and header at the top, on every render pass.
96
+ * In a horizontal ListView, the header is rendered on the left and the
97
+ * footer on the right.
98
+ */
47
99
renderFooter ?: ?Function ,
48
100
renderHeader ?: ?Function ,
101
+ /**
102
+ * (sectionData, sectionID) => renderable
103
+ *
104
+ * If provided, a header is rendered for this section.
105
+ */
49
106
renderSectionHeader ?: ?Function ,
107
+ /**
108
+ * (props) => renderable
109
+ *
110
+ * A function that returns the scrollable component in which the list rows
111
+ * are rendered. Defaults to returning a ScrollView with the given props.
112
+ */
50
113
renderScrollComponent ?: ?Function ,
114
+ /**
115
+ * How early to start rendering rows before they come on screen, in
116
+ * pixels.
117
+ */
51
118
scrollRenderAheadDistance ?: ?number ,
119
+ /**
120
+ * (visibleRows, changedRows) => void
121
+ *
122
+ * Called when the set of visible rows changes. `visibleRows` maps
123
+ * { sectionID: { rowID: true }} for all the visible rows, and
124
+ * `changedRows` maps { sectionID: { rowID: true | false }} for the rows
125
+ * that have changed their visibility, with true indicating visible, and
126
+ * false indicating the view has moved out of view.
127
+ */
52
128
onChangeVisibleRows ?: ?Function ,
129
+ /**
130
+ * A performance optimization for improving scroll perf of
131
+ * large lists, used in conjunction with overflow: 'hidden' on the row
132
+ * containers. This is enabled by default.
133
+ */
53
134
removeClippedSubviews ?: ?boolean ,
135
+ /**
136
+ * Makes the sections headers sticky. The sticky behavior means that it
137
+ * will scroll with the content at the top of the section until it reaches
138
+ * the top of the screen, at which point it will stick to the top until it
139
+ * is pushed off the screen by the next section header. This property is
140
+ * not supported in conjunction with `horizontal={true}`. Only enabled by
141
+ * default on iOS because of typical platform standards.
142
+ */
54
143
stickySectionHeadersEnabled ?: ?boolean ,
144
+ /**
145
+ * An array of child indices determining which children get docked to the
146
+ * top of the screen when scrolling. For example, passing
147
+ * `stickyHeaderIndices={[0]}` will cause the first child to be fixed to the
148
+ * top of the scroll view. This property is not supported in conjunction
149
+ * with `horizontal={true}`.
150
+ */
55
151
stickyHeaderIndices ?: ?$ReadOnlyArray < number > ,
152
+ /**
153
+ * Flag indicating whether empty section headers should be rendered. In the future release
154
+ * empty section headers will be rendered by default, and the flag will be deprecated.
155
+ * If empty sections are not desired to be rendered their indices should be excluded from sectionID object.
156
+ */
56
157
enableEmptySections ?: ?boolean ,
57
158
| } > ;
58
159
@@ -128,136 +229,6 @@ const ListView = createReactClass({
128
229
DataSource : ListViewDataSource ,
129
230
} ,
130
231
131
- /**
132
- * You must provide a renderRow function. If you omit any of the other render
133
- * functions, ListView will simply skip rendering them.
134
- *
135
- * - renderRow(rowData, sectionID, rowID, highlightRow);
136
- * - renderSectionHeader(sectionData, sectionID);
137
- */
138
- propTypes : {
139
- ...ScrollView . propTypes ,
140
- /**
141
- * An instance of [ListView.DataSource](docs/listviewdatasource.html) to use
142
- */
143
- dataSource : PropTypes . instanceOf ( ListViewDataSource ) . isRequired ,
144
- /**
145
- * (sectionID, rowID, adjacentRowHighlighted) => renderable
146
- *
147
- * If provided, a renderable component to be rendered as the separator
148
- * below each row but not the last row if there is a section header below.
149
- * Take a sectionID and rowID of the row above and whether its adjacent row
150
- * is highlighted.
151
- */
152
- renderSeparator : PropTypes . func ,
153
- /**
154
- * (rowData, sectionID, rowID, highlightRow) => renderable
155
- *
156
- * Takes a data entry from the data source and its ids and should return
157
- * a renderable component to be rendered as the row. By default the data
158
- * is exactly what was put into the data source, but it's also possible to
159
- * provide custom extractors. ListView can be notified when a row is
160
- * being highlighted by calling `highlightRow(sectionID, rowID)`. This
161
- * sets a boolean value of adjacentRowHighlighted in renderSeparator, allowing you
162
- * to control the separators above and below the highlighted row. The highlighted
163
- * state of a row can be reset by calling highlightRow(null).
164
- */
165
- renderRow : PropTypes . func . isRequired ,
166
- /**
167
- * How many rows to render on initial component mount. Use this to make
168
- * it so that the first screen worth of data appears at one time instead of
169
- * over the course of multiple frames.
170
- */
171
- initialListSize : PropTypes . number . isRequired ,
172
- /**
173
- * Called when all rows have been rendered and the list has been scrolled
174
- * to within onEndReachedThreshold of the bottom. The native scroll
175
- * event is provided.
176
- */
177
- onEndReached : PropTypes . func ,
178
- /**
179
- * Threshold in pixels (virtual, not physical) for calling onEndReached.
180
- */
181
- onEndReachedThreshold : PropTypes . number . isRequired ,
182
- /**
183
- * Number of rows to render per event loop. Note: if your 'rows' are actually
184
- * cells, i.e. they don't span the full width of your view (as in the
185
- * ListViewGridLayoutExample), you should set the pageSize to be a multiple
186
- * of the number of cells per row, otherwise you're likely to see gaps at
187
- * the edge of the ListView as new pages are loaded.
188
- */
189
- pageSize : PropTypes . number . isRequired ,
190
- /**
191
- * () => renderable
192
- *
193
- * The header and footer are always rendered (if these props are provided)
194
- * on every render pass. If they are expensive to re-render, wrap them
195
- * in StaticContainer or other mechanism as appropriate. Footer is always
196
- * at the bottom of the list, and header at the top, on every render pass.
197
- * In a horizontal ListView, the header is rendered on the left and the
198
- * footer on the right.
199
- */
200
- renderFooter : PropTypes . func ,
201
- renderHeader : PropTypes . func ,
202
- /**
203
- * (sectionData, sectionID) => renderable
204
- *
205
- * If provided, a header is rendered for this section.
206
- */
207
- renderSectionHeader : PropTypes . func ,
208
- /**
209
- * (props) => renderable
210
- *
211
- * A function that returns the scrollable component in which the list rows
212
- * are rendered. Defaults to returning a ScrollView with the given props.
213
- */
214
- renderScrollComponent : PropTypes . func . isRequired ,
215
- /**
216
- * How early to start rendering rows before they come on screen, in
217
- * pixels.
218
- */
219
- scrollRenderAheadDistance : PropTypes . number . isRequired ,
220
- /**
221
- * (visibleRows, changedRows) => void
222
- *
223
- * Called when the set of visible rows changes. `visibleRows` maps
224
- * { sectionID: { rowID: true }} for all the visible rows, and
225
- * `changedRows` maps { sectionID: { rowID: true | false }} for the rows
226
- * that have changed their visibility, with true indicating visible, and
227
- * false indicating the view has moved out of view.
228
- */
229
- onChangeVisibleRows : PropTypes . func ,
230
- /**
231
- * A performance optimization for improving scroll perf of
232
- * large lists, used in conjunction with overflow: 'hidden' on the row
233
- * containers. This is enabled by default.
234
- */
235
- removeClippedSubviews : PropTypes . bool ,
236
- /**
237
- * Makes the sections headers sticky. The sticky behavior means that it
238
- * will scroll with the content at the top of the section until it reaches
239
- * the top of the screen, at which point it will stick to the top until it
240
- * is pushed off the screen by the next section header. This property is
241
- * not supported in conjunction with `horizontal={true}`. Only enabled by
242
- * default on iOS because of typical platform standards.
243
- */
244
- stickySectionHeadersEnabled : PropTypes . bool ,
245
- /**
246
- * An array of child indices determining which children get docked to the
247
- * top of the screen when scrolling. For example, passing
248
- * `stickyHeaderIndices={[0]}` will cause the first child to be fixed to the
249
- * top of the scroll view. This property is not supported in conjunction
250
- * with `horizontal={true}`.
251
- */
252
- stickyHeaderIndices : PropTypes . arrayOf ( PropTypes . number ) . isRequired ,
253
- /**
254
- * Flag indicating whether empty section headers should be rendered. In the future release
255
- * empty section headers will be rendered by default, and the flag will be deprecated.
256
- * If empty sections are not desired to be rendered their indices should be excluded from sectionID object.
257
- */
258
- enableEmptySections : PropTypes . bool ,
259
- } ,
260
-
261
232
/**
262
233
* Exports some data, e.g. for perf investigations or analytics.
263
234
*/
@@ -296,7 +267,7 @@ const ListView = createReactClass({
296
267
*
297
268
* See `ScrollView#scrollTo`.
298
269
*/
299
- scrollTo : function ( ...args : Array < mixed > ) {
270
+ scrollTo : function ( ...args : any ) {
300
271
if ( this . _scrollComponent && this . _scrollComponent . scrollTo ) {
301
272
this . _scrollComponent . scrollTo ( ...args ) ;
302
273
}
@@ -312,7 +283,7 @@ const ListView = createReactClass({
312
283
*
313
284
* See `ScrollView#scrollToEnd`.
314
285
*/
315
- scrollToEnd : function ( options ?: ?{ animated ?: ? boolean } ) {
286
+ scrollToEnd : function ( options ?: ?{ animated ?: boolean } ) {
316
287
if ( this . _scrollComponent ) {
317
288
if ( this . _scrollComponent . scrollToEnd ) {
318
289
this . _scrollComponent . scrollToEnd ( options ) ;
@@ -366,7 +337,7 @@ const ListView = createReactClass({
366
337
} ,
367
338
368
339
getInnerViewNode : function ( ) {
369
- return this . _scrollComponent . getInnerViewNode ( ) ;
340
+ return this . _scrollComponent && this . _scrollComponent . getInnerViewNode ( ) ;
370
341
} ,
371
342
372
343
UNSAFE_componentWillMount : function ( ) {
0 commit comments