From ee779f0e760c64c53bccb1dc5c08b084c228f76d Mon Sep 17 00:00:00 2001 From: Edmund Hung Date: Mon, 13 Nov 2023 00:49:35 +0100 Subject: [PATCH] chore: fix remix example --- examples/remix/app/routes/login-fetcher.tsx | 54 +++++++++--------- examples/remix/app/routes/login.tsx | 54 +++++++++--------- examples/remix/app/routes/signup.tsx | 62 ++++++++++----------- examples/remix/app/routes/todos.tsx | 28 +++++----- packages/conform-dom/form.ts | 7 ++- packages/conform-react/context.tsx | 5 +- packages/conform-react/index.ts | 2 +- tests/conform-react.spec.ts | 30 +++++----- 8 files changed, 121 insertions(+), 121 deletions(-) diff --git a/examples/remix/app/routes/login-fetcher.tsx b/examples/remix/app/routes/login-fetcher.tsx index cc408bba..5ecdcdcc 100644 --- a/examples/remix/app/routes/login-fetcher.tsx +++ b/examples/remix/app/routes/login-fetcher.tsx @@ -1,4 +1,4 @@ -import { ConformBoundary, conform, useForm } from '@conform-to/react'; +import { conform, useForm } from '@conform-to/react'; import { parse } from '@conform-to/zod'; import type { ActionArgs } from '@remix-run/node'; import { json, redirect } from '@remix-run/node'; @@ -24,7 +24,7 @@ export async function action({ request }: ActionArgs) { export default function Login() { const fetcher = useFetcher(); - const { form, fields, context } = useForm({ + const { form, fields } = useForm({ // Sync the result of last submission lastResult: fetcher.data, @@ -37,33 +37,31 @@ export default function Login() { }); return ( - - + +
+ + +
{fields.email.errors}
+
+
+ + +
{fields.password.errors}
+
+
-
+ +
+ + ); } diff --git a/examples/remix/app/routes/login.tsx b/examples/remix/app/routes/login.tsx index b2cf81c7..09760403 100644 --- a/examples/remix/app/routes/login.tsx +++ b/examples/remix/app/routes/login.tsx @@ -1,4 +1,4 @@ -import { ConformBoundary, conform, useForm } from '@conform-to/react'; +import { conform, useForm } from '@conform-to/react'; import { parse } from '@conform-to/zod'; import type { ActionArgs } from '@remix-run/node'; import { json, redirect } from '@remix-run/node'; @@ -25,7 +25,7 @@ export async function action({ request }: ActionArgs) { export default function Login() { // Last submission returned by the server const lastResult = useActionData(); - const { form, context, fields } = useForm({ + const { form, fields } = useForm({ // Sync the result of last submission lastResult, @@ -39,33 +39,31 @@ export default function Login() { }); return ( - -
+ +
+ + +
{fields.email.errors}
+
+
+ + +
{fields.password.errors}
+
+
+ +
+ + ); } diff --git a/examples/remix/app/routes/signup.tsx b/examples/remix/app/routes/signup.tsx index 63593519..ae87eb14 100644 --- a/examples/remix/app/routes/signup.tsx +++ b/examples/remix/app/routes/signup.tsx @@ -1,4 +1,4 @@ -import { ConformBoundary, conform, useForm } from '@conform-to/react'; +import { conform, useForm } from '@conform-to/react'; import { parse, refine } from '@conform-to/zod'; import type { ActionArgs } from '@remix-run/node'; import { json, redirect } from '@remix-run/node'; @@ -73,7 +73,7 @@ export async function action({ request }: ActionArgs) { export default function Signup() { const lastResult = useActionData(); - const { form, fields, context } = useForm({ + const { form, fields } = useForm({ lastResult, onValidate({ formData }) { return parse(formData, { @@ -85,35 +85,33 @@ export default function Signup() { }); return ( - -
- - - -
- -
-
+
+ + + +
+ +
); } diff --git a/examples/remix/app/routes/todos.tsx b/examples/remix/app/routes/todos.tsx index 0ad4970f..71540435 100644 --- a/examples/remix/app/routes/todos.tsx +++ b/examples/remix/app/routes/todos.tsx @@ -1,11 +1,11 @@ import type { Field } from '@conform-to/react'; import { + FormProvider, useForm, useFieldset, useFieldList, conform, intent, - ConformBoundary, } from '@conform-to/react'; import { parse } from '@conform-to/zod'; import type { ActionArgs } from '@remix-run/node'; @@ -40,9 +40,9 @@ export default function TodoForm() { const lastResult = useActionData(); const { form, fields, context } = useForm({ lastResult, - onValidate({ formData }) { - return parse(formData, { schema: todosSchema }); - }, + // onValidate({ formData }) { + // return parse(formData, { schema: todosSchema }); + // }, shouldValidate: 'onBlur', }); const taskList = useFieldList({ @@ -52,20 +52,20 @@ export default function TodoForm() { }); return ( - +
-
{fields.title.error}
+
{fields.title.errors}

-
{fields.tasks.error}
+
{fields.tasks.errors}
{taskList.map((task, index) => ( -

+

Clear -

+
))}
-
+ ); } @@ -118,16 +118,16 @@ function TaskFieldset({ title, name, formId }: TaskFieldsetProps) {
-
{fields.content.error}
+
{fields.content.errors}