Skip to content

Instantly share code, notes, and snippets.

View wesokuhara's full-sized avatar
🎯
Focusing

Wes Okuhara wesokuhara

🎯
Focusing
View GitHub Profile
// Often you will need to scroll to the top of a long page, that when navigated to stays scrolled down. Make sure to wrap it in withRouter to give it access to the Router's props.
import React, { Component } from 'react';
import { withRouter } from 'react-router-dom';
class ScrollTopOnNavigation extends Component {
componentDidUpdate(prevProps) {
if (this.props.location !== prevProps.location) {
window.scrollTo(0, 0);
}
}

Keybase proof

I hereby claim:

  • I am wesokuhara on github.
  • I am wesokuhara (https://keybase.io/wesokuhara) on keybase.
  • I have a public key ASAGzuTWyD8z5ss93ffyYPF6-H6aD5BQMRdEOS-VuwkYego

To claim this, I am signing this object: