question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

🤔 Container scrolls back to top when new data is loaded

See original GitHub issue

I’m using this Component with useWindow set to false and the height of the parent set to 64vh.

The loader works just fine, calls the api at the end of the list, but when new data is loaded, it scrolls to the top of the list.

I’m using redux here. My code looks like this :

<div style={{height}} className={`overflow-y-scroll ${className}`}>
    <ReactInfiniteScroll
      loadMore={onEndReached}
      hasMore={hasMore}
      loader={loader}
      useWindow={useWindow}
      threshold={8}
      // initialLoad={false}
    >
      {children}
    </ReactInfiniteScroll>
  </div>

and the children here are :

{conversations.map(c => <Row key={c.id} conversation={c}/>)}

Thanks.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
ilkermutlucommented, May 20, 2020

@shivekkhurana thanks.

Turns out mine doesn’t have to do anything with the reducer as well. I think I solved it by updating my render logic. Just the same as you guys.

1reaction
shivekkhuranacommented, Oct 24, 2018

I figured that it was a bug in my rendering logic that removed and added the listview back each time.

This gave me the impression that the list view scrolled back to the top, but in reality, it was being re-rendered. Closing the issue as there is nothing wrong with this library.

Thanks

Read more comments on GitHub >

github_iconTop Results From Across the Web

Scroll back to the top of scrollable div - Stack Overflow
When a variableLongtext is loaded in the container div and am looking at the middle of it, then swipe to the new variableLongtext,...
Read more >
Option to maintain current scroll position? · Issue #37 - GitHub
This solution doesn't seem to be working anymore. It seems as though turbo is scrolling back to the top after the turbo:load event...
Read more >
overscroll-behavior - CSS: Cascading Style Sheets | MDN
The overscroll-behavior CSS property sets what a browser does when reaching the boundary of a scrolling area.
Read more >
How To Create a Scroll Back To Top Button - W3Schools
Well organized and easy to understand Web building tutorials with lots of examples of how to use HTML, CSS, JavaScript, SQL, Python, PHP,...
Read more >
Scroll to the top of the page using JavaScript/jQuery
Method 2: Using scrollTop() in jQuery: In jQuery, the scrollTo() method is used to set or return the vertical scrollbar position for a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found