Skip to content

Commit a71b4e2

Browse files
committed
Merge branch 'release-next' into dev
2 parents e2c0d82 + edd9ad4 commit a71b4e2

33 files changed

+488
-341
lines changed

.changeset/404-root-with-path.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

.changeset/error-response-type.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

.changeset/partial-future-config.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

.changeset/soft-forks-cough.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

.changeset/start-view-transition.md

Lines changed: 0 additions & 46 deletions
This file was deleted.

contributors.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@
218218
- tkindy
219219
- tlinhart
220220
- tom-sherman
221+
- tomasr8
221222
- triangularcube
222223
- trungpv1601
223224
- turansky

docs/components/form.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -273,9 +273,7 @@ See also: [`<Link preventScrollReset>`][link-preventscrollreset]
273273

274274
The `unstable_viewTransition` prop enables a [View Transition][view-transitions] for this navigation by wrapping the final state update in `document.startViewTransition()`. If you need to apply specific styles for this view transition, you will also need to leverage the [`unstable_useViewTransitionState()`][use-view-transition-state].
275275

276-
<docs-warn>
277-
Please note that this API is marked unstable and may be subject to breaking changes without a major release.
278-
</docs-warn>
276+
<docs-warning>Please note that this API is marked unstable and may be subject to breaking changes without a major release</docs-warning>
279277

280278
# Examples
281279

docs/components/link.md

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -153,13 +153,16 @@ The `unstable_viewTransition` prop enables a [View Transition][view-transitions]
153153

154154
```jsx
155155
<Link to={to} unstable_viewTransition>
156+
Click me
157+
</Link>
156158
```
157159

158-
If you need to apply specific styles for this view transition, you will also need to leverage the [`unstable_useViewTransitionState()`][use-view-transition-state]:
160+
If you need to apply specific styles for this view transition, you will also need to leverage the [`unstable_useViewTransitionState()`][use-view-transition-state] hook (or check out the `transitioning` class and `isTransitioning` render prop in [NavLink][navlink]):
159161

160162
```jsx
161163
function ImageLink(to) {
162-
let isTransitioning = unstable_useViewTransitionState(to);
164+
const isTransitioning =
165+
unstable_useViewTransitionState(to);
163166
return (
164167
<Link to={to} unstable_viewTransition>
165168
<p
@@ -185,9 +188,9 @@ function ImageLink(to) {
185188
}
186189
```
187190

188-
<docs-warn>
189-
Please note that this API is marked unstable and may be subject to breaking changes without a major release.
190-
</docs-warn>
191+
<docs-warning>`unstable_viewTransition` only works when using a data router, see [Picking a Router][picking-a-router]</docs-warning>
192+
193+
<docs-warning>Please note that this API is marked unstable and may be subject to breaking changes without a major release</docs-warning>
191194

192195
[link-native]: ./link-native
193196
[scrollrestoration]: ./scroll-restoration
@@ -196,3 +199,5 @@ Please note that this API is marked unstable and may be subject to breaking chan
196199
[history-state]: https://developer.mozilla.org/en-US/docs/Web/API/History/state
197200
[use-view-transition-state]: ../hooks//use-view-transition-state
198201
[view-transitions]: https://developer.mozilla.org/en-US/docs/Web/API/View_Transitions_API
202+
[picking-a-router]: ../routers/picking-a-router
203+
[navlink]: ./nav-link

docs/components/nav-link.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,10 +171,9 @@ You may also use the `className`/`style` props or the render props passed to `ch
171171
</NavLink>
172172
```
173173

174-
<docs-warn>
174+
<docs-warning>
175175
Please note that this API is marked unstable and may be subject to breaking changes without a major release.
176-
</docs-warn>
176+
</docs-warning>
177177

178178
[aria-current]: https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-current
179179
[view-transitions]: https://developer.mozilla.org/en-US/docs/Web/API/View_Transitions_API
180-
[use-view-transition-state]: ../hooks//use-view-transition-state

docs/hooks/use-navigate.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,9 @@ function EditContact() {
8989

9090
The `unstable_viewTransition` option enables a [View Transition][view-transitions] for this navigation by wrapping the final state update in `document.startViewTransition()`. If you need to apply specific styles for this view transition, you will also need to leverage the [`unstable_useViewTransitionState()`][use-view-transition-state].
9191

92-
<docs-warn>
93-
Please note that this API is marked unstable and may be subject to breaking changes without a major release.
94-
</docs-warn>
92+
<docs-warning>`unstable_viewTransition` only works when using a data router, see [Picking a Router][picking-a-router]</docs-warning>
93+
94+
<docs-warning>Please note that this API is marked unstable and may be subject to breaking changes without a major release</docs-warning>
9595

9696
[link]: ../components/link
9797
[redirect]: ../fetch/redirect
@@ -101,3 +101,4 @@ Please note that this API is marked unstable and may be subject to breaking chan
101101
[scrollrestoration]: ../components/scroll-restoration
102102
[use-view-transition-state]: ../hooks//use-view-transition-state
103103
[view-transitions]: https://developer.mozilla.org/en-US/docs/Web/API/View_Transitions_API
104+
[picking-a-router]: ../routers/picking-a-router

docs/route/action.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ new: true
77

88
Route actions are the "writes" to route [loader][loader] "reads". They provide a way for apps to perform data mutations with simple HTML and HTTP semantics while React Router abstracts away the complexity of asynchronous UI and revalidation. This gives you the simple mental model of HTML + HTTP (where the browser handles the asynchrony and revalidation) with the behavior and UX capabilities of modern SPAs.
99

10-
<docs-error>This feature only works if using a data router like [`createBrowserRouter`][createbrowserrouter]</docs-error>
10+
<docs-warning>This feature only works if using a data router, see [Picking a Router][pickingarouter]</docs-warning>
1111

1212
```tsx
1313
<Route

docs/route/error-element.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ When exceptions are thrown in [loaders][loader], [actions][action], or component
99

1010
<docs-info>If you do not wish to specify a React element (i.e., `errorElement={<MyErrorBoundary />}`) you may specify an `ErrorBoundary` component instead (i.e., `ErrorBoundary={MyErrorBoundary}`) and React Router will call `createElement` for you internally.</docs-info>
1111

12-
<docs-error>This feature only works if using a data router like [`createBrowserRouter`][createbrowserrouter]</docs-error>
12+
<docs-warning>This feature only works if using a data router, see [Picking a Router][pickingarouter]</docs-warning>
1313

1414
```tsx
1515
<Route

docs/routers/picking-a-router.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ The following APIs are introduced in React Router 6.4 and will only work when us
109109
- [`useRouteError`][userouteerror]
110110
- [`useRouteLoaderData`][userouteloaderdata]
111111
- [`useSubmit`][usesubmit]
112+
- `startViewTransition` support on [Link][viewtransition-link] and [useNavigate][viewtransition-navigate]
112113

113114
[createbrowserrouter]: ./create-browser-router
114115
[createhashrouter]: ./create-hash-router
@@ -142,3 +143,5 @@ The following APIs are introduced in React Router 6.4 and will only work when us
142143
[userouteerror]: ../hooks/use-route-error
143144
[userouteloaderdata]: ../hooks/use-route-loader-data
144145
[usesubmit]: ../hooks/use-submit
146+
[viewtransition-link]: ../components/link#unstable_viewtransition
147+
[viewtransition-navigate]: ../hooks/use-navigate#optionsunstable_viewtransition

examples/view-transitions/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ This example demonstrates a simple usage of a Data Router with `document.startVi
1111

1212
Open this example on [StackBlitz](https://stackblitz.com):
1313

14-
[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/remix-run/react-router/tree/brophdawg11/start-view-transition/examples/view-transitions?file=src/App.tsx)
14+
[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/remix-run/react-router/tree/main/examples/view-transitions?file=src/App.tsx)

examples/view-transitions/package-lock.json

Lines changed: 13 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/view-transitions/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"dependencies": {
1010
"react": "18.2.0",
1111
"react-dom": "18.2.0",
12-
"react-router-dom": "^6.16.0"
12+
"react-router-dom": "6.17.0-pre.2"
1313
},
1414
"devDependencies": {
1515
"@rollup/plugin-replace": "5.0.2",

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,16 +113,16 @@
113113
"none": "48.3 kB"
114114
},
115115
"packages/react-router/dist/react-router.production.min.js": {
116-
"none": "15.2 kB"
116+
"none": "13.9 kB"
117117
},
118118
"packages/react-router/dist/umd/react-router.production.min.js": {
119-
"none": "17.6 kB"
119+
"none": "16.3 kB"
120120
},
121121
"packages/react-router-dom/dist/react-router-dom.production.min.js": {
122-
"none": "13.6 kB"
122+
"none": "15.9 kB"
123123
},
124124
"packages/react-router-dom/dist/umd/react-router-dom.production.min.js": {
125-
"none": "19.9 kB"
125+
"none": "22.1 kB"
126126
}
127127
}
128128
}

packages/react-router-dom-v5-compat/CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# `react-router-dom-v5-compat`
22

3+
## 6.17.0
4+
5+
### Patch Changes
6+
7+
- Updated dependencies:
8+
9+
10+
311
## 6.16.0
412

513
### Minor Changes

packages/react-router-dom-v5-compat/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-router-dom-v5-compat",
3-
"version": "6.16.0",
3+
"version": "6.17.0",
44
"description": "Migration path to React Router v6 from v4/5",
55
"keywords": [
66
"react",
@@ -24,7 +24,7 @@
2424
"types": "./dist/index.d.ts",
2525
"dependencies": {
2626
"history": "^5.3.0",
27-
"react-router": "6.16.0"
27+
"react-router": "6.17.0"
2828
},
2929
"peerDependencies": {
3030
"react": ">=16.8",

packages/react-router-dom/CHANGELOG.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,59 @@
11
# `react-router-dom`
22

3+
## 6.17.0
4+
5+
### Minor Changes
6+
7+
- Add experimental support for the [View Transitions API](https://developer.mozilla.org/en-US/docs/Web/API/ViewTransition) via `document.startViewTransition` to enable CSS animated transitions on SPA navigations in your application. ([#10916](https://github.com/remix-run/react-router/pull/10916))
8+
9+
The simplest approach to enabling a View Transition in your React Router app is via the new `<Link unstable_viewTransition>` prop. This will cause the navigation DOM update to be wrapped in `document.startViewTransition` which will enable transitions for the DOM update. Without any additional CSS styles, you'll get a basic cross-fade animation for your page.
10+
11+
If you need to apply more fine-grained styles for your animations, you can leverage the `unstable_useViewTransitionState` hook which will tell you when a transition is in progress and you can use that to apply classes or styles:
12+
13+
```jsx
14+
function ImageLink(to, src, alt) {
15+
let isTransitioning = unstable_useViewTransitionState(to);
16+
return (
17+
<Link to={to} unstable_viewTransition>
18+
<img
19+
src={src}
20+
alt={alt}
21+
style={{
22+
viewTransitionName: isTransitioning ? "image-expand" : "",
23+
}}
24+
/>
25+
</Link>
26+
);
27+
}
28+
```
29+
30+
You can also use the `<NavLink unstable_viewTransition>` shorthand which will manage the hook usage for you and automatically add a `transitioning` class to the `<a>` during the transition:
31+
32+
```css
33+
a.transitioning img {
34+
view-transition-name: "image-expand";
35+
}
36+
```
37+
38+
```jsx
39+
<NavLink to={to} unstable_viewTransition>
40+
<img src={src} alt={alt} />
41+
</NavLink>
42+
```
43+
44+
For an example usage of View Transitions with React Router, check out [our fork](https://github.com/brophdawg11/react-router-records) of the [Astro Records](https://github.com/Charca/astro-records) demo.
45+
46+
For more information on using the View Transitions API, please refer to the [Smooth and simple transitions with the View Transitions API](https://developer.chrome.com/docs/web-platform/view-transitions/) guide from the Google Chrome team.
47+
48+
Please note, that because the `ViewTransition` API is a DOM API, we now export a specific `RouterProvider` from `react-router-dom` with this functionality. If you are importing `RouterProvider` from `react-router`, then it will not support view transitions. ([#10928](https://github.com/remix-run/react-router/pull/10928)
49+
50+
### Patch Changes
51+
52+
- Log a warning and fail gracefully in `ScrollRestoration` when `sessionStorage` is unavailable ([#10848](https://github.com/remix-run/react-router/pull/10848))
53+
- Updated dependencies:
54+
- `@remix-run/[email protected]`
55+
56+
357
## 6.16.0
458

559
### Minor Changes

0 commit comments

Comments
 (0)