From 031478d4acc46cc631673ef14e3215fac97dee8b Mon Sep 17 00:00:00 2001 From: Matt Brophy Date: Thu, 9 May 2024 10:17:24 -0400 Subject: [PATCH] Add defensive window.document check when checking for startViewTransition (#11544) Co-authored-by: Nathan Rajlich --- .changeset/good-donkeys-kiss.md | 5 +++++ contributors.yml | 1 + packages/react-router-dom/index.tsx | 1 + 3 files changed, 7 insertions(+) create mode 100644 .changeset/good-donkeys-kiss.md diff --git a/.changeset/good-donkeys-kiss.md b/.changeset/good-donkeys-kiss.md new file mode 100644 index 0000000000..15be073c5d --- /dev/null +++ b/.changeset/good-donkeys-kiss.md @@ -0,0 +1,5 @@ +--- +"react-router-dom": patch +--- + +Check for `document` existence when checking `startViewTransition` diff --git a/contributors.yml b/contributors.yml index a2aab00d2e..d3c533fac1 100644 --- a/contributors.yml +++ b/contributors.yml @@ -241,6 +241,7 @@ - tlinhart - tom-sherman - tomasr8 +- TooTallNate - triangularcube - trungpv1601 - turansky diff --git a/packages/react-router-dom/index.tsx b/packages/react-router-dom/index.tsx index 1d4675396e..1f2e515f75 100644 --- a/packages/react-router-dom/index.tsx +++ b/packages/react-router-dom/index.tsx @@ -526,6 +526,7 @@ export function RouterProvider({ let isViewTransitionUnavailable = router.window == null || + router.window.document == null || typeof router.window.document.startViewTransition !== "function"; // If this isn't a view transition or it's not available in this browser,