Comments (9)
No problem.
I'm tempted to say that in this case, you should just trigger your own reload for the currently-visible rows (since your component is flushing the cached state). You already have the necessary information to do this if you just tapped into the onRowsRendered
callback like so:
<InfiniteLoader
isRowLoaded={this._isRowLoaded}
loadMoreRows={this._loadMoreRows}
rowsCount={list.size}
>
{({ onRowsRendered, registerChild }) => (
<AutoSizer disableHeight>
{({ width }) => (
<VirtualScroll
ref={virtScroll => {
// EDITED #2
this.virtScroll = virtScroll;
registerChild(virtScroll);
}}
className={styles.VirtualScroll}
height={200}
onRowsRendered={({ startIndex, stopIndex }) => {
this._visibleRowStartIndex = startIndex
this._visibleRowStopIndex = stopIndex
onRowsRendered({ startIndex, stopIndex })
}}
rowsCount={list.size}
rowHeight={30}
rowRenderer={this._rowRenderer}
scrollToIndex={randomScrollToIndex}
width={width}
/>
)}
</AutoSizer>
)}
</InfiniteLoader>
Then when you cleared the cache you could kick off reloading for the visible range:
_clearData () {
this.setState({
loadedRowsCount: 0,
loadedRowsMap: {},
loadingRowsCount: 0
});
// EDITED #1
if (this.virtScroll) {
this.virtScroll.forceUpdate();
}
if (this._visibleRowStartIndex >= 0) {
this._loadMoreRows ({
startIndex: this._visibleRowStartIndex,
stopIndex: this._visibleRowStopIndex
})
}
}
from react-virtualized.
Hi @willemx,
Yes. VirtualScroll
(or FlexTable
) could totally be used as you describe. Any time the rowsCount
property changes, the components will automatically update.
If you think there's a chance of an existing row changing then you could just call forceUpdate
to make the list redraw its visible rows. If you are making use of the dynamic rowHeight
feature and the change may have invalidated the height of the visible rows, then you could call recomputeRowHeights
.
Does this answer your question? :)
from react-virtualized.
Yes, thanks!
from react-virtualized.
@bvaughn , thanks for you answer. I've tried it and it really forces rendering. VirtualScroll calls the callback rowRender for each row now. But how to make it also call the callback isRowLoaded? I have a case when I need to invalidate and reload the rows that are currently shown.
from react-virtualized.
@ArtemZag sounds like you're also using the InfiniteLoader
HOC?
That is called when the onRowsRendered
callback is invoked, which should happen each time a virtual component renders... ah, except that I "memoize" things so the rows rendered callback isn't called a bunch of times with the same values if a user is slow-scrolling.
I guess I'm not clear on your use case to be honest. If you've just invalidated the data by updating it as was originally described in this issue- then can't you manually trigger your isRowLoaded
function in that case (if you need to)?
from react-virtualized.
@bvaughn ,
Yes, you are right - I use InfiniteLoader
. Sorry I didn't say this before.
can't you manually trigger your isRowLoaded function in that case (if you need to)?
I mean callback isRowLoaded
of InfiniteLoader.
Not my own function.
I guess I'm not clear on your use case to be honest.
My fault. I'll try to create some small example tomorrow to show you what I mean.
from react-virtualized.
Hi @bvaughn . Sorry for the late answer.
I've created brief example (based on this: https://bvaughn.github.io/react-virtualized/ -> tab "INFINITELOADER")
Here it is: https://github.com/ArtemZag/infinite-loader-example
Take a look at line 82 and 110 of InfiniteLoader.example.js.
My example does the same thing original example does but I also try to reload the data from the source. In my example if you click "Flush data" you'll see list with empty values. But I'd like to force InfiniteLoader
to reload the rows. And I have no idea how to do it. Maybe you will help me.
P.S.: It does reload the rows if you scroll the list (even if you scroll just 1 row). But I need to do it on "Flush data" click.
from react-virtualized.
@bvaughn , cool! This is exactly what I need. Than you very much.
from react-virtualized.
Happy to hear :) You're welcome.
On Saturday, February 20, 2016, ArtemZag [email protected] wrote:
@bvaughn https://github.com/bvaughn , cool! This is exactly what I
need. Than you very much.—
Reply to this email directly or view it on GitHub
#69 (comment)
.
from react-virtualized.
Related Issues (20)
- [Question] What are the criteria for determining the number of rows in a list?
- Your official website is blocked HOT 1
- Main link is broken HOT 1
- Access to Multigrid public method recomputeGridSize() returns undefined
- Version 9.22.5 is a ghost not visible in this repository?
- Height Issue after rendering
- Virtualisation fail ? Why invisible content is added to my list ?
- react18.2.0 HOT 1
- Tips for displaying a dropdown to overflow the React Virtualized container without being hidden?
- Failed to fetch dynamically
- The styles.css isn't part of the 9.23.0 version
- How to load JSON-formatted data virtually?
- TypeError : RegisterChild in WindowScroller
- Props ScrollElement of WindowScroller load every items if parent is InfiniteLoader HOT 2
- Autosizer component does not accept any refs or spread props.
- Change scrolling approach for Table component
- Table's data columns are not resized until scrolling the content [regression]
- `scrollToRow()` on `List` with `WindowScroller` not working HOT 2
- How to use search functionality similar to ctrl+f using react-virtualized HOT 1
- Rows with dynamic height overlap when using CellMeasurer HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-virtualized.