MCPcopy
hub / github.com/molefrog/wouter / Route

Function Route

packages/wouter/src/index.js:240–261  ·  view source on GitHub ↗
({ path, nest, match, ...renderProps })

Source from the content-addressed store, hash-verified

238}
239
240export const Route = ({ path, nest, match, ...renderProps }) => {
241 const router = useRouter();
242 const [location] = useLocationFromRouter(router);
243
244 const [matches, routeParams, base] =
245 // `match` is a special prop to give up control to the parent,
246 // it is used by the `Switch` to avoid double matching
247 match ?? matchRoute(router.parser, path, location, nest);
248
249 // when `routeParams` is `null` (there was no match), the argument
250 // below becomes {...null} = {}, see the Object Spread specs
251 // https://tc39.es/proposal-object-rest-spread/#AbstractOperations-CopyDataProperties
252 const params = useCachedParams({ ...useParams(), ...routeParams });
253
254 if (!matches) return null;
255
256 const children = base
257 ? h(Router, { base }, h_route(renderProps, params))
258 : h_route(renderProps, params);
259
260 return h(ParamsCtx.Provider, { value: params, children });
261};
262
263export const Link = forwardRef((props, ref) => {
264 const router = useRouter();

Callers

nothing calls this directly

Calls 6

useRouterFunction · 0.85
useLocationFromRouterFunction · 0.85
matchRouteFunction · 0.85
useCachedParamsFunction · 0.85
useParamsFunction · 0.85
h_routeFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…