Skip to content

Commit 22d98c2

Browse files
authored
chore(deps): upgrade React Router to v7 (#419)
1 parent 72e052a commit 22d98c2

27 files changed

+955
-2728
lines changed

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,7 @@ build
4848
.cache
4949

5050
# macOS
51-
.DS_Store
51+
.DS_Store
52+
53+
# React Router
54+
.react-router/

eslint.config.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export default [
1616
pluginJs.configs.recommended,
1717
...tseslint.configs.recommended,
1818
{
19+
files: ['frontend/**/*.{ts,tsx}', 'components/**/*.{ts,tsx}'],
1920
...pluginReact.configs.flat.recommended,
2021
settings: {
2122
react: {
@@ -40,6 +41,13 @@ export default [
4041
}
4142
},
4243
{
43-
ignores: ['**/node_modules/', '**/dist/', '**/build/', '**/public/init.js']
44+
ignores: [
45+
'**/node_modules/',
46+
'**/dist/',
47+
'**/build/',
48+
'**/public/init.js',
49+
'**/.react-router/',
50+
'**/.wrangler/'
51+
]
4452
}
4553
]

frontend/app/components/ButtonOrLink.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Link, type LinkProps } from '@remix-run/react'
1+
import { Link, type LinkProps } from 'react-router'
22
import { forwardRef, type ComponentProps } from 'react'
33

44
type AnchorOrLinkProps = ComponentProps<'a'> & Partial<LinkProps>

frontend/app/components/redesign/components/BuilderBackground.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React from 'react'
22
import { useSnapshot } from 'valtio'
33
import { cx } from 'class-variance-authority'
44
import { toolState } from '~/stores/toolStore'
5-
import { ToolsSecondaryButton } from '@/components'
5+
import { ToolsSecondaryButton } from '@/components/ToolsSecondaryButton'
66
import { SLIDE_ANIMATION } from '@shared/types'
77

88
const DOT_PATTERN_SVG = `<svg width="12" height="12" viewBox="0 0 12 12" fill="none" xmlns="http://www.w3.org/2000/svg"><circle cx="6" cy="6" r="2" fill="white" fill-opacity="0.5" /></svg>`

frontend/app/components/redesign/components/HeadingCore.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react'
2-
import { GhostButton } from '@/components'
2+
import { GhostButton } from '@/components/GhostButton'
33
import { Heading1, Heading2SemiBold } from '@/typography'
44
import { SVGArrowLeft } from '@/assets'
55

frontend/app/components/redesign/components/landing/ToolCard.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { useId } from 'react'
2-
import { Link } from '@remix-run/react'
2+
import { Link } from 'react-router'
33
import { PillTag } from '@/components'
44
import arrowOutwardIcon from '~/assets/images/landing/arrow-outward.svg'
55

frontend/app/entry.client.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* For more information, see https://remix.run/file-conventions/entry.client
55
*/
66

7-
import { RemixBrowser } from '@remix-run/react'
7+
import { HydratedRouter } from 'react-router/dom'
88
import { startTransition, StrictMode } from 'react'
99
import { hydrateRoot } from 'react-dom/client'
1010
import { scan } from 'react-scan'
@@ -22,7 +22,7 @@ startTransition(() => {
2222
hydrateRoot(
2323
document,
2424
<StrictMode>
25-
<RemixBrowser />
25+
<HydratedRouter />
2626
</StrictMode>
2727
)
2828
})

frontend/app/entry.server.tsx

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,32 +4,31 @@
44
* For more information, see https://remix.run/file-conventions/entry.server
55
*/
66

7-
import type { AppLoadContext, EntryContext } from '@remix-run/cloudflare'
8-
import { RemixServer } from '@remix-run/react'
7+
import {
8+
ServerRouter,
9+
type AppLoadContext,
10+
type EntryContext
11+
} from 'react-router'
912
import { isbot } from 'isbot'
1013
import { renderToReadableStream } from 'react-dom/server'
1114

12-
const ABORT_DELAY = 5000
15+
export const streamTimeout = 5000
1316

1417
export default async function handleRequest(
1518
request: Request,
1619
responseStatusCode: number,
1720
responseHeaders: Headers,
18-
remixContext: EntryContext,
21+
reactRouterContext: EntryContext,
1922
// This is ignored so we can keep it in the template for visibility. Feel
2023
// free to delete this parameter in your app if you're not using it!
2124
// eslint-disable-next-line @typescript-eslint/no-unused-vars
2225
loadContext: AppLoadContext
2326
) {
2427
const controller = new AbortController()
25-
const timeoutId = setTimeout(() => controller.abort(), ABORT_DELAY)
28+
const timeoutId = setTimeout(() => controller.abort(), streamTimeout)
2629

2730
const body = await renderToReadableStream(
28-
<RemixServer
29-
context={remixContext}
30-
url={request.url}
31-
abortDelay={ABORT_DELAY}
32-
/>,
31+
<ServerRouter context={reactRouterContext} url={request.url} />,
3332
{
3433
signal: controller.signal,
3534
onError(error: unknown) {

frontend/app/hooks/usePathTracker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useLocation } from '@remix-run/react'
1+
import { useLocation } from 'react-router'
22
import { useEffect } from 'react'
33
import { TOOL_TYPES, toolActions, type ToolType } from '~/stores/toolStore'
44

frontend/app/root.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
import type { LinksFunction, MetaFunction } from '@remix-run/cloudflare'
21
import {
32
Links,
43
Meta,
54
Outlet,
65
Scripts,
76
ScrollRestoration,
87
useRouteError,
9-
isRouteErrorResponse
10-
} from '@remix-run/react'
8+
isRouteErrorResponse,
9+
type LinksFunction,
10+
type MetaFunction
11+
} from 'react-router'
1112
import type { ReactNode } from 'react'
1213
import stylesheet from '~/tailwind.css?url'
1314
import { Button } from './components/index.js'

0 commit comments

Comments
 (0)