Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to Remix 2.12.0 #295

Merged
merged 4 commits into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions app/routes/[_]actions.newsletter.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { json } from "@remix-run/node";
import { unstable_data as data } from "@remix-run/node";
import type { ActionFunctionArgs } from "@remix-run/node";
import { subscribeToNewsletter } from "~/lib/convertkit";
import { requirePost } from "~/lib/http.server";
Expand All @@ -9,14 +9,14 @@ export const action = async ({ request }: ActionFunctionArgs) => {
let body = new URLSearchParams(await request.text());
let email = body.get("email");
if (typeof email !== "string" || email.indexOf("@") === -1) {
return json({ error: "Invalid Email", ok: false }, { status: 400 });
return data({ error: "Invalid Email", ok: false }, { status: 400 });
}

try {
await subscribeToNewsletter(email);
} catch (e: any) {
return json({ error: e.message || "Unknown error", ok: false });
return data({ error: e.message || "Unknown error", ok: false });
}

return json({ error: null, ok: true });
return data({ error: null, ok: true });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This and the prior one don't need data() because they don't care about the status but there's a known issue in our type inference that doesn't like the mixing and matching of data/json/etc. and raw objects so using data everywhere to avoid that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left a comment on the RR PR, should have read this one first.

Thanks for the explanation!

};
16 changes: 6 additions & 10 deletions app/routes/docs.$lang.$ref.$.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,8 @@ import {
useParams,
useRouteError,
} from "@remix-run/react";
import { json } from "@remix-run/node";
import type {
HeadersFunction,
LoaderFunctionArgs,
SerializeFrom,
} from "@remix-run/node";
import { unstable_data as data } from "@remix-run/node";
import type { HeadersFunction, LoaderFunctionArgs } from "@remix-run/node";
import type { MetaFunction } from "@remix-run/react";
import { CACHE_CONTROL, handleRedirects } from "~/lib/http.server";
import invariant from "tiny-invariant";
Expand All @@ -36,7 +32,7 @@ export async function loader({ params, request }: LoaderFunctionArgs) {
: `docs/${params["*"] || "index"}`;
let doc = await getRepoDoc(params.ref, slug);
if (!doc) throw null;
return json(
return data(
{ doc, siteUrl, ogImageUrl },
{ headers: { "Cache-Control": CACHE_CONTROL.DEFAULT } },
);
Expand All @@ -47,7 +43,7 @@ export async function loader({ params, request }: LoaderFunctionArgs) {
// to a missing slug on an old version or tag, then a 404 feels appropriate.
handleRedirects(`/docs/${params["*"]}`);
}
throw json(null, { status: 404 });
throw data(null, { status: 404 });
}
}

Expand Down Expand Up @@ -156,7 +152,7 @@ export default function DocPage() {
);
}

function LargeOnThisPage({ doc }: { doc: SerializeFrom<Doc> }) {
function LargeOnThisPage({ doc }: { doc: Doc }) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With Single Fetch now we just get back a Doc

return (
<div className="sticky top-36 order-1 mt-20 hidden max-h-[calc(100vh-9rem)] w-56 flex-shrink-0 self-start overflow-y-auto pb-10 xl:block">
<nav className="mb-3 flex items-center font-semibold">On this page</nav>
Expand All @@ -182,7 +178,7 @@ function LargeOnThisPage({ doc }: { doc: SerializeFrom<Doc> }) {
);
}

function SmallOnThisPage({ doc }: { doc: SerializeFrom<Doc> }) {
function SmallOnThisPage({ doc }: { doc: Doc }) {
return (
<details className="group -mx-4 flex h-full flex-col sm:-mx-6 lg:mx-0 lg:mt-4 xl:ml-80 xl:hidden">
<summary className="_no-triangle flex cursor-pointer select-none items-center gap-2 border-b border-gray-50 bg-white px-2 py-3 text-sm font-medium hover:bg-gray-50 active:bg-gray-100 dark:border-gray-700 dark:bg-gray-900 dark:hover:bg-gray-800 dark:active:bg-gray-700">
Expand Down
Loading