UNPKG

49.1 kBJavaScriptView Raw
1/**
2 * React Router v6.9.0
3 *
4 * Copyright (c) Remix Software Inc.
5 *
6 * This source code is licensed under the MIT license found in the
7 * LICENSE.md file in the root directory of this source tree.
8 *
9 * @license MIT
10 */
11import { UNSAFE_invariant, joinPaths, matchPath, UNSAFE_getPathContributingMatches, UNSAFE_warning, resolveTo, parsePath, matchRoutes, Action, isRouteErrorResponse, createMemoryHistory, stripBasename, AbortedDeferredError, createRouter } from '@remix-run/router';
12export { AbortedDeferredError, Action as NavigationType, createPath, defer, generatePath, isRouteErrorResponse, json, matchPath, matchRoutes, parsePath, redirect, resolvePath } from '@remix-run/router';
13import * as React from 'react';
14
15/**
16 * Copyright (c) Facebook, Inc. and its affiliates.
17 *
18 * This source code is licensed under the MIT license found in the
19 * LICENSE file in the root directory of this source tree.
20 */
21/**
22 * inlined Object.is polyfill to avoid requiring consumers ship their own
23 * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
24 */
25
26function isPolyfill(x, y) {
27 return x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y // eslint-disable-line no-self-compare
28 ;
29}
30
31const is = typeof Object.is === "function" ? Object.is : isPolyfill; // Intentionally not using named imports because Rollup uses dynamic
32// dispatch for CommonJS interop named imports.
33
34const {
35 useState,
36 useEffect,
37 useLayoutEffect,
38 useDebugValue
39} = React;
40let didWarnOld18Alpha = false;
41let didWarnUncachedGetSnapshot = false; // Disclaimer: This shim breaks many of the rules of React, and only works
42// because of a very particular set of implementation details and assumptions
43// -- change any one of them and it will break. The most important assumption
44// is that updates are always synchronous, because concurrent rendering is
45// only available in versions of React that also have a built-in
46// useSyncExternalStore API. And we only use this shim when the built-in API
47// does not exist.
48//
49// Do not assume that the clever hacks used by this hook also work in general.
50// The point of this shim is to replace the need for hacks by other libraries.
51
52function useSyncExternalStore$2(subscribe, getSnapshot, // Note: The shim does not use getServerSnapshot, because pre-18 versions of
53// React do not expose a way to check if we're hydrating. So users of the shim
54// will need to track that themselves and return the correct value
55// from `getSnapshot`.
56getServerSnapshot) {
57 {
58 if (!didWarnOld18Alpha) {
59 if ("startTransition" in React) {
60 didWarnOld18Alpha = true;
61 console.error("You are using an outdated, pre-release alpha of React 18 that " + "does not support useSyncExternalStore. The " + "use-sync-external-store shim will not work correctly. Upgrade " + "to a newer pre-release.");
62 }
63 }
64 } // Read the current snapshot from the store on every render. Again, this
65 // breaks the rules of React, and only works here because of specific
66 // implementation details, most importantly that updates are
67 // always synchronous.
68
69
70 const value = getSnapshot();
71
72 {
73 if (!didWarnUncachedGetSnapshot) {
74 const cachedValue = getSnapshot();
75
76 if (!is(value, cachedValue)) {
77 console.error("The result of getSnapshot should be cached to avoid an infinite loop");
78 didWarnUncachedGetSnapshot = true;
79 }
80 }
81 } // Because updates are synchronous, we don't queue them. Instead we force a
82 // re-render whenever the subscribed state changes by updating an some
83 // arbitrary useState hook. Then, during render, we call getSnapshot to read
84 // the current value.
85 //
86 // Because we don't actually use the state returned by the useState hook, we
87 // can save a bit of memory by storing other stuff in that slot.
88 //
89 // To implement the early bailout, we need to track some things on a mutable
90 // object. Usually, we would put that in a useRef hook, but we can stash it in
91 // our useState hook instead.
92 //
93 // To force a re-render, we call forceUpdate({inst}). That works because the
94 // new object always fails an equality check.
95
96
97 const [{
98 inst
99 }, forceUpdate] = useState({
100 inst: {
101 value,
102 getSnapshot
103 }
104 }); // Track the latest getSnapshot function with a ref. This needs to be updated
105 // in the layout phase so we can access it during the tearing check that
106 // happens on subscribe.
107
108 useLayoutEffect(() => {
109 inst.value = value;
110 inst.getSnapshot = getSnapshot; // Whenever getSnapshot or subscribe changes, we need to check in the
111 // commit phase if there was an interleaved mutation. In concurrent mode
112 // this can happen all the time, but even in synchronous mode, an earlier
113 // effect may have mutated the store.
114
115 if (checkIfSnapshotChanged(inst)) {
116 // Force a re-render.
117 forceUpdate({
118 inst
119 });
120 } // eslint-disable-next-line react-hooks/exhaustive-deps
121
122 }, [subscribe, value, getSnapshot]);
123 useEffect(() => {
124 // Check for changes right before subscribing. Subsequent changes will be
125 // detected in the subscription handler.
126 if (checkIfSnapshotChanged(inst)) {
127 // Force a re-render.
128 forceUpdate({
129 inst
130 });
131 }
132
133 const handleStoreChange = () => {
134 // TODO: Because there is no cross-renderer API for batching updates, it's
135 // up to the consumer of this library to wrap their subscription event
136 // with unstable_batchedUpdates. Should we try to detect when this isn't
137 // the case and print a warning in development?
138 // The store changed. Check if the snapshot changed since the last time we
139 // read from the store.
140 if (checkIfSnapshotChanged(inst)) {
141 // Force a re-render.
142 forceUpdate({
143 inst
144 });
145 }
146 }; // Subscribe to the store and return a clean-up function.
147
148
149 return subscribe(handleStoreChange); // eslint-disable-next-line react-hooks/exhaustive-deps
150 }, [subscribe]);
151 useDebugValue(value);
152 return value;
153}
154
155function checkIfSnapshotChanged(inst) {
156 const latestGetSnapshot = inst.getSnapshot;
157 const prevValue = inst.value;
158
159 try {
160 const nextValue = latestGetSnapshot();
161 return !is(prevValue, nextValue);
162 } catch (error) {
163 return true;
164 }
165}
166
167/**
168 * Copyright (c) Facebook, Inc. and its affiliates.
169 *
170 * This source code is licensed under the MIT license found in the
171 * LICENSE file in the root directory of this source tree.
172 *
173 * @flow
174 */
175function useSyncExternalStore$1(subscribe, getSnapshot, getServerSnapshot) {
176 // Note: The shim does not use getServerSnapshot, because pre-18 versions of
177 // React do not expose a way to check if we're hydrating. So users of the shim
178 // will need to track that themselves and return the correct value
179 // from `getSnapshot`.
180 return getSnapshot();
181}
182
183/**
184 * Inlined into the react-router repo since use-sync-external-store does not
185 * provide a UMD-compatible package, so we need this to be able to distribute
186 * UMD react-router bundles
187 */
188const canUseDOM = !!(typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined");
189const isServerEnvironment = !canUseDOM;
190const shim = isServerEnvironment ? useSyncExternalStore$1 : useSyncExternalStore$2;
191const useSyncExternalStore = "useSyncExternalStore" in React ? (module => module.useSyncExternalStore)(React) : shim;
192
193const DataRouterContext = /*#__PURE__*/React.createContext(null);
194
195{
196 DataRouterContext.displayName = "DataRouter";
197}
198
199const DataRouterStateContext = /*#__PURE__*/React.createContext(null);
200
201{
202 DataRouterStateContext.displayName = "DataRouterState";
203}
204
205const AwaitContext = /*#__PURE__*/React.createContext(null);
206
207{
208 AwaitContext.displayName = "Await";
209}
210
211const NavigationContext = /*#__PURE__*/React.createContext(null);
212
213{
214 NavigationContext.displayName = "Navigation";
215}
216
217const LocationContext = /*#__PURE__*/React.createContext(null);
218
219{
220 LocationContext.displayName = "Location";
221}
222
223const RouteContext = /*#__PURE__*/React.createContext({
224 outlet: null,
225 matches: []
226});
227
228{
229 RouteContext.displayName = "Route";
230}
231
232const RouteErrorContext = /*#__PURE__*/React.createContext(null);
233
234{
235 RouteErrorContext.displayName = "RouteError";
236}
237
238/**
239 * Returns the full href for the given "to" value. This is useful for building
240 * custom links that are also accessible and preserve right-click behavior.
241 *
242 * @see https://reactrouter.com/hooks/use-href
243 */
244
245function useHref(to, {
246 relative
247} = {}) {
248 !useInRouterContext() ? UNSAFE_invariant(false, // TODO: This error is probably because they somehow have 2 versions of the
249 // router loaded. We can help them understand how to avoid that.
250 `useHref() may be used only in the context of a <Router> component.`) : void 0;
251 let {
252 basename,
253 navigator
254 } = React.useContext(NavigationContext);
255 let {
256 hash,
257 pathname,
258 search
259 } = useResolvedPath(to, {
260 relative
261 });
262 let joinedPathname = pathname; // If we're operating within a basename, prepend it to the pathname prior
263 // to creating the href. If this is a root navigation, then just use the raw
264 // basename which allows the basename to have full control over the presence
265 // of a trailing slash on root links
266
267 if (basename !== "/") {
268 joinedPathname = pathname === "/" ? basename : joinPaths([basename, pathname]);
269 }
270
271 return navigator.createHref({
272 pathname: joinedPathname,
273 search,
274 hash
275 });
276}
277/**
278 * Returns true if this component is a descendant of a <Router>.
279 *
280 * @see https://reactrouter.com/hooks/use-in-router-context
281 */
282
283function useInRouterContext() {
284 return React.useContext(LocationContext) != null;
285}
286/**
287 * Returns the current location object, which represents the current URL in web
288 * browsers.
289 *
290 * Note: If you're using this it may mean you're doing some of your own
291 * "routing" in your app, and we'd like to know what your use case is. We may
292 * be able to provide something higher-level to better suit your needs.
293 *
294 * @see https://reactrouter.com/hooks/use-location
295 */
296
297function useLocation() {
298 !useInRouterContext() ? UNSAFE_invariant(false, // TODO: This error is probably because they somehow have 2 versions of the
299 // router loaded. We can help them understand how to avoid that.
300 `useLocation() may be used only in the context of a <Router> component.`) : void 0;
301 return React.useContext(LocationContext).location;
302}
303/**
304 * Returns the current navigation action which describes how the router came to
305 * the current location, either by a pop, push, or replace on the history stack.
306 *
307 * @see https://reactrouter.com/hooks/use-navigation-type
308 */
309
310function useNavigationType() {
311 return React.useContext(LocationContext).navigationType;
312}
313/**
314 * Returns a PathMatch object if the given pattern matches the current URL.
315 * This is useful for components that need to know "active" state, e.g.
316 * <NavLink>.
317 *
318 * @see https://reactrouter.com/hooks/use-match
319 */
320
321function useMatch(pattern) {
322 !useInRouterContext() ? UNSAFE_invariant(false, // TODO: This error is probably because they somehow have 2 versions of the
323 // router loaded. We can help them understand how to avoid that.
324 `useMatch() may be used only in the context of a <Router> component.`) : void 0;
325 let {
326 pathname
327 } = useLocation();
328 return React.useMemo(() => matchPath(pattern, pathname), [pathname, pattern]);
329}
330/**
331 * Returns an imperative method for changing the location. Used by <Link>s, but
332 * may also be used by other elements to change the location.
333 *
334 * @see https://reactrouter.com/hooks/use-navigate
335 */
336
337function useNavigate() {
338 !useInRouterContext() ? UNSAFE_invariant(false, // TODO: This error is probably because they somehow have 2 versions of the
339 // router loaded. We can help them understand how to avoid that.
340 `useNavigate() may be used only in the context of a <Router> component.`) : void 0;
341 let {
342 basename,
343 navigator
344 } = React.useContext(NavigationContext);
345 let {
346 matches
347 } = React.useContext(RouteContext);
348 let {
349 pathname: locationPathname
350 } = useLocation();
351 let routePathnamesJson = JSON.stringify(UNSAFE_getPathContributingMatches(matches).map(match => match.pathnameBase));
352 let activeRef = React.useRef(false);
353 React.useEffect(() => {
354 activeRef.current = true;
355 });
356 let navigate = React.useCallback((to, options = {}) => {
357 UNSAFE_warning(activeRef.current, `You should call navigate() in a React.useEffect(), not when ` + `your component is first rendered.`) ;
358 if (!activeRef.current) return;
359
360 if (typeof to === "number") {
361 navigator.go(to);
362 return;
363 }
364
365 let path = resolveTo(to, JSON.parse(routePathnamesJson), locationPathname, options.relative === "path"); // If we're operating within a basename, prepend it to the pathname prior
366 // to handing off to history. If this is a root navigation, then we
367 // navigate to the raw basename which allows the basename to have full
368 // control over the presence of a trailing slash on root links
369
370 if (basename !== "/") {
371 path.pathname = path.pathname === "/" ? basename : joinPaths([basename, path.pathname]);
372 }
373
374 (!!options.replace ? navigator.replace : navigator.push)(path, options.state, options);
375 }, [basename, navigator, routePathnamesJson, locationPathname]);
376 return navigate;
377}
378const OutletContext = /*#__PURE__*/React.createContext(null);
379/**
380 * Returns the context (if provided) for the child route at this level of the route
381 * hierarchy.
382 * @see https://reactrouter.com/hooks/use-outlet-context
383 */
384
385function useOutletContext() {
386 return React.useContext(OutletContext);
387}
388/**
389 * Returns the element for the child route at this level of the route
390 * hierarchy. Used internally by <Outlet> to render child routes.
391 *
392 * @see https://reactrouter.com/hooks/use-outlet
393 */
394
395function useOutlet(context) {
396 let outlet = React.useContext(RouteContext).outlet;
397
398 if (outlet) {
399 return /*#__PURE__*/React.createElement(OutletContext.Provider, {
400 value: context
401 }, outlet);
402 }
403
404 return outlet;
405}
406/**
407 * Returns an object of key/value pairs of the dynamic params from the current
408 * URL that were matched by the route path.
409 *
410 * @see https://reactrouter.com/hooks/use-params
411 */
412
413function useParams() {
414 let {
415 matches
416 } = React.useContext(RouteContext);
417 let routeMatch = matches[matches.length - 1];
418 return routeMatch ? routeMatch.params : {};
419}
420/**
421 * Resolves the pathname of the given `to` value against the current location.
422 *
423 * @see https://reactrouter.com/hooks/use-resolved-path
424 */
425
426function useResolvedPath(to, {
427 relative
428} = {}) {
429 let {
430 matches
431 } = React.useContext(RouteContext);
432 let {
433 pathname: locationPathname
434 } = useLocation();
435 let routePathnamesJson = JSON.stringify(UNSAFE_getPathContributingMatches(matches).map(match => match.pathnameBase));
436 return React.useMemo(() => resolveTo(to, JSON.parse(routePathnamesJson), locationPathname, relative === "path"), [to, routePathnamesJson, locationPathname, relative]);
437}
438/**
439 * Returns the element of the route that matched the current location, prepared
440 * with the correct context to render the remainder of the route tree. Route
441 * elements in the tree must render an <Outlet> to render their child route's
442 * element.
443 *
444 * @see https://reactrouter.com/hooks/use-routes
445 */
446
447function useRoutes(routes, locationArg) {
448 !useInRouterContext() ? UNSAFE_invariant(false, // TODO: This error is probably because they somehow have 2 versions of the
449 // router loaded. We can help them understand how to avoid that.
450 `useRoutes() may be used only in the context of a <Router> component.`) : void 0;
451 let {
452 navigator
453 } = React.useContext(NavigationContext);
454 let dataRouterStateContext = React.useContext(DataRouterStateContext);
455 let {
456 matches: parentMatches
457 } = React.useContext(RouteContext);
458 let routeMatch = parentMatches[parentMatches.length - 1];
459 let parentParams = routeMatch ? routeMatch.params : {};
460 let parentPathname = routeMatch ? routeMatch.pathname : "/";
461 let parentPathnameBase = routeMatch ? routeMatch.pathnameBase : "/";
462 let parentRoute = routeMatch && routeMatch.route;
463
464 {
465 // You won't get a warning about 2 different <Routes> under a <Route>
466 // without a trailing *, but this is a best-effort warning anyway since we
467 // cannot even give the warning unless they land at the parent route.
468 //
469 // Example:
470 //
471 // <Routes>
472 // {/* This route path MUST end with /* because otherwise
473 // it will never match /blog/post/123 */}
474 // <Route path="blog" element={<Blog />} />
475 // <Route path="blog/feed" element={<BlogFeed />} />
476 // </Routes>
477 //
478 // function Blog() {
479 // return (
480 // <Routes>
481 // <Route path="post/:id" element={<Post />} />
482 // </Routes>
483 // );
484 // }
485 let parentPath = parentRoute && parentRoute.path || "";
486 warningOnce(parentPathname, !parentRoute || parentPath.endsWith("*"), `You rendered descendant <Routes> (or called \`useRoutes()\`) at ` + `"${parentPathname}" (under <Route path="${parentPath}">) but the ` + `parent route path has no trailing "*". This means if you navigate ` + `deeper, the parent won't match anymore and therefore the child ` + `routes will never render.\n\n` + `Please change the parent <Route path="${parentPath}"> to <Route ` + `path="${parentPath === "/" ? "*" : `${parentPath}/*`}">.`);
487 }
488
489 let locationFromContext = useLocation();
490 let location;
491
492 if (locationArg) {
493 let parsedLocationArg = typeof locationArg === "string" ? parsePath(locationArg) : locationArg;
494 !(parentPathnameBase === "/" || parsedLocationArg.pathname?.startsWith(parentPathnameBase)) ? UNSAFE_invariant(false, `When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, ` + `the location pathname must begin with the portion of the URL pathname that was ` + `matched by all parent routes. The current pathname base is "${parentPathnameBase}" ` + `but pathname "${parsedLocationArg.pathname}" was given in the \`location\` prop.`) : void 0;
495 location = parsedLocationArg;
496 } else {
497 location = locationFromContext;
498 }
499
500 let pathname = location.pathname || "/";
501 let remainingPathname = parentPathnameBase === "/" ? pathname : pathname.slice(parentPathnameBase.length) || "/";
502 let matches = matchRoutes(routes, {
503 pathname: remainingPathname
504 });
505
506 {
507 UNSAFE_warning(parentRoute || matches != null, `No routes matched location "${location.pathname}${location.search}${location.hash}" `) ;
508 UNSAFE_warning(matches == null || matches[matches.length - 1].route.element !== undefined || matches[matches.length - 1].route.Component !== undefined, `Matched leaf route at location "${location.pathname}${location.search}${location.hash}" ` + `does not have an element or Component. This means it will render an <Outlet /> with a ` + `null value by default resulting in an "empty" page.`) ;
509 }
510
511 let renderedMatches = _renderMatches(matches && matches.map(match => Object.assign({}, match, {
512 params: Object.assign({}, parentParams, match.params),
513 pathname: joinPaths([parentPathnameBase, // Re-encode pathnames that were decoded inside matchRoutes
514 navigator.encodeLocation ? navigator.encodeLocation(match.pathname).pathname : match.pathname]),
515 pathnameBase: match.pathnameBase === "/" ? parentPathnameBase : joinPaths([parentPathnameBase, // Re-encode pathnames that were decoded inside matchRoutes
516 navigator.encodeLocation ? navigator.encodeLocation(match.pathnameBase).pathname : match.pathnameBase])
517 })), parentMatches, dataRouterStateContext || undefined); // When a user passes in a `locationArg`, the associated routes need to
518 // be wrapped in a new `LocationContext.Provider` in order for `useLocation`
519 // to use the scoped location instead of the global location.
520
521
522 if (locationArg && renderedMatches) {
523 return /*#__PURE__*/React.createElement(LocationContext.Provider, {
524 value: {
525 location: {
526 pathname: "/",
527 search: "",
528 hash: "",
529 state: null,
530 key: "default",
531 ...location
532 },
533 navigationType: Action.Pop
534 }
535 }, renderedMatches);
536 }
537
538 return renderedMatches;
539}
540
541function DefaultErrorComponent() {
542 let error = useRouteError();
543 let message = isRouteErrorResponse(error) ? `${error.status} ${error.statusText}` : error instanceof Error ? error.message : JSON.stringify(error);
544 let stack = error instanceof Error ? error.stack : null;
545 let lightgrey = "rgba(200,200,200, 0.5)";
546 let preStyles = {
547 padding: "0.5rem",
548 backgroundColor: lightgrey
549 };
550 let codeStyles = {
551 padding: "2px 4px",
552 backgroundColor: lightgrey
553 };
554 let devInfo = null;
555
556 {
557 devInfo = /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("p", null, "\uD83D\uDCBF Hey developer \uD83D\uDC4B"), /*#__PURE__*/React.createElement("p", null, "You can provide a way better UX than this when your app throws errors by providing your own\u00A0", /*#__PURE__*/React.createElement("code", {
558 style: codeStyles
559 }, "ErrorBoundary"), " prop on\u00A0", /*#__PURE__*/React.createElement("code", {
560 style: codeStyles
561 }, "<Route>")));
562 }
563
564 return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("h2", null, "Unexpected Application Error!"), /*#__PURE__*/React.createElement("h3", {
565 style: {
566 fontStyle: "italic"
567 }
568 }, message), stack ? /*#__PURE__*/React.createElement("pre", {
569 style: preStyles
570 }, stack) : null, devInfo);
571}
572
573class RenderErrorBoundary extends React.Component {
574 constructor(props) {
575 super(props);
576 this.state = {
577 location: props.location,
578 error: props.error
579 };
580 }
581
582 static getDerivedStateFromError(error) {
583 return {
584 error: error
585 };
586 }
587
588 static getDerivedStateFromProps(props, state) {
589 // When we get into an error state, the user will likely click "back" to the
590 // previous page that didn't have an error. Because this wraps the entire
591 // application, that will have no effect--the error page continues to display.
592 // This gives us a mechanism to recover from the error when the location changes.
593 //
594 // Whether we're in an error state or not, we update the location in state
595 // so that when we are in an error state, it gets reset when a new location
596 // comes in and the user recovers from the error.
597 if (state.location !== props.location) {
598 return {
599 error: props.error,
600 location: props.location
601 };
602 } // If we're not changing locations, preserve the location but still surface
603 // any new errors that may come through. We retain the existing error, we do
604 // this because the error provided from the app state may be cleared without
605 // the location changing.
606
607
608 return {
609 error: props.error || state.error,
610 location: state.location
611 };
612 }
613
614 componentDidCatch(error, errorInfo) {
615 console.error("React Router caught the following error during render", error, errorInfo);
616 }
617
618 render() {
619 return this.state.error ? /*#__PURE__*/React.createElement(RouteContext.Provider, {
620 value: this.props.routeContext
621 }, /*#__PURE__*/React.createElement(RouteErrorContext.Provider, {
622 value: this.state.error,
623 children: this.props.component
624 })) : this.props.children;
625 }
626
627}
628
629function RenderedRoute({
630 routeContext,
631 match,
632 children
633}) {
634 let dataRouterContext = React.useContext(DataRouterContext); // Track how deep we got in our render pass to emulate SSR componentDidCatch
635 // in a DataStaticRouter
636
637 if (dataRouterContext && dataRouterContext.static && dataRouterContext.staticContext && (match.route.errorElement || match.route.ErrorBoundary)) {
638 dataRouterContext.staticContext._deepestRenderedBoundaryId = match.route.id;
639 }
640
641 return /*#__PURE__*/React.createElement(RouteContext.Provider, {
642 value: routeContext
643 }, children);
644}
645
646function _renderMatches(matches, parentMatches = [], dataRouterState) {
647 if (matches == null) {
648 if (dataRouterState?.errors) {
649 // Don't bail if we have data router errors so we can render them in the
650 // boundary. Use the pre-matched (or shimmed) matches
651 matches = dataRouterState.matches;
652 } else {
653 return null;
654 }
655 }
656
657 let renderedMatches = matches; // If we have data errors, trim matches to the highest error boundary
658
659 let errors = dataRouterState?.errors;
660
661 if (errors != null) {
662 let errorIndex = renderedMatches.findIndex(m => m.route.id && errors?.[m.route.id]);
663 !(errorIndex >= 0) ? UNSAFE_invariant(false, `Could not find a matching route for the current errors: ${errors}`) : void 0;
664 renderedMatches = renderedMatches.slice(0, Math.min(renderedMatches.length, errorIndex + 1));
665 }
666
667 return renderedMatches.reduceRight((outlet, match, index) => {
668 let error = match.route.id ? errors?.[match.route.id] : null; // Only data routers handle errors
669
670 let errorElement = null;
671
672 if (dataRouterState) {
673 if (match.route.ErrorBoundary) {
674 errorElement = /*#__PURE__*/React.createElement(match.route.ErrorBoundary, null);
675 } else if (match.route.errorElement) {
676 errorElement = match.route.errorElement;
677 } else {
678 errorElement = /*#__PURE__*/React.createElement(DefaultErrorComponent, null);
679 }
680 }
681
682 let matches = parentMatches.concat(renderedMatches.slice(0, index + 1));
683
684 let getChildren = () => {
685 let children = outlet;
686
687 if (error) {
688 children = errorElement;
689 } else if (match.route.Component) {
690 children = /*#__PURE__*/React.createElement(match.route.Component, null);
691 } else if (match.route.element) {
692 children = match.route.element;
693 }
694
695 return /*#__PURE__*/React.createElement(RenderedRoute, {
696 match: match,
697 routeContext: {
698 outlet,
699 matches
700 },
701 children: children
702 });
703 }; // Only wrap in an error boundary within data router usages when we have an
704 // ErrorBoundary/errorElement on this route. Otherwise let it bubble up to
705 // an ancestor ErrorBoundary/errorElement
706
707
708 return dataRouterState && (match.route.ErrorBoundary || match.route.errorElement || index === 0) ? /*#__PURE__*/React.createElement(RenderErrorBoundary, {
709 location: dataRouterState.location,
710 component: errorElement,
711 error: error,
712 children: getChildren(),
713 routeContext: {
714 outlet: null,
715 matches
716 }
717 }) : getChildren();
718 }, null);
719}
720var DataRouterHook;
721
722(function (DataRouterHook) {
723 DataRouterHook["UseBlocker"] = "useBlocker";
724 DataRouterHook["UseRevalidator"] = "useRevalidator";
725})(DataRouterHook || (DataRouterHook = {}));
726
727var DataRouterStateHook;
728
729(function (DataRouterStateHook) {
730 DataRouterStateHook["UseBlocker"] = "useBlocker";
731 DataRouterStateHook["UseLoaderData"] = "useLoaderData";
732 DataRouterStateHook["UseActionData"] = "useActionData";
733 DataRouterStateHook["UseRouteError"] = "useRouteError";
734 DataRouterStateHook["UseNavigation"] = "useNavigation";
735 DataRouterStateHook["UseRouteLoaderData"] = "useRouteLoaderData";
736 DataRouterStateHook["UseMatches"] = "useMatches";
737 DataRouterStateHook["UseRevalidator"] = "useRevalidator";
738})(DataRouterStateHook || (DataRouterStateHook = {}));
739
740function getDataRouterConsoleError(hookName) {
741 return `${hookName} must be used within a data router. See https://reactrouter.com/routers/picking-a-router.`;
742}
743
744function useDataRouterContext(hookName) {
745 let ctx = React.useContext(DataRouterContext);
746 !ctx ? UNSAFE_invariant(false, getDataRouterConsoleError(hookName)) : void 0;
747 return ctx;
748}
749
750function useDataRouterState(hookName) {
751 let state = React.useContext(DataRouterStateContext);
752 !state ? UNSAFE_invariant(false, getDataRouterConsoleError(hookName)) : void 0;
753 return state;
754}
755
756function useRouteContext(hookName) {
757 let route = React.useContext(RouteContext);
758 !route ? UNSAFE_invariant(false, getDataRouterConsoleError(hookName)) : void 0;
759 return route;
760}
761
762function useCurrentRouteId(hookName) {
763 let route = useRouteContext(hookName);
764 let thisRoute = route.matches[route.matches.length - 1];
765 !thisRoute.route.id ? UNSAFE_invariant(false, `${hookName} can only be used on routes that contain a unique "id"`) : void 0;
766 return thisRoute.route.id;
767}
768/**
769 * Returns the current navigation, defaulting to an "idle" navigation when
770 * no navigation is in progress
771 */
772
773
774function useNavigation() {
775 let state = useDataRouterState(DataRouterStateHook.UseNavigation);
776 return state.navigation;
777}
778/**
779 * Returns a revalidate function for manually triggering revalidation, as well
780 * as the current state of any manual revalidations
781 */
782
783function useRevalidator() {
784 let dataRouterContext = useDataRouterContext(DataRouterHook.UseRevalidator);
785 let state = useDataRouterState(DataRouterStateHook.UseRevalidator);
786 return {
787 revalidate: dataRouterContext.router.revalidate,
788 state: state.revalidation
789 };
790}
791/**
792 * Returns the active route matches, useful for accessing loaderData for
793 * parent/child routes or the route "handle" property
794 */
795
796function useMatches() {
797 let {
798 matches,
799 loaderData
800 } = useDataRouterState(DataRouterStateHook.UseMatches);
801 return React.useMemo(() => matches.map(match => {
802 let {
803 pathname,
804 params
805 } = match; // Note: This structure matches that created by createUseMatchesMatch
806 // in the @remix-run/router , so if you change this please also change
807 // that :) Eventually we'll DRY this up
808
809 return {
810 id: match.route.id,
811 pathname,
812 params,
813 data: loaderData[match.route.id],
814 handle: match.route.handle
815 };
816 }), [matches, loaderData]);
817}
818/**
819 * Returns the loader data for the nearest ancestor Route loader
820 */
821
822function useLoaderData() {
823 let state = useDataRouterState(DataRouterStateHook.UseLoaderData);
824 let routeId = useCurrentRouteId(DataRouterStateHook.UseLoaderData);
825
826 if (state.errors && state.errors[routeId] != null) {
827 console.error(`You cannot \`useLoaderData\` in an errorElement (routeId: ${routeId})`);
828 return undefined;
829 }
830
831 return state.loaderData[routeId];
832}
833/**
834 * Returns the loaderData for the given routeId
835 */
836
837function useRouteLoaderData(routeId) {
838 let state = useDataRouterState(DataRouterStateHook.UseRouteLoaderData);
839 return state.loaderData[routeId];
840}
841/**
842 * Returns the action data for the nearest ancestor Route action
843 */
844
845function useActionData() {
846 let state = useDataRouterState(DataRouterStateHook.UseActionData);
847 let route = React.useContext(RouteContext);
848 !route ? UNSAFE_invariant(false, `useActionData must be used inside a RouteContext`) : void 0;
849 return Object.values(state?.actionData || {})[0];
850}
851/**
852 * Returns the nearest ancestor Route error, which could be a loader/action
853 * error or a render error. This is intended to be called from your
854 * ErrorBoundary/errorElement to display a proper error message.
855 */
856
857function useRouteError() {
858 let error = React.useContext(RouteErrorContext);
859 let state = useDataRouterState(DataRouterStateHook.UseRouteError);
860 let routeId = useCurrentRouteId(DataRouterStateHook.UseRouteError); // If this was a render error, we put it in a RouteError context inside
861 // of RenderErrorBoundary
862
863 if (error) {
864 return error;
865 } // Otherwise look for errors from our data router state
866
867
868 return state.errors?.[routeId];
869}
870/**
871 * Returns the happy-path data from the nearest ancestor <Await /> value
872 */
873
874function useAsyncValue() {
875 let value = React.useContext(AwaitContext);
876 return value?._data;
877}
878/**
879 * Returns the error from the nearest ancestor <Await /> value
880 */
881
882function useAsyncError() {
883 let value = React.useContext(AwaitContext);
884 return value?._error;
885}
886let blockerId = 0;
887/**
888 * Allow the application to block navigations within the SPA and present the
889 * user a confirmation dialog to confirm the navigation. Mostly used to avoid
890 * using half-filled form data. This does not handle hard-reloads or
891 * cross-origin navigations.
892 */
893
894function useBlocker(shouldBlock) {
895 let {
896 router
897 } = useDataRouterContext(DataRouterHook.UseBlocker);
898 let state = useDataRouterState(DataRouterStateHook.UseBlocker);
899 let [blockerKey] = React.useState(() => String(++blockerId));
900 let blockerFunction = React.useCallback(args => {
901 return typeof shouldBlock === "function" ? !!shouldBlock(args) : !!shouldBlock;
902 }, [shouldBlock]);
903 let blocker = router.getBlocker(blockerKey, blockerFunction); // Cleanup on unmount
904
905 React.useEffect(() => () => router.deleteBlocker(blockerKey), [router, blockerKey]); // Prefer the blocker from state since DataRouterContext is memoized so this
906 // ensures we update on blocker state updates
907
908 return state.blockers.get(blockerKey) || blocker;
909}
910const alreadyWarned = {};
911
912function warningOnce(key, cond, message) {
913 if (!cond && !alreadyWarned[key]) {
914 alreadyWarned[key] = true;
915 UNSAFE_warning(false, message) ;
916 }
917}
918
919/**
920 * Given a Remix Router instance, render the appropriate UI
921 */
922
923function RouterProvider({
924 fallbackElement,
925 router
926}) {
927 let getState = React.useCallback(() => router.state, [router]); // Sync router state to our component state to force re-renders
928
929 let state = useSyncExternalStore(router.subscribe, getState, // We have to provide this so React@18 doesn't complain during hydration,
930 // but we pass our serialized hydration data into the router so state here
931 // is already synced with what the server saw
932 getState);
933 let navigator = React.useMemo(() => {
934 return {
935 createHref: router.createHref,
936 encodeLocation: router.encodeLocation,
937 go: n => router.navigate(n),
938 push: (to, state, opts) => router.navigate(to, {
939 state,
940 preventScrollReset: opts?.preventScrollReset
941 }),
942 replace: (to, state, opts) => router.navigate(to, {
943 replace: true,
944 state,
945 preventScrollReset: opts?.preventScrollReset
946 })
947 };
948 }, [router]);
949 let basename = router.basename || "/";
950 let dataRouterContext = React.useMemo(() => ({
951 router,
952 navigator,
953 static: false,
954 basename
955 }), [router, navigator, basename]); // The fragment and {null} here are important! We need them to keep React 18's
956 // useId happy when we are server-rendering since we may have a <script> here
957 // containing the hydrated server-side staticContext (from StaticRouterProvider).
958 // useId relies on the component tree structure to generate deterministic id's
959 // so we need to ensure it remains the same on the client even though
960 // we don't need the <script> tag
961
962 return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(DataRouterContext.Provider, {
963 value: dataRouterContext
964 }, /*#__PURE__*/React.createElement(DataRouterStateContext.Provider, {
965 value: state
966 }, /*#__PURE__*/React.createElement(Router, {
967 basename: router.basename,
968 location: router.state.location,
969 navigationType: router.state.historyAction,
970 navigator: navigator
971 }, router.state.initialized ? /*#__PURE__*/React.createElement(Routes, null) : fallbackElement))), null);
972}
973/**
974 * A <Router> that stores all entries in memory.
975 *
976 * @see https://reactrouter.com/router-components/memory-router
977 */
978
979function MemoryRouter({
980 basename,
981 children,
982 initialEntries,
983 initialIndex
984}) {
985 let historyRef = React.useRef();
986
987 if (historyRef.current == null) {
988 historyRef.current = createMemoryHistory({
989 initialEntries,
990 initialIndex,
991 v5Compat: true
992 });
993 }
994
995 let history = historyRef.current;
996 let [state, setState] = React.useState({
997 action: history.action,
998 location: history.location
999 });
1000 React.useLayoutEffect(() => history.listen(setState), [history]);
1001 return /*#__PURE__*/React.createElement(Router, {
1002 basename: basename,
1003 children: children,
1004 location: state.location,
1005 navigationType: state.action,
1006 navigator: history
1007 });
1008}
1009/**
1010 * Changes the current location.
1011 *
1012 * Note: This API is mostly useful in React.Component subclasses that are not
1013 * able to use hooks. In functional components, we recommend you use the
1014 * `useNavigate` hook instead.
1015 *
1016 * @see https://reactrouter.com/components/navigate
1017 */
1018
1019function Navigate({
1020 to,
1021 replace,
1022 state,
1023 relative
1024}) {
1025 !useInRouterContext() ? UNSAFE_invariant(false, // TODO: This error is probably because they somehow have 2 versions of
1026 // the router loaded. We can help them understand how to avoid that.
1027 `<Navigate> may be used only in the context of a <Router> component.`) : void 0;
1028 UNSAFE_warning(!React.useContext(NavigationContext).static, `<Navigate> must not be used on the initial render in a <StaticRouter>. ` + `This is a no-op, but you should modify your code so the <Navigate> is ` + `only ever rendered in response to some user interaction or state change.`) ;
1029 let dataRouterState = React.useContext(DataRouterStateContext);
1030 let navigate = useNavigate();
1031 React.useEffect(() => {
1032 // Avoid kicking off multiple navigations if we're in the middle of a
1033 // data-router navigation, since components get re-rendered when we enter
1034 // a submitting/loading state
1035 if (dataRouterState && dataRouterState.navigation.state !== "idle") {
1036 return;
1037 }
1038
1039 navigate(to, {
1040 replace,
1041 state,
1042 relative
1043 });
1044 });
1045 return null;
1046}
1047/**
1048 * Renders the child route's element, if there is one.
1049 *
1050 * @see https://reactrouter.com/components/outlet
1051 */
1052
1053function Outlet(props) {
1054 return useOutlet(props.context);
1055}
1056/**
1057 * Declares an element that should be rendered at a certain URL path.
1058 *
1059 * @see https://reactrouter.com/components/route
1060 */
1061
1062function Route(_props) {
1063 UNSAFE_invariant(false, `A <Route> is only ever to be used as the child of <Routes> element, ` + `never rendered directly. Please wrap your <Route> in a <Routes>.`) ;
1064}
1065/**
1066 * Provides location context for the rest of the app.
1067 *
1068 * Note: You usually won't render a <Router> directly. Instead, you'll render a
1069 * router that is more specific to your environment such as a <BrowserRouter>
1070 * in web browsers or a <StaticRouter> for server rendering.
1071 *
1072 * @see https://reactrouter.com/router-components/router
1073 */
1074
1075function Router({
1076 basename: basenameProp = "/",
1077 children = null,
1078 location: locationProp,
1079 navigationType = Action.Pop,
1080 navigator,
1081 static: staticProp = false
1082}) {
1083 !!useInRouterContext() ? UNSAFE_invariant(false, `You cannot render a <Router> inside another <Router>.` + ` You should never have more than one in your app.`) : void 0; // Preserve trailing slashes on basename, so we can let the user control
1084 // the enforcement of trailing slashes throughout the app
1085
1086 let basename = basenameProp.replace(/^\/*/, "/");
1087 let navigationContext = React.useMemo(() => ({
1088 basename,
1089 navigator,
1090 static: staticProp
1091 }), [basename, navigator, staticProp]);
1092
1093 if (typeof locationProp === "string") {
1094 locationProp = parsePath(locationProp);
1095 }
1096
1097 let {
1098 pathname = "/",
1099 search = "",
1100 hash = "",
1101 state = null,
1102 key = "default"
1103 } = locationProp;
1104 let locationContext = React.useMemo(() => {
1105 let trailingPathname = stripBasename(pathname, basename);
1106
1107 if (trailingPathname == null) {
1108 return null;
1109 }
1110
1111 return {
1112 location: {
1113 pathname: trailingPathname,
1114 search,
1115 hash,
1116 state,
1117 key
1118 },
1119 navigationType
1120 };
1121 }, [basename, pathname, search, hash, state, key, navigationType]);
1122 UNSAFE_warning(locationContext != null, `<Router basename="${basename}"> is not able to match the URL ` + `"${pathname}${search}${hash}" because it does not start with the ` + `basename, so the <Router> won't render anything.`) ;
1123
1124 if (locationContext == null) {
1125 return null;
1126 }
1127
1128 return /*#__PURE__*/React.createElement(NavigationContext.Provider, {
1129 value: navigationContext
1130 }, /*#__PURE__*/React.createElement(LocationContext.Provider, {
1131 children: children,
1132 value: locationContext
1133 }));
1134}
1135/**
1136 * A container for a nested tree of <Route> elements that renders the branch
1137 * that best matches the current location.
1138 *
1139 * @see https://reactrouter.com/components/routes
1140 */
1141
1142function Routes({
1143 children,
1144 location
1145}) {
1146 let dataRouterContext = React.useContext(DataRouterContext); // When in a DataRouterContext _without_ children, we use the router routes
1147 // directly. If we have children, then we're in a descendant tree and we
1148 // need to use child routes.
1149
1150 let routes = dataRouterContext && !children ? dataRouterContext.router.routes : createRoutesFromChildren(children);
1151 return useRoutes(routes, location);
1152}
1153/**
1154 * Component to use for rendering lazily loaded data from returning defer()
1155 * in a loader function
1156 */
1157
1158function Await({
1159 children,
1160 errorElement,
1161 resolve
1162}) {
1163 return /*#__PURE__*/React.createElement(AwaitErrorBoundary, {
1164 resolve: resolve,
1165 errorElement: errorElement
1166 }, /*#__PURE__*/React.createElement(ResolveAwait, null, children));
1167}
1168var AwaitRenderStatus;
1169
1170(function (AwaitRenderStatus) {
1171 AwaitRenderStatus[AwaitRenderStatus["pending"] = 0] = "pending";
1172 AwaitRenderStatus[AwaitRenderStatus["success"] = 1] = "success";
1173 AwaitRenderStatus[AwaitRenderStatus["error"] = 2] = "error";
1174})(AwaitRenderStatus || (AwaitRenderStatus = {}));
1175
1176const neverSettledPromise = new Promise(() => {});
1177
1178class AwaitErrorBoundary extends React.Component {
1179 constructor(props) {
1180 super(props);
1181 this.state = {
1182 error: null
1183 };
1184 }
1185
1186 static getDerivedStateFromError(error) {
1187 return {
1188 error
1189 };
1190 }
1191
1192 componentDidCatch(error, errorInfo) {
1193 console.error("<Await> caught the following error during render", error, errorInfo);
1194 }
1195
1196 render() {
1197 let {
1198 children,
1199 errorElement,
1200 resolve
1201 } = this.props;
1202 let promise = null;
1203 let status = AwaitRenderStatus.pending;
1204
1205 if (!(resolve instanceof Promise)) {
1206 // Didn't get a promise - provide as a resolved promise
1207 status = AwaitRenderStatus.success;
1208 promise = Promise.resolve();
1209 Object.defineProperty(promise, "_tracked", {
1210 get: () => true
1211 });
1212 Object.defineProperty(promise, "_data", {
1213 get: () => resolve
1214 });
1215 } else if (this.state.error) {
1216 // Caught a render error, provide it as a rejected promise
1217 status = AwaitRenderStatus.error;
1218 let renderError = this.state.error;
1219 promise = Promise.reject().catch(() => {}); // Avoid unhandled rejection warnings
1220
1221 Object.defineProperty(promise, "_tracked", {
1222 get: () => true
1223 });
1224 Object.defineProperty(promise, "_error", {
1225 get: () => renderError
1226 });
1227 } else if (resolve._tracked) {
1228 // Already tracked promise - check contents
1229 promise = resolve;
1230 status = promise._error !== undefined ? AwaitRenderStatus.error : promise._data !== undefined ? AwaitRenderStatus.success : AwaitRenderStatus.pending;
1231 } else {
1232 // Raw (untracked) promise - track it
1233 status = AwaitRenderStatus.pending;
1234 Object.defineProperty(resolve, "_tracked", {
1235 get: () => true
1236 });
1237 promise = resolve.then(data => Object.defineProperty(resolve, "_data", {
1238 get: () => data
1239 }), error => Object.defineProperty(resolve, "_error", {
1240 get: () => error
1241 }));
1242 }
1243
1244 if (status === AwaitRenderStatus.error && promise._error instanceof AbortedDeferredError) {
1245 // Freeze the UI by throwing a never resolved promise
1246 throw neverSettledPromise;
1247 }
1248
1249 if (status === AwaitRenderStatus.error && !errorElement) {
1250 // No errorElement, throw to the nearest route-level error boundary
1251 throw promise._error;
1252 }
1253
1254 if (status === AwaitRenderStatus.error) {
1255 // Render via our errorElement
1256 return /*#__PURE__*/React.createElement(AwaitContext.Provider, {
1257 value: promise,
1258 children: errorElement
1259 });
1260 }
1261
1262 if (status === AwaitRenderStatus.success) {
1263 // Render children with resolved value
1264 return /*#__PURE__*/React.createElement(AwaitContext.Provider, {
1265 value: promise,
1266 children: children
1267 });
1268 } // Throw to the suspense boundary
1269
1270
1271 throw promise;
1272 }
1273
1274}
1275/**
1276 * @private
1277 * Indirection to leverage useAsyncValue for a render-prop API on <Await>
1278 */
1279
1280
1281function ResolveAwait({
1282 children
1283}) {
1284 let data = useAsyncValue();
1285 let toRender = typeof children === "function" ? children(data) : children;
1286 return /*#__PURE__*/React.createElement(React.Fragment, null, toRender);
1287} ///////////////////////////////////////////////////////////////////////////////
1288// UTILS
1289///////////////////////////////////////////////////////////////////////////////
1290
1291/**
1292 * Creates a route config from a React "children" object, which is usually
1293 * either a `<Route>` element or an array of them. Used internally by
1294 * `<Routes>` to create a route config from its children.
1295 *
1296 * @see https://reactrouter.com/utils/create-routes-from-children
1297 */
1298
1299
1300function createRoutesFromChildren(children, parentPath = []) {
1301 let routes = [];
1302 React.Children.forEach(children, (element, index) => {
1303 if (! /*#__PURE__*/React.isValidElement(element)) {
1304 // Ignore non-elements. This allows people to more easily inline
1305 // conditionals in their route config.
1306 return;
1307 }
1308
1309 if (element.type === React.Fragment) {
1310 // Transparently support React.Fragment and its children.
1311 routes.push.apply(routes, createRoutesFromChildren(element.props.children, parentPath));
1312 return;
1313 }
1314
1315 !(element.type === Route) ? UNSAFE_invariant(false, `[${typeof element.type === "string" ? element.type : element.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`) : void 0;
1316 !(!element.props.index || !element.props.children) ? UNSAFE_invariant(false, "An index route cannot have child routes.") : void 0;
1317 let treePath = [...parentPath, index];
1318 let route = {
1319 id: element.props.id || treePath.join("-"),
1320 caseSensitive: element.props.caseSensitive,
1321 element: element.props.element,
1322 Component: element.props.Component,
1323 index: element.props.index,
1324 path: element.props.path,
1325 loader: element.props.loader,
1326 action: element.props.action,
1327 errorElement: element.props.errorElement,
1328 ErrorBoundary: element.props.ErrorBoundary,
1329 hasErrorBoundary: element.props.ErrorBoundary != null || element.props.errorElement != null,
1330 shouldRevalidate: element.props.shouldRevalidate,
1331 handle: element.props.handle,
1332 lazy: element.props.lazy
1333 };
1334
1335 if (element.props.children) {
1336 route.children = createRoutesFromChildren(element.props.children, treePath);
1337 }
1338
1339 routes.push(route);
1340 });
1341 return routes;
1342}
1343/**
1344 * Renders the result of `matchRoutes()` into a React element.
1345 */
1346
1347function renderMatches(matches) {
1348 return _renderMatches(matches);
1349}
1350
1351function detectErrorBoundary(route) {
1352 {
1353 if (route.Component && route.element) {
1354 UNSAFE_warning(false, "You should not include both `Component` and `element` on your route - " + "`element` will be ignored.") ;
1355 }
1356
1357 if (route.ErrorBoundary && route.errorElement) {
1358 UNSAFE_warning(false, "You should not include both `ErrorBoundary` and `errorElement` on your route - " + "`errorElement` will be ignored.") ;
1359 }
1360 } // Note: this check also occurs in createRoutesFromChildren so update
1361 // there if you change this
1362
1363
1364 return Boolean(route.ErrorBoundary) || Boolean(route.errorElement);
1365}
1366
1367function createMemoryRouter(routes, opts) {
1368 return createRouter({
1369 basename: opts?.basename,
1370 history: createMemoryHistory({
1371 initialEntries: opts?.initialEntries,
1372 initialIndex: opts?.initialIndex
1373 }),
1374 hydrationData: opts?.hydrationData,
1375 routes,
1376 detectErrorBoundary
1377 }).initialize();
1378} ///////////////////////////////////////////////////////////////////////////////
1379
1380export { Await, MemoryRouter, Navigate, Outlet, Route, Router, RouterProvider, Routes, DataRouterContext as UNSAFE_DataRouterContext, DataRouterStateContext as UNSAFE_DataRouterStateContext, LocationContext as UNSAFE_LocationContext, NavigationContext as UNSAFE_NavigationContext, RouteContext as UNSAFE_RouteContext, detectErrorBoundary as UNSAFE_detectErrorBoundary, createMemoryRouter, createRoutesFromChildren, createRoutesFromChildren as createRoutesFromElements, renderMatches, useBlocker as unstable_useBlocker, useActionData, useAsyncError, useAsyncValue, useHref, useInRouterContext, useLoaderData, useLocation, useMatch, useMatches, useNavigate, useNavigation, useNavigationType, useOutlet, useOutletContext, useParams, useResolvedPath, useRevalidator, useRouteError, useRouteLoaderData, useRoutes };
1381//# sourceMappingURL=react-router.development.js.map