Skip to content

Commit 7086a14

Browse files
hapumeesimsim0709
authored andcommitted
Translation of Advanced Guides > Portals (#131)
* Draft of Advanced Guides > Portals * Revise
1 parent 5bb3fc5 commit 7086a14

File tree

1 file changed

+30
-33
lines changed

1 file changed

+30
-33
lines changed

content/docs/portals.md

Lines changed: 30 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,21 @@ title: Portals
44
permalink: docs/portals.html
55
---
66

7-
Portals provide a first-class way to render children into a DOM node that exists outside the DOM hierarchy of the parent component.
7+
Portal은 부모 컴포넌트의 DOM 계층 구조 바깥에 있는 DOM 노드로 자식을 렌더링하는 최고의 방법을 제공합니다.
88

99
```js
1010
ReactDOM.createPortal(child, container)
1111
```
1212

13-
The first argument (`child`) is any [renderable React child](/docs/react-component.html#render), such as an element, string, or fragment. The second argument (`container`) is a DOM element.
13+
첫 번째 인자(`child`)는 엘리먼트, 문자열, 혹은 fragment와 같은 어떤 종류이든 [렌더링할 수 있는 React 자식](/docs/react-component.html#render)입니다. 두 번째 인자(`container`)DOM 엘리먼트입니다.
1414

15-
## Usage {#usage}
15+
## 사용법 {#usage}
1616

17-
Normally, when you return an element from a component's render method, it's mounted into the DOM as a child of the nearest parent node:
17+
보통 컴포넌트 렌더링 메서드에서 엘리먼트를 반환할 때 그 엘리먼트는 부모 노드에서 가장 가까운 자식으로 DOM에 마운트됩니다.
1818

1919
```js{4,6}
2020
render() {
21-
// React mounts a new div and renders the children into it
21+
// React는 새로운 div를 마운트하고 그 안에 자식을 렌더링합니다.
2222
return (
2323
<div>
2424
{this.props.children}
@@ -27,34 +27,34 @@ render() {
2727
}
2828
```
2929

30-
However, sometimes it's useful to insert a child into a different location in the DOM:
30+
그런데 가끔 DOM의 다른 위치에 자식을 삽입하는 것이 유용할 수 있습니다.
3131

3232
```js{6}
3333
render() {
34-
// React does *not* create a new div. It renders the children into `domNode`.
35-
// `domNode` is any valid DOM node, regardless of its location in the DOM.
34+
// React는 새로운 div를 생성하지 *않고* `domNode` 안에 자식을 렌더링합니다.
35+
// `domNode`는 DOM 노드라면 어떠한 것이든 유효하고, 그것은 DOM 내부의 어디에 있든지 상관없습니다.
3636
return ReactDOM.createPortal(
3737
this.props.children,
3838
domNode
3939
);
4040
}
4141
```
4242

43-
A typical use case for portals is when a parent component has an `overflow: hidden` or `z-index` style, but you need the child to visually "break out" of its container. For example, dialogs, hovercards, and tooltips.
43+
portal의 전형적인 유스케이스는 부모 컴포넌트에 `overflow: hidden`이나 `z-index`가 있는 경우이지만, 시각적으로 자식을 "튀어나오도록" 보여야 하는 경우도 있습니다. 예를 들어, 다이얼로그, 호버카드나 툴팁과 같은 것입니다.
4444

45-
> Note:
45+
>주의
4646
>
47-
> When working with portals, remember that [managing keyboard focus](/docs/accessibility.html#programmatically-managing-focus) becomes very important.
47+
> portal을 이용하여 작업할 때 [키보드 포커스 관리](/docs/accessibility.html#programmatically-managing-focus)가 매우 중요하다는 것을 염두에 두십시오.
4848
>
49-
> For modal dialogs, ensure that everyone can interact with them by following the [WAI-ARIA Modal Authoring Practices](https://www.w3.org/TR/wai-aria-practices-1.1/#dialog_modal).
49+
> 모달 다이얼로그(modal dialogs)의 경우 [WAI-ARIA Modal Authoring Practices](https://www.w3.org/TR/wai-aria-practices-1.1/#dialog_modal)에 따라 모든 모달 다이얼로그(modal dialogs)와 상호작용할 수 있는지 확인하십시오.
5050
51-
[**Try it on CodePen**](https://codepen.io/gaearon/pen/yzMaBd)
51+
[**CodePen에서 실행하기**](https://codepen.io/gaearon/pen/yzMaBd)
5252

53-
## Event Bubbling Through Portals {#event-bubbling-through-portals}
53+
## Portal을 통한 이벤트 버블링 {#event-bubbling-through-portals}
5454

55-
Even though a portal can be anywhere in the DOM tree, it behaves like a normal React child in every other way. Features like context work exactly the same regardless of whether the child is a portal, as the portal still exists in the *React tree* regardless of position in the *DOM tree*.
55+
portal이 DOM 트리의 어디에도 존재할 수 있다 하더라도 모든 다른 면에서 일반적인 React 자식처럼 동작합니다. context와 같은 기능은 자식이 portal이든지 아니든지 상관없이 정확하게 같게 동작합니다. 이는 *DOM 트리*에서의 위치에 상관없이 portal은 여전히 *React 트리*에 존재하기 때문입니다.
5656

57-
This includes event bubbling. An event fired from inside a portal will propagate to ancestors in the containing *React tree*, even if those elements are not ancestors in the *DOM tree*. Assuming the following HTML structure:
57+
이것에는 이벤트 버블링도 포함되어 있습니다. portal 내부에서 발생한 이벤트는 *React 트리*에 포함된 상위로 전파될 것입니다. *DOM 트리*에서는 그 상위가 아니라 하더라도 말입니다. 다음의 HTML 구조를 가정해 봅시다.
5858

5959
```html
6060
<html>
@@ -65,10 +65,10 @@ This includes event bubbling. An event fired from inside a portal will propagate
6565
</html>
6666
```
6767

68-
A `Parent` component in `#app-root` would be able to catch an uncaught, bubbling event from the sibling node `#modal-root`.
68+
`#app-root` 안에 있는 `Parent` 컴포넌트는 형제 노드인 `#modal-root` 안의 컴포넌트에서 전파된 이벤트가 포착되지 않았을 경우 그것을 포착할 수 있습니다.
6969

7070
```js{28-31,42-49,53,61-63,70-71,74}
71-
// These two containers are siblings in the DOM
71+
// 여기 이 두 컨테이너는 DOM에서 형제 관계입니다.
7272
const appRoot = document.getElementById('app-root');
7373
const modalRoot = document.getElementById('modal-root');
7474
@@ -79,14 +79,11 @@ class Modal extends React.Component {
7979
}
8080
8181
componentDidMount() {
82-
// The portal element is inserted in the DOM tree after
83-
// the Modal's children are mounted, meaning that children
84-
// will be mounted on a detached DOM node. If a child
85-
// component requires to be attached to the DOM tree
86-
// immediately when mounted, for example to measure a
87-
// DOM node, or uses 'autoFocus' in a descendant, add
88-
// state to Modal and only render the children when Modal
89-
// is inserted in the DOM tree.
82+
// Portal 엘리먼트는 Modal의 자식이 마운트된 후 DOM 트리에 삽입됩니다.
83+
// 요컨대, 자식은 어디에도 연결되지 않은 DOM 노드로 마운트됩니다.
84+
// 만약 자식 컴포넌트가 마운트될 때 그것을 즉시 DOM 트리에 연결해야만 한다면,
85+
// 예를 들어, DOM 노드를 계산한다든지 자식 노드에서 'autoFocus'를 사용한다든지 하는 경우에,
86+
// Modal에 state를 추가하고 Modal이 DOM 트리에 삽입되어 있을 때만 자식을 렌더링하십시오.
9087
modalRoot.appendChild(this.el);
9188
}
9289
@@ -110,9 +107,8 @@ class Parent extends React.Component {
110107
}
111108
112109
handleClick() {
113-
// This will fire when the button in Child is clicked,
114-
// updating Parent's state, even though button
115-
// is not direct descendant in the DOM.
110+
// 이것은 Child에 있는 버튼이 클릭 되었을 때 발생하고 Parent의 state를 갱신합니다.
111+
// 비록 버튼이 DOM 상에서 직계 자식이 아니라고 하더라도 말입니다.
116112
this.setState(state => ({
117113
clicks: state.clicks + 1
118114
}));
@@ -137,8 +133,8 @@ class Parent extends React.Component {
137133
}
138134
139135
function Child() {
140-
// The click event on this button will bubble up to parent,
141-
// because there is no 'onClick' attribute defined
136+
// 이 버튼에서의 클릭 이벤트는 부모로 버블링됩니다.
137+
// 왜냐하면 'onClick' 속성이 정의되지 않았기 때문입니다.
142138
return (
143139
<div className="modal">
144140
<button>Click</button>
@@ -149,6 +145,7 @@ function Child() {
149145
ReactDOM.render(<Parent />, appRoot);
150146
```
151147

152-
[**Try it on CodePen**](https://codepen.io/gaearon/pen/jGBWpE)
148+
[**CodePen에서 실행하기**](https://codepen.io/gaearon/pen/jGBWpE)
153149

154-
Catching an event bubbling up from a portal in a parent component allows the development of more flexible abstractions that are not inherently reliant on portals. For example, if you render a `<Modal />` component, the parent can capture its events regardless of whether it's implemented using portals.
150+
portal에서 버블링된 이벤트를 부모 컴포넌트에서 포착한다는 것은 본질적으로 portal에 의존하지 않는 조금 더 유연한 추상화 개발이 가능함을 나타냅니다.
151+
예를 들어, `<Modal />` 컴포넌트를 렌더링할 때 부모는 그것이 portal을 사용했는지와 관계없이 `<Modal />`의 이벤트를 포착할 수 있습니다.

0 commit comments

Comments
 (0)