Skip to content

Instantly share code, notes, and snippets.

@wwwhatley
Created June 28, 2018 15:54
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save wwwhatley/c9baafb39f9c2227c85798e6d00de803 to your computer and use it in GitHub Desktop.
Save wwwhatley/c9baafb39f9c2227c85798e6d00de803 to your computer and use it in GitHub Desktop.
import {withRouter} from 'react-router-dom';
class App extends React.Component {
constructor() {
super();
this.state = {path: ''}
}
componentDidMount() {
let pathName = this.props.location.pathname;
this.setState(() => {
return {
path: pathName,
}
})
}
render() {
return (
<div>
<h1>Hi! I'm being rendered at: {this.state.path}</h1>
</div>
)
}
}
export default withRouter(App);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment