Last active
March 7, 2016 08:32
-
-
Save samidarko/7e2de3cd70653655b868 to your computer and use it in GitHub Desktop.
how to preserve your window of scrolling up after rendering/updating a list in react
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
componentWillUpdate() { | |
this.scrollY = window.scrollY; | |
} | |
componentDidUpdate() { | |
if (this.scrollY) { | |
window.scroll(0, this.scrollY); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment