Skip to content

Instantly share code, notes, and snippets.

@steevehook
Forked from wwwhatley/App.jsx
Created July 16, 2018 06:34
Show Gist options
  • Save steevehook/1a4939d21cb1627f765ff09bb15da0e6 to your computer and use it in GitHub Desktop.
Save steevehook/1a4939d21cb1627f765ff09bb15da0e6 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