Comments (6)
Please see if my answer about using clear: both
fixes your issue as I first wrote here #14.
from react-infinite-scroller.
I added it the the component, so it is now:
loader={<div style={{ clear: 'both' }}>Loading...</div>}
But it is still not working. Important to note that if I remove the loader prop, it does not do the infinite fetching if scrolled to the bottom, however a user would never know that there are now more items to view below the last list item.
from react-infinite-scroller.
It's the way you're merging newItems
. Doing the following removes the issue with your example (thanks for providing the full code π)
const items = this.state.items.concat(newItems);
this.setState({
items,
start
});
I thought [...old, ...new]
would return a new array (as I'm guessing you thought) but React must see that as a mutation and therefore the items appear above the scroll position.
from react-infinite-scroller.
Your response got me curious as to why it was re-rendering. Turns out the problem was my key
prop going into the items.
changed
key={Date.now() + item}
to
key={item}
It was unique everytime :( ... can't say it wasn't my first time making that mistake. Thanks for the help tho!
from react-infinite-scroller.
I made that change too but assumed it was the former change that fixed it! π
from react-infinite-scroller.
Also, it's better to add .map((item, i) => ...
and then key={i}
, it doesn't have to be unique across the whole app, just that loop
from react-infinite-scroller.
Related Issues (20)
- Imports failure while building with Vite HOT 1
- Is it possible to reset the start page when requesting new data or switching the filter? HOT 2
- bug: changing hasMore before you scroll down doesnt update component HOT 1
- useWindow={true} not working HOT 2
- loadmore and then, scroll return the firstpage HOT 1
- Support TypeScript HOT 1
- New data doesn't get fetched when thereΒ΄s no scrollbar HOT 4
- Upgrading to React 18 breaks remove event listeners. HOT 7
- support virtual dom HOT 2
- Pull to refresh not works on latest versions HOT 1
- Add feature to render it as a React Fragment with the element prop HOT 1
- Why is `page` prop called `page`?
- Virtual dom
- How to pull up the element and get data from last page?
- getScrollParent doesn't work with ref, but works with id HOT 1
- RollupError: "default" is not exported by "node_modules/react-infinite-scroller/index.js"
- isReverse broken with combination of column-reverse HOT 4
- Warning: Each child in a list should have a unique "key" prop. HOT 1
- Installation Error Not compatible for react version 18 HOT 2
- Project is still maintained?
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-infinite-scroller.