🤔 Container scrolls back to top when new data is loaded
See original GitHub issueI’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:
- Created 5 years ago
- Reactions:2
- Comments:9 (2 by maintainers)
Top 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 >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
@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.
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