Created
August 7, 2018 21:46
-
-
Save manoelneto/3fe1fa7330ef70186811a021df4b3318 to your computer and use it in GitHub Desktop.
withRouter.js
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
| export default const withRouter = (OriginalComponent) => { | |
| class NewComponent extends Component { | |
| state = { | |
| router: initialRouter | |
| } | |
| anotherFunc = () => { | |
| ... | |
| } | |
| render() { | |
| <OriginalComponent {...this.props} router={this.state.router} anotherFunc={this.anotherFunc} /> | |
| } | |
| } | |
| return NewComponent | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment