Skip to content
This repository was archived by the owner on Apr 6, 2023. It is now read-only.

Commit 3e30d98

Browse files
jpedroschmitzJoão Pedro Schmitz
authored andcommitted
docs: Add note about input type reset
1 parent 3c71b18 commit 3e30d98

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

docs/src/docs/guides/reset-form.mdx

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,23 @@ title: Reset form
33
description: Manually reseting a form using the resetForm method
44
---
55

6+
> Don't use the `<input type="reset" />` to reset the form data. It won't work correctly with Unform and may cause bugs.
7+
68
There are two ways to reset all form data:
79

810
## 1. Reset after submit
911

10-
Besides the `data`, the `onSubmit` function also receives a second parameter with form helpers like `resetForm`:
12+
Besides the `data`, the `onSubmit` function also receives a second parameter with form helpers:
1113

1214
```jsx
1315
export default function SignIn() {
1416
function handleSubmit(data, { reset }) {
15-
console.log(data);
17+
console.log(data)
1618

17-
reset();
19+
reset()
1820
}
1921

20-
return <Form onSubmit={handleSubmit}>...</Form>;
22+
return <Form onSubmit={handleSubmit}>...</Form>
2123
}
2224
```
2325

@@ -27,19 +29,19 @@ If you need to reset form data without a submit use the `reset` function exposed
2729

2830
```jsx
2931
export default function SignIn() {
30-
const formRef = useRef(null);
32+
const formRef = useRef(null)
3133

3234
function functionThatResetsForm() {
33-
formRef.current.reset();
35+
formRef.current.reset()
3436

3537
// You can also clear a single input value
36-
formRef.current.clearField('email');
38+
formRef.current.clearField('email')
3739
}
3840

3941
return (
4042
<Form ref={formRef} onSubmit={handleSubmit}>
4143
<Input name="email" />
4244
</Form>
43-
);
45+
)
4446
}
4547
```

0 commit comments

Comments
 (0)