Skip to content

Commit 77f0bc8

Browse files
committed
docs: update form.md
1 parent 1662f2a commit 77f0bc8

File tree

1 file changed

+29
-67
lines changed
  • src/content/reference/react-dom/components

1 file changed

+29
-67
lines changed

src/content/reference/react-dom/components/form.md

Lines changed: 29 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,6 @@
22
title: "<form>"
33
---
44

5-
<<<<<<< HEAD
6-
<Canary>
7-
8-
React의 익스텐션인 `<form>`은 현재 React Canary(카나리)와 실험적 채널에서만 사용할 수 있습니다. React에서의 안정적인 배포를 위해 `<form>`[내장 브라우저 HTML 컴포넌트](https://react.dev/reference/react-dom/components#all-html-components)로서만 동작합니다. 더 자세한 사항은 [React 배포 채널](/community/versioning-policy#all-release-channels)을 확인하세요.
9-
10-
</Canary>
11-
12-
13-
=======
14-
>>>>>>> b1a249d597016c6584e4c186daa28b180cc9aafc
155
<Intro>
166

177
[내장 브라우저 `<form>` 컴포넌트](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form)는 정보 제출을 위한 대화형 컨트롤을 만들 수 있습니다.
@@ -33,7 +23,7 @@ React의 익스텐션인 `<form>`은 현재 React Canary(카나리)와 실험적
3323

3424
### `<form>` {/*form*/}
3525

36-
정보 제출을 위한 대화형 컨트롤을 생성하기 위해, [내장된 브라우저 `<form>` 컴포넌트](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form)를 렌더링하세요.
26+
정보 제출을 위한 대화형 컨트롤을 생성하기 위해, [내장 브라우저 `<form>` 컴포넌트](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form)를 렌더링하세요.
3727

3828
```js
3929
<form action={search}>
@@ -42,30 +32,25 @@ React의 익스텐션인 `<form>`은 현재 React Canary(카나리)와 실험적
4232
</form>
4333
```
4434

45-
[아래 예시를 보세요.](#usage)
35+
[아래 예시를 참고하세요.](#usage)
4636

4737
#### Props {/*props*/}
4838

49-
`<form>`은 모든 [공통 엘리먼트 props](/reference/react-dom/components/common#props)를 지원합니다.
39+
`<form>`은 모든 [공통 엘리먼트 Props](/reference/react-dom/components/common#props)를 지원합니다.
5040

51-
[`action`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form#action): URL 혹은 함수.
52-
URL이 `action`을 통해 전달되면, 폼은 HTML 폼 컴포넌트처럼 행동합니다. 함수가 action을 통해 전달되면, 해당 함수는 폼 제출처럼 동작합니다. `action`을 통한 함수는 비동기로 동작할 수 있으며, 폼을 통해 제출된 [formData](https://developer.mozilla.org/ko/docs/Web/API/FormData)를 포함한 단일 인수로 호출됩니다. `action`의 프로퍼티는 `formAction`의 속성인 `<button>`, `<input type="submit">`, 혹은 `<input type="image">`로 재정의될 수 있습니다.
41+
[`action`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form#action): URL 혹은 함수. URL을 `action`을 통해 전달하면, 폼은 HTML 폼 컴포넌트처럼 동작합니다. 함수를 `action`을 통해 전달하면, 해당 함수는 폼 제출을 처리합니다. `action`을 통한 함수는 비동기로 동작할 수 있으며, 폼을 통해 제출된 [`formData`](https://developer.mozilla.org/ko/docs/Web/API/FormData)를 포함한 단일 인수로 호출됩니다. `action`의 프로퍼티는 `formAction`의 속성인 `<button>`, `<input type="submit">`, 혹은 `<input type="image">`로 재정의될 수 있습니다.
5342

5443
#### 주의 사항 {/*caveats*/}
5544

56-
* 함수가 `action`이나 `formAction`전달되면, HTTP 메서드는 `method` 프로퍼티의 값과 관계없이 POST로 처리됩니다.
45+
* 함수를 `action`이나 `formAction`전달하면, HTTP 메서드는 `method` 프로퍼티의 값과 관계없이 POST로 처리합니다.
5746

5847
---
5948

6049
## 사용법 {/*usage*/}
6150

6251
### 클라이언트에서 폼 제출 처리하기 {/*handle-form-submission-on-the-client*/}
6352

64-
<<<<<<< HEAD
65-
폼이 제출될 때 함수를 실행하기 위해, 폼의 `action` 프로퍼티에 함수를 전달하세요. [`formData`](https://developer.mozilla.org/ko/docs/Web/API/FormData)가 함수에 인자로 전달되어, 폼에서 전달된 데이터에 접근할 수 있습니다. 이 점이 URL만 받던 기존 [HTML action](https://developer.mozilla.org/ko/docs/Web/HTML/Element/form)과의 차이점입니다.
66-
=======
67-
Pass a function to the `action` prop of form to run the function when the form is submitted. [`formData`](https://developer.mozilla.org/en-US/docs/Web/API/FormData) will be passed to the function as an argument so you can access the data submitted by the form. This differs from the conventional [HTML action](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form#action), which only accepts URLs. After the `action` function succeeds, all uncontrolled field elements in the form are reset.
68-
>>>>>>> b1a249d597016c6584e4c186daa28b180cc9aafc
53+
폼이 제출될 때 함수를 실행하기 위해, 폼의 `action` 프로퍼티에 함수를 전달하세요. [`formData`](https://developer.mozilla.org/ko/docs/Web/API/FormData)가 함수에 인수로 전달되어, 폼에서 전달된 데이터에 접근할 수 있습니다. 이 점이 URL만 받던 기존 [HTML action](https://developer.mozilla.org/ko/docs/Web/HTML/Element/form)과의 차이점입니다. After the `action` function succeeds, all uncontrolled field elements in the form are reset.
6954

7055
<Sandpack>
7156

@@ -86,24 +71,14 @@ export default function Search() {
8671

8772
</Sandpack>
8873

89-
<<<<<<< HEAD
90-
### Server Action에서 폼 제출 처리하기 {/*handle-form-submission-with-a-server-action*/}
91-
92-
입력과 제출 버튼과 함께 `<form>`을 렌더링하세요. 폼이 제출될 때 해당 함수를 실행하기 위해 Server Action([`'use server'`](/reference/rsc/use-server)가 표시된 함수)를 폼의 `action`의 프로퍼티로 전달하세요.
74+
### 서버 함수에서 폼 제출 처리하기 {/*handle-form-submission-with-a-server-action*/}
9375

94-
`<form action>`에 Server Action을 전달하면 자바스크립트가 활성화되기 전이나 코드가 로드되기 전에 사용자가 폼을 제출할 수 있습니다. 이는 연결 상태나 기계가 느리거나 자바스크립트가 비활성화된 사용자에게 유용하고, `action` 프로퍼티에 URL이 전달될 때와 폼이 동작하는 방식은 비슷합니다.
76+
입력 및 제출 버튼과 함께 `<form>`을 렌더링하세요. 폼을 제출할 때 해당 함수를 실행하기 위해 서버 함수([`'use server'`](/reference/rsc/use-server)가 표시된 함수)를 폼의 `action` 프로퍼티로 전달하세요.
9577

96-
`<form>`의 액션에 데이터를 제공하기 위해 폼 필드의 `hidden`을 사용할 수 있습니다. Server Action은 [`formData`](https://developer.mozilla.org/ko/docs/Web/API/FormData) 대신 `hidden`이 적용된 폼 필드 데이터를 불러 올 수 있습니다.
78+
`<form action>`에 서버 함수를 전달하면 자바스크립트가 활성화되기 전이나 코드가 로드되기 전에 사용자가 폼을 제출할 수 있습니다. 이는 연결 상태나 기계가 느리거나 자바스크립트가 비활성화된 사용자에게 유용하고, `action` 프로퍼티에 URL이 전달될 때와 폼이 동작하는 방식은 비슷합니다.
9779

98-
=======
99-
### Handle form submission with a Server Function {/*handle-form-submission-with-a-server-function*/}
80+
`<form>`의 액션에 데이터를 제공하기 위해 폼 필드의 `hidden`을 사용할 수 있습니다. 서버 함수는 [`formData`](https://developer.mozilla.org/ko/docs/Web/API/FormData) 대신 `hidden`이 적용된 폼 필드 데이터를 불러올 수 있습니다.
10081

101-
Render a `<form>` with an input and submit button. Pass a Server Function (a function marked with [`'use server'`](/reference/rsc/use-server)) to the `action` prop of form to run the function when the form is submitted.
102-
103-
Passing a Server Function to `<form action>` allow users to submit forms without JavaScript enabled or before the code has loaded. This is beneficial to users who have a slow connection, device, or have JavaScript disabled and is similar to the way forms work when a URL is passed to the `action` prop.
104-
105-
You can use hidden form fields to provide data to the `<form>`'s action. The Server Function will be called with the hidden form field data as an instance of [`FormData`](https://developer.mozilla.org/en-US/docs/Web/API/FormData).
106-
>>>>>>> b1a249d597016c6584e4c186daa28b180cc9aafc
10782

10883
```jsx
10984
import { updateCart } from './lib.js';
@@ -119,12 +94,11 @@ function AddToCart({productId}) {
11994
<input type="hidden" name="productId" value={productId} />
12095
<button type="submit">Add to Cart</button>
12196
</form>
122-
12397
);
12498
}
12599
```
126100

127-
폼 액션에 따른 데이터를 제공하기 위해 `hidden` 폼 필드를 사용하는 대신에 <CodeStep step={1}>`bind`</CodeStep>를 호출해 추가 인자를 제공할 수 있습니다. 이렇게 하면 함수에 인수로 전달되는 <CodeStep step={3}>`formData`</CodeStep> 외에 새 인수((<CodeStep step={2}>`productId`</CodeStep>))가 함수에 바인딩됩니다.
101+
폼 액션에 따른 데이터를 제공하기 위해 `hidden` 폼 필드를 사용하는 대신에 <CodeStep step={1}>`bind`</CodeStep>를 호출해 추가 인수를 제공할 수 있습니다. 이렇게 하면 함수에 인수로 전달되는 <CodeStep step={3}>`formData`</CodeStep> 외에 새 인수(<CodeStep step={2}>`productId`</CodeStep>)가 함수에 바인딩됩니다.
128102

129103
```jsx [[1, 8, "bind"], [2,8, "productId"], [2,4, "productId"], [3,4, "formData"]]
130104
import { updateCart } from './lib.js';
@@ -143,17 +117,13 @@ function AddToCart({productId}) {
143117
}
144118
```
145119

146-
<<<<<<< HEAD
147-
`<form>`[서버컴포넌트](/reference/rsc/use-client)에 의해 렌더링되고 [Server Action](/reference/rsc/use-server)`<form>``action` 프로퍼티에 전달 되면, 폼은 [점진적으로 향상](https://developer.mozilla.org/ko/docs/Glossary/Progressive_Enhancement)됩니다.
148-
=======
149-
When `<form>` is rendered by a [Server Component](/reference/rsc/use-client), and a [Server Function](/reference/rsc/server-functions) is passed to the `<form>`'s `action` prop, the form is [progressively enhanced](https://developer.mozilla.org/en-US/docs/Glossary/Progressive_Enhancement).
150-
>>>>>>> b1a249d597016c6584e4c186daa28b180cc9aafc
120+
`<form>`[서버 컴포넌트](/reference/rsc/use-client)에 의해 렌더링되고 [서버 함수](/reference/rsc/server-functions)`<form>``action` 프로퍼티에 전달되면, 폼은 [점진적으로 향상](https://developer.mozilla.org/ko/docs/Glossary/Progressive_Enhancement)됩니다.
151121

152-
### 폼이 제출되는 동안 pending 상태 보여주기 {/*display-a-pending-state-during-form-submission*/}
122+
### 폼이 제출되는 동안 대기 상태 보여주기 {/*display-a-pending-state-during-form-submission*/}
153123

154-
폼이 제출되는 동안 pending 상태를 보여주기 위해, `<form>`렌더되는 컴포넌트 안에서 `useFormStatus` hook을 호출해 반환된 `pending` 프로퍼티를 읽어낼 수 있습니다.
124+
폼이 제출되는 동안 대기<sup>Pending</sup> 상태를 보여주기 위해, `<form>`렌더링되는 컴포넌트 안에서 `useFormStatus` Hook을 호출해 반환된 `pending` 프로퍼티를 읽을 수 있습니다.
155125

156-
여기 폼이 제출되고 있음을 나타내기 위해 `pending` 프로퍼티를 사용해 보았습니다.
126+
여기 폼이 제출되고 있음을 나타내기 위해 `pending` 프로퍼티를 사용하였습니다.
157127

158128
<Sandpack>
159129

@@ -191,13 +161,13 @@ export async function submitForm(query) {
191161

192162
</Sandpack>
193163

194-
`useFormStatus` hook에 대해 더 알고 싶다면, [참고 문서](/reference/react-dom/hooks/useFormStatus)를 확인하세요.
164+
`useFormStatus` Hook에 대해 더 알고 싶다면, [참고 문서](/reference/react-dom/hooks/useFormStatus)를 확인하세요.
195165

196166
### 낙관적으로 폼 데이터 업데이트하기 {/*optimistically-updating-form-data*/}
197167

198-
`useOptimistic` hook은 네트워크 요청과 같은 백그라운드의 작업이 끝나기 전에 사용자 인터페이스에 낙관적으로 업데이트하는 방법을 제공합니다. 폼의 맥락에서 이 기술은 앱을 더욱 반응형으로 느끼게 해줍니다. 사용자가 폼을 제출하면 인터페이스는 사용자가 기대하는 결과물로 즉시 업데이트됩니다.
168+
`useOptimistic` Hook은 네트워크 요청과 같은 백그라운드의 작업이 끝나기 전에 사용자 인터페이스에 낙관적으로 업데이트하는 방법을 제공합니다. 폼의 맥락에서 이 기술은 앱을 더욱 반응형으로 느끼게 해줍니다. 사용자가 폼을 제출하면 인터페이스는 사용자가 기대하는 결과물로 즉시 업데이트됩니다.
199169

200-
예를 들어, 사용자가 폼에 메시지를 입력하고 "제출" 버튼을 클릭하면 `useOptimistic` hook은 "제출중..." 라벨과 함께 메시지가 서버에 보내지기 전에 리스트에 즉시 보입니다. 이러한 '낙관적인' 접근 방식은 속도와 반응성이 뛰어나다는 인상을 줍니다. 그다음 폼은 실제로 백그라운드에 메시지 보내기를 시도합니다. 서버에 메시지가 잘 도착하면, "제출중..." 라벨은 사라집니다.
170+
예를 들어, 사용자가 폼에 메시지를 입력하고 "제출" 버튼을 클릭하면 `useOptimistic` Hook은 "제출중..." 라벨과 함께 메시지가 서버에 보내지기 전에 리스트에 즉시 보입니다. 이러한 '낙관적인' 접근 방식은 속도와 반응성이 뛰어나다는 인상을 줍니다. 그다음 폼은 실제로 백그라운드에 메시지 보내기를 시도합니다. 서버에 메시지가 잘 도착하면, "제출중..." 라벨은 사라집니다.
201171

202172

203173
<Sandpack>
@@ -262,11 +232,11 @@ export async function deliverMessage(message) {
262232

263233
</Sandpack>
264234

265-
`useOptimistic` hook에 대해 더 알고 싶다면 [참고 문서](/reference/react/hooks/useOptimistic)확인해 보세요.
235+
`useOptimistic` Hook에 대해 더 알고 싶다면 [참고 문서](/reference/react/hooks/useOptimistic)확인하세요.
266236

267-
### 폼 제출 에러 처리하기 {/*handling-form-submission-errors*/}
237+
### 폼 제출 오류 처리하기 {/*handling-form-submission-errors*/}
268238

269-
`<form>``action` 프로퍼티로 전달된 어떤 함수는 에러를 던지기도 합니다. 이런 에러를 `<form>`에 에러 바운더리를 감싸 해결할 수 있습니다. 만약 `<form>``action` 프로퍼티에서 호출된 함수가 에러를 던진다면 에러 바운더리의 fallback이 보이게 됩니다.
239+
`<form>``action` 프로퍼티로 전달된 어떤 함수는 오류를 던지기도 합니다. 이런 오류를 `<form>`에 에러 바운더리를 감싸 해결할 수 있습니다. 만약 `<form>``action` 프로퍼티에서 호출된 함수가 오류를 던진다면 에러 바운더리의 Fallback이 보이게 됩니다.
270240

271241
<Sandpack>
272242

@@ -279,7 +249,7 @@ export default function Search() {
279249
}
280250
return (
281251
<ErrorBoundary
282-
fallback={<p>폼 제출 중에 에러가 발생했습니다.</p>}
252+
fallback={<p>폼 제출 중에 오류가 발생했습니다.</p>}
283253
>
284254
<form action={search}>
285255
<input name="query" />
@@ -306,23 +276,15 @@ export default function Search() {
306276

307277
</Sandpack>
308278

309-
### 자바스크립트 없이 폼 제출 에러 보여주기 {/*display-a-form-submission-error-without-javascript*/}
310-
311-
점진적 향상을 위해 자바스크립트 번들이 로드되기 전 에러 메시지를 보여주기 위해 다음 요소들이 지켜져야 합니다.
279+
### 자바스크립트 없이 폼 제출 오류 보여주기 {/*display-a-form-submission-error-without-javascript*/}
312280

313-
<<<<<<< HEAD
314-
1. `<form>`[서버 컴포넌트](/reference/rsc/use-client)에서 렌더.
315-
2. `<form>``action` 프로퍼티로 전달된 함수가 [Server Action](/reference/rsc/use-server).
316-
3. `useActionState` hook이 에러메시지를 보여주기 위해 사용.
281+
점진적 향상을 위해 자바스크립트 번들이 로드되기 전 오류 메시지를 보여주기 위해 다음 요소들이 지켜져야 합니다.
317282

318-
`useActionState`[Server Action](/reference/rsc/use-server)과 초기 상태 값이라는 두 개의 매개변수를 가집니다. `useActionState`는 상태 변수와 액션이라는 두 개의 값을 반환합니다. `useActionState`를 통해 반환된 액션은 폼의 `action` 프로퍼티에 전달될 수 있습니다. `useActionState`를 통해 반환된 상태 변수는 에러 메시지를 보여주는 데 사용됩니다. `useActionState`에 전달된 [Server Action](/reference/rsc/use-server)에서 반환된 값은 상태 변수를 업데이트하는 데 사용됩니다.
319-
=======
320-
1. `<form>` be rendered by a [Server Component](/reference/rsc/use-client)
321-
1. the function passed to the `<form>`'s `action` prop be a [Server Function](/reference/rsc/server-functions)
322-
1. the `useActionState` Hook be used to display the error message
283+
1. `<form>`[서버 컴포넌트](/reference/rsc/use-client)에서 렌더링.
284+
2. `<form>``action` 프로퍼티로 전달된 함수가 [서버 함수](/reference/rsc/server-functions).
285+
3. `useActionState` Hook이 오류 메시지를 보여주기 위해 사용.
323286

324-
`useActionState` takes two parameters: a [Server Function](/reference/rsc/server-functions) and an initial state. `useActionState` returns two values, a state variable and an action. The action returned by `useActionState` should be passed to the `action` prop of the form. The state variable returned by `useActionState` can be used to display an error message. The value returned by the Server Function passed to `useActionState` will be used to update the state variable.
325-
>>>>>>> b1a249d597016c6584e4c186daa28b180cc9aafc
287+
`useActionState`[서버 함수](/reference/rsc/use-server)와 초기 State라는 두 개의 매개변수를 가집니다. `useActionState`는 State 변수와 액션이라는 두 개의 값을 반환합니다. `useActionState`를 통해 반환된 액션은 폼의 `action` 프로퍼티에 전달될 수 있습니다. `useActionState`를 통해 반환된 상태 변수는 오류 메시지를 보여주는 데 사용됩니다. `useActionState`에 전달된 [서버 함수](/reference/rsc/server-functions)에서 반환된 값은 State 변수를 업데이트하는 데 사용됩니다.
326288

327289
<Sandpack>
328290

@@ -370,7 +332,7 @@ export async function signUpNewUser(newEmail) {
370332

371333
</Sandpack>
372334

373-
[`useActionState`](/reference/react/useActionState)문서를 통해 폼 작업에서 상태를 업데이트하는 방법에 대해 자세히 알아보세요.
335+
[`useActionState`](/reference/react/useActionState) 문서를 통해 폼 작업에서 상태를 업데이트하는 방법에 대해 자세히 알아보세요.
374336

375337
### 다양한 제출 타입 처리하기 {/*handling-multiple-submission-types*/}
376338

0 commit comments

Comments
 (0)