Skip to content

Commit c147df0

Browse files
authored
React Router 7 (#2628)
* bump package version * convert all the imports, everything works but the scroll restore test * make scroll restore test pass * upgrade vite and vitest * use 7.1.1 stable * fix package-lock.json
1 parent 63954c8 commit c147df0

File tree

97 files changed

+376
-805
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

97 files changed

+376
-805
lines changed

app/components/ErrorBoundary.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Copyright Oxide Computer Company
77
*/
88
import { ErrorBoundary as BaseErrorBoundary } from 'react-error-boundary'
9-
import { useRouteError } from 'react-router-dom'
9+
import { useRouteError } from 'react-router'
1010

1111
import { type ApiError } from '~/api/errors'
1212

app/components/ErrorPage.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Copyright Oxide Computer Company
77
*/
88
import type { ReactNode } from 'react'
9-
import { Link } from 'react-router-dom'
9+
import { Link } from 'react-router'
1010

1111
import { Error12Icon, PrevArrow12Icon } from '@oxide/design-system/icons/react'
1212

app/components/QueryParamTabs.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*
66
* Copyright Oxide Computer Company
77
*/
8-
import { useSearchParams } from 'react-router-dom'
8+
import { useSearchParams } from 'react-router'
99

1010
import { Tabs, type TabsRootProps } from '~/ui/lib/Tabs'
1111

app/components/RouteTabs.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*/
88
import cn from 'classnames'
99
import type { ReactNode } from 'react'
10-
import { Link, Outlet } from 'react-router-dom'
10+
import { Link, Outlet } from 'react-router'
1111

1212
import { useIsActivePath } from '~/hooks/use-is-active-path'
1313
import { KEYS } from '~/ui/util/keys'

app/components/Sidebar.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Copyright Oxide Computer Company
77
*/
88
import cn from 'classnames'
9-
import { NavLink, useLocation } from 'react-router-dom'
9+
import { NavLink, useLocation } from 'react-router'
1010

1111
import { Action16Icon, Document16Icon } from '@oxide/design-system/icons/react'
1212

app/components/TopBar.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Copyright Oxide Computer Company
77
*/
88
import cn from 'classnames'
9-
import { Link } from 'react-router-dom'
9+
import { Link } from 'react-router'
1010

1111
import { navToLogin, useApiMutation } from '@oxide/api'
1212
import {

app/components/form/FullPageForm.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*/
88
import { cloneElement, useEffect, type ReactNode } from 'react'
99
import type { FieldValues, UseFormReturn } from 'react-hook-form'
10-
import { useBlocker, type Blocker } from 'react-router-dom'
10+
import { useBlocker, type Blocker } from 'react-router'
1111

1212
import type { ApiError } from '@oxide/api'
1313

app/components/form/SideModalForm.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
import { useEffect, useId, useState, type ReactNode } from 'react'
1010
import type { FieldValues, UseFormReturn } from 'react-hook-form'
11-
import { NavigationType, useNavigationType } from 'react-router-dom'
11+
import { NavigationType, useNavigationType } from 'react-router'
1212

1313
import type { ApiError } from '@oxide/api'
1414

app/forms/disk-create.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import { filesize } from 'filesize'
99
import { useMemo } from 'react'
1010
import { useController, useForm, type Control } from 'react-hook-form'
11-
import { useNavigate, type NavigateFunction } from 'react-router-dom'
11+
import { useNavigate, type NavigateFunction } from 'react-router'
1212

1313
import {
1414
useApiMutation,

app/forms/firewall-rules-create.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Copyright Oxide Computer Company
77
*/
88
import { useForm } from 'react-hook-form'
9-
import { useNavigate, useParams, type LoaderFunctionArgs } from 'react-router-dom'
9+
import { useNavigate, useParams, type LoaderFunctionArgs } from 'react-router'
1010

1111
import {
1212
apiQueryClient,

app/forms/firewall-rules-edit.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Copyright Oxide Computer Company
77
*/
88
import { useForm } from 'react-hook-form'
9-
import { useNavigate, type LoaderFunctionArgs } from 'react-router-dom'
9+
import { useNavigate, type LoaderFunctionArgs } from 'react-router'
1010

1111
import {
1212
apiQueryClient,

app/forms/floating-ip-create.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import * as Accordion from '@radix-ui/react-accordion'
99
import { useState } from 'react'
1010
import { useForm } from 'react-hook-form'
11-
import { useNavigate } from 'react-router-dom'
11+
import { useNavigate } from 'react-router'
1212

1313
import {
1414
useApiMutation,

app/forms/floating-ip-edit.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Copyright Oxide Computer Company
77
*/
88
import { useForm } from 'react-hook-form'
9-
import { useNavigate, type LoaderFunctionArgs } from 'react-router-dom'
9+
import { useNavigate, type LoaderFunctionArgs } from 'react-router'
1010

1111
import { apiq, queryClient, useApiMutation, usePrefetchedApiQuery } from '@oxide/api'
1212

app/forms/idp/create.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*/
88
import { useEffect, useState } from 'react'
99
import { useForm } from 'react-hook-form'
10-
import { useNavigate } from 'react-router-dom'
10+
import { useNavigate } from 'react-router'
1111

1212
import { useApiMutation, useApiQueryClient } from '@oxide/api'
1313

app/forms/idp/edit.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Copyright Oxide Computer Company
77
*/
88
import { useForm } from 'react-hook-form'
9-
import { useNavigate, type LoaderFunctionArgs } from 'react-router-dom'
9+
import { useNavigate, type LoaderFunctionArgs } from 'react-router'
1010

1111
import { apiQueryClient, usePrefetchedApiQuery } from '@oxide/api'
1212
import { Access16Icon } from '@oxide/design-system/icons/react'

app/forms/image-edit.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Copyright Oxide Computer Company
77
*/
88
import { useForm } from 'react-hook-form'
9-
import { useNavigate, type LoaderFunctionArgs } from 'react-router-dom'
9+
import { useNavigate, type LoaderFunctionArgs } from 'react-router'
1010

1111
import { apiQueryClient, usePrefetchedApiQuery, type Image } from '@oxide/api'
1212
import { Images16Icon } from '@oxide/design-system/icons/react'

app/forms/image-from-snapshot.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*/
88
import { filesize } from 'filesize'
99
import { useForm } from 'react-hook-form'
10-
import { useNavigate, type LoaderFunctionArgs } from 'react-router-dom'
10+
import { useNavigate, type LoaderFunctionArgs } from 'react-router'
1111

1212
import {
1313
apiq,

app/forms/image-upload.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import pMap from 'p-map'
1212
import pRetry from 'p-retry'
1313
import { useRef, useState } from 'react'
1414
import { useForm } from 'react-hook-form'
15-
import { useNavigate } from 'react-router-dom'
15+
import { useNavigate } from 'react-router'
1616

1717
import {
1818
useApiMutation,

app/forms/instance-create.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import * as Accordion from '@radix-ui/react-accordion'
99
import { useEffect, useMemo, useState } from 'react'
1010
import { useController, useForm, useWatch, type Control } from 'react-hook-form'
11-
import { useNavigate, type LoaderFunctionArgs } from 'react-router-dom'
11+
import { useNavigate, type LoaderFunctionArgs } from 'react-router'
1212
import type { SetRequired } from 'type-fest'
1313

1414
import {

app/forms/ip-pool-create.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Copyright Oxide Computer Company
77
*/
88
import { useForm } from 'react-hook-form'
9-
import { useNavigate } from 'react-router-dom'
9+
import { useNavigate } from 'react-router'
1010

1111
import { useApiMutation, useApiQueryClient, type IpPoolCreate } from '@oxide/api'
1212

app/forms/ip-pool-edit.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Copyright Oxide Computer Company
77
*/
88
import { useForm } from 'react-hook-form'
9-
import { useNavigate, type LoaderFunctionArgs } from 'react-router-dom'
9+
import { useNavigate, type LoaderFunctionArgs } from 'react-router'
1010

1111
import {
1212
apiQueryClient,

app/forms/ip-pool-range-add.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Copyright Oxide Computer Company
77
*/
88
import { useForm, type FieldErrors } from 'react-hook-form'
9-
import { useNavigate } from 'react-router-dom'
9+
import { useNavigate } from 'react-router'
1010

1111
import { useApiMutation, useApiQueryClient, type IpRange } from '@oxide/api'
1212

app/forms/project-create.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Copyright Oxide Computer Company
77
*/
88
import { useForm } from 'react-hook-form'
9-
import { useNavigate } from 'react-router-dom'
9+
import { useNavigate } from 'react-router'
1010

1111
import { useApiMutation, useApiQueryClient, type ProjectCreate } from '@oxide/api'
1212

app/forms/project-edit.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Copyright Oxide Computer Company
77
*/
88
import { useForm } from 'react-hook-form'
9-
import { useNavigate, type LoaderFunctionArgs } from 'react-router-dom'
9+
import { useNavigate, type LoaderFunctionArgs } from 'react-router'
1010

1111
import { apiq, queryClient, useApiMutation, usePrefetchedQuery } from '@oxide/api'
1212

app/forms/silo-create.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*/
88
import { useEffect } from 'react'
99
import { useForm } from 'react-hook-form'
10-
import { useNavigate } from 'react-router-dom'
10+
import { useNavigate } from 'react-router'
1111

1212
import { useApiMutation, useApiQueryClient, type SiloCreate } from '@oxide/api'
1313

app/forms/snapshot-create.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*/
88
import { useMemo } from 'react'
99
import { useForm } from 'react-hook-form'
10-
import { useNavigate } from 'react-router-dom'
10+
import { useNavigate } from 'react-router'
1111

1212
import {
1313
diskCan,

app/forms/ssh-key-create.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Copyright Oxide Computer Company
77
*/
88
import { useForm } from 'react-hook-form'
9-
import { useNavigate } from 'react-router-dom'
9+
import { useNavigate } from 'react-router'
1010

1111
import { useApiMutation, useApiQueryClient, type SshKeyCreate } from '@oxide/api'
1212

app/forms/ssh-key-edit.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Copyright Oxide Computer Company
77
*/
88
import { useForm } from 'react-hook-form'
9-
import { useNavigate, type LoaderFunctionArgs } from 'react-router-dom'
9+
import { useNavigate, type LoaderFunctionArgs } from 'react-router'
1010

1111
import { apiQueryClient, usePrefetchedApiQuery } from '@oxide/api'
1212
import { Key16Icon } from '@oxide/design-system/icons/react'

app/forms/subnet-create.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Copyright Oxide Computer Company
77
*/
88
import { useForm } from 'react-hook-form'
9-
import { useNavigate } from 'react-router-dom'
9+
import { useNavigate } from 'react-router'
1010

1111
import { useApiMutation, useApiQueryClient, type VpcSubnetCreate } from '@oxide/api'
1212

app/forms/subnet-edit.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Copyright Oxide Computer Company
77
*/
88
import { useForm } from 'react-hook-form'
9-
import { useNavigate, type LoaderFunctionArgs } from 'react-router-dom'
9+
import { useNavigate, type LoaderFunctionArgs } from 'react-router'
1010

1111
import {
1212
apiq,

app/forms/vpc-create.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Copyright Oxide Computer Company
77
*/
88
import { useForm } from 'react-hook-form'
9-
import { useNavigate } from 'react-router-dom'
9+
import { useNavigate } from 'react-router'
1010

1111
import { useApiMutation, useApiQueryClient, type VpcCreate } from '@oxide/api'
1212

app/forms/vpc-edit.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Copyright Oxide Computer Company
77
*/
88
import { useForm } from 'react-hook-form'
9-
import { useNavigate, type LoaderFunctionArgs } from 'react-router-dom'
9+
import { useNavigate, type LoaderFunctionArgs } from 'react-router'
1010

1111
import { apiq, queryClient, useApiMutation, usePrefetchedQuery } from '@oxide/api'
1212

app/forms/vpc-router-create.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Copyright Oxide Computer Company
77
*/
88
import { useForm } from 'react-hook-form'
9-
import { useNavigate } from 'react-router-dom'
9+
import { useNavigate } from 'react-router'
1010

1111
import { useApiMutation, useApiQueryClient, type VpcRouterCreate } from '@oxide/api'
1212

app/forms/vpc-router-edit.tsx

+1-5
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,7 @@
66
* Copyright Oxide Computer Company
77
*/
88
import { useForm } from 'react-hook-form'
9-
import {
10-
useNavigate,
11-
type LoaderFunctionArgs,
12-
type NavigateFunction,
13-
} from 'react-router-dom'
9+
import { useNavigate, type LoaderFunctionArgs, type NavigateFunction } from 'react-router'
1410

1511
import {
1612
apiq,

app/forms/vpc-router-route-create.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Copyright Oxide Computer Company
77
*/
88
import { useForm } from 'react-hook-form'
9-
import { useNavigate, type LoaderFunctionArgs } from 'react-router-dom'
9+
import { useNavigate, type LoaderFunctionArgs } from 'react-router'
1010

1111
import { apiQueryClient, useApiMutation, useApiQueryClient } from '@oxide/api'
1212

app/forms/vpc-router-route-edit.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Copyright Oxide Computer Company
77
*/
88
import { useForm } from 'react-hook-form'
9-
import { useNavigate, type LoaderFunctionArgs } from 'react-router-dom'
9+
import { useNavigate, type LoaderFunctionArgs } from 'react-router'
1010
import * as R from 'remeda'
1111

1212
import {

app/hooks/use-crumbs.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*
66
* Copyright Oxide Computer Company
77
*/
8-
import { useMatches, type Params, type UIMatch } from 'react-router-dom'
8+
import { useMatches, type Params, type UIMatch } from 'react-router'
99

1010
import { invariant } from '~/util/invariant'
1111

app/hooks/use-is-active-path.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*
66
* Copyright Oxide Computer Company
77
*/
8-
import { useLocation, useResolvedPath } from 'react-router-dom'
8+
import { useLocation, useResolvedPath } from 'react-router'
99

1010
interface ActivePathOptions {
1111
to: string
@@ -16,7 +16,7 @@ interface ActivePathOptions {
1616
*
1717
* This implementation is based on logic from React Router's NavLink component.
1818
*
19-
* @see https://github.com/remix-run/react-router/blob/67f16e73603765158c63a27afb70d3a4b3e823d3/packages/react-router-dom/index.tsx#L448-L467
19+
* @see https://github.com/remix-run/react-router/blob/67f16e73603765158c63a27afb70d3a4b3e823d3/packages/react-router/index.tsx#L448-L467
2020
*
2121
* @param to The path to check
2222
* @param options.end Ensure this path isn't matched as "active" when its descendant paths are matched.

app/hooks/use-params.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*/
88
import { hashKey } from '@tanstack/react-query'
99
import { useMemo } from 'react'
10-
import { useParams, type Params } from 'react-router-dom'
10+
import { useParams, type Params } from 'react-router'
1111

1212
import { invariant } from '~/util/invariant'
1313

app/hooks/use-quick-actions.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Copyright Oxide Computer Company
77
*/
88
import { useEffect, useMemo } from 'react'
9-
import { useLocation, useNavigate } from 'react-router-dom'
9+
import { useLocation, useNavigate } from 'react-router'
1010
import { create } from 'zustand'
1111

1212
import { useCurrentUser } from '~/layouts/AuthenticatedLayout'

app/hooks/use-scroll-restoration.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Copyright Oxide Computer Company
77
*/
88
import { useEffect } from 'react'
9-
import { useLocation, useNavigation } from 'react-router-dom'
9+
import { useLocation, useNavigation } from 'react-router'
1010

1111
function getScrollPosition(key: string) {
1212
const pos = window.sessionStorage.getItem(key)

app/layouts/AuthLayout.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*
66
* Copyright Oxide Computer Company
77
*/
8-
import { Outlet } from 'react-router-dom'
8+
import { Outlet } from 'react-router'
99

1010
import { OxideLogo } from '~/components/OxideLogo'
1111

app/layouts/AuthenticatedLayout.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*
66
* Copyright Oxide Computer Company
77
*/
8-
import { Outlet } from 'react-router-dom'
8+
import { Outlet } from 'react-router'
99

1010
import { apiQueryClient, useApiQueryErrorsAllowed, usePrefetchedApiQuery } from '@oxide/api'
1111

0 commit comments

Comments
 (0)