);\n\n const matches = currentPathname.match(matcher);\n\n \u002F\u002F The route doesn't match\n \u002F\u002F Let's end this\n if (!matches) {\n return null;\n }\n\n \u002F\u002F First value is the corresponding value: currentPathname\n const matchValues = matches.slice(1);\n\n return pathParams.reduce(\n (acc, paramName, index) =\u003E {\n acc.params[paramName] = matchValues[index];\n return acc;\n },\n {\n params: {},\n element: route.element,\n \u002F\u002F We want the real path\n \u002F\u002F and not the one with path variables (ex :name)\n path: matches[0]\n }\n );\n}\n\nconst RouteContext = React.createContext({ params: {}, path: \"\" });\n\nexport const useRouteContext = () =\u003E useContext(RouteContext);\n\nexport const useParams = () =\u003E useRouteContext().params;\n\nexport default function Routes({ children }) {\n \u002F\u002F Get the current pathname\n const { pathname: currentPathname } = useLocation();\n \u002F\u002F Construct an Array of object corresponding to available Route elements\n const routeElements = buildRouteElementsFromChildren(children);\n\n \u002F\u002F We want to normalize the pahts\n \u002F\u002F They need to start by a \"\u002F\"\"\n normalizePathOfRouteElements(routeElements);\n\n \u002F\u002F A Routes component can only have one matching Route\n const matchingRoute = findFirstMatchingRoute(routeElements, currentPathname);\n\n \u002F\u002F No matching, let's show nothing\n if (!matchingRoute) {\n return null;\n }\n\n const { params, element, path } = matchingRoute;\n\n return (\n \u003CRouteContext.Provider\n value={{\n params,\n path\n }}\n \u003E\n {element}\n \u003C\u002FRouteContext.Provider\u003E\n );\n}\n","id":"mod_F299dNi2QJ4a5XGdNqZs26","is_binary":false,"title":"Routes.js","sha":null,"inserted_at":"2021-08-16T16:13:14","updated_at":"2021-08-28T08:53:40","upload_id":null,"shortid":"7zjnQ","source_id":"src_7HVpwoLeU8cJKn71g5Md16","directory_shortid":"B6Bkn"}],"is_sse":false,"inserted_at":"2021-08-16T16:13:14","always_on":false};