Skip to content

Instantly share code, notes, and snippets.

@maximgatilin
Created August 10, 2018 05:43
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 maximgatilin/bc03d278999f5a5a19ff0d2e3895e8e2 to your computer and use it in GitHub Desktop.
Save maximgatilin/bc03d278999f5a5a19ff0d2e3895e8e2 to your computer and use it in GitHub Desktop.
import {browserHistory} from 'react-router';
export function getValueFromUrl(input) {
const [pathname, prop] = input.split('.');
const currentLocation = browserHistory.getCurrentLocation();
if (currentLocation.pathname !== `/${pathname}`) {
return null;
}
const targetProp = currentLocation.query[prop];
return targetProp === undefined ? null : targetProp;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment