Guest User

Untitled

a guest
Apr 27th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. class Component extends React.Component {
  2. constructor(props) {
  3. super(props);
  4.  
  5. this.state = {
  6. location: '',
  7. };
  8. }
  9.  
  10. static getDerivedStateFromProps(nextProps, prevState) {
  11. return {
  12. location: nextProps.location.pathname,
  13. };
  14. }
  15.  
  16. render() {....}
  17. }
  18.  
  19. const EnhancedComponent = withRouter(Component);
  20. export default EnhancedComponent;
Add Comment
Please, Sign In to add comment