Skip to content

Commit

Permalink
replace DataFunctionArgs
Browse files Browse the repository at this point in the history
  • Loading branch information
kentcdodds committed Jul 3, 2024
1 parent e52bcda commit c4efabc
Show file tree
Hide file tree
Showing 2,999 changed files with 10,300 additions and 7,701 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Changelog

This file will keep track of significant changes that have happened in the
workshop material that is different from what you'll see in the videos.

## DataFunctionArgs

`DataFunctionArgs` was deprecated in Remix and will be removed in the future. It
is recommended to use `LoaderFunctionArgs` and `ActionFunctionArgs` instead
which are the exact same.
2 changes: 1 addition & 1 deletion epicshop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
"execa": "^8.0.1",
"fs-extra": "^11.1.1"
}
}
}
22 changes: 11 additions & 11 deletions epicshop/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"compilerOptions": {
"module": "NodeNext",
"target": "es2022",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"allowJs": true,
"skipLibCheck": true,
"noEmit": true
}
}
{
"compilerOptions": {
"module": "NodeNext",
"target": "es2022",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"allowJs": true,
"skipLibCheck": true,
"noEmit": true
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export function GeneralErrorBoundary({
? (statusHandlers?.[error.status] ?? defaultStatusHandler)({
error,
params,
})
})
: unexpectedErrorHandler(error)}
</div>
)
Expand Down
7 changes: 4 additions & 3 deletions exercises/01.cookies/01.problem.fetcher/app/root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import { parse } from '@conform-to/zod'
import { cssBundleHref } from '@remix-run/css-bundle'
import {
json,
type DataFunctionArgs,
type LoaderFunctionArgs,
type ActionFunctionArgs,
type LinksFunction,
} from '@remix-run/node'
import {
Expand Down Expand Up @@ -47,7 +48,7 @@ export const links: LinksFunction = () => {
].filter(Boolean)
}

export async function loader({ request }: DataFunctionArgs) {
export async function loader({ request }: LoaderFunctionArgs) {
const [csrfToken, csrfCookieHeader] = await csrf.commitToken(request)
const honeyProps = honeypot.getInputProps()
return json(
Expand All @@ -67,7 +68,7 @@ const ThemeFormSchema = z.object({
theme: z.enum(['light', 'dark']),
})

export async function action({ request }: DataFunctionArgs) {
export async function action({ request }: ActionFunctionArgs) {
const formData = await request.formData()
invariantResponse(
formData.get('intent') === 'update-theme',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { getFieldsetConstraint, parse } from '@conform-to/zod'
import {
json,
redirect,
type DataFunctionArgs,
type ActionFunctionArgs,
type MetaFunction,
} from '@remix-run/node'
import { Form, Link, useActionData } from '@remix-run/react'
Expand All @@ -24,7 +24,7 @@ const LoginFormSchema = z.object({
password: PasswordSchema,
})

export async function action({ request }: DataFunctionArgs) {
export async function action({ request }: ActionFunctionArgs) {
const formData = await request.formData()
await validateCSRF(formData, request.headers)
checkHoneypot(formData)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { getFieldsetConstraint, parse } from '@conform-to/zod'
import {
json,
redirect,
type DataFunctionArgs,
type ActionFunctionArgs,
type MetaFunction,
} from '@remix-run/node'
import { Form, useActionData } from '@remix-run/react'
Expand Down Expand Up @@ -46,7 +46,7 @@ const SignupFormSchema = z
}
})

export async function action({ request }: DataFunctionArgs) {
export async function action({ request }: ActionFunctionArgs) {
const formData = await request.formData()
await validateCSRF(formData, request.headers)
checkHoneypot(formData)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { type DataFunctionArgs } from '@remix-run/node'
import { type LoaderFunctionArgs } from '@remix-run/node'
import { prisma } from '#app/utils/db.server.ts'
import { invariantResponse } from '#app/utils/misc.tsx'

export async function loader({ params }: DataFunctionArgs) {
export async function loader({ params }: LoaderFunctionArgs) {
invariantResponse(params.imageId, 'Image ID is required', { status: 400 })
const image = await prisma.noteImage.findUnique({
where: { id: params.imageId },
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { type DataFunctionArgs } from '@remix-run/node'
import { type LoaderFunctionArgs } from '@remix-run/node'
import { prisma } from '#app/utils/db.server.ts'
import { invariantResponse } from '#app/utils/misc.tsx'

export async function loader({ params }: DataFunctionArgs) {
export async function loader({ params }: LoaderFunctionArgs) {
invariantResponse(params.imageId, 'Image ID is required', { status: 400 })
const image = await prisma.userImage.findUnique({
where: { id: params.imageId },
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { json, type DataFunctionArgs } from '@remix-run/node'
import { json, type LoaderFunctionArgs } from '@remix-run/node'
import { Link, useLoaderData, type MetaFunction } from '@remix-run/react'
import { GeneralErrorBoundary } from '#app/components/error-boundary.tsx'
import { Spacer } from '#app/components/spacer.tsx'
import { Button } from '#app/components/ui/button.tsx'
import { prisma } from '#app/utils/db.server.ts'
import { getUserImgSrc, invariantResponse } from '#app/utils/misc.tsx'

export async function loader({ params }: DataFunctionArgs) {
export async function loader({ params }: LoaderFunctionArgs) {
const user = await prisma.user.findFirst({
select: {
name: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
json,
unstable_parseMultipartFormData as parseMultipartFormData,
redirect,
type DataFunctionArgs,
type ActionFunctionArgs,
type SerializeFrom,
} from '@remix-run/node'
import { Form, useActionData } from '@remix-run/react'
Expand Down Expand Up @@ -72,7 +72,7 @@ const NoteEditorSchema = z.object({
images: z.array(ImageFieldsetSchema).max(5).optional(),
})

export async function action({ request, params }: DataFunctionArgs) {
export async function action({ request, params }: ActionFunctionArgs) {
const formData = await parseMultipartFormData(
request,
createMemoryUploadHandler({ maxPartSize: MAX_UPLOAD_SIZE }),
Expand Down Expand Up @@ -226,7 +226,7 @@ export function NoteEditor({
className="relative border-b-2 border-muted-foreground"
>
<button
className="text-foreground-destructive absolute right-0 top-0"
className="absolute right-0 top-0 text-foreground-destructive"
{...list.remove(fields.images.name, { index })}
>
<span aria-hidden>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import { useForm } from '@conform-to/react'
import { getFieldsetConstraint, parse } from '@conform-to/zod'
import { json, redirect, type DataFunctionArgs } from '@remix-run/node'
import {
json,
redirect,
type ActionFunctionArgs,
type LoaderFunctionArgs,
} from '@remix-run/node'
import {
Form,
Link,
Expand All @@ -26,7 +31,7 @@ import {
} from '#app/utils/misc.tsx'
import { type loader as notesLoader } from './notes.tsx'

export async function loader({ params }: DataFunctionArgs) {
export async function loader({ params }: LoaderFunctionArgs) {
const note = await prisma.note.findUnique({
where: { id: params.noteId },
select: {
Expand Down Expand Up @@ -60,7 +65,7 @@ const DeleteFormSchema = z.object({
noteId: z.string(),
})

export async function action({ request, params }: DataFunctionArgs) {
export async function action({ request, params }: ActionFunctionArgs) {
const formData = await request.formData()
await validateCSRF(formData, request.headers)
const submission = parse(formData, {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { json, type DataFunctionArgs } from '@remix-run/node'
import { json, type LoaderFunctionArgs } from '@remix-run/node'
import { useLoaderData } from '@remix-run/react'
import { prisma } from '#app/utils/db.server.ts'
import { invariantResponse } from '#app/utils/misc.tsx'
import { NoteEditor, action } from './__note-editor.tsx'

export { action }

export async function loader({ params }: DataFunctionArgs) {
export async function loader({ params }: LoaderFunctionArgs) {
const note = await prisma.note.findFirst({
select: {
id: true,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { json, type DataFunctionArgs } from '@remix-run/node'
import { json, type LoaderFunctionArgs } from '@remix-run/node'
import { Link, NavLink, Outlet, useLoaderData } from '@remix-run/react'
import { GeneralErrorBoundary } from '#app/components/error-boundary.tsx'
import { Icon } from '#app/components/ui/icon.tsx'
import { prisma } from '#app/utils/db.server.ts'
import { cn, getUserImgSrc, invariantResponse } from '#app/utils/misc.tsx'

export async function loader({ params }: DataFunctionArgs) {
export async function loader({ params }: LoaderFunctionArgs) {
const owner = await prisma.user.findFirst({
select: {
id: true,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { json, redirect, type DataFunctionArgs } from '@remix-run/node'
import { json, redirect, type LoaderFunctionArgs } from '@remix-run/node'
import { Link, useLoaderData } from '@remix-run/react'
import { z } from 'zod'
import { GeneralErrorBoundary } from '#app/components/error-boundary.tsx'
Expand All @@ -16,7 +16,7 @@ const UserSearchResultSchema = z.object({

const UserSearchResultsSchema = z.array(UserSearchResultSchema)

export async function loader({ request }: DataFunctionArgs) {
export async function loader({ request }: LoaderFunctionArgs) {
const searchTerm = new URL(request.url).searchParams.get('search')
if (searchTerm === '') {
return redirect('/users')
Expand Down
12 changes: 6 additions & 6 deletions exercises/01.cookies/01.problem.fetcher/app/utils/db.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ const prisma = remember('prisma', () => {
e.duration < logThreshold * 1.1
? 'green'
: e.duration < logThreshold * 1.2
? 'blue'
: e.duration < logThreshold * 1.3
? 'yellow'
: e.duration < logThreshold * 1.4
? 'redBright'
: 'red'
? 'blue'
: e.duration < logThreshold * 1.3
? 'yellow'
: e.duration < logThreshold * 1.4
? 'redBright'
: 'red'
const dur = chalk[color](`${e.duration}ms`)
console.info(`prisma:query - ${dur} - ${e.query}`)
})
Expand Down
4 changes: 2 additions & 2 deletions exercises/01.cookies/01.problem.fetcher/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ const server = app.listen(portToUse, () => {
desiredPort === portToUse
? desiredPort
: addy && typeof addy === 'object'
? addy.port
: 0
? addy.port
: 0

if (portUsed !== desiredPort) {
console.warn(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export function GeneralErrorBoundary({
? (statusHandlers?.[error.status] ?? defaultStatusHandler)({
error,
params,
})
})
: unexpectedErrorHandler(error)}
</div>
)
Expand Down
7 changes: 4 additions & 3 deletions exercises/01.cookies/01.solution.fetcher/app/root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import { parse } from '@conform-to/zod'
import { cssBundleHref } from '@remix-run/css-bundle'
import {
json,
type DataFunctionArgs,
type ActionFunctionArgs,
type LoaderFunctionArgs,
type LinksFunction,
} from '@remix-run/node'
import {
Expand Down Expand Up @@ -48,7 +49,7 @@ export const links: LinksFunction = () => {
].filter(Boolean)
}

export async function loader({ request }: DataFunctionArgs) {
export async function loader({ request }: LoaderFunctionArgs) {
const [csrfToken, csrfCookieHeader] = await csrf.commitToken(request)
const honeyProps = honeypot.getInputProps()
return json(
Expand All @@ -68,7 +69,7 @@ const ThemeFormSchema = z.object({
theme: z.enum(['light', 'dark']),
})

export async function action({ request }: DataFunctionArgs) {
export async function action({ request }: ActionFunctionArgs) {
const formData = await request.formData()
invariantResponse(
formData.get('intent') === 'update-theme',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { getFieldsetConstraint, parse } from '@conform-to/zod'
import {
json,
redirect,
type DataFunctionArgs,
type ActionFunctionArgs,
type MetaFunction,
} from '@remix-run/node'
import { Form, Link, useActionData } from '@remix-run/react'
Expand All @@ -24,7 +24,7 @@ const LoginFormSchema = z.object({
password: PasswordSchema,
})

export async function action({ request }: DataFunctionArgs) {
export async function action({ request }: ActionFunctionArgs) {
const formData = await request.formData()
await validateCSRF(formData, request.headers)
checkHoneypot(formData)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { getFieldsetConstraint, parse } from '@conform-to/zod'
import {
json,
redirect,
type DataFunctionArgs,
type ActionFunctionArgs,
type MetaFunction,
} from '@remix-run/node'
import { Form, useActionData } from '@remix-run/react'
Expand Down Expand Up @@ -46,7 +46,7 @@ const SignupFormSchema = z
}
})

export async function action({ request }: DataFunctionArgs) {
export async function action({ request }: ActionFunctionArgs) {
const formData = await request.formData()
await validateCSRF(formData, request.headers)
checkHoneypot(formData)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { type DataFunctionArgs } from '@remix-run/node'
import { type LoaderFunctionArgs } from '@remix-run/node'
import { prisma } from '#app/utils/db.server.ts'
import { invariantResponse } from '#app/utils/misc.tsx'

export async function loader({ params }: DataFunctionArgs) {
export async function loader({ params }: LoaderFunctionArgs) {
invariantResponse(params.imageId, 'Image ID is required', { status: 400 })
const image = await prisma.noteImage.findUnique({
where: { id: params.imageId },
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { type DataFunctionArgs } from '@remix-run/node'
import { type LoaderFunctionArgs } from '@remix-run/node'
import { prisma } from '#app/utils/db.server.ts'
import { invariantResponse } from '#app/utils/misc.tsx'

export async function loader({ params }: DataFunctionArgs) {
export async function loader({ params }: LoaderFunctionArgs) {
invariantResponse(params.imageId, 'Image ID is required', { status: 400 })
const image = await prisma.userImage.findUnique({
where: { id: params.imageId },
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { json, type DataFunctionArgs } from '@remix-run/node'
import { json, type LoaderFunctionArgs } from '@remix-run/node'
import { Link, useLoaderData, type MetaFunction } from '@remix-run/react'
import { GeneralErrorBoundary } from '#app/components/error-boundary.tsx'
import { Spacer } from '#app/components/spacer.tsx'
import { Button } from '#app/components/ui/button.tsx'
import { prisma } from '#app/utils/db.server.ts'
import { getUserImgSrc, invariantResponse } from '#app/utils/misc.tsx'

export async function loader({ params }: DataFunctionArgs) {
export async function loader({ params }: LoaderFunctionArgs) {
const user = await prisma.user.findFirst({
select: {
name: true,
Expand Down
Loading

0 comments on commit c4efabc

Please sign in to comment.