New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Preseving item state after scrolling away #141
Comments
storing the expanded state in list’s parent would be a solution. Propagate the expanded event and store it in object or something and pass down the expanded state to list element. |
This is indeed a good solution, but the thing is the state might contain more than just the expansion state. I'm actually trying to achieve a generic component that will accept any kind of item as a child, and remember each one's state when it's not visible. Passing a |
It's not possible to have it stored in the object its self. You have two choices:
The second one is definitely my preferred option as all my data for the entire app is already held in a redux store. |
I second the suggestions provided here - the item state should be preserved externally, using the state management of your choice. |
@itayganor Can I see the code for this expandable list you made? |
As in just for the list, or including the redux part? |
@fonty422 Just for the list would be good enough, but redux would be a nice-to-have :-) |
Here's a basic sandbox complete with a basic redux set up. |
Thank you fonty422. Much appreciated. I see the Accordion control is a bit cleaner to use than the Collapse control. |
Hi :)
Just wanted to say thank you for the most simple virtualization library I've ever seen. I've been through
react-virtualized
andreact-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:
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!
The text was updated successfully, but these errors were encountered: