Skip to content

Translate ReactDOM #28

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

Merged
merged 7 commits into from
Mar 2, 2019
Merged
Changes from 4 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
63 changes: 31 additions & 32 deletions content/docs/reference-react-dom.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,53 +6,51 @@ category: Reference
permalink: docs/react-dom.html
---

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')`.
만약 React를 `<script>` 태그로 불러온다면 `ReactDOM` 글로벌 영역에서 상위 레벨 API를 이용할 수 있습니다. 만약 npm과 ES6를 사용한다면 `import ReactDOM from 'react-dom'`로 쓸 수 있습니다. npm과 ES5의 경우에는 `var ReactDOM = require('react-dom')`로 쓸 수 있습니다.

## Overview {#overview}
## 개요 {#overview}

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.
`react-dom` 패키지는 어플리케이션 최상위 레벨에서 사용할 수 있는 DOM에 특화된 메소드, 그리고 필요한 경우 React 모델 외부로 나갈 수 있는 탈출구를 제공합니다. 대다수 컴포넌트는 이 모듈을 사용할 필요가 없습니다.

- [`render()`](#render)
- [`hydrate()`](#hydrate)
- [`unmountComponentAtNode()`](#unmountcomponentatnode)
- [`findDOMNode()`](#finddomnode)
- [`createPortal()`](#createportal)

### Browser Support {#browser-support}
### 브라우저 지원 {#browser-support}

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.
React는 Internet Explorer 9과 그 이후 버전을 포함한 모든 주요 브라우저를 지원합니다. 그러나 IE 9과 IE 10과 같은 구형 브라우저는 [polyfill이 필요합니다](/docs/javascript-environment-requirements.html).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

React는 Internet Explorer 9와 상위 버전을 포함한 모든 주요 브라우저를 지원합니다. 그러나 IE 9와 IE 10과 같은 구형 브라우저는 폴리필(polyfill)이 필요합니다.

  • 그 이후 버전 -> 상위 버전 그리고 숫자 9에 대한 조사 사용( -> )에 대해 위처럼 수정 부탁드립니다.
  • polyfill에 대한 번역은 최초 등장시 폴리필(polyfill)로 번역하고 그 이후는 폴리필로 번역하도록 논의되고 있어요. translate glossary #2 (comment)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

9를 nine으로 읽는다고 생각해서 로 번역했는데 로 읽는게 더 자연스러운가요?

Copy link
Member

@taehwanno taehwanno Feb 18, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이 부분은 저도 정확한 지침을 자세히 모르겠네요.

구글 검색을 통해 다른 회사의 사례를 살펴보면 위처럼 나오는데 이 맞지 않을까 생각하고 있어요. 이에 대한 지침을 한번 찾아봐야겠네요.

Copy link
Member

@taehwanno taehwanno Feb 28, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@taggon @simsim0709 @gnujoow @hg-pyun @b9words
이 부분에 대한 의견 부탁드릴게요 :)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

확실한 지침은 모르겠지만 9는을 더 많이 사용 하고 있는 것 같습니다.


> Note
> 주의
>
> 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.
> 우리는 ES5 메소드를 사용할 수 없는 구형 브라우저를 지원하지 않지만, 만약 어플리케이션의 페이지에 [es5-shim과 es5-sham](https://github.com/es-shims/es5-shim)과 같은 polyfill을 포함한다면 어플리케이션이 구형 브라우저에서도 동작한다는 것을 알 수 있을 것입니다. 이 방식을 선택한다면 스스로 해결해 나갈 것입니다.

* * *

## Reference {#reference}
## 참조 {#reference}

### `render()` {#render}

```javascript
ReactDOM.render(element, container[, callback])
```

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)).
React 엘리먼트를 DOM의 제공된 `컨테이너` 내부에 렌더링하고 [레퍼런스](/docs/more-about-refs.html)를 컴포넌트로 반환합니다([무상태 컴포넌트](/docs/components-and-props.html#functional-and-class-components)의 경우 `null`을 반환합니다).

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.
만약 React 엘리먼트가 이전에 `컨테이너` 내부에 렌더링 되었다면 해당 구문은 업데이트를 수행하며 최신의 React 엘리먼트를 반영하는 데에 필요한 DOM만 변경합니다.

If the optional callback is provided, it will be executed after the component is rendered or updated.
만약 선택적인 콜백이 제공된다면 컴포넌트의 렌더링 또는 업데이트 이후에 실행됩니다.

> Note:
> 주의
>
> `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.
> `ReactDOM.render()`는 전달한 컨테이너 노드의 콘텐츠를 제어합니다. 이 구문을 처음 호출할 때 기존의 DOM 엘리먼트를 교체하며 이후의 호출은 React의 DOM diffing 알고리즘을 사용하여 더욱 효율적으로 업데이트합니다.
>
> `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.
> `ReactDOM.render()`는 컨테이너 노드를 수정하지 않고 컨테이너의 하위 노드만 수정합니다. 그렇기 때문에 자식 노드를 덮어쓸 필요 없이 기존의 DOM 노드에 컴포넌트를 추가할 수 있습니다.
>
> `ReactDOM.render()` currently returns a reference to the root `ReactComponent` instance. However, using this return value is legacy
> 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
> [callback ref](/docs/more-about-refs.html#the-ref-callback-attribute) to the root element.
> `ReactDOM.render()`는 현재 `ReactComponent` 루트 인스턴스에 대한 레퍼런스를 반환합니다. 그러나 이 반환 값을 사용하는 것은 레거시이며 React 신규 버전이 컴포넌트를 비동기로 렌더링하는 경우가 있기 때문에 피해야 합니다. 만약 `ReactComponent` 인스턴스의 레퍼런스가 필요하다면 권장하는 해결책은 루트 엘리먼트에 [콜백 ref](/docs/more-about-refs.html#the-ref-callback-attribute)를 첨부하는 것입니다.
>
> Using `ReactDOM.render()` to hydrate a server-rendered container is deprecated and will be removed in React 17. Use [`hydrate()`](#hydrate) instead.
> 서버에서 렌더링한 컨테이너를 공급하기 위해 `ReactDOM.render()`를 사용하는 것은 deprecated 되었으며 React 17 버전에서 삭제될 예정입니다. [`hydrate()`](#hydrate)를 사용해주세요.

* * *

Expand All @@ -62,15 +60,15 @@ If the optional callback is provided, it will be executed after the component is
ReactDOM.hydrate(element, container[, callback])
```

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.
[`render()`](#render)와 동일하지만 HTML 콘텐츠가 [`ReactDOMServer`](/docs/react-dom-server.html)로 렌더링 된 컨테이너를 공급하기 위해 사용됩니다. React는 기존 마크업에 이벤트 리스너를 연결할 것입니다.

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.
React는 렌더링 된 콘텐츠가 서버와 클라이언트 간에 같을 것으로 예상합니다. React가 텍스트 콘텐츠의 차이를 고칠 수는 있지만 이러한 불일치를 버그로 취급하여 고쳐야 합니다. 개발 모드에서 React는 공급 중 발생하는 불일치에 대해 경고합니다. 불일치가 발생하는 경우에 어트리뷰트 차이를 고친다는 보장이 없습니다. 대다수의 어플리케이션에서 불일치가 발생하는 경우는 많지 않으며 발생하는 경우 모든 마크업을 검증하는 것이 매우 큰 비용을 수반하기 때문에 성능상의 이유로 중요한 문제입니다.

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.
만약 서버와 클라이언트 사이에서 단일 엘리먼트의 어트리뷰트나 텍스트가 불가피하게 다르다면(예를 들어 timestamp의 경우) 그 엘리먼트에 `suppressHydrationWarning={true}`를 추가하는 것으로 경고를 끌 수 있습니다. 이는 한 단계까지만 작동하며 탈출구로써 의도한 것입니다. 절대 남용하지 마세요. 텍스트가 아니라면 React는 해당 엘리먼트를 고치지 않을 것이며 이후의 업데이트까지 차이나는 대로 남아있을 것입니다.

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.
만약 서버와 클라이언트 간의 차이를 의도한다면 2 패스 렌더링을 사용할 수 있습니다. 클라이언트에서 다르게 렌더링 되는 컴포넌트는 `componentDidMount()`에서 `true`로 설정할 수 있는 `this.state.isClient`와 같은 상태 변수를 읽을 수 있습니다. 이 방식으로 초기 렌더 패스는 서버와 같은 콘텐츠를 렌더링하여 불일치를 방지하지만, 공급 직후에 추가 패스가 동기로 발생합니다. 이 방식은 컴포넌트를 두 번 렌더링하게 만들어 속도를 느리게 할 수 있기 때문에 주의를 기울여야 합니다.

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.
느린 연결에서의 사용자 경험에 유의해야 합니다. JavaScript 코드는 최초 HTML 렌더링보다 매우 늦게 로드될 수 있으며 만약 클라이언트 전용 패스에서 다른 무언가를 렌더링한다면 그 전환 과정에서 방해를 받을 수 있습니다. 그러나 정상적으로 실행된다면 서버에 어플리케이션 "shell"을 렌더링하고 클라이언트에서 일부 추가 위젯만 표시하는 것이 효과적일 수 있습니다. 마크업 불일치 문제없이 이 방식을 사용하길 원한다면 이전 단락의 설명을 참고해주세요.

* * *

Expand All @@ -80,28 +78,29 @@ Remember to be mindful of user experience on slow connections. The JavaScript co
ReactDOM.unmountComponentAtNode(container)
```

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.
마운트된 React 컴포넌트를 DOM에서 제거하고 컴포넌트의 이벤트 핸들러와 state를 정리합니다. 만약 컨테이너에 아무런 컴포넌트도 마운트 되지 않았다면 해당 함수를 호출하더라도 아무런 동작을 하지 않습니다. 컴포넌트가 마운트 해제되었다면 `true`, 마운트 해제할 컴포넌트가 존재하지 않는다면 `false`를 반환합니다.

* * *

### `findDOMNode()` {#finddomnode}

> Note:
> 주의
>
> `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)
> `findDOMNode`는 기본 DOM 노드를 이용하는 데에 사용되는 탈출구입니다. 대부분의 경우에서 이 탈출구를 사용하는 것은 컴포넌트 추상화를 위반하기 때문에 권장하지 않습니다. [이 메소드는 `StrictMode`에서 deprecated 되었습니다.](/docs/strict-mode.html#warning-about-deprecated-finddomnode-usage)

```javascript
ReactDOM.findDOMNode(component)
```
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.**

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.
만약 매개 변수로 전달받은 컴포넌트가 DOM 내부에 마운트되었다면 컴포넌트에 해당하는 네이티브 브라우저의 DOM 엘리먼트를 반환합니다. 해당 메소드는 form 필드 값이나 DOM 성능 측정과 같이 DOM에서 값을 읽을 때 유용합니다. **대부분의 경우에서 DOM 노드에 ref를 첨부할 수 있으며 `findDOMNode`를 사용할 필요가 전혀 없습니다.**

> Note:
컴포넌트가 `null`이나 `false`를 렌더링하는 경우 `findDOMNode`은 `null`을 반환합니다. 컴포넌트가 문자를 반환하는 경우 `findDOMNode`은 문자 값을 포함하고 있는 텍스트 DOM 노드를 반환합니다. React 16부터 컴포넌트는 복수의 자식을 보유한 fragment를 반환할 수 있으며 이 경우에 `findDOMNode`는 비어있지 않은 첫 번째 자식에 해당하는 DOM 노드를 반환할 것입니다.

> 주의
>
> `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.
> `findDOMNode`는 마운트된 컴포넌트에만 동작합니다(즉 컴포넌트는 DOM 내부에 존재해야 합니다). 만약 아직 마운트되지 않은 컴포넌트를 대상으로 해당 메소드를 호출한다면(예를 들어 아직 생성되지 않은 컴포넌트의 `render()`에서 `findDOMNode()`를 호출하는 것) exception이 발생할 것입니다.
>
> `findDOMNode` cannot be used on function components.
> `findDOMNode`은 함수 컴포넌트에서는 사용할 수 없습니다.

* * *

Expand All @@ -111,4 +110,4 @@ When a component renders to `null` or `false`, `findDOMNode` returns `null`. Whe
ReactDOM.createPortal(child, container)
```

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).
portal을 생성합니다. Portal은 [DOM 컴포넌트 구조의 외부에 존재하는 DOM 노드에 자식을 렌더링](/docs/portals.html)하는 방법을 제공합니다.