Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Component extends React.Component {
- constructor(props) {
- super(props);
- this.state = {
- location: '',
- };
- }
- static getDerivedStateFromProps(nextProps, prevState) {
- return {
- location: nextProps.location.pathname,
- };
- }
- render() {....}
- }
- const EnhancedComponent = withRouter(Component);
- export default EnhancedComponent;
Add Comment
Please, Sign In to add comment