Skip to content

Commit

Permalink
Docs(useForm/reset): edit options section & add values type (#1086)
Browse files Browse the repository at this point in the history
* docs: edit options section & add values type

* fix: lint error

* fix: lint error

* fix: semicolnm delete

* fix:ci error

---------

Co-authored-by: Beier (Bill) <[email protected]>
  • Loading branch information
developer-bandi and bluebill1049 authored Dec 22, 2024
1 parent c1d3d7e commit 385d6c2
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions src/content/docs/useform/reset.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,18 @@ Reset the entire form state, fields reference, and subscriptions. There are opti

`Reset` has the ability to retain formState. Here are the options you may use:

| Name | Type | Description |
| ------------------- | ---------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `values` | <TypeText>object</TypeText> | An optional object to reset form values, and it's recommended to provide the **entire** defaultValues when supplied. |
| `keepErrors` | <TypeText>boolean</TypeText> | All errors will remain. This will not guarantee with further user actions. |
| `keepDirty` | <TypeText>boolean</TypeText> | `DirtyFields` form state will remain, and `isDirty` will temporarily remain as the current state until further user's action.<br/><br/>**Important:** this keep option doesn't reflect form input values but only dirty fields form state. |
| `keepDirtyValues` | <TypeText>boolean</TypeText> | `DirtyFields` and `isDirty` will remained, and only none dirty fields will be updated to the latest rest value. [Check out the example.](https://codesandbox.io/s/react-keepdirtyvalues-o8to91)<br/><br/>**Important:** formState `dirtyFields` will need to be subscribed. |
| `keepValues` | <TypeText>boolean</TypeText> | Form input values will be unchanged. |
| `keepDefaultValues` | <TypeText>boolean</TypeText> | Keep the same defaultValues which are initialised via `useForm`.<ul><li>`isDirty` will be checked again: it is set to be the result of the comparison of any new values provided against the original `defaultValues`.</li> <li>`dirtyFields` will be updated again if values are provided: it is set to be result of the comparison between the new values provided against the original `defaultValues`.</li></ul> |
| `keepIsSubmitted` | <TypeText>boolean</TypeText> | `isSubmitted` state will be unchanged. |
| `keepTouched` | <TypeText>boolean</TypeText> | `isTouched` state will be unchanged. |
| `keepIsValid` | <TypeText>boolean</TypeText> | `isValid` will temporarily persist as the current state until additional user actions. |
| `keepSubmitCount` | <TypeText>boolean</TypeText> | `submitCount` state will be unchanged. |
| Name | | Type | Description |
| --------- | ------------------- | ---------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `values` | | <TypeText>object \| (values: Object) => Object </TypeText> | An optional object to reset form values, and it's recommended to provide the **entire** defaultValues when supplied. |
| `options` | `keepErrors` | <TypeText>boolean</TypeText> | All errors will remain. This will not guarantee with further user actions. |
| | `keepDirty` | <TypeText>boolean</TypeText> | `DirtyFields` form state will remain, and `isDirty` will temporarily remain as the current state until further user's action.<br/><br/>**Important:** this keep option doesn't reflect form input values but only dirty fields form state. |
| | `keepDirtyValues` | <TypeText>boolean</TypeText> | `DirtyFields` and `isDirty` will remained, and only none dirty fields will be updated to the latest rest value. [Check out the example.](https://codesandbox.io/s/react-keepdirtyvalues-o8to91)<br/><br/>**Important:** formState `dirtyFields` will need to be subscribed. |
| | `keepValues` | <TypeText>boolean</TypeText> | Form input values will be unchanged. |
| | `keepDefaultValues` | <TypeText>boolean</TypeText> | Keep the same defaultValues which are initialised via `useForm`.<ul><li>`isDirty` will be checked again: it is set to be the result of the comparison of any new values provided against the original `defaultValues`.</li> <li>`dirtyFields` will be updated again if values are provided: it is set to be result of the comparison between the new values provided against the original `defaultValues`.</li></ul> |
| | `keepIsSubmitted` | <TypeText>boolean</TypeText> | `isSubmitted` state will be unchanged. |
| | `keepTouched` | <TypeText>boolean</TypeText> | `isTouched` state will be unchanged. |
| | `keepIsValid` | <TypeText>boolean</TypeText> | `isValid` will temporarily persist as the current state until additional user actions. |
| | `keepSubmitCount` | <TypeText>boolean</TypeText> | `submitCount` state will be unchanged. |

<Admonition type="important" title="Rules">

Expand Down

0 comments on commit 385d6c2

Please sign in to comment.