Skip to content

Commit

Permalink
Revert "Update to React Router 7 pre.2"
Browse files Browse the repository at this point in the history
This reverts commit 9ac7563.
  • Loading branch information
brookslybrand committed Oct 25, 2024
1 parent 9ac7563 commit b5af095
Show file tree
Hide file tree
Showing 47 changed files with 12,774 additions and 5,688 deletions.
6 changes: 3 additions & 3 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
*/
module.exports = {
extends: [
// "@remix-run/eslint-config",
// "@remix-run/eslint-config/node",
// "@remix-run/eslint-config/jest-testing-library",
"@remix-run/eslint-config",
"@remix-run/eslint-config/node",
"@remix-run/eslint-config/jest-testing-library",
"prettier",
],
// we're using vitest which has a very similar API to jest
Expand Down
2 changes: 1 addition & 1 deletion app/components/color-scheme-toggle.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import classNames from "classnames";
import * as React from "react";
import { Form, useLocation } from "react-router";
import { Form, useLocation } from "@remix-run/react";
import { useColorScheme } from "~/modules/color-scheme/components";
import iconsHref from "~/icons.svg";
import { DetailsMenu } from "~/modules/details-menu";
Expand Down
6 changes: 5 additions & 1 deletion app/components/doc-error-boundary.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { isRouteErrorResponse, useParams, useRouteError } from "react-router";
import {
isRouteErrorResponse,
useParams,
useRouteError,
} from "@remix-run/react";

export function ErrorBoundary() {
let error = useRouteError();
Expand Down
3 changes: 2 additions & 1 deletion app/components/doc-layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ import { useRef } from "react";
import { type Doc } from "~/modules/gh-docs/.server";
import { useDelegatedReactRouterLinks } from "~/ui/delegate-markdown-links";
import { LargeOnThisPage, SmallOnThisPage } from "./on-this-page";
import { type SerializeFrom } from "@remix-run/node";

export function DocLayout({ doc }: { doc: Doc }) {
export function DocLayout({ doc }: { doc: SerializeFrom<Doc> }) {
let ref = useRef<HTMLDivElement>(null);
useDelegatedReactRouterLinks(ref);

Expand Down
2 changes: 1 addition & 1 deletion app/components/docs-footer.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Link, useParams } from "react-router";
import { Link, useParams } from "@remix-run/react";
import { useDoc } from "~/hooks/use-doc";
import iconsHref from "~/icons.svg";

Expand Down
5 changes: 4 additions & 1 deletion app/components/docs-header/data.server.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { type SerializeFrom } from "@remix-run/node";
import { getRepoBranches, getRepoTags } from "~/modules/gh-docs/.server";
import { getLatestVersion } from "~/modules/gh-docs/.server/tags";

export type HeaderData = Awaited<ReturnType<typeof getHeaderData>>;
export type HeaderData = Awaited<
SerializeFrom<ReturnType<typeof getHeaderData>>
>;

export async function getHeaderData(lang: string, ref?: string) {
let githubRef = ref || "main";
Expand Down
2 changes: 1 addition & 1 deletion app/components/docs-header/docs-header.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Link, useNavigate } from "react-router";
import { Link, useNavigate } from "@remix-run/react";
import iconsHref from "~/icons.svg";
import { ColorSchemeToggle } from "../color-scheme-toggle";
import classNames from "classnames";
Expand Down
4 changes: 2 additions & 2 deletions app/components/docs-header/use-header-data.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { useLoaderData, useMatches } from "react-router";
import { useLoaderData, useMatches } from "@remix-run/react";
import type { HeaderData } from "./data.server";
import invariant from "tiny-invariant";

export function useHeaderData() {
let data = useLoaderData<{ header: HeaderData }>();
let data = useLoaderData() as { header: HeaderData };
invariant(data && data.header, "Expected `header` in loader data");
return data.header;
}
Expand Down
9 changes: 7 additions & 2 deletions app/components/docs-menu/data.server.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
import { type SerializeFrom } from "@remix-run/node";
import {
getRepoDocsMenu,
getRepoDocsReferenceMenu,
} from "~/modules/gh-docs/.server";

export type GuidesMenu = Awaited<ReturnType<typeof loadGuidesMenu>>;
export type GuidesMenu = Awaited<
SerializeFrom<ReturnType<typeof loadGuidesMenu>>
>;

export type ReferenceMenu = Awaited<ReturnType<typeof loadGuidesMenu>>;
export type ReferenceMenu = Awaited<
SerializeFrom<ReturnType<typeof loadGuidesMenu>>
>;

export async function loadGuidesMenu(ref: string) {
return getRepoDocsMenu(ref, "en");
Expand Down
2 changes: 1 addition & 1 deletion app/components/docs-menu/menu.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from "react";
import { Link, useLoaderData } from "react-router";
import { Link, useLoaderData } from "@remix-run/react";
import classNames from "classnames";

import iconsHref from "~/icons.svg";
Expand Down
2 changes: 1 addition & 1 deletion app/components/nav-pill.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { NavLink, useNavigation, useParams } from "react-router";
import { NavLink, useNavigation, useParams } from "@remix-run/react";
import classNames from "classnames";
import { VersionSelect } from "./version-select";
import { useHeaderData } from "./docs-header/use-header-data";
Expand Down
7 changes: 4 additions & 3 deletions app/components/on-this-page.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { Link } from "react-router";
import { type SerializeFrom } from "@remix-run/node";
import { Link } from "@remix-run/react";
import { type Doc } from "~/modules/gh-docs/.server";
import iconsHref from "~/icons.svg";

export function LargeOnThisPage({ doc }: { doc: Doc }) {
export function LargeOnThisPage({ doc }: { doc: SerializeFrom<Doc> }) {
return (
<div className="sticky top-36 order-1 mt-20 hidden max-h-[calc(100vh-9rem)] w-56 min-w-min 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 @@ -26,7 +27,7 @@ export function LargeOnThisPage({ doc }: { doc: Doc }) {
);
}

export function SmallOnThisPage({ doc }: { doc: Doc }) {
export function SmallOnThisPage({ doc }: { doc: SerializeFrom<Doc> }) {
return (
<details className="group flex flex-col lg:mt-4 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
8 changes: 4 additions & 4 deletions app/components/package-select.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import classNames from "classnames";
import { Link, useLoaderData, useParams } from "react-router";
import { Link, useLoaderData, useParams } from "@remix-run/react";
import invariant from "tiny-invariant";

import { type SerializeFrom } from "@remix-run/node";
import iconsHref from "~/icons.svg";
import { DetailsMenu } from "~/modules/details-menu";
import { DetailsPopup } from "./details-popup";
import { PopupLabel } from "./popup-label";
import { type loadPackageNames } from "~/components/docs-menu/data.server";

type Pkg = Awaited<ReturnType<typeof loadPackageNames>>;
type Pkg = Awaited<SerializeFrom<ReturnType<typeof loadPackageNames>>>;

export function PackageSelect() {
let { pkgs } = useLoaderData<{ pkgs: Pkg }>();
let { pkgs } = useLoaderData() as { pkgs: Pkg };
invariant(pkgs, "Expected loaderData.pkgs");

let { pkg } = useParams();
Expand Down
2 changes: 1 addition & 1 deletion app/components/use-doc-layout-id.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useMatches } from "react-router";
import { useMatches } from "@remix-run/react";

export function useDocLayoutId() {
let matches = useMatches();
Expand Down
2 changes: 1 addition & 1 deletion app/components/version-select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import iconsHref from "~/icons.svg";
import { DetailsMenu } from "~/modules/details-menu";
import { DetailsPopup } from "./details-popup";
import { PopupLabel } from "./popup-label";
import { Link } from "react-router";
import { Link } from "@remix-run/react";
import classNames from "classnames";
import { useHeaderData } from "./docs-header/use-header-data";
import { useDocLayoutId } from "./use-doc-layout-id";
Expand Down
2 changes: 1 addition & 1 deletion app/components/version-warning.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Link } from "react-router";
import { Link } from "@remix-run/react";
import { useHeaderData } from "./docs-header/use-header-data";

export function VersionWarning() {
Expand Down
2 changes: 1 addition & 1 deletion app/hooks/use-doc.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useMatches } from "react-router";
import { useMatches } from "@remix-run/react";
import type { Doc } from "~/modules/gh-docs/.server";

/**
Expand Down
2 changes: 1 addition & 1 deletion app/hooks/use-navigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {
useLocation,
useNavigation as useNavigation_,
useResolvedPath,
} from "react-router";
} from "@remix-run/react";

export function useNavigation(to?: string, end?: boolean) {
let navigation_ = useNavigation_();
Expand Down
7 changes: 3 additions & 4 deletions app/modules/color-scheme/components.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { useLayoutEffect, useMemo } from "react";
import { useMatches, useNavigation } from "react-router";
import type { SerializeFrom } from "@remix-run/node";
import { useMatches, useNavigation } from "@remix-run/react";
import type { loader as rootLoader } from "../../root";
import type { ColorScheme } from "./types";

export function useColorScheme(): ColorScheme {
let rootLoaderData = useMatches()[0].data as Awaited<
ReturnType<typeof rootLoader>
>;
let rootLoaderData = useMatches()[0].data as SerializeFrom<typeof rootLoader>;
let { formData } = useNavigation();
let optimisticColorScheme =
formData && formData.has("colorScheme")
Expand Down
4 changes: 2 additions & 2 deletions app/modules/color-scheme/server.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createCookie, redirect } from "react-router";
import type { ActionFunction } from "react-router";
import { createCookie, redirect } from "@remix-run/node";
import type { ActionFunction } from "@remix-run/node";
import type { ColorScheme } from "./types";

let cookie = createCookie("color-scheme", {
Expand Down
2 changes: 1 addition & 1 deletion app/modules/details-menu/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useLocation, useNavigation } from "react-router";
import { useLocation, useNavigation } from "@remix-run/react";
import * as React from "react";

/**
Expand Down
2 changes: 1 addition & 1 deletion app/modules/http-utils/ensure-secure.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { redirect } from "react-router";
import { redirect } from "@remix-run/node";

export async function ensureSecure(request: Request) {
let proto = request.headers.get("x-forwarded-proto");
Expand Down
2 changes: 1 addition & 1 deletion app/modules/http-utils/remove-slashes.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { redirect } from "react-router";
import { redirect } from "@remix-run/node";

export async function removeTrailingSlashes(request: Request) {
let url = new URL(request.url);
Expand Down
2 changes: 1 addition & 1 deletion app/modules/redirects/.server/check-url.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { redirect } from "react-router";
import { redirect } from "@remix-run/node";
import type { Redirect } from "./get-redirects";

export async function checkUrl(url: string, redirects: Redirect[]) {
Expand Down
2 changes: 1 addition & 1 deletion app/modules/remix-seo/seo.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { LinkDescriptor, MetaDescriptor } from "react-router";
import type { LinkDescriptor, MetaDescriptor } from "@remix-run/node";
import merge from "lodash.merge";

export function getSeo(defaultConfig: SeoProps) {
Expand Down
4 changes: 2 additions & 2 deletions app/pages/api-doc.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { HeadersArgs, LoaderFunctionArgs } from "react-router";
import { useLoaderData, type MetaFunction } from "react-router";
import type { HeadersArgs, LoaderFunctionArgs } from "@remix-run/node";
import { useLoaderData, type MetaFunction } from "@remix-run/react";
import invariant from "tiny-invariant";

import { CACHE_CONTROL } from "~/http";
Expand Down
4 changes: 2 additions & 2 deletions app/pages/api-index.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import * as React from "react";
import type { HeadersArgs, LoaderFunctionArgs } from "react-router";
import type { HeadersArgs, LoaderFunctionArgs } from "@remix-run/node";
import {
type MetaFunction,
useLoaderData,
useRouteLoaderData,
} from "react-router";
} from "@remix-run/react";
import invariant from "tiny-invariant";

import { CACHE_CONTROL } from "~/http";
Expand Down
4 changes: 2 additions & 2 deletions app/pages/api-layout.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import invariant from "tiny-invariant";
import { Outlet } from "react-router";
import { Outlet } from "@remix-run/react";
import classNames from "classnames";

import docsStylesheet from "~/styles/docs.css?url";
Expand All @@ -15,7 +15,7 @@ import {
import { PackageSelect } from "~/components/package-select";
import { Menu } from "~/components/docs-menu/menu";

import type { LinksFunction, LoaderFunctionArgs } from "react-router";
import type { LinksFunction, LoaderFunctionArgs } from "@remix-run/node";

export let links: LinksFunction = () => {
return [{ rel: "stylesheet", href: docsStylesheet }];
Expand Down
2 changes: 1 addition & 1 deletion app/pages/api-redirect.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type LoaderFunctionArgs, redirect } from "react-router";
import { type LoaderFunctionArgs, redirect } from "@remix-run/node";

export function loader({ params }: LoaderFunctionArgs) {
return redirect(
Expand Down
2 changes: 1 addition & 1 deletion app/pages/brand.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { MetaFunction } from "react-router";
import type { MetaFunction } from "@remix-run/node";
import classNames from "classnames";

export const meta: MetaFunction = () => {
Expand Down
4 changes: 2 additions & 2 deletions app/pages/guide.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import invariant from "tiny-invariant";
import { useLoaderData } from "react-router";
import { useLoaderData } from "@remix-run/react";

import { getRepoDoc } from "~/modules/gh-docs/.server";
import { CACHE_CONTROL } from "~/http";
Expand All @@ -9,7 +9,7 @@ import type {
LoaderFunctionArgs,
MetaFunction,
HeadersArgs,
} from "react-router";
} from "@remix-run/node";

import {
getGuideMatchData,
Expand Down
4 changes: 2 additions & 2 deletions app/pages/guides-index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { HeadersArgs, MetaFunction } from "react-router";
import { Link } from "react-router";
import type { HeadersArgs, MetaFunction } from "@remix-run/node";
import { Link } from "@remix-run/react";
import classNames from "classnames";
import { CACHE_CONTROL } from "~/http";
import {
Expand Down
4 changes: 2 additions & 2 deletions app/pages/guides-layout.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { LinksFunction, LoaderFunctionArgs } from "react-router";
import { Outlet } from "react-router";
import type { LinksFunction, LoaderFunctionArgs } from "@remix-run/node";
import { Outlet } from "@remix-run/react";
import classNames from "classnames";

import docsStylesheet from "~/styles/docs.css?url";
Expand Down
2 changes: 1 addition & 1 deletion app/pages/healthcheck.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// learn more: https://fly.io/docs/reference/configuration/#services-http_checks
import type { LoaderFunction } from "react-router";
import type { LoaderFunction } from "@remix-run/node";

export const loader: LoaderFunction = async ({ request }) => {
const host =
Expand Down
8 changes: 4 additions & 4 deletions app/pages/home.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { type MetaFunction } from "react-router";
import { Await, Link, useLoaderData } from "react-router";
import { type MetaFunction } from "@remix-run/node";
import { Await, Link, useLoaderData } from "@remix-run/react";
import { Suspense } from "react";

import iconsHref from "~/icons.svg";
import { getStats, type Stats } from "~/modules/stats";
import { getStats } from "~/modules/stats";
import { getRootMatchData } from "~/ui/meta";

export let loader = async () => {
Expand Down Expand Up @@ -148,7 +148,7 @@ export default function Home() {
<div>
<Suspense fallback={null}>
<Await resolve={stats} errorElement={null}>
{(stats: Stats[]) => (
{(stats) => (
<ul className="mt-8 grid grid-cols-1 gap-8 md:grid md:grid-cols-2">
{/* TODO: single fetch bug? */}
{stats.map(({ svgId, count, label }) => (
Expand Down
4 changes: 2 additions & 2 deletions app/pages/notfound.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { type MetaFunction } from "react-router";
import { Link, isRouteErrorResponse, useRouteError } from "react-router";
import { type MetaFunction } from "@remix-run/react";
import { Link, isRouteErrorResponse, useRouteError } from "@remix-run/react";
import { CACHE_CONTROL } from "~/http";

export let loader = async () => {
Expand Down
2 changes: 1 addition & 1 deletion app/pages/redirect-v6-doc.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { redirect, type LoaderFunctionArgs } from "react-router";
import { redirect, type LoaderFunctionArgs } from "@remix-run/node";
import { getRepoTags } from "~/modules/gh-docs/.server";
import * as semver from "semver";

Expand Down
2 changes: 1 addition & 1 deletion app/pages/redirect-v7-doc.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { redirect, type LoaderFunctionArgs } from "react-router";
import { redirect, type LoaderFunctionArgs } from "@remix-run/node";
import { getRepoTags } from "~/modules/gh-docs/.server";
import * as semver from "semver";

Expand Down
4 changes: 2 additions & 2 deletions app/root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ import type {
HeadersArgs,
LinksFunction,
LoaderFunctionArgs,
} from "react-router";
} from "@remix-run/node";
import {
Link,
Links,
Meta,
Outlet,
Scripts,
ScrollRestoration,
} from "react-router";
} from "@remix-run/react";
import { CACHE_CONTROL, middlewares } from "./http";

import { parseColorScheme } from "./modules/color-scheme/server";
Expand Down
Loading

0 comments on commit b5af095

Please sign in to comment.