Skip to content

Commit 74d59fd

Browse files
committed
docs: update Children.md
1 parent e28d7a0 commit 74d59fd

File tree

1 file changed

+30
-30
lines changed

1 file changed

+30
-30
lines changed

src/content/reference/react/Children.md

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ title: Children
44

55
<Pitfall>
66

7-
`Children`을 사용하는 것은 일반적이지 않고 취약한 코드가 될 수 있습니다. [일반적으로 사용하는 대안을 살펴보세요.](#alternatives)
7+
`Children`을 사용하는 것은 일반적이지 않고 불안정한 코드를 만들 수 있습니다. [일반적으로 사용하는 대안을 살펴보세요.](#alternatives)
88

99
</Pitfall>
1010

1111
<Intro>
1212

13-
`Children`을 사용해서 [`children` prop](/learn/passing-props-to-a-component#passing-jsx-as-children)로 받은 JSX를 조작하고 변환할 수 있습니다.
13+
`Children`을 사용해서 [`children` Prop](/learn/passing-props-to-a-component#passing-jsx-as-children)로 받은 JSX를 조작하고 변환할 수 있습니다.
1414

1515
```js
1616
const mappedChildren = Children.map(children, child =>
@@ -46,19 +46,19 @@ function RowList({ children }) {
4646
}
4747
```
4848

49-
[아래 예시 보기](#counting-children)
49+
[아래 예시 보기](#counting-children).
5050

5151
#### 매개변수 {/*children-count-parameters*/}
5252

53-
* `children`: 컴포넌트에서 받은 [`children` prop](/learn/passing-props-to-a-component#passing-jsx-as-children)의 값.
53+
* `children`: 컴포넌트에서 받은 [`children` Prop](/learn/passing-props-to-a-component#passing-jsx-as-children)의 값.
5454

5555
#### 반환값 {/*children-count-returns*/}
5656

5757
`children` 내부 노드의 수.
5858

5959
#### 주의 사항 {/*children-count-caveats*/}
6060

61-
- 빈 노드(`null`, `undefined` 혹은 Boolean), 문자열, 숫자, [React 엘리먼트](/reference/react/createElement)는 개별 노드로 간주합니다. 배열 자체는 개별 노드가 아니지만 배열의 자식 요소는 개별 노드로 간주합니다. **React 엘리먼트의 하위 요소는 순회하지 않습니다.** React 엘리먼트는 렌더링 되지 않으며 자식 요소를 순회하지 않습니다. [Fragments](/reference/react/Fragment) 역시 순회하지 않습니다.
61+
- 빈 노드(`null`, `undefined` 혹은 Boolean), 문자열, 숫자, [React 엘리먼트](/reference/react/createElement)는 개별 노드로 간주합니다. 배열 자체는 개별 노드가 아니지만 배열의 자식 요소는 개별 노드로 간주합니다. **React 엘리먼트의 하위 요소는 순회하지 않습니다.** React 엘리먼트는 렌더링 되지 않으며 자식 요소를 순회하지 않습니다. [Fragment](/reference/react/Fragment) 역시 순회하지 않습니다.
6262

6363
---
6464

@@ -78,11 +78,11 @@ function SeparatorList({ children }) {
7878
// ...
7979
```
8080
81-
[아래 예시 보기](#running-some-code-for-each-child)
81+
[아래 예시 보기](#running-some-code-for-each-child).
8282
8383
#### 매개변수 {/*children-foreach-parameters*/}
8484
85-
* `children`: 컴포넌트에서 받은 [`children` prop](/learn/passing-props-to-a-component#passing-jsx-as-children)의 값.
85+
* `children`: 컴포넌트에서 받은 [`children` Prop](/learn/passing-props-to-a-component#passing-jsx-as-children)의 값.
8686
* `fn`: [배열의`forEach` 메서드](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach) 콜백처럼 각 자식 요소에서 실행할 함수. 자식 요소를 첫 번째 인수로, 인덱스를 두 번째 인수로 받습니다. 인덱스는 0에서 시작해서 호출할 때마다 증가합니다.
8787
* **optional** `thisArg`: `fn` 함수가 호출될 때 사용될 [`this`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/this)의 값. 생략 시 `undefined`로 간주합니다.
8888
@@ -116,11 +116,11 @@ function RowList({ children }) {
116116
}
117117
```
118118
119-
[아래 예시 보기](#transforming-children)
119+
[아래 예시 보기](#transforming-children).
120120
121121
#### 매개변수 {/*children-map-parameters*/}
122122
123-
* `children`: 컴포넌트에서 받은 [`children` prop](/learn/passing-props-to-a-component#passing-jsx-as-children)의 값.
123+
* `children`: 컴포넌트에서 받은 [`children` Prop](/learn/passing-props-to-a-component#passing-jsx-as-children)의 값.
124124
* `fn`: [베열의 `map` 메서드](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map) 콜백같은 매핑 함수. 자식 요소를 첫 번째 인수로, 인덱스를 두 번째 인수로 받습니다. 인덱스는 0에서 시작해서 호출할 때마다 증가합니다. 함수는 빈 노드(`null`, `undefined` 혹은 Boolean), 문자열, 숫자, React 엘리먼트 혹은 다른 React 노드의 배열과 같은 React 노드를 반환해야 합니다.
125125
* **optional** `thisArg`: `fn` 함수가 호출될 때 사용될 [`this`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/this)의 값. 생략시 `undefined`로 간주합니다.
126126
@@ -151,12 +151,12 @@ function Box({ children }) {
151151
152152
#### 매개변수 {/*children-only-parameters*/}
153153
154-
* `children`: 컴포넌트에서 받은 [`children` prop](/learn/passing-props-to-a-component#passing-jsx-as-children)의 값.
154+
* `children`: 컴포넌트에서 받은 [`children` Prop](/learn/passing-props-to-a-component#passing-jsx-as-children)의 값.
155155
156156
#### 반환값 {/*children-only-returns*/}
157157
158158
`children`이 [유효한 엘리먼트](/reference/react/isValidElement)라면 그 엘리먼트를 반환합니다.
159-
그렇지 않다면, 에러를 throw합니다.
159+
그렇지 않다면, 에러를 던집니다.
160160
161161
#### 주의 사항 {/*children-only-caveats*/}
162162
@@ -179,7 +179,7 @@ export default function ReversedList({ children }) {
179179
180180
#### 매개변수 {/*children-toarray-parameters*/}
181181
182-
* `children`: 컴포넌트에서 받은 [`children` prop](/learn/passing-props-to-a-component#passing-jsx-as-children)의 값.
182+
* `children`: 컴포넌트에서 받은 [`children` Prop](/learn/passing-props-to-a-component#passing-jsx-as-children)의 값.
183183
184184
#### 반환값 {/*children-toarray-returns*/}
185185
@@ -188,15 +188,15 @@ export default function ReversedList({ children }) {
188188
#### 주의 사항 {/*children-toarray-caveats*/}
189189
190190
191-
- 빈 노드(`null`, `undefined`, 혹은 Booleans)는 반환된 배열에서 생략됩니다. **반환된 엘리먼트의 key는 기존 엘리먼트의 key, 중첩 수준과 위치를 기준으로 계산되므로** 배열을 평면화하더라도 동작이 변경되지 않습니다.
191+
- 빈 노드(`null`, `undefined`, 혹은 Boolean)는 반환된 배열에서 생략됩니다. **반환된 엘리먼트의 key는 기존 엘리먼트의 key, 중첩 수준과 위치를 기준으로 계산되므로** 배열을 평면화하더라도 동작이 변경되지 않습니다.
192192
193193
---
194194
195195
## 사용법 {/*usage*/}
196196
197197
### `children` 변환하기 {/*transforming-children*/}
198198
199-
`Children.map`은 [`children` prop로 받은](/learn/passing-props-to-a-component#passing-jsx-as-children) JSX를 변환합니다.
199+
`Children.map`은 [`children` Prop로 받은](/learn/passing-props-to-a-component#passing-jsx-as-children) JSX를 변환합니다.
200200
201201
```js {6,10}
202202
import { Children } from 'react';
@@ -214,7 +214,7 @@ function RowList({ children }) {
214214
}
215215
```
216216
217-
위 예시에서 `RowList`는 모든 자식 요소를 `<div className="Row">`로 감싸줍니다. 부모 컴포넌트가 `RowList`에 세 개의 `<p>` 태그를 `children` prop로 넘겨준다고 가정해 봅시다.
217+
위 예시에서 `RowList`는 모든 자식 요소를 `<div className="Row">`로 감싸줍니다. 부모 컴포넌트가 `RowList`에 세 개의 `<p>` 태그를 `children` Prop로 넘겨준다고 가정해 봅시다.
218218
219219
```js
220220
<RowList>
@@ -293,24 +293,24 @@ export default function RowList({ children }) {
293293
294294
<DeepDive>
295295
296-
#### `children` prop는 왜 항상 배열이 아닌가요? {/*why-is-the-children-prop-not-always-an-array*/}
296+
#### `children` Prop는 왜 항상 배열이 아닌가요? {/*why-is-the-children-prop-not-always-an-array*/}
297297
298-
React에서 `children` prop는 *불분명한* 데이터 구조로 취급됩니다. `children`이 구조화된 방식에 의존할 수 없다는 의미입니다. 변환하거나 필터링하거나 개수를 세기 위해서는 `Children` 메서드를 사용해야 합니다.
298+
React에서 `children` Prop는 *불분명한* 데이터 구조로 취급됩니다. `children`이 구조화된 방식에 의존할 수 없다는 의미입니다. 변환하거나 필터링하거나 개수를 세기 위해서는 `Children` 메서드를 사용해야 합니다.
299299
300-
실제로 `children` 데이터 구조는 내부적으로 배열로 표현되고는 합니다. 그러나 만약 하나의 자식만 있다면 React는 불필요한 메모리 오버헤드를 방지하기 위해 배열을 추가로 생성하지 않습니다. `children` prop에 직접 접근하지 않고 `Children` 메서드를 사용한다면, 실제로 React가 데이터 구조를 어떻게 구현했더라도 코드는 깨지지 않습니다.
300+
실제로 `children` 데이터 구조는 내부적으로 배열로 표현되고는 합니다. 그러나 만약 하나의 자식만 있다면 React는 불필요한 메모리 오버헤드를 방지하기 위해 배열을 추가로 생성하지 않습니다. `children` Prop에 직접 접근하지 않고 `Children` 메서드를 사용한다면, 실제로 React가 데이터 구조를 어떻게 구현했더라도 코드는 깨지지 않습니다.
301301
302302
`children`이 배열이더라도 `Children.map`을 유용하게 쓸 수 있습니다. 예를 들어 `Children.map`은 반환된 엘리먼트의 [key](/learn/rendering-lists#keeping-list-items-in-order-with-key)를 전달받은 `children`의 key와 병합합니다. 이를 통해 위 예시처럼 감싸지더라도 원본 JSX 자식 요소는 key를 잃어버리지 않습니다.
303303
304304
</DeepDive>
305305
306306
<Pitfall>
307307
308-
`children` 데이터 구조는 JSX로 전달된 컴포넌트의 **렌더링 결과를 포함하지 않습니다.** 아래 예시에서 `RowList`가 받은 `children`에는 세 개가 아닌 두 개의 아이템만 포함됩니다.
308+
`children` 데이터 구조는 JSX로 전달된 컴포넌트의 **렌더링 결과를 포함하지 않습니다.** 아래 예시에서 `RowList`가 받은 `children`에는 세 개가 아닌 두 개의 아이템만 포함합니다.
309309
310310
1. `<p>This is the first item.</p>`
311311
2. `<MoreRows />`
312312
313-
그렇기 때문에 아래 예시에서는 두 개의 래퍼만 생성됩니다.
313+
그렇기 때문에 아래 예시에서는 두 개의 래퍼만 생성합니다.
314314
315315
<Sandpack>
316316
@@ -492,7 +492,7 @@ export default function RowList({ children }) {
492492
493493
### `children` 배열로 병합하기 {/*converting-children-to-an-array*/}
494494
495-
`Children.toArray(children)``children` 데이터 구조를 일반적인 JavaScript 배열로 변경합니다. 이것을 사용해서 [`filter`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter), [`sort`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort), [`reverse`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reverse)와 같은 배열의 내장 메서드를 조작할 수 있습니다.
495+
`Children.toArray(children)``children` 데이터 구조를 일반적인 자바스크립트 배열로 변경합니다. 이것을 사용해서 [`filter`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter), [`sort`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort), [`reverse`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reverse)와 같은 배열의 내장 메서드를 조작할 수 있습니다.
496496
497497
<Sandpack>
498498
@@ -540,7 +540,7 @@ export default function ReversedList({ children }) {
540540
import { Children } from 'react';
541541
```
542542
543-
소문자 `c`인 [`children`prop](/learn/passing-props-to-a-component#passing-jsx-as-children)와 혼동해서는 안 됩니다. [`children`prop](/learn/passing-props-to-a-component#passing-jsx-as-children)는 좋은 방법이고 권장되는 방식입니다.
543+
소문자 `c`인 [`children` Prop](/learn/passing-props-to-a-component#passing-jsx-as-children)와 혼동해서는 안 됩니다. [`children` Prop](/learn/passing-props-to-a-component#passing-jsx-as-children)는 좋은 방법이고 권장되는 방식입니다.
544544
545545
</Note>
546546
@@ -679,9 +679,9 @@ export function Row({ children }) {
679679
680680
---
681681
682-
### prop로 객체 배열 받기 {/*accepting-an-array-of-objects-as-a-prop*/}
682+
### Prop로 객체 배열 받기 {/*accepting-an-array-of-objects-as-a-prop*/}
683683
684-
prop로 명시적으로 배열을 전달할 수 있습니다. 예를 들어, 아래 예시에서 `RowList``rows` 배열을 prop로 받습니다.
684+
Prop로 명시적으로 배열을 전달할 수 있습니다. 예를 들어, 아래 예시에서 `RowList``rows` 배열을 Prop로 받습니다.
685685
686686
<Sandpack>
687687
@@ -730,9 +730,9 @@ export function RowList({ rows }) {
730730
731731
</Sandpack>
732732
733-
`rows`는 일반적인 JavaScript 배열이기 때문에, `RowList` 컴포넌트는 [`map`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map)과 같은 내장 배열 메서드를 사용할 수 있습니다.
733+
`rows`는 일반적인 자바스크립트 배열이기 때문에, `RowList` 컴포넌트는 [`map`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map)과 같은 내장 배열 메서드를 사용할 수 있습니다.
734734
735-
이 패턴은 구조화된 데이터를 자식 요소와 함께 전달할 때 더 유용합니다. 아래 예시에서 `TabSwitcher` 컴포넌트는 `tabs` prop로 객체 배열을 받습니다.
735+
이 패턴은 구조화된 데이터를 자식 요소와 함께 전달할 때 더 유용합니다. 아래 예시에서 `TabSwitcher` 컴포넌트는 `tabs` Prop로 객체 배열을 받습니다.
736736
737737
<Sandpack>
738738
@@ -794,7 +794,7 @@ JSX로 자식 요소를 전달할 때와 달리 이런 방식은 각 아이템
794794
795795
---
796796
797-
### 렌더링 prop로 렌더링 커스텀하기 {/*calling-a-render-prop-to-customize-rendering*/}
797+
### 렌더링 Prop로 렌더링 커스텀하기 {/*calling-a-render-prop-to-customize-rendering*/}
798798
799799
모든 개별 항목에 대해 JSX를 생성하는 대신 JSX를 반환하는 함수를 전달하고 필요할 때 해당 함수를 호출할 수도 있습니다. 아래 예시에서 `App` 컴포넌트는 `renderContent` 함수를 `TabSwitcher` 컴포넌트에 전달합니다. `TabSwitcher` 컴포넌트는 선택된 탭에 대해서만 `renderContent`를 호출합니다.
800800
@@ -845,10 +845,10 @@ export default function TabSwitcher({ tabIds, getHeader, renderContent }) {
845845
846846
</Sandpack>
847847
848-
`renderContent`와 같이 사용자 인터페이스의 일부를 어떻게 렌더링할지 정의하는 prop를 *렌더링 prop*라고 합니다. 하지만 특별한 것은 아닙니다. 단지 일반적인 함수의 prop일 뿐입니다.
848+
`renderContent`와 같이 사용자 인터페이스의 일부를 어떻게 렌더링할지 정의하는 Prop를 *렌더링 Prop*라고 합니다. 하지만 특별한 것은 아닙니다. 단지 일반적인 함수의 Prop일 뿐입니다.
849849
850-
렌더링 props는 함수이므로 정보를 전달할 수 있습니다.
851-
아래 예시에서 `RowList` 컴포넌트는 각 row의 `id``index``renderRow`에 렌더링 prop로 전달하고, `index`가 짝수인 row를 강조합니다.
850+
렌더링 Prop은은 함수이므로 정보를 전달할 수 있습니다.
851+
아래 예시에서 `RowList` 컴포넌트는 각 row의 `id``index``renderRow`에 렌더링 Prop로 전달하고, `index`가 짝수인 row를 강조합니다.
852852
853853
<Sandpack>
854854

0 commit comments

Comments
 (0)