Created
June 28, 2018 15:54
-
-
Save wwwhatley/c9baafb39f9c2227c85798e6d00de803 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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