From 841b30ef9fa3ef7d2a3f9a8a16cddf02dfba0888 Mon Sep 17 00:00:00 2001 From: candymask0712 Date: Thu, 17 Jul 2025 22:31:01 +0900 Subject: [PATCH 1/5] fix: fix typo issue in link for formState --- src/content/docs/useform/subscribe.mdx | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/content/docs/useform/subscribe.mdx b/src/content/docs/useform/subscribe.mdx index 86d9fc075..a58ad3417 100644 --- a/src/content/docs/useform/subscribe.mdx +++ b/src/content/docs/useform/subscribe.mdx @@ -16,7 +16,7 @@ Subscribe to [`formState`](/docs/useform/formState) changes and value updates. Y | --------- | --------------------------------------------- | ------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | name | undefined | Subscribe to the entire form | `subscribe()` | | | string[] | Subscribe on multiple fields by **name**. | `subscribe({ name: ['firstName', 'lastName'] })` | -| formState | `Partial` | Pick which [`formState`](/docs/useform/formState) to be subscribed. | | +| formState | `Partial` | Pick which [`formState`](/docs/useform/formstate) to be subscribed. | | | callback | `Function` | The callback function for the subscription. | { \n console.log(values) \n } \n})`}/> | | exact | boolean | This prop will enable an exact match for input name subscriptions. | `subscribe({ name: 'target', exact: true })` | @@ -24,7 +24,11 @@ Subscribe to [`formState`](/docs/useform/formState) changes and value updates. Y
  • -

    This function is intended for subscribing to changes only; dispatching state updates or triggering re-renders is not allowed. eg `setValue` or `reset`

    +

    + This function is intended for subscribing to changes only; dispatching + state updates or triggering re-renders is not allowed. eg `setValue` or + `reset` +

  • @@ -64,14 +68,14 @@ export default function App() { // make sure to unsubscribe; const callback = subscribe({ formState: { - values: true + values: true, }, callback: ({ values }) => { - console.log(values); - } + console.log(values) + }, }) - return () => callback(); + return () => callback() // You can also just return the subscribe // return subscribe(); From 798b9c5f57c5a8feeebc78825203f23088f5891b Mon Sep 17 00:00:00 2001 From: candymask0712 Date: Thu, 17 Jul 2025 22:34:55 +0900 Subject: [PATCH 2/5] chore: format code with pnpm run format --- src/content/docs/useform.mdx | 40 +++++++++++++---------- src/content/docs/useform/handlesubmit.mdx | 3 +- src/content/ts.mdx | 7 ++-- 3 files changed, 29 insertions(+), 21 deletions(-) diff --git a/src/content/docs/useform.mdx b/src/content/docs/useform.mdx index 5ad2aff52..7999930bf 100644 --- a/src/content/docs/useform.mdx +++ b/src/content/docs/useform.mdx @@ -494,10 +494,12 @@ const App = () => { }) return ( -

    { - // handle inputs - console.log(data); - })}> + { + // handle inputs + console.log(data) + })} + > @@ -507,27 +509,31 @@ const App = () => { ``` ```tsx copy sandbox="https://codesandbox.io/s/react-hook-form-joiresolver-v6-ts-forked-5pseh" -import { useForm } from "react-hook-form"; -import { joiResolver } from "@hookform/resolvers/joi"; -import Joi from "joi"; +import { useForm } from "react-hook-form" +import { joiResolver } from "@hookform/resolvers/joi" +import Joi from "joi" interface IFormInput { - name: string; - age: number; + name: string + age: number } const schema = Joi.object({ name: Joi.string().required(), - age: Joi.number().required() -}); + age: Joi.number().required(), +}) const App = () => { - const { register, handleSubmit, formState: { errors } } = useForm({ - resolver: joiResolver(schema) - }); + const { + register, + handleSubmit, + formState: { errors }, + } = useForm({ + resolver: joiResolver(schema), + }) const onSubmit = (data: IFormInput) => { - console.log(data); - }; + console.log(data) + } return ( @@ -535,7 +541,7 @@ const App = () => { - ); + ) } ``` diff --git a/src/content/docs/useform/handlesubmit.mdx b/src/content/docs/useform/handlesubmit.mdx index 773641adc..4246c0c81 100644 --- a/src/content/docs/useform/handlesubmit.mdx +++ b/src/content/docs/useform/handlesubmit.mdx @@ -66,7 +66,8 @@ type FormValues = { export default function App() { const { register, handleSubmit } = useForm() const onSubmit: SubmitHandler = (data) => console.log(data) - const onError: SubmitErrorHandler = (errors) => console.log(errors) + const onError: SubmitErrorHandler = (errors) => + console.log(errors) return (
    diff --git a/src/content/ts.mdx b/src/content/ts.mdx index aede486a2..da74ce935 100644 --- a/src/content/ts.mdx +++ b/src/content/ts.mdx @@ -96,12 +96,13 @@ type FormValues = { export default function App() { const { register, handleSubmit } = useForm() const onSubmit: SubmitHandler = (data) => console.log(data) - const onError: SubmitErrorHandler = (errors) => console.log(errors); + const onError: SubmitErrorHandler = (errors) => + console.log(errors) return ( - - + + From 7020bacfe6545a247a7b0d2819b1d31ee88be39d Mon Sep 17 00:00:00 2001 From: candymask0712 Date: Thu, 17 Jul 2025 23:26:36 +0900 Subject: [PATCH 3/5] fix: correct formState type example --- src/content/docs/useform/subscribe.mdx | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/content/docs/useform/subscribe.mdx b/src/content/docs/useform/subscribe.mdx index a58ad3417..e9c467574 100644 --- a/src/content/docs/useform/subscribe.mdx +++ b/src/content/docs/useform/subscribe.mdx @@ -12,13 +12,13 @@ Subscribe to [`formState`](/docs/useform/formState) changes and value updates. Y --- -| Name | Type | Description | Example | -| --------- | --------------------------------------------- | ------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| name | undefined | Subscribe to the entire form | `subscribe()` | -| | string[] | Subscribe on multiple fields by **name**. | `subscribe({ name: ['firstName', 'lastName'] })` | -| formState | `Partial` | Pick which [`formState`](/docs/useform/formstate) to be subscribed. | | -| callback | `Function` | The callback function for the subscription. | { \n console.log(values) \n } \n})`}/> | -| exact | boolean | This prop will enable an exact match for input name subscriptions. | `subscribe({ name: 'target', exact: true })` | +| Name | Type | Description | Example | +| --------- | --------------------------------------------- | ------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| name | undefined | Subscribe to the entire form | `subscribe()` | +| | string[] | Subscribe on multiple fields by **name**. | `subscribe({ name: ['firstName', 'lastName'] })` | +| formState | `Partial` | Pick which [`formState`](/docs/useform/formstate) to be subscribed. | | +| callback | `Function` | The callback function for the subscription. | { \n console.log(values) \n } \n})`}/> | +| exact | boolean | This prop will enable an exact match for input name subscriptions. | `subscribe({ name: 'target', exact: true })` | From 88bcb9d51e28ecd6570a172dfed8d2011962dcf0 Mon Sep 17 00:00:00 2001 From: candymask0712 Date: Fri, 18 Jul 2025 19:12:11 +0900 Subject: [PATCH 4/5] Revert "chore: format code with pnpm run format" This reverts commit 798b9c5f57c5a8feeebc78825203f23088f5891b. --- src/content/docs/useform.mdx | 40 ++++++++++------------- src/content/docs/useform/handlesubmit.mdx | 3 +- src/content/ts.mdx | 7 ++-- 3 files changed, 21 insertions(+), 29 deletions(-) diff --git a/src/content/docs/useform.mdx b/src/content/docs/useform.mdx index 7999930bf..5ad2aff52 100644 --- a/src/content/docs/useform.mdx +++ b/src/content/docs/useform.mdx @@ -494,12 +494,10 @@ const App = () => { }) return ( - { - // handle inputs - console.log(data) - })} - > + { + // handle inputs + console.log(data); + })}> @@ -509,31 +507,27 @@ const App = () => { ``` ```tsx copy sandbox="https://codesandbox.io/s/react-hook-form-joiresolver-v6-ts-forked-5pseh" -import { useForm } from "react-hook-form" -import { joiResolver } from "@hookform/resolvers/joi" -import Joi from "joi" +import { useForm } from "react-hook-form"; +import { joiResolver } from "@hookform/resolvers/joi"; +import Joi from "joi"; interface IFormInput { - name: string - age: number + name: string; + age: number; } const schema = Joi.object({ name: Joi.string().required(), - age: Joi.number().required(), -}) + age: Joi.number().required() +}); const App = () => { - const { - register, - handleSubmit, - formState: { errors }, - } = useForm({ - resolver: joiResolver(schema), - }) + const { register, handleSubmit, formState: { errors } } = useForm({ + resolver: joiResolver(schema) + }); const onSubmit = (data: IFormInput) => { - console.log(data) - } + console.log(data); + }; return ( @@ -541,7 +535,7 @@ const App = () => { - ) + ); } ``` diff --git a/src/content/docs/useform/handlesubmit.mdx b/src/content/docs/useform/handlesubmit.mdx index 4246c0c81..773641adc 100644 --- a/src/content/docs/useform/handlesubmit.mdx +++ b/src/content/docs/useform/handlesubmit.mdx @@ -66,8 +66,7 @@ type FormValues = { export default function App() { const { register, handleSubmit } = useForm() const onSubmit: SubmitHandler = (data) => console.log(data) - const onError: SubmitErrorHandler = (errors) => - console.log(errors) + const onError: SubmitErrorHandler = (errors) => console.log(errors) return (
    diff --git a/src/content/ts.mdx b/src/content/ts.mdx index da74ce935..aede486a2 100644 --- a/src/content/ts.mdx +++ b/src/content/ts.mdx @@ -96,13 +96,12 @@ type FormValues = { export default function App() { const { register, handleSubmit } = useForm() const onSubmit: SubmitHandler = (data) => console.log(data) - const onError: SubmitErrorHandler = (errors) => - console.log(errors) + const onError: SubmitErrorHandler = (errors) => console.log(errors); return ( - - + + From 5239ed28b9d11da1d7721cd81c947eb686b31af5 Mon Sep 17 00:00:00 2001 From: candymask0712 Date: Fri, 18 Jul 2025 19:20:24 +0900 Subject: [PATCH 5/5] chore: format code with 'pnpm run format --write' without 'src/content/ts.mdx' file --- src/content/docs/useform.mdx | 40 +++++++++++++---------- src/content/docs/useform/handlesubmit.mdx | 3 +- 2 files changed, 25 insertions(+), 18 deletions(-) diff --git a/src/content/docs/useform.mdx b/src/content/docs/useform.mdx index 5ad2aff52..7999930bf 100644 --- a/src/content/docs/useform.mdx +++ b/src/content/docs/useform.mdx @@ -494,10 +494,12 @@ const App = () => { }) return ( - { - // handle inputs - console.log(data); - })}> + { + // handle inputs + console.log(data) + })} + > @@ -507,27 +509,31 @@ const App = () => { ``` ```tsx copy sandbox="https://codesandbox.io/s/react-hook-form-joiresolver-v6-ts-forked-5pseh" -import { useForm } from "react-hook-form"; -import { joiResolver } from "@hookform/resolvers/joi"; -import Joi from "joi"; +import { useForm } from "react-hook-form" +import { joiResolver } from "@hookform/resolvers/joi" +import Joi from "joi" interface IFormInput { - name: string; - age: number; + name: string + age: number } const schema = Joi.object({ name: Joi.string().required(), - age: Joi.number().required() -}); + age: Joi.number().required(), +}) const App = () => { - const { register, handleSubmit, formState: { errors } } = useForm({ - resolver: joiResolver(schema) - }); + const { + register, + handleSubmit, + formState: { errors }, + } = useForm({ + resolver: joiResolver(schema), + }) const onSubmit = (data: IFormInput) => { - console.log(data); - }; + console.log(data) + } return ( @@ -535,7 +541,7 @@ const App = () => { - ); + ) } ``` diff --git a/src/content/docs/useform/handlesubmit.mdx b/src/content/docs/useform/handlesubmit.mdx index 773641adc..4246c0c81 100644 --- a/src/content/docs/useform/handlesubmit.mdx +++ b/src/content/docs/useform/handlesubmit.mdx @@ -66,7 +66,8 @@ type FormValues = { export default function App() { const { register, handleSubmit } = useForm() const onSubmit: SubmitHandler = (data) => console.log(data) - const onError: SubmitErrorHandler = (errors) => console.log(errors) + const onError: SubmitErrorHandler = (errors) => + console.log(errors) return (