Giter VIP home page Giter VIP logo

Comments (6)

danbovey avatar danbovey commented on September 23, 2024

Please see if my answer about using clear: both fixes your issue as I first wrote here #14.

from react-infinite-scroller.

yussinsharp avatar yussinsharp commented on September 23, 2024

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.

danbovey avatar danbovey commented on September 23, 2024

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.

yussinsharp avatar yussinsharp commented on September 23, 2024

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.

danbovey avatar danbovey commented on September 23, 2024

I made that change too but assumed it was the former change that fixed it! πŸ˜†

from react-infinite-scroller.

danbovey avatar danbovey commented on September 23, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.