Skip to content

Instantly share code, notes, and snippets.

@HaNdTriX
Created July 19, 2017 00:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save HaNdTriX/915e86c82da224bd3383c965de43fce6 to your computer and use it in GitHub Desktop.
Save HaNdTriX/915e86c82da224bd3383c965de43fce6 to your computer and use it in GitHub Desktop.
next.js withRoute hoc
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