Created
July 19, 2017 00:42
-
-
Save HaNdTriX/915e86c82da224bd3383c965de43fce6 to your computer and use it in GitHub Desktop.
next.js withRoute hoc
This file contains hidden or 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 React from 'react' | |
import Router from 'next/router' | |
const widthRoute = (Component) => { | |
return class extends React.Component { | |
componentDidMount() { | |
this.route = Router.route() | |
this.forceUpdate() | |
} | |
render() { | |
return <Component {this.props.children} route={this.route} /> | |
} | |
} | |
} | |
export default withRoute |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment