Skip to content

Commit bc5a38a

Browse files
authored
Fix Next.js and Remix form examples (#5392)
1 parent b197e3a commit bc5a38a

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

packages/dev/docs/pages/react-aria/forms.mdx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -314,8 +314,8 @@ React Aria is compatible with errors returned from schema validation libraries l
314314
import {z} from 'zod';
315315

316316
const schema = z.object({
317-
name: z.string().required(),
318-
age: z.coerce.number().positive().required(),
317+
name: z.string().min(1),
318+
age: z.coerce.number().positive()
319319
});
320320

321321
function handleRequest(formData: FormData) {
@@ -374,7 +374,7 @@ export function AddForm() {
374374
// app/actions.ts
375375
'use server';
376376

377-
export function createTodo(prevState: any, formData: FormData) {
377+
export async function createTodo(prevState: any, formData: FormData) {
378378
try {
379379
// Create the todo...
380380
} catch (err) {
@@ -395,7 +395,7 @@ export function createTodo(prevState: any, formData: FormData) {
395395

396396
```tsx
397397
// app/routes/signup.tsx
398-
import type {ActionArgs} from '@remix-run/node';
398+
import type {ActionFunctionArgs} from '@remix-run/node';
399399
import {useActionData, useSubmit} from '@remix-run/react';
400400
import {Form, TextField, Label, Input, FieldError, Button} from 'react-aria-components';
401401

@@ -432,7 +432,7 @@ export default function SignupForm() {
432432
);
433433
}
434434

435-
export async function action({request}: ActionArgs) {
435+
export async function action({request}: ActionFunctionArgs) {
436436
try {
437437
// Validate data and perform action...
438438
} catch (err) {

packages/dev/docs/pages/react-spectrum/forms.mdx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -274,8 +274,8 @@ React Spectrum is compatible with errors returned from schema validation librari
274274
import {z} from 'zod';
275275

276276
const schema = z.object({
277-
name: z.string().required(),
278-
age: z.coerce.number().positive().required(),
277+
name: z.string().min(1),
278+
age: z.coerce.number().positive()
279279
});
280280

281281
function handleRequest(formData: FormData) {
@@ -330,7 +330,7 @@ export function AddForm() {
330330
// app/actions.ts
331331
'use server';
332332

333-
export function createTodo(prevState: any, formData: FormData) {
333+
export async function createTodo(prevState: any, formData: FormData) {
334334
try {
335335
// Create the todo...
336336
} catch (err) {
@@ -351,7 +351,7 @@ export function createTodo(prevState: any, formData: FormData) {
351351

352352
```tsx
353353
// app/routes/signup.tsx
354-
import type {ActionArgs} from '@remix-run/node';
354+
import type {ActionFunctionArgs} from '@remix-run/node';
355355
import {useActionData, useSubmit} from '@remix-run/react';
356356
import {Form, TextField, Button} from '@adobe/react-spectrum';
357357

@@ -380,7 +380,7 @@ export default function SignupForm() {
380380
);
381381
}
382382

383-
export async function action({request}: ActionArgs) {
383+
export async function action({request}: ActionFunctionArgs) {
384384
try {
385385
// Validate data and perform action...
386386
} catch (err) {

0 commit comments

Comments
 (0)