Skip to content

Instantly share code, notes, and snippets.

View Gurenax's full-sized avatar
🇦🇺

Glenn Dimaliwat Gurenax

🇦🇺
View GitHub Profile
@Gurenax
Gurenax / ScrollToTop.js
Last active March 7, 2018 11:28
Enable scroll to top on every Route in react-router
import { Component } from 'react'
import { withRouter } from 'react-router'
import PropTypes from 'prop-types'
class ScrollToTop extends Component {
componentDidUpdate(prevProps) {
if (this.props.location !== prevProps.location) {
window.scrollTo(0, 0)
}
}
@Gurenax
Gurenax / App.js
Created March 7, 2018 10:31
React Router Nav Links - Highlighting Active Links
import React, { Component } from 'react'
import { BrowserRouter as Router, Route, Switch, NavLink } from 'react-router-dom'
import './App.css'
class App extends Component {
render() {
return (
<div className="App">
<h1>React Router Nav Links</h1>

Keybase proof

I hereby claim:

  • I am gurenax on github.
  • I am gurenax (https://keybase.io/gurenax) on keybase.
  • I have a public key ASCEAqoHGt8TW0KXAQoHebYzaWk-9DPDIc4ItRvSyL8RJAo

To claim this, I am signing this object: