Created
December 5, 2018 13:52
-
-
Save NGMarmaduke/9db900b7b5f4c9434aab02eb6ed94d52 to your computer and use it in GitHub Desktop.
withUrlParams HOC
This file contains 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 { withRouter } from "react-router"; | |
import queryString from "query-string"; | |
const withUrlParams = Component => { | |
const C = ({ location, ...rest }) => { | |
const params = queryString.parse(location.search); | |
return <Component urlParams={params} {...rest} />; | |
}; | |
return withRouter(C); | |
}; | |
export default withUrlParams; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment