Skip to content

Fix misuse of second argument as nextState (the actual argument is prevState) #27

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

Merged
merged 1 commit into from
Oct 24, 2017

Conversation

gabrielecirulli
Copy link
Contributor

I am working on a horizontal timeline that uses react-tiny-virtual-list to reduce the amount of items rendered at any one time. Clicking on an item on this timeline should center it horizontally. I noticed that when clicking on an item after scrolling, the item would not center.

This fixes instances where, right after scrolling, a change in the scrollToIndex prop will not actually scroll to the item at the passed index correctly. This is due to the componentDidUpdate method considering the previous state to actually be the next state and looking at scrollChangeReason on it, seeing the old scrollChangeReason caused by the user scrolling, thus not calling scrollTo to actually center the element.

…evState)

This fixes instances where, right after scrolling, a change in the
`scrollToIndex` prop will not actually scroll to the item at the passed
index correctly. This is due to the `componentDidUpdate` method
considering the previous state to actually be the next state and
looking at `scrollChangeReason` on it, seeing the old
`scrollChangeReason` caused by the user scrolling, thus not calling
`scrollTo` to actually center the element.
Copy link
Owner

@clauderic clauderic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh man, good catch 🙈

@clauderic clauderic merged commit caa304f into clauderic:master Oct 24, 2017
@clauderic
Copy link
Owner

Just published this change in 2.1.4, thanks again for your contribution 😄

@gabrielecirulli
Copy link
Contributor Author

Perfect, thank you very much!

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

Successfully merging this pull request may close these issues.

2 participants