Skip to content

Instantly share code, notes, and snippets.

@samidarko
Last active March 7, 2016 08:32
Show Gist options
  • Save samidarko/7e2de3cd70653655b868 to your computer and use it in GitHub Desktop.
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
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