Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: update intent-button.md #761

Merged
merged 10 commits into from
Oct 1, 2024
16 changes: 14 additions & 2 deletions docs/intent-button.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,13 +136,25 @@ To manipulate a field list, you can use the **insert**, **remove** and **reorder

```tsx
import { useForm } from '@conform-to/react';
import { parseWithZod } from "@conform-to/zod";
import { z } from "zod";

const todosSchema = z.object({
title: z.string(),
tasks: z.array(z.string()),
});

export default function Tasks() {
const [form, fields] = useForm();
const [form, fields] = useForm({
onValidate({ formData }) {
return parseWithZod(formData, { schema: todosSchema });
},
shouldValidate: "onBlur",
});
const tasks = fields.tasks.getFieldList();

return (
<form id={form.id}>
<form id={form.id} onSubmit={form.onSubmit}>
<ul>
{tasks.map((task, index) => (
<li key={task.key}>
Expand Down
16 changes: 14 additions & 2 deletions docs/ja/intent-button.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,13 +136,25 @@ export default function Tasks() {

```tsx
import { useForm } from '@conform-to/react';
import { parseWithZod } from "@conform-to/zod";
import { z } from "zod";

const todosSchema = z.object({
title: z.string(),
tasks: z.array(z.string()),
});

export default function Tasks() {
const [form, fields] = useForm();
const [form, fields] = useForm({
onValidate({ formData }) {
return parseWithZod(formData, { schema: todosSchema });
},
shouldValidate: "onBlur",
});
const tasks = fields.tasks.getFieldList();

return (
<form id={form.id}>
<form id={form.id} onSubmit={form.onSubmit}>
<ul>
{tasks.map((task, index) => (
<li key={task.key}>
Expand Down