Skip to content

Instantly share code, notes, and snippets.

@NGMarmaduke
Created December 5, 2018 13:52
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 NGMarmaduke/9db900b7b5f4c9434aab02eb6ed94d52 to your computer and use it in GitHub Desktop.
Save NGMarmaduke/9db900b7b5f4c9434aab02eb6ed94d52 to your computer and use it in GitHub Desktop.
withUrlParams HOC
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