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: reset-field.mdx #25

Open
wants to merge 1 commit into
base: master-ko
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 18 additions & 18 deletions src/content/docs/useform/resetfield.mdx
Original file line number Diff line number Diff line change
@@ -1,49 +1,49 @@
---
title: resetField
description: Reset field state and value
description: 필드 상태 및 값 재설정
sidebar: apiLinks
---

## \</> `resetField:` <TypeText>`(name: string, options?: Record<string, boolean | any>) => void`</TypeText>

Reset an individual field state.
개별 필드 상태를 재설정합니다.

### Props

---

After invoke this function.
이 함수를 호출한 후.

- `isValid` form state will be reevaluated.
- `isDirty` form state will be reevaluated.
- `isValid` form 상태가 재평가 됩니다.
- `isDirty` form 상태가 재평가 됩니다.

`ResetField` has the ability to retain field state. Here are the options you may want to use:
`ResetField`에는 필드 상태를 유지하는 기능이 있습니다. 사용할 수 있는 옵션은 다음과 같습니다:

| Name | | Type | Description |
| ------- | -------------- | ---------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `name` | | <TypeText>string</TypeText> | registered field name. |
| options | `keepError` | <TypeText>boolean</TypeText> | When set to `true`, field error will be retained. |
| | `keepDirty` | <TypeText>boolean</TypeText> | When set to `true`, `dirtyFields` will be retained. |
| | `keepTouched` | <TypeText>boolean</TypeText> | When set to `true`, `touchedFields` state will be unchanged. |
| | `defaultValue` | <TypeText>unknown</TypeText> | When this value is **not** provided, field will be revert back to it's defaultValue.<br/>When this value is provided:<br/><ul><li>field will be updated with the supplied value</li> <li>field's `defaultValue` will be updated to this value.</li> <li>Only support non <code>undefined</code> value.</li> </ul> |
| `name` | | <TypeText>string</TypeText> | 등록된 필드 이름. |
| options | `keepError` | <TypeText>boolean</TypeText> | `true`로 설정하면, 필드 에러가 유지됩니다. |
| | `keepDirty` | <TypeText>boolean</TypeText> | `true`로 설정하면, `dirtyFields`는 유지됩니다. |
| | `keepTouched` | <TypeText>boolean</TypeText> | `true`로 설정하면, `touchedFields`상태는 변경되지 않습니다. |
| | `defaultValue` | <TypeText>unknown</TypeText> | 값이 제공되지 **않은** 경우, 필드는 defaultValue로 되돌아갑니다.<br/>값이 제공되는 경우:<br/><ul><li>필드는 제공된 값으로 업데이트됩니다.</li> <li>필드의 `defaultValue`도 해당 값으로 업데이트됩니다.</li> <li><code>undefined</code> 값을 제외한 값만 지원됩니다.</li> </ul> |

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

- name need to match registered field name.
- 이름은 등록된 필드 이름과 일치해야 합니다.

```javascript
register("test")
resetField("test") // ✅ register input and resetField works
resetField("non-existent-name") // ❌ failed by input not found
resetField("test") // ✅ 입력 등록 및 재설정 필드 작동
resetField("non-existent-name") // ❌ 입력을 찾을 수 없어 실패
```

</Admonition>

**Examples:**
**예시:**

---

**Reset Field State**
**필드 상태 재설정**

```javascript copy sandbox="https://codesandbox.io/s/priceless-firefly-d0kuv"
import * as React from "react"
Expand Down Expand Up @@ -77,7 +77,7 @@ export default function App() {
}
```

**Reset With Options**
**옵션으로 재설정**

```javascript copy sandbox="https://codesandbox.io/s/resetfield-with-options-iw4wd"
import * as React from "react"
Expand Down Expand Up @@ -140,6 +140,6 @@ export default function App() {

---

The following video tutorial demonstrates `resetField` API.
다음 동영상 튜토리얼에서는 `resetField` API에 대해 설명합니다.

<YouTube youTubeId="IdLFcNaEFEo" />