Skip to content
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

stateupdate scrolls list to top #113

Closed
davalapar opened this issue Dec 25, 2018 · 3 comments
Closed

stateupdate scrolls list to top #113

davalapar opened this issue Dec 25, 2018 · 3 comments

Comments

@davalapar
Copy link

Hi, I'm using this list to display chat messages (which the variablelist fits well) and I'm wondering why is it that when I get state updates, ie. the user types something, the list scrolls to top.

I'm aware with ref scrollToItem but it's snappy (scrolls to top first, then scrolls to the item, fast). Setting initialScrollOffset to 99999 seems to help but I'm pretty sure I'm doing something wrong here right? </3

@TrySound
Copy link
Contributor

I think this issue is related to yours.
#105

@davalapar
Copy link
Author

davalapar commented Dec 26, 2018

Dang this is crazy, thanks for responding mate.

  1. Could I get away by wrapping it as another component and using shouldComponentUpdate instead?
  2. I got minor state updates like the message statuses like 'sent' and 'delivered', which according to my understanding requires a re-render - could there be a way to at least preserve the scroll position to not affect user experience?

@davalapar
Copy link
Author

davalapar commented Dec 26, 2018

Eventually fixed it. My list kept on re-rendering because I was wrapping it in a component similar to react-virtualized's AutoSizer. I ended up un-wrapping it and using the local component state instead to auto-size that part.

I have no idea why it happens but all that matters now is it really works as it should, I can even update message statuses from sent to delivered and the list won't unexpectedly scroll anywhere - very beautiful.

Thank you guys for this component, it's perfect as hell!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants