-
-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
46 changed files
with
3,455 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
--- | ||
title: unstable_useViewTransitionState | ||
--- | ||
|
||
# `unstable_useViewTransitionState` | ||
|
||
<details> | ||
<summary>Type declaration</summary> | ||
|
||
```tsx | ||
declare function unstable_useViewTransitionState( | ||
to: To, | ||
opts: { relative?: "route" : "path" } = {} | ||
): boolean; | ||
|
||
type To = string | Partial<Path>; | ||
|
||
interface Path { | ||
pathname: string; | ||
search: string; | ||
hash: string; | ||
} | ||
``` | ||
|
||
</details> | ||
|
||
This hook returns `true` when there is an active [View Transition][view-transitions] to the specified location. This can be used to apply finer-grained styles to elements to further customize the view transition. This requires that view transitions have been enabled for the given navigation via the [unstable_viewTransition][link-view-transition] prop on the `Link` (or the `Form`, `navigate`, or `submit` call). | ||
|
||
Consider clicking on an image in a list that you need to expand into the hero image on the destination page: | ||
|
||
```jsx | ||
function NavImage({ src, alt, id }) { | ||
let to = `/images/${idx}`; | ||
let vt = unstable_useViewTransitionState(href); | ||
return ( | ||
<Link to={to} unstable_viewTransition> | ||
<img | ||
src={src} | ||
alt={alt} | ||
style={{ | ||
viewTransitionName: vt ? "image-expand" : "", | ||
}} | ||
/> | ||
</Link> | ||
); | ||
} | ||
``` | ||
|
||
[link-view-transition]: ../components/link#unstable_viewtransition | ||
[view-transitions]: https://developer.mozilla.org/en-US/docs/Web/API/View_Transitions_API |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
node_modules | ||
.DS_Store | ||
dist | ||
dist-ssr | ||
*.local |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"installDependencies": true, | ||
"startCommand": "npm run dev" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
--- | ||
title: View Transitions | ||
toc: false | ||
--- | ||
|
||
# startViewTransition (Experimental) | ||
|
||
This example demonstrates a simple usage of a Data Router with `document.startViewTransition` enabled. | ||
|
||
## Preview | ||
|
||
Open this example on [StackBlitz](https://stackblitz.com): | ||
|
||
[![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) |
Oops, something went wrong.