You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/docs/reference-react-dom.md
+31-32
Original file line number
Diff line number
Diff line change
@@ -6,53 +6,51 @@ category: Reference
6
6
permalink: docs/react-dom.html
7
7
---
8
8
9
-
If you load React from a `<script>`tag, these top-level APIs are available on the `ReactDOM`global. If you use ES6 with npm, you can write `import ReactDOM from 'react-dom'`. If you use ES5 with npm, you can write `var ReactDOM = require('react-dom')`.
9
+
React를 `<script>`태그로 불러온다면 `ReactDOM`글로벌 영역에서 상위 레벨 API를 이용할 수 있습니다. 만약 npm과 ES6를 사용한다면 `import ReactDOM from 'react-dom'`로 쓸 수 있습니다. npm과 ES5의 경우에는 `var ReactDOM = require('react-dom')`로 쓸 수 있습니다.
10
10
11
-
## Overview {#overview}
11
+
## 개요 {#overview}
12
12
13
-
The `react-dom`package provides DOM-specific methods that can be used at the top level of your app and as an escape hatch to get outside of the React model if you need to. Most of your components should not need to use this module.
13
+
`react-dom`package는 앱의 최상위 레벨에서 사용할 수 있는 DOM에 특화된 메서드와 필요한 경우 React 모델 외부로 나갈 수 있는 해결책을 제공합니다. 대다수 컴포넌트는 이 모듈을 사용할 필요가 없습니다.
React supports all popular browsers, including Internet Explorer 9 and above, although [some polyfills are required](/docs/javascript-environment-requirements.html) for older browsers such as IE 9 and IE 10.
23
+
React는 Internet Explorer 9과 상위 버전을 포함한 모든 주요 브라우저를 지원합니다. 그러나 IE 9과 IE 10과 같은 구형 브라우저는 [폴리필(polyfill)이 필요합니다](/docs/javascript-environment-requirements.html).
24
24
25
-
> Note
25
+
> 주의
26
26
>
27
-
> We don't support older browsers that don't support ES5 methods, but you may find that your apps do work in older browsers if polyfills such as [es5-shim and es5-sham](https://github.com/es-shims/es5-shim) are included in the page. You're on your own if you choose to take this path.
27
+
> 우리는 ES5 메서드를 지원하지 않는 구형 브라우저를 지원하지 않지만, 페이지에 [es5-shim과 es5-sham](https://github.com/es-shims/es5-shim)과 같은 폴리필을 포함한다면 앱이 구형 브라우저에서도 동작할 수 있습니다. 이 길을 선택한다면 스스로 해결해야 합니다.
28
28
29
29
* * *
30
30
31
-
## Reference {#reference}
31
+
## 참조 {#reference}
32
32
33
33
### `render()` {#render}
34
34
35
35
```javascript
36
36
ReactDOM.render(element, container[, callback])
37
37
```
38
38
39
-
Render a React element into the DOM in the supplied `container` and return a [reference](/docs/more-about-refs.html) to the component (or returns `null` for [stateless components](/docs/components-and-props.html#functional-and-class-components)).
If the React element was previously rendered into `container`, this will perform an update on it and only mutate the DOM as necessary to reflect the latest React element.
41
+
React 엘리먼트가 이전에 `container` 내부에 렌더링 되었다면 해당 엘리먼트는 업데이트하고 최신의 React 엘리먼트를 반영하는 데 필요한 DOM만 변경합니다.
42
42
43
-
If the optional callback is provided, it will be executed after the component is rendered or updated.
43
+
추가적인 콜백이 제공된다면 컴포넌트가 렌더링되거나 업데이트된 후 실행됩니다.
44
44
45
-
> Note:
45
+
> 주의
46
46
>
47
-
> `ReactDOM.render()` controls the contents of the container node you pass in. Any existing DOM elements inside are replaced when first called. Later calls use React’s DOM diffing algorithm for efficient updates.
47
+
> `ReactDOM.render()`는 전달한 컨테이너 노드의 콘텐츠를 제어합니다. 처음 호출할 때 기존의 DOM 엘리먼트를 교체하며 이후의 호출은 React의 DOM diffing 알고리즘을 사용하여 더욱 효율적으로 업데이트합니다.
48
48
>
49
-
> `ReactDOM.render()` does not modify the container node (only modifies the children of the container). It may be possible to insert a component to an existing DOM node without overwriting the existing children.
49
+
> `ReactDOM.render()`는 컨테이너 노드를 수정하지 않고 컨테이너의 하위 노드만 수정합니다. 그렇기 때문에 자식 노드를 덮어쓸 필요 없이 기존의 DOM 노드에 컴포넌트를 추가할 수 있습니다.
50
50
>
51
-
> `ReactDOM.render()` currently returns a reference to the root `ReactComponent` instance. However, using this return value is legacy
52
-
> and should be avoided because future versions of React may render components asynchronously in some cases. If you need a reference to the root `ReactComponent` instance, the preferred solution is to attach a
53
-
> [callback ref](/docs/more-about-refs.html#the-ref-callback-attribute) to the root element.
51
+
> `ReactDOM.render()`는 현재 `ReactComponent` 루트(root) 인스턴스에 대한 참조를 반환합니다. 그러나 이 반환 값을 사용하는 것은 레거시이며 React 신규 버전이 컴포넌트를 비동기로 렌더링하는 경우가 있기 때문에 피해야 합니다. `ReactComponent` 인스턴스의 참조가 필요하다면 권장하는 해결책은 루트 엘리먼트에 [콜백 ref](/docs/more-about-refs.html#the-ref-callback-attribute)를 붙이는 것입니다.
54
52
>
55
-
> Using `ReactDOM.render()` to hydrate a server-rendered container is deprecated and will be removed in React 17. Use [`hydrate()`](#hydrate) instead.
53
+
> `ReactDOM.render()`를 사용해 서버에서 렌더링한 컨테이너에 이벤트를 보충하는 것은 권장되지 않으며 React 17 버전에서 삭제될 예정입니다. [`hydrate()`](#hydrate)를 사용해주세요.
56
54
57
55
* * *
58
56
@@ -62,15 +60,15 @@ If the optional callback is provided, it will be executed after the component is
62
60
ReactDOM.hydrate(element, container[, callback])
63
61
```
64
62
65
-
Same as [`render()`](#render), but is used to hydrate a container whose HTML contents were rendered by [`ReactDOMServer`](/docs/react-dom-server.html). React will attempt to attach event listeners to the existing markup.
63
+
[`render()`](#render)와 동일하지만 HTML 콘텐츠가 [`ReactDOMServer`](/docs/react-dom-server.html)로 렌더링 된 컨테이너에 이벤트를 보충하기 위해 사용됩니다. React는 기존 마크업에 이벤트 리스너를 연결합니다.
66
64
67
-
React expects that the rendered content is identical between the server and the client. It can patch up differences in text content, but you should treat mismatches as bugs and fix them. In development mode, React warns about mismatches during hydration. There are no guarantees that attribute differences will be patched up in case of mismatches. This is important for performance reasons because in most apps, mismatches are rare, and so validating all markup would be prohibitively expensive.
65
+
React는 렌더링 된 콘텐츠가 서버와 클라이언트 간에 같을 것으로 예상합니다. React가 텍스트 콘텐츠의 차이를 고칠 수는 있지만 이러한 불일치를 버그로 취급하여 고쳐야 합니다. 개발 모드에서 React는 이벤트 보충 중 발생하는 불일치에 대해 경고합니다. 불일치가 발생하는 경우에 어트리뷰트 차이를 고친다는 보장이 없습니다. 대다수의 어플리케이션에서 불일치가 발생하는 경우는 많지 않으며 발생하는 경우 모든 마크업을 검증하는 것이 매우 큰 비용을 수반하기 때문에 성능상의 이유로 중요한 문제입니다.
68
66
69
-
If a single element's attribute or text content is unavoidably different between the server and the client (for example, a timestamp), you may silence the warning by adding `suppressHydrationWarning={true}` to the element. It only works one level deep, and is intended to be an escape hatch. Don't overuse it. Unless it's text content, React still won't attempt to patch it up, so it may remain inconsistent until future updates.
67
+
서버와 클라이언트 사이에서 단일 엘리먼트의 어트리뷰트나 텍스트가 불가피하게 다르다면(예를 들어 timestamp의 경우) 그 엘리먼트에 `suppressHydrationWarning={true}`를 추가하는 것으로 경고를 끌 수 있습니다. 이는 한 단계까지만 작동하며 의도된 해결책입니다. 절대 남용하지 마세요. 텍스트가 아니라면 React는 해당 엘리먼트를 고치지 않을 것이며 이후의 업데이트까지 일치하지 않은 채로 남아있을 것입니다.
70
68
71
-
If you intentionally need to render something different on the server and the client, you can do a two-pass rendering. Components that render something different on the client can read a state variable like `this.state.isClient`, which you can set to `true` in `componentDidMount()`. This way the initial render pass will render the same content as the server, avoiding mismatches, but an additional pass will happen synchronously right after hydration. Note that this approach will make your components slower because they have to render twice, so use it with caution.
69
+
서버와 클라이언트 간의 차이를 의도한다면 2단계 렌더링을 사용할 수 있습니다. 클라이언트에서 다르게 렌더링 되는 컴포넌트는 `componentDidMount()`에서 `true`로 설정할 수 있는 `this.state.isClient`와 같은 상태 변수를 읽을 수 있습니다. 이 방식으로 초기 렌더 단계는 서버와 같은 콘텐츠를 렌더링하여 불일치를 방지하지만, 이벤트 보충 직후에 추가적인 단계가 동기적으로 발생합니다. 이 방식은 컴포넌트를 두 번 렌더링하게 만들어 속도를 느리게 할 수 있기 때문에 주의를 기울여야 합니다.
72
70
73
-
Remember to be mindful of user experience on slow connections. The JavaScript code may load significantly later than the initial HTML render, so if you render something different in the client-only pass, the transition can be jarring. However, if executed well, it may be beneficial to render a "shell" of the application on the server, and only show some of the extra widgets on the client. To learn how to do this without getting the markup mismatch issues, refer to the explanation in the previous paragraph.
71
+
느린 연결에서의 사용자 경험에 유의해야 합니다. JavaScript 코드는 최초 HTML 렌더링보다 매우 늦게 로드될 수 있으며 만약 클라이언트 전용 단계에서 다른 무언가를 렌더링한다면 그 전환 과정에서 방해를 받을 수 있습니다. 그러나 정상적으로 실행된다면 서버에 어플리케이션 "shell"을 렌더링하고 클라이언트에서 일부 추가 위젯만 표시하는 것이 효과적일 수 있습니다. 마크업 불일치 문제없이 이 방식을 사용하길 원한다면 이전 단락의 설명을 참고해주세요.
74
72
75
73
* * *
76
74
@@ -80,28 +78,29 @@ Remember to be mindful of user experience on slow connections. The JavaScript co
80
78
ReactDOM.unmountComponentAtNode(container)
81
79
```
82
80
83
-
Remove a mounted React component from the DOM and clean up its event handlers and state. If no component was mounted in the container, calling this function does nothing. Returns `true` if a component was unmounted and `false` if there was no component to unmount.
81
+
마운트된 React 컴포넌트를 DOM에서 제거하고 컴포넌트의 이벤트 핸들러와 state를 정리합니다. 만약 컨테이너에 아무런 컴포넌트도 마운트 되지 않았다면 해당 함수를 호출하더라도 아무런 동작을 하지 않습니다. 컴포넌트가 마운트 해제되었다면 `true`, 마운트 해제할 컴포넌트가 존재하지 않는다면 `false`를 반환합니다.
84
82
85
83
* * *
86
84
87
85
### `findDOMNode()` {#finddomnode}
88
86
89
-
> Note:
87
+
> 주의
90
88
>
91
-
> `findDOMNode` is an escape hatch used to access the underlying DOM node. In most cases, use of this escape hatch is discouraged because it pierces the component abstraction. [It has been deprecated in `StrictMode`.](/docs/strict-mode.html#warning-about-deprecated-finddomnode-usage)
89
+
> `findDOMNode`는 기본 DOM 노드를 이용하는 데에 사용되는 해결책입니다. 대부분의 경우에서 이 해결책을 사용하는 것은 컴포넌트 추상화를 위반하기 때문에 권장하지 않습니다. [이 메서드는 `StrictMode`에서 권장되지 않습니다.](/docs/strict-mode.html#warning-about-deprecated-finddomnode-usage)
92
90
93
91
```javascript
94
92
ReactDOM.findDOMNode(component)
95
93
```
96
-
If this component has been mounted into the DOM, this returns the corresponding native browser DOM element. This method is useful for reading values out of the DOM, such as form field values and performing DOM measurements. **In most cases, you can attach a ref to the DOM node and avoid using `findDOMNode` at all.**
97
94
98
-
When a component renders to `null` or `false`, `findDOMNode` returns `null`. When a component renders to a string, `findDOMNode` returns a text DOM node containing that value. As of React 16, a component may return a fragment with multiple children, in which case `findDOMNode` will return the DOM node corresponding to the first non-empty child.
95
+
매개 변수로 전달받은 컴포넌트가 DOM 내부에 마운트되었다면 컴포넌트에 해당하는 네이티브 브라우저의 DOM 엘리먼트를 반환합니다. 해당 메서드는 form 필드 값이나 DOM 성능 측정과 같이 DOM에서 값을 읽을 때 유용합니다. **대부분의 경우에서 DOM 노드에 ref를 붙일 수 있으며 `findDOMNode`를 사용할 필요가 전혀 없습니다.**
99
96
100
-
> Note:
97
+
컴포넌트가 `null`이나 `false`를 렌더링하는 경우 `findDOMNode`은 `null`을 반환합니다. 컴포넌트가 문자를 반환하는 경우 `findDOMNode`은 문자 값을 포함하고 있는 텍스트 DOM 노드를 반환합니다. React 16부터 컴포넌트는 여러 개의 자식을 가진 fragment를 반환할 수 있으며 이 경우에 `findDOMNode`는 비어있지 않은 첫 번째 자식에 해당하는 DOM 노드를 반환합니다.
98
+
99
+
> 주의
101
100
>
102
-
> `findDOMNode` only works on mounted components (that is, components that have been placed in the DOM). If you try to call this on a component that has not been mounted yet (like calling `findDOMNode()` in `render()` on a component that has yet to be created) an exception will be thrown.
101
+
> `findDOMNode`는 마운트된 컴포넌트에만 동작합니다(즉 컴포넌트는 DOM 내부에 존재해야 합니다). 아직 마운트되지 않은 컴포넌트를 대상으로 해당 메서드를 호출한다면(예를 들어 아직 생성되지 않은 컴포넌트의 `render()`에서 `findDOMNode()`를 호출하는 것) exception이 발생합니다.
103
102
>
104
-
> `findDOMNode` cannot be used on function components.
103
+
> `findDOMNode`은 함수 컴포넌트에서는 사용할 수 없습니다.
105
104
106
105
* * *
107
106
@@ -111,4 +110,4 @@ When a component renders to `null` or `false`, `findDOMNode` returns `null`. Whe
111
110
ReactDOM.createPortal(child, container)
112
111
```
113
112
114
-
Creates a portal. Portals provide a way to [render children into a DOM node that exists outside the hierarchy of the DOM component](/docs/portals.html).
113
+
portal을 생성합니다. Portal은 [DOM 컴포넌트 구조의 외부에 존재하는 DOM 노드에 자식을 렌더링](/docs/portals.html)하는 방법을 제공합니다.
0 commit comments