Skip to content

Commit

Permalink
switch to react-router v7
Browse files Browse the repository at this point in the history
one tricky part was needing to _remove_ package-lock.json
as that was holding onto a remix version that was no longer
used

another tricky part was that the codemod didn't realize that
cloudflare and cloudflare-pages were combined under react-router.
i found that through this pull request: remix-run/react-router#11801

i kept the file system paths for now, and will switch to route
config once i look more into it.
  • Loading branch information
dlcoffee committed Dec 2, 2024
1 parent b39742c commit 6576c03
Show file tree
Hide file tree
Showing 16 changed files with 4,781 additions and 9,382 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ node_modules
.env
.dev.vars

.react-router/
.wrangler
.env

Expand Down
4 changes: 2 additions & 2 deletions app/entry.client.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
* For more information, see https://remix.run/file-conventions/entry.client
*/

import { RemixBrowser } from '@remix-run/react'
import { HydratedRouter } from 'react-router/dom';
import { startTransition, StrictMode } from 'react'
import { hydrateRoot } from 'react-dom/client'

startTransition(() => {
hydrateRoot(
document,
<StrictMode>
<RemixBrowser />
<HydratedRouter />
</StrictMode>
)
})
8 changes: 4 additions & 4 deletions app/entry.server.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
* For more information, see https://remix.run/file-conventions/entry.server
*/

import type { AppLoadContext, EntryContext } from '@remix-run/cloudflare'
import { RemixServer } from '@remix-run/react'
import type { AppLoadContext, EntryContext } from 'react-router';
import { ServerRouter } from 'react-router';
import { isbot } from 'isbot'
import { renderToReadableStream } from 'react-dom/server'

Expand All @@ -15,7 +15,7 @@ export default async function handleRequest(
request: Request,
responseStatusCode: number,
responseHeaders: Headers,
remixContext: EntryContext,
reactRouterContext: EntryContext,
// This is ignored so we can keep it in the template for visibility. Feel
// free to delete this parameter in your app if you're not using it!
// eslint-disable-next-line @typescript-eslint/no-unused-vars
Expand All @@ -25,7 +25,7 @@ export default async function handleRequest(
const timeoutId = setTimeout(() => controller.abort(), ABORT_DELAY)

const body = await renderToReadableStream(
<RemixServer context={remixContext} url={request.url} abortDelay={ABORT_DELAY} />,
<ServerRouter context={reactRouterContext} url={request.url} abortDelay={ABORT_DELAY} />,
{
signal: controller.signal,
onError(error: unknown) {
Expand Down
4 changes: 2 additions & 2 deletions app/root.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { type MetaFunction } from '@remix-run/cloudflare'
import { Link, Links, Meta, Outlet, Scripts, ScrollRestoration } from '@remix-run/react'
import { type MetaFunction } from 'react-router';
import { Link, Links, Meta, Outlet, Scripts, ScrollRestoration } from 'react-router';
import '~/tailwind.css'

export const meta: MetaFunction = () => {
Expand Down
4 changes: 4 additions & 0 deletions app/routes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { flatRoutes } from '@react-router/fs-routes'
import { type RouteConfig } from '@react-router/dev/routes'

export default flatRoutes() satisfies RouteConfig
2 changes: 1 addition & 1 deletion app/routes/_index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { type ReactNode } from 'react'
import { Link, useLoaderData } from '@remix-run/react'
import { Link, useLoaderData } from 'react-router';
import { formatInTimeZone } from 'date-fns-tz'
import { type Day, type Item, type SourceDomain } from '~/data/items'

Expand Down
4 changes: 2 additions & 2 deletions app/routes/a.$id.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useLoaderData } from '@remix-run/react'
import type { LoaderFunctionArgs, MetaFunction } from '@remix-run/cloudflare'
import { useLoaderData } from 'react-router';
import type { LoaderFunctionArgs, MetaFunction } from 'react-router';

import { db } from '~/utils/db.server'

Expand Down
4 changes: 2 additions & 2 deletions app/routes/m.$id.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useLoaderData } from '@remix-run/react'
import { type LoaderFunctionArgs } from '@remix-run/cloudflare'
import { useLoaderData } from 'react-router';
import { type LoaderFunctionArgs } from 'react-router';

import { db } from '~/utils/db.server'

Expand Down
9 changes: 4 additions & 5 deletions app/routes/t._$index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Link, useLoaderData } from '@remix-run/react'
import { type LoaderFunctionArgs } from '@remix-run/cloudflare'
import { Link, useLoaderData } from 'react-router';
import { type LoaderFunctionArgs } from 'react-router';
import { formatInTimeZone } from 'date-fns-tz'
import { type Day, type Item, type SourceDomain } from '~/data/items'

Expand Down Expand Up @@ -35,9 +35,8 @@ function isCharacterTalentMaterial(item: Item) {

return (
// talent materials are typed both ways for some reason
(type.includes('Character Talent Material') || type.includes('Talent Level-Up Material')) &&
names.some((name) => item.name.toLowerCase().includes(name))
)
((type.includes('Character Talent Material') || type.includes('Talent Level-Up Material')) && names.some((name) => item.name.toLowerCase().includes(name)))
);
}

function isCharacterAscensionMaterial(item: Item) {
Expand Down
2 changes: 1 addition & 1 deletion app/routes/t.new.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useState } from 'react'
import { useLoaderData, useNavigate } from '@remix-run/react'
import { useLoaderData, useNavigate } from 'react-router';

import { db } from '~/utils/db.server'

Expand Down
2 changes: 1 addition & 1 deletion functions/[[path]].ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createPagesFunctionHandler } from '@remix-run/cloudflare-pages'
import { createPagesFunctionHandler } from '@react-router/cloudflare'

// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore - the server build file is generated by `remix vite:build`
Expand Down
Loading

0 comments on commit 6576c03

Please sign in to comment.