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 4c50be1 commit 8cc76b5
Show file tree
Hide file tree
Showing 378 changed files with 1,120 additions and 840 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.
4 changes: 2 additions & 2 deletions exercises/01.schema/01.problem.init/app/root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import os from 'node:os'
import { cssBundleHref } from '@remix-run/css-bundle'
import {
json,
type DataFunctionArgs,
type LoaderFunctionArgs,
type LinksFunction,
} from '@remix-run/node'
import {
Expand Down Expand Up @@ -38,7 +38,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 Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {
redirect,
type DataFunctionArgs,
type ActionFunctionArgs,
type MetaFunction,
} from '@remix-run/node'
import { Form } from '@remix-run/react'
Expand All @@ -12,7 +12,7 @@ import { Label } from '#app/components/ui/label.tsx'
import { validateCSRF } from '#app/utils/csrf.server.ts'
import { checkHoneypot } from '#app/utils/honeypot.server.ts'

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 @@ -2,12 +2,12 @@ import fs from 'node:fs'
import { PassThrough } from 'node:stream'
import {
createReadableStreamFromReadable,
type DataFunctionArgs,
type LoaderFunctionArgs,
} from '@remix-run/node'
import { db } 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, 'Invalid image ID')
const image = db.image.findFirst({
where: { id: { equals: 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 { db } 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 = db.user.findFirst({
where: {
username: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import { json, redirect, type DataFunctionArgs } from '@remix-run/node'
import {
json,
redirect,
type ActionFunctionArgs,
type LoaderFunctionArgs,
} from '@remix-run/node'
import { Form, Link, useLoaderData, type MetaFunction } from '@remix-run/react'
import { AuthenticityTokenInput } from 'remix-utils/csrf/react'
import { GeneralErrorBoundary } from '#app/components/error-boundary.tsx'
Expand All @@ -9,7 +14,7 @@ import { db } from '#app/utils/db.server.ts'
import { getNoteImgSrc, invariantResponse } 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 = db.note.findFirst({
where: {
id: {
Expand All @@ -29,7 +34,7 @@ export async function loader({ params }: DataFunctionArgs) {
})
}

export async function action({ request, params }: DataFunctionArgs) {
export async function action({ request, params }: ActionFunctionArgs) {
invariantResponse(params.noteId, 'noteId param is required')

const formData = await request.formData()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import {
json,
unstable_parseMultipartFormData as parseMultipartFormData,
redirect,
type DataFunctionArgs,
type ActionFunctionArgs,
type LoaderFunctionArgs,
} from '@remix-run/node'
import { Form, useActionData, useLoaderData } from '@remix-run/react'
import { useRef, useState } from 'react'
Expand All @@ -35,7 +36,7 @@ import {
useIsPending,
} from '#app/utils/misc.tsx'

export async function loader({ params }: DataFunctionArgs) {
export async function loader({ params }: LoaderFunctionArgs) {
const note = db.note.findFirst({
where: {
id: {
Expand Down Expand Up @@ -79,7 +80,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) {
invariantResponse(params.noteId, 'noteId param is required')

const formData = await parseMultipartFormData(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
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 { db } 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 = db.user.findFirst({
where: {
username: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
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 { GeneralErrorBoundary } from '#app/components/error-boundary.tsx'
import { SearchBar } from '#app/components/search-bar.tsx'
import { db } from '#app/utils/db.server.ts'
import { cn, getUserImgSrc, useDelayedIsPending } from '#app/utils/misc.tsx'

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
4 changes: 2 additions & 2 deletions exercises/01.schema/01.solution.init/app/root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import os from 'node:os'
import { cssBundleHref } from '@remix-run/css-bundle'
import {
json,
type DataFunctionArgs,
type LoaderFunctionArgs,
type LinksFunction,
} from '@remix-run/node'
import {
Expand Down Expand Up @@ -38,7 +38,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 Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {
redirect,
type DataFunctionArgs,
type ActionFunctionArgs,
type MetaFunction,
} from '@remix-run/node'
import { Form } from '@remix-run/react'
Expand All @@ -12,7 +12,7 @@ import { Label } from '#app/components/ui/label.tsx'
import { validateCSRF } from '#app/utils/csrf.server.ts'
import { checkHoneypot } from '#app/utils/honeypot.server.ts'

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 @@ -2,12 +2,12 @@ import fs from 'node:fs'
import { PassThrough } from 'node:stream'
import {
createReadableStreamFromReadable,
type DataFunctionArgs,
type LoaderFunctionArgs,
} from '@remix-run/node'
import { db } 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, 'Invalid image ID')
const image = db.image.findFirst({
where: { id: { equals: 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 { db } 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 = db.user.findFirst({
where: {
username: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import { json, redirect, type DataFunctionArgs } from '@remix-run/node'
import {
json,
redirect,
type ActionFunctionArgs,
type LoaderFunctionArgs,
} from '@remix-run/node'
import { Form, Link, useLoaderData, type MetaFunction } from '@remix-run/react'
import { AuthenticityTokenInput } from 'remix-utils/csrf/react'
import { GeneralErrorBoundary } from '#app/components/error-boundary.tsx'
Expand All @@ -9,7 +14,7 @@ import { db } from '#app/utils/db.server.ts'
import { getNoteImgSrc, invariantResponse } 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 = db.note.findFirst({
where: {
id: {
Expand All @@ -29,7 +34,7 @@ export async function loader({ params }: DataFunctionArgs) {
})
}

export async function action({ request, params }: DataFunctionArgs) {
export async function action({ request, params }: ActionFunctionArgs) {
invariantResponse(params.noteId, 'noteId param is required')

const formData = await request.formData()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import {
json,
unstable_parseMultipartFormData as parseMultipartFormData,
redirect,
type DataFunctionArgs,
type ActionFunctionArgs,
type LoaderFunctionArgs,
} from '@remix-run/node'
import { Form, useActionData, useLoaderData } from '@remix-run/react'
import { useRef, useState } from 'react'
Expand All @@ -35,7 +36,7 @@ import {
useIsPending,
} from '#app/utils/misc.tsx'

export async function loader({ params }: DataFunctionArgs) {
export async function loader({ params }: LoaderFunctionArgs) {
const note = db.note.findFirst({
where: {
id: {
Expand Down Expand Up @@ -79,7 +80,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) {
invariantResponse(params.noteId, 'noteId param is required')

const formData = await parseMultipartFormData(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
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 { db } 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 = db.user.findFirst({
where: {
username: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
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 { GeneralErrorBoundary } from '#app/components/error-boundary.tsx'
import { SearchBar } from '#app/components/search-bar.tsx'
import { db } from '#app/utils/db.server.ts'
import { cn, getUserImgSrc, useDelayedIsPending } from '#app/utils/misc.tsx'

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
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import os from 'node:os'
import { cssBundleHref } from '@remix-run/css-bundle'
import {
json,
type DataFunctionArgs,
type LoaderFunctionArgs,
type LinksFunction,
} from '@remix-run/node'
import {
Expand Down Expand Up @@ -38,7 +38,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 Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {
redirect,
type DataFunctionArgs,
type ActionFunctionArgs,
type MetaFunction,
} from '@remix-run/node'
import { Form } from '@remix-run/react'
Expand All @@ -12,7 +12,7 @@ import { Label } from '#app/components/ui/label.tsx'
import { validateCSRF } from '#app/utils/csrf.server.ts'
import { checkHoneypot } from '#app/utils/honeypot.server.ts'

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 @@ -2,12 +2,12 @@ import fs from 'node:fs'
import { PassThrough } from 'node:stream'
import {
createReadableStreamFromReadable,
type DataFunctionArgs,
type LoaderFunctionArgs,
} from '@remix-run/node'
import { db } 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, 'Invalid image ID')
const image = db.image.findFirst({
where: { id: { equals: 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 { db } 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 = db.user.findFirst({
where: {
username: {
Expand Down
Loading

0 comments on commit 8cc76b5

Please sign in to comment.