Skip to content

Instantly share code, notes, and snippets.

@stuartc
Created February 25, 2016 13:10
Show Gist options
  • Save stuartc/def41f2e1c9b36fdb44d to your computer and use it in GitHub Desktop.
Save stuartc/def41f2e1c9b36fdb44d to your computer and use it in GitHub Desktop.
React Router Pattern Match by Hand
import { matchPattern } from "react-router/lib/PatternUtils";
import { zipObject } from "lodash";
const matchedPattern = matchPattern("/receipts/:id/inspect", location.pathname)
const params = zipObject(matchedPattern.paramNames, matchedPattern.paramValues)
console.log(params);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment