Skip to content

Commit a7e90b1

Browse files
authored
Upgrade to React Router 7.9.6 (#369)
* Upgrade to 7.9.6 * useRouteLoaderData -> unstable_useRoute * Fix type issue * Fix lint issues
1 parent 98edf75 commit a7e90b1

13 files changed

+336
-442
lines changed

app/lib/color-scheme.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
import { useMemo } from "react";
2-
import { useNavigation, useRouteLoaderData } from "react-router";
3-
import type { loader as rootLoader } from "~/root";
2+
import { unstable_useRoute as useRoute, useNavigation } from "react-router";
43
import { useLayoutEffect } from "~/ui/primitives/utils";
54

65
export type ColorScheme = "dark" | "light" | "system";
76

87
export function useColorScheme(): ColorScheme {
9-
let rootLoaderData = useRouteLoaderData<typeof rootLoader>("root");
10-
let rootColorScheme = rootLoaderData?.colorScheme ?? "system";
8+
let rootRoute = useRoute("root");
9+
let rootColorScheme = rootRoute.loaderData?.colorScheme ?? "system";
1110

1211
let { formData } = useNavigation();
1312
let optimisticColorScheme = formData?.has("colorScheme")

app/lib/md.server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ export async function loadPlugins() {
100100
const remarkCodeBlocksShiki: InternalPlugin<
101101
UnistNode.Root,
102102
UnistNode.Root
103-
> = (options) => {
103+
> = () => {
104104
let theme: ReturnType<typeof toShikiTheme>;
105105
let highlighterPromise: ReturnType<typeof getHighlighter>;
106106

app/root.tsx

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import { canUseDOM } from "./ui/primitives/utils";
3030
import { GlobalLoading } from "./ui/global-loading";
3131
import { type Route } from "./+types/root";
3232

33-
const redirectOldDocs: Route.unstable_MiddlewareFunction = ({ request }) => {
33+
const redirectOldDocs: Route.MiddlewareFunction = ({ request }) => {
3434
const { pathname } = new URL(request.url);
3535

3636
if (pathname === "/docs") {
@@ -74,15 +74,15 @@ const redirectOldDocs: Route.unstable_MiddlewareFunction = ({ request }) => {
7474
}
7575
};
7676

77-
const redirectResources: Route.unstable_MiddlewareFunction = ({ request }) => {
77+
const redirectResources: Route.MiddlewareFunction = ({ request }) => {
7878
const { pathname, search } = new URL(request.url);
7979

8080
if (pathname === "/resources" || pathname.startsWith("/resources/")) {
8181
throw redirect(`https://v2.remix.run/${pathname + search}`);
8282
}
8383
};
8484

85-
export const unstable_middleware: Route.unstable_MiddlewareFunction[] = [
85+
export const middleware: Route.MiddlewareFunction[] = [
8686
redirectOldDocs,
8787
redirectResources,
8888
];
@@ -144,7 +144,6 @@ interface DocumentProps {
144144
title?: string;
145145
forceDark?: boolean;
146146
darkBg?: string;
147-
isDev?: boolean;
148147
noIndex: boolean;
149148
children: React.ReactNode;
150149
}
@@ -155,7 +154,6 @@ function Document({
155154
forceDark,
156155
darkBg,
157156
noIndex,
158-
isDev,
159157
}: DocumentProps) {
160158
let colorScheme = useColorScheme();
161159
let matches = useMatches();
@@ -223,11 +221,7 @@ export default function App() {
223221
}
224222

225223
return (
226-
<Document
227-
noIndex={noIndex}
228-
forceDark={forceDark}
229-
isDev={process.env.NODE_ENV === "development"}
230-
>
224+
<Document noIndex={noIndex} forceDark={forceDark}>
231225
<Outlet />
232226
<img
233227
src={iconsHref}

app/routes/[_]actions.newsletter.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { data } from "react-router";
22
import { subscribeToNewsletter } from "~/lib/convertkit";
33
import { requirePost } from "~/lib/http.server";
4-
import type { Route, Info } from "./+types/[_]actions.newsletter";
4+
import type { Route } from "./+types/[_]actions.newsletter";
55

66
export async function action({ request }: Route.ActionArgs) {
77
requirePost(request);
@@ -26,5 +26,3 @@ export async function action({ request }: Route.ActionArgs) {
2626

2727
return { error: null, ok: true };
2828
}
29-
30-
export type NewsletterActionData = Info["actionData"];

app/routes/_marketing._index.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,13 +99,11 @@ function Hero({ sample, sampleSm }: { sample: Prose; sampleSm: Prose }) {
9999
<div className="h-9 xl:h-10" />
100100
<div className="xl: flex flex-col gap-4 xl:flex-row">
101101
<PrimaryButtonLink
102-
prefetch="intent"
103102
to="/docs/start/quickstart"
104103
className="w-full xl:order-1 xl:w-60"
105104
children="Get Started"
106105
/>
107106
<OutlineButtonLink
108-
prefetch="intent"
109107
to="/docs"
110108
className="w-full xl:w-60"
111109
children="Read the Docs"

app/routes/conf.2022._index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export const loader = async ({ request }: LoaderFunctionArgs) => {
2727
.map(
2828
({
2929
// @ts-expect-error -- type is typed wrong
30+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
3031
bio,
3132
...s
3233
}) => s,

app/routes/conf.2023.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export default function ConfTwentyTwentyThree() {
6666
<>
6767
{showTopBanner ? <TopBanner /> : null}
6868
<div className="__layout flex h-full flex-1 flex-col bg-black text-white">
69-
<Header hasTopBanner={showTopBanner} />
69+
<Header />
7070
<main className="flex flex-1 flex-col" tabIndex={-1}>
7171
<Outlet />
7272
</main>
@@ -128,7 +128,7 @@ function SignUp() {
128128
);
129129
}
130130

131-
function Header({ hasTopBanner }: { hasTopBanner?: boolean }) {
131+
function Header() {
132132
let location = useLocation();
133133
let isConfHome =
134134
location.pathname === "/conf" || location.pathname === "/conf/2023";

app/routes/jam/pages/2025.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import ogImageSrc from "../images/og-thumbnail-1.jpg";
1010
import iconsHref from "~/icons.svg";
1111

1212
import type { Route } from "./+types/2025";
13-
import type { NewsletterActionData } from "~/routes/[_]actions.newsletter";
13+
import type { action as newsletterAction } from "~/routes/[_]actions.newsletter";
1414

1515
type EventStatus = "before" | "live" | "after";
1616

@@ -186,7 +186,7 @@ function FadeInBadge({
186186
}
187187

188188
function NewsletterSignup({ className }: { className?: string }) {
189-
const subscribe = useFetcher<NewsletterActionData>();
189+
const subscribe = useFetcher<typeof newsletterAction>();
190190
const { isSuccessful, isError, error } = getSubscribeStatus(subscribe);
191191

192192
return (

app/ui/homepage-scroll-experience.tsx

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -319,23 +319,11 @@ function MutationNetwork() {
319319
<div className="w-4/5 pb-10">
320320
<Network>
321321
<Resource name="POST new" start={0} size={40} />
322-
<Resource
323-
name="GET invoices"
324-
start={40}
325-
size={10}
326-
cancel
327-
hideUntilStart
328-
/>
329-
<Resource
330-
name="GET 102000"
331-
start={40}
332-
size={10}
333-
cancel
334-
hideUntilStart
335-
/>
336-
<Resource name="POST new" start={50} size={20} hideUntilStart />
337-
<Resource name="GET invoices" start={70} size={20} hideUntilStart />
338-
<Resource name="GET 102000" start={70} size={15} hideUntilStart />
322+
<Resource name="GET invoices" start={40} size={10} cancel />
323+
<Resource name="GET 102000" start={40} size={10} cancel />
324+
<Resource name="POST new" start={50} size={20} />
325+
<Resource name="GET invoices" start={70} size={20} />
326+
<Resource name="GET 102000" start={70} size={15} />
339327
</Network>
340328
</div>
341329
</div>
@@ -711,13 +699,11 @@ function Resource({
711699
size,
712700
start,
713701
cancel,
714-
hideUntilStart,
715702
}: {
716703
name: string;
717704
size: number;
718705
start: number;
719706
cancel?: boolean;
720-
hideUntilStart?: boolean;
721707
}) {
722708
let actor = useActor();
723709
let progress = actor.progress * 100;

app/ui/subscribe.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { useFetcher } from "react-router";
33
import type { FormProps } from "react-router";
44
import { Button, Input } from "./buttons";
55
import cx from "clsx";
6-
import type { NewsletterActionData } from "~/routes/[_]actions.newsletter";
6+
import type { action as newsletterAction } from "~/routes/[_]actions.newsletter";
77

88
// TODO: look into if v3_fetcherPersist simplifies this component
99

@@ -31,7 +31,7 @@ function Subscribe({
3131
}
3232

3333
function SubscribeProvider({ children }: { children: React.ReactNode }) {
34-
let subscribe = useFetcher<NewsletterActionData>();
34+
let subscribe = useFetcher<typeof newsletterAction>();
3535
let inputRef = React.useRef<HTMLInputElement>(null);
3636

3737
React.useEffect(() => {
@@ -48,7 +48,7 @@ function SubscribeProvider({ children }: { children: React.ReactNode }) {
4848
}
4949

5050
const SubscribeContext = React.createContext<null | {
51-
fetcher: ReturnType<typeof useFetcher<NewsletterActionData>>;
51+
fetcher: ReturnType<typeof useFetcher<typeof newsletterAction>>;
5252
inputRef: React.RefObject<HTMLInputElement>;
5353
}>(null);
5454

@@ -94,6 +94,7 @@ const SubscribeInput = React.forwardRef<
9494
>(
9595
(
9696
{
97+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
9798
children,
9899
className = "w-full sm:w-auto sm:flex-1 dark:placeholder-gray-500",
99100
...props
@@ -153,7 +154,7 @@ function SubscribeSubmit({
153154
}
154155

155156
export function getSubscribeStatus(
156-
subscribe: ReturnType<typeof useFetcher<NewsletterActionData>>,
157+
subscribe: ReturnType<typeof useFetcher<typeof newsletterAction>>,
157158
) {
158159
let { isSuccessful } =
159160
subscribe.state === "idle" && subscribe.data?.ok

0 commit comments

Comments
 (0)