react-router 6.4.0-pre.10 → 6.4.0-pre.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +82 -26
- package/dist/index.d.ts +9 -9
- package/dist/index.js +197 -93
- package/dist/index.js.map +1 -1
- package/dist/lib/components.d.ts +26 -16
- package/dist/lib/context.d.ts +17 -2
- package/dist/lib/hooks.d.ts +15 -7
- package/dist/lib/use-sync-external-store-shim/index.d.ts +2 -1
- package/dist/main.js +1 -1
- package/dist/react-router.development.js +164 -79
- package/dist/react-router.development.js.map +1 -1
- package/dist/react-router.production.min.js +2 -2
- package/dist/react-router.production.min.js.map +1 -1
- package/dist/umd/react-router.development.js +200 -98
- package/dist/umd/react-router.development.js.map +1 -1
- package/dist/umd/react-router.production.min.js +2 -2
- package/dist/umd/react-router.production.min.js.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,18 +1,74 @@
|
|
|
1
1
|
# react-router
|
|
2
2
|
|
|
3
|
+
## 6.4.0-pre.13
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- feat: add `relative=path` option for url-relative routing (#9160)
|
|
8
|
+
|
|
9
|
+
Adds a `relative=path` option to navigation aspects to allow users to opt-into paths behaving relative to the current URL instead of the current route hierarchy. This is useful if you're sharing route patterns in a non-nested structure UI reasons:
|
|
10
|
+
|
|
11
|
+
```jsx
|
|
12
|
+
// Contact and EditContact do not share UI layout
|
|
13
|
+
<Route path="contacts/:id" element={<Contact />} />
|
|
14
|
+
<Route path="contacts:id/edit" element={<EditContact />} />
|
|
15
|
+
|
|
16
|
+
function EditContact() {
|
|
17
|
+
return <Link to=".." relative="path">Cancel</Link>
|
|
18
|
+
}
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Without this, the user would need to reconstruct the `contacts/:id` url using `useParams` and either hardcoding the `/contacts` prefix or parsing it from `useLocation`.
|
|
22
|
+
|
|
23
|
+
This applies to all path-related hooks and components:
|
|
24
|
+
|
|
25
|
+
- `react-router`: `useHref`, `useResolvedPath`, `useNavigate`, `Navigate`
|
|
26
|
+
- `react-router-dom`: `useLinkClickHandler`, `useFormAction`, `useSubmit`, `Link`, `Form`
|
|
27
|
+
- `react-router-native`: `useLinkPressHandler`, `Link`
|
|
28
|
+
|
|
29
|
+
- Updated dependencies
|
|
30
|
+
- @remix-run/router@0.2.0-pre.8
|
|
31
|
+
|
|
32
|
+
## 6.4.0-pre.12
|
|
33
|
+
|
|
34
|
+
### Patch Changes
|
|
35
|
+
|
|
36
|
+
- fix: avoid navigation loops in `<Navigate>` re-renders in data routers (#9124)
|
|
37
|
+
- Updated dependencies
|
|
38
|
+
- @remix-run/router@0.2.0-pre.7
|
|
39
|
+
|
|
40
|
+
## 6.4.0-pre.11
|
|
41
|
+
|
|
42
|
+
### Patch Changes
|
|
43
|
+
|
|
44
|
+
- c3406eb9: fix: Rename `<Deferred>` to `<Await>` (#9095)
|
|
45
|
+
|
|
46
|
+
- We are no longer replacing the `Promise` on `loaderData` with the value/error
|
|
47
|
+
when it settles so it's now always a `Promise`.
|
|
48
|
+
- To that end, we changed from `<Deferred value={promise}>` to
|
|
49
|
+
`<Await resolve={promise}>` for clarity, and it also now supports using
|
|
50
|
+
`<Await>` with raw promises from anywhere, not only those on `loaderData`
|
|
51
|
+
from a defer() call.
|
|
52
|
+
- Note that raw promises will not be automatically cancelled on interruptions
|
|
53
|
+
so they are not recommended
|
|
54
|
+
- The hooks are now `useAsyncValue`/`useAsyncError`
|
|
55
|
+
|
|
56
|
+
- Updated dependencies
|
|
57
|
+
- @remix-run/router@0.2.0-pre.6
|
|
58
|
+
|
|
3
59
|
## 6.4.0-pre.10
|
|
4
60
|
|
|
5
61
|
### Patch Changes
|
|
6
62
|
|
|
7
63
|
- feat: Deferred API Updates (#9070)
|
|
8
64
|
|
|
9
|
-
- Removes `<Suspense>` from inside `<
|
|
10
|
-
- Updates `
|
|
65
|
+
- Removes `<Suspense>` from inside `<Await>`, requires users to render their own suspense boundaries
|
|
66
|
+
- Updates `Await` to use a true error boundary to catch render errors as well as data errors
|
|
11
67
|
- Support array and single promise usages
|
|
12
|
-
- `return
|
|
13
|
-
- `return
|
|
68
|
+
- `return defer([ await critical(), lazy() ])`
|
|
69
|
+
- `return defer(lazy())`
|
|
14
70
|
- Remove `Deferrable`/`ResolvedDeferrable` in favor of raw `Promise`'s and `Awaited`
|
|
15
|
-
- Remove generics from `
|
|
71
|
+
- Remove generics from `useAsyncValue` until `useLoaderData` generic is decided in 6.5
|
|
16
72
|
|
|
17
73
|
- Updated dependencies
|
|
18
74
|
- @remix-run/router@0.2.0-pre.5
|
|
@@ -21,46 +77,46 @@
|
|
|
21
77
|
|
|
22
78
|
### Patch Changes
|
|
23
79
|
|
|
24
|
-
- Feat: adds `
|
|
80
|
+
- Feat: adds `defer()` support to data routers (#9002)
|
|
25
81
|
|
|
26
|
-
Returning a `
|
|
82
|
+
Returning a `defer()` from a `loader` allows you to separate _critical_ loader data that you want to wait for prior to rendering the destination page from _non-critical_ data that you are OK to show a spinner for until it loads.
|
|
27
83
|
|
|
28
84
|
```jsx
|
|
29
|
-
// In your route loader, return a
|
|
85
|
+
// In your route loader, return a defer() and choose per-key whether to
|
|
30
86
|
// await the promise or not. As soon as the awaited promises resolve, the
|
|
31
87
|
// page will be rendered.
|
|
32
88
|
function loader() {
|
|
33
|
-
return
|
|
89
|
+
return defer({
|
|
34
90
|
critical: await getCriticalData(),
|
|
35
91
|
lazy: getLazyData(),
|
|
36
92
|
});
|
|
37
93
|
};
|
|
38
94
|
|
|
39
95
|
// In your route element, grab the values from useLoaderData and render them
|
|
40
|
-
// with <
|
|
41
|
-
function
|
|
96
|
+
// with <Await>
|
|
97
|
+
function Page() {
|
|
42
98
|
let data = useLoaderData();
|
|
43
99
|
return (
|
|
44
100
|
<>
|
|
45
101
|
<p>Critical Data: {data.critical}</p>
|
|
46
|
-
<Suspense fallback={<p>Loading...</p>}>
|
|
47
|
-
<
|
|
48
|
-
<
|
|
49
|
-
</
|
|
50
|
-
</Suspense>
|
|
102
|
+
<React.Suspense fallback={<p>Loading...</p>}>
|
|
103
|
+
<Await resolve={data.lazy} errorElement={<RenderError />}>
|
|
104
|
+
<RenderData />
|
|
105
|
+
</Await>
|
|
106
|
+
</React.Suspense>
|
|
51
107
|
</>
|
|
52
108
|
);
|
|
53
109
|
}
|
|
54
110
|
|
|
55
111
|
// Use separate components to render the data once it resolves, and access it
|
|
56
|
-
// via the
|
|
57
|
-
function
|
|
58
|
-
let data =
|
|
112
|
+
// via the useAsyncValue hook
|
|
113
|
+
function RenderData() {
|
|
114
|
+
let data = useAsyncValue();
|
|
59
115
|
return <p>Lazy: {data}</p>;
|
|
60
116
|
}
|
|
61
117
|
|
|
62
|
-
function
|
|
63
|
-
let data =
|
|
118
|
+
function RenderError() {
|
|
119
|
+
let data = useAsyncError();
|
|
64
120
|
return <p>Error! {data.message} {data.stack}</p>;
|
|
65
121
|
}
|
|
66
122
|
```
|
|
@@ -69,16 +125,16 @@
|
|
|
69
125
|
pattern and handle the rendering of the deferred data inline:
|
|
70
126
|
|
|
71
127
|
```jsx
|
|
72
|
-
function
|
|
128
|
+
function Page() {
|
|
73
129
|
let data = useLoaderData();
|
|
74
130
|
return (
|
|
75
131
|
<>
|
|
76
132
|
<p>Critical Data: {data.critical}</p>
|
|
77
|
-
<Suspense fallback={<p>Loading...</p>}>
|
|
78
|
-
<
|
|
133
|
+
<React.Suspense fallback={<p>Loading...</p>}>
|
|
134
|
+
<Await resolve={data.lazy} errorElement={<RenderError />}>
|
|
79
135
|
{(data) => <p>{data}</p>}
|
|
80
|
-
</
|
|
81
|
-
</Suspense>
|
|
136
|
+
</Await>
|
|
137
|
+
</React.Suspense>
|
|
82
138
|
</>
|
|
83
139
|
);
|
|
84
140
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import type { ActionFunction, ActionFunctionArgs,
|
|
2
|
-
import { Action as NavigationType, createPath,
|
|
3
|
-
import type { DataMemoryRouterProps,
|
|
4
|
-
import { createRoutesFromChildren, renderMatches, DataMemoryRouter, DataRouter, DataRouterProvider,
|
|
5
|
-
import type { Navigator, NavigateOptions } from "./lib/context";
|
|
1
|
+
import type { ActionFunction, ActionFunctionArgs, Fetcher, JsonFunction, LoaderFunction, LoaderFunctionArgs, Location, Navigation, Params, ParamParseKey, Path, PathMatch, PathPattern, RedirectFunction, ShouldRevalidateFunction, To } from "@remix-run/router";
|
|
2
|
+
import { Action as NavigationType, createPath, defer, generatePath, isRouteErrorResponse, json, matchPath, matchRoutes, parsePath, redirect, resolvePath } from "@remix-run/router";
|
|
3
|
+
import type { DataMemoryRouterProps, AwaitProps, MemoryRouterProps, NavigateProps, OutletProps, RouteProps, PathRouteProps, LayoutRouteProps, IndexRouteProps, RouterProps, RoutesProps } from "./lib/components";
|
|
4
|
+
import { enhanceManualRouteObjects, createRoutesFromChildren, renderMatches, DataMemoryRouter, DataRouter, DataRouterProvider, Await, MemoryRouter, Navigate, Outlet, Route, Router, Routes } from "./lib/components";
|
|
5
|
+
import type { DataRouteMatch, DataRouteObject, Navigator, NavigateOptions, RouteMatch, RouteObject, RelativeRoutingType } from "./lib/context";
|
|
6
6
|
import { DataRouterContext, DataRouterStateContext, DataStaticRouterContext, LocationContext, NavigationContext, RouteContext } from "./lib/context";
|
|
7
7
|
import type { NavigateFunction } from "./lib/hooks";
|
|
8
|
-
import { useHref, useInRouterContext, useLocation, useMatch, useNavigationType, useNavigate, useOutlet, useOutletContext, useParams, useResolvedPath, useRoutes, useActionData,
|
|
8
|
+
import { useHref, useInRouterContext, useLocation, useMatch, useNavigationType, useNavigate, useOutlet, useOutletContext, useParams, useResolvedPath, useRoutes, useActionData, useAsyncError, useAsyncValue, useLoaderData, useMatches, useNavigation, useRevalidator, useRouteError, useRouteLoaderData } from "./lib/hooks";
|
|
9
9
|
declare type Hash = string;
|
|
10
10
|
declare type Pathname = string;
|
|
11
11
|
declare type Search = string;
|
|
12
|
-
export type { ActionFunction, ActionFunctionArgs, DataMemoryRouterProps, DataRouteMatch,
|
|
13
|
-
export { DataMemoryRouter,
|
|
12
|
+
export type { ActionFunction, ActionFunctionArgs, AwaitProps, DataMemoryRouterProps, DataRouteMatch, DataRouteObject, Fetcher, Hash, IndexRouteProps, JsonFunction, LayoutRouteProps, LoaderFunction, LoaderFunctionArgs, Location, MemoryRouterProps, NavigateFunction, NavigateOptions, NavigateProps, Navigation, Navigator, OutletProps, Params, ParamParseKey, Path, PathMatch, Pathname, PathPattern, PathRouteProps, RedirectFunction, RelativeRoutingType, RouteMatch, RouteObject, RouteProps, RouterProps, RoutesProps, Search, ShouldRevalidateFunction, To, };
|
|
13
|
+
export { DataMemoryRouter, Await, MemoryRouter, Navigate, NavigationType, Outlet, Route, Router, Routes, createPath, createRoutesFromChildren, defer, isRouteErrorResponse, generatePath, json, matchPath, matchRoutes, parsePath, redirect, renderMatches, resolvePath, useActionData, useAsyncError, useAsyncValue, useHref, useInRouterContext, useLoaderData, useLocation, useMatch, useMatches, useNavigate, useNavigation, useNavigationType, useOutlet, useOutletContext, useParams, useResolvedPath, useRevalidator, useRouteError, useRouteLoaderData, useRoutes, };
|
|
14
14
|
/** @internal */
|
|
15
|
-
export { DataRouter as UNSAFE_DataRouter, DataRouterProvider as UNSAFE_DataRouterProvider, NavigationContext as UNSAFE_NavigationContext, LocationContext as UNSAFE_LocationContext, RouteContext as UNSAFE_RouteContext, DataRouterContext as UNSAFE_DataRouterContext, DataRouterStateContext as UNSAFE_DataRouterStateContext, DataStaticRouterContext as UNSAFE_DataStaticRouterContext, };
|
|
15
|
+
export { DataRouter as UNSAFE_DataRouter, DataRouterProvider as UNSAFE_DataRouterProvider, NavigationContext as UNSAFE_NavigationContext, LocationContext as UNSAFE_LocationContext, RouteContext as UNSAFE_RouteContext, DataRouterContext as UNSAFE_DataRouterContext, DataRouterStateContext as UNSAFE_DataRouterStateContext, DataStaticRouterContext as UNSAFE_DataStaticRouterContext, enhanceManualRouteObjects as UNSAFE_enhanceManualRouteObjects, };
|