react-router
Version:
A complete routing library for React
21 lines (16 loc) • 468 B
JavaScript
import { getParamNames } from './PatternUtils';
/**
* Extracts an object of params the given route cares about from
* the given params object.
*/
function getRouteParams(route, params) {
var routeParams = {};
if (!route.path) return routeParams;
getParamNames(route.path).forEach(function (p) {
if (Object.prototype.hasOwnProperty.call(params, p)) {
routeParams[p] = params[p];
}
});
return routeParams;
}
export default getRouteParams;