-
-
Save steevehook/1a4939d21cb1627f765ff09bb15da0e6 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