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.

Preseving item state after scrolling away

See original GitHub issue

Hi 😃

Just wanted to say thank you for the most simple virtualization library I’ve ever seen. I’ve been through react-virtualized and react-window, and this one is just heaven.

I do have one question though: When I expand one of my list items, It won’t be expanded the next time it will be mounted. In other words - it seems like I lose the component’s state when it’s out of view.

Here’s an example:

d3dd7770-b74f-4277-8aad-f99837e3b133

As you can see, the default state is collapsed. I expand one of the items, scroll down, and scroll back up to make it inside the view again, and it’s collapsed again. You can see the scrollbar jumping a few pixels when the list item gets remounted with a wrong height (collapsed instead of expanded, but the virtual list remembers the last height).

I couldn’t find anything related to this on docs.

How can this be solved? I imagine some kind of memoization, but I couldn’t make it work.

Thanks!

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
fonty422commented, Jun 9, 2021

Here’s a basic sandbox complete with a basic redux set up. If you’re not familiar with using redux, this might appear a bit confusing and I recommend a good tutorial - perhaps even a tutorial series. I’ve tried to add plenty of comments where I think they’re needed for clarification.

1reaction
pyretacommented, Mar 4, 2021

@itayganor Can I see the code for this expandable list you made?

Read more comments on GitHub >

github_iconTop Results From Across the Web

How can I retain the scroll position of a scrollable area when ...
During page unload, get the scroll position and store it in local storage. Then during page load, check local storage and set that...
Read more >
Storing and Restoring Scroll Position with React Window
Create a bit of state storing the user's most recent scroll location. Navigate the user to their most recent scroll location on table...
Read more >
Preserve scroll position in prototypes - Figma Help Center
The preserve scroll position setting lets you keep the same scroll location when you transition between screens. This applies to vertical scroll depth,...
Read more >
Scroll-Then-Fix Content | CSS-Tricks
Switching States. The trick here is applying that class at just the right moment. In our little demo, we can just test for...
Read more >
Saving Scroll Positions of Nested RecyclerViews - Medium
The idea behind this solution is that we will save the current scroll index of each horizontal carousel in some data structure before...
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