InfiniteLoader with FlexTable doesn't work correctly
See original GitHub issueI tried the demo with the InfiniteLoader
using a VirtualScroll
and it posed no problems. But when I exchanged the VirtualScroll
with the FlexTable
it results in an unexpected behaviour.
It seems to start loading the items but doesn’t rerender the items until I scroll again.
This gif shows the issue:
When you initialize the list, it’ll say loading forever. No matter how long you wait. But as soon as you start scrolling, the loaded date will be rendered)
vs expected behavior (using VirtualScroll
):
Code using FlexTable
:
import * as React from 'react'
import {AutoSizer, InfiniteLoader, FlexColumn, FlexTable} from 'react-virtualized'
interface Props {
model: any
}
export default class InifiniteTable extends React.Component<Props, {}> {
list = [
{ name: 'Brian Vaughn', description: 'Software engineer', loaded: false },
{ name: 'John Doe', description: 'PM', loaded: false },
];
constructor() {
super()
for (let i = 0; i < 3000000; i++) {
this.list.push({ name: 'John Doe', description: 'PM', loaded: false })
}
}
loadMoreRows = ({startIndex, stopIndex}) => {
console.log(`loading more rows ${startIndex} - ${stopIndex}`)
return new Promise(
(resolve) =>
setTimeout(() => {
for (let i = startIndex; i < stopIndex; i++) {
this.list[i].loaded = true
}
resolve(this.list.slice(startIndex, stopIndex))
}, 1000)
)
}
render() {
let width = 408 / this.props.model.fields.edges.length
return (
<div style={{height: '100%'}}>
<InfiniteLoader
rowCount={this.list.length}
isRowLoaded={({index}) => this.list[index].loaded}
loadMoreRows={this.loadMoreRows}
>
{({onRowsRendered, registerChild}) => (
<AutoSizer>
{({width, height}) => (
<FlexTable
ref={registerChild}
width={width}
height={height}
onRowsRendered={onRowsRendered}
headerHeight={30}
rowHeight={30}
rowCount={this.list.length}
rowGetter={({index}) => this.list[index].loaded ? this.list[index] : ({name: 'loading', description: 'loading'})}
>
<FlexColumn label='Name' dataKey='name' width={width / 2} />
<FlexColumn label='Description' dataKey='description' width={width / 2} />
</FlexTable>
)}
</AutoSizer>
)}
</InfiniteLoader>
</div>
)
}
}
Issue Analytics
- State:
- Created 7 years ago
- Comments:14 (9 by maintainers)
Top Results From Across the Web
React-Virtualized Infinite Loader Not Scrolling Through ...
The FlexTable didn't rerender a row when the data changed until I started scrolling. but the data is there before and it should...
Read more >Chapter 4 Rendering | Using the flextable R package
When working in RStudio, flextable will be printed in the rstudio viewer pane, the default format is HTML output. flextable objects can be...
Read more >react-virtualized - UNPKG
36, Fixed edge-case bug where `InfiniteLoader` did not respect ... FlexTable__Grid` classes to fix edge-case scrollbar bug experienced by some users.
Read more >react-virtualized | Yarn - Package Manager
This supports special use-cases where deferred measuring is not desired. Added estimatedRowSize property to FlexTable and VirtualScroll to be passed through to ...
Read more >bvaughn/react-virtualized - Gitter
@jpollard-cs You can use CellMeasurer and InfiniteLoader together, ... If your total rowCount is activities + contributions, then that should work.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Check out release 7.22.1 ~ should be fixed for you 😄
Thanks for the nice bug report.
In either way, the fix is easy (despite being a bit hackish). I’ll add some tests and inline comments explaining the reasoning…then I should be able to deploy. If not before lunch, then sometime this afternoon. I’ll ping this issue again once the fix is live.