@@ -271,7 +271,7 @@ class Table extends React.Component {
271271 }
272272
273273 getTBody ( columns , data , sortBy , itemHeight ) {
274- const buildRowOptions = this . props . buildRowOptions ;
274+ const { buildRowOptions, virtualizeDataThreshold } = this . props ;
275275 let childToMeasure ;
276276
277277 if ( itemHeight === 0 && data . length ) {
@@ -290,13 +290,32 @@ class Table extends React.Component {
290290 return < tbody > { this . getEmptyRowCell ( columns ) } </ tbody > ;
291291 }
292292
293+ const sortedData = sortData ( columns , data , sortBy ) ;
294+
295+ if ( data . length < virtualizeDataThreshold ) {
296+ // Do not use virtual list for "small" data sets
297+ return (
298+ < tbody >
299+ { sortedData . map ( ( item , index ) => {
300+ return this . getRowCells (
301+ columns ,
302+ sortBy ,
303+ buildRowOptions ,
304+ item ,
305+ index
306+ ) ;
307+ } ) }
308+ </ tbody >
309+ ) ;
310+ }
311+
293312 return (
294313 < VirtualList
295314 className = "table-virtual-list"
296315 container = { this . container }
297316 itemBuffer = { 70 }
298317 itemHeight = { itemHeight }
299- items = { sortData ( columns , data , sortBy ) }
318+ items = { sortedData }
300319 renderBufferItem = { this . getBufferItem . bind ( this , columns ) }
301320 renderItem = { this . getRowCells . bind (
302321 this ,
@@ -336,7 +355,8 @@ Table.defaultProps = {
336355 return { } ;
337356 } ,
338357 sortBy : { } ,
339- emptyMessage : "No data"
358+ emptyMessage : "No data" ,
359+ virtualizeDataThreshold : 1000
340360} ;
341361
342362Table . propTypes = {
@@ -405,7 +425,10 @@ Table.propTypes = {
405425 sortBy : PropTypes . shape ( {
406426 order : PropTypes . oneOf ( [ "asc" , "desc" ] ) ,
407427 prop : PropTypes . oneOfType ( [ PropTypes . string , PropTypes . number ] )
408- } )
428+ } ) ,
429+
430+ // Optional cutoff at which to begin rendering a virtualized list
431+ virtualizeDataThreshold : PropTypes . number
409432} ;
410433
411434module . exports = Table ;
0 commit comments