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: src/content/reference/react-dom/render.md
+31-31
Original file line number
Diff line number
Diff line change
@@ -1,18 +1,18 @@
1
1
---
2
-
title: render
2
+
title: レンダー
3
3
---
4
4
5
5
<Deprecated>
6
6
7
-
This API will be removed in a future major version of React.
7
+
この API は、今後のメジャーバージョンの React で削除される予定です。
8
8
9
-
In React 18, `render`was replaced by [`createRoot`.](/reference/react-dom/client/createRoot)Using `render` in React 18 will warn that your app will behave as if it’s running React 17. Learn more [here.](/blog/2022/03/08/react-18-upgrade-guide#updates-to-client-rendering-apis)
React will display `<App />`in the `domNode`, and take over managing the DOM inside it.
40
+
React は `domNode` 内に `<App />`を表示し、その内部の DOM の管理を行います。
41
41
42
-
An app fully built with React will usually only have one `render`call with its root component. A page that uses "sprinkles" of React for parts of the page may have as many `render`calls as needed.
* `reactNode`: A *React node* that you want to display. This will usually be a piece of JSX like `<App />`, but you can also pass a React element constructed with [`createElement()`](/reference/react/createElement), a string, a number, `null`, or `undefined`.
* `domNode`: A [DOM element.](https://developer.mozilla.org/en-US/docs/Web/API/Element)React will display the `reactNode`you pass inside this DOM element. From this moment, React will manage the DOM inside the `domNode`and update it when your React tree changes.
50
+
* `domNode`: [DOM 要素](https://developer.mozilla.org/en-US/docs/Web/API/Element)。React は、渡された `reactNode`をこの DOM 要素内に表示します。この瞬間から、React は `domNode`内の DOM を管理し、React ツリーが変更されたときにそれを更新するようになります。
51
51
52
-
* **optional** `callback`: A function. If passed, React will call it after your component is placed into the DOM.
52
+
* **省略可能** `callback`: 関数。渡された場合、React はコンポーネントが DOM に配置された後にそれを呼び出します。
53
53
54
54
55
-
#### Returns {/*returns*/}
55
+
#### 返り値 {/*returns*/}
56
56
57
-
`render`usually returns `null`. However, if the `reactNode`you pass is a *class component*, then it will return an instance of that component.
* The first time you call `render`, React will clear all the existing HTML content inside the `domNode`before rendering the React component into it. If your `domNode` contains HTML generated by React on the server or during the build, use [`hydrate()`](/reference/react-dom/hydrate) instead, which attaches the event handlers to the existing HTML.
63
+
* `render` を初めて呼び出したとき、React は React ルート内の既存の HTML コンテンツをすべてクリアしてから、React コンポーネントをレンダーします。`domNode`がサーバ上であるいはビルド中に React によって生成された HTML を含んでいる場合は、代わりに既存の HTML にイベントハンドラをアタッチできる [`hydrate()`](/reference/react-dom/hydrate) を使用してください。
64
64
65
-
* If you call `render` on the same `domNode` more than once, React will update the DOM as necessary to reflect the latest JSX you passed. React will decide which parts of the DOM can be reused and which need to be recreated by ["matching it up"](/learn/preserving-and-resetting-state) with the previously rendered tree. Calling `render` on the same `domNode` again is similar to calling the [`set`function](/reference/react/useState#setstate) on the root component: React avoids unnecessary DOM updates.
* If your app is fully built with React, you'll likely have only one `render`call in your app. (If you use a framework, it might do this call for you.) When you want to render a piece of JSX in a different part of the DOM tree that isn't a child of your component (for example, a modal or a tooltip), use [`createPortal`](/reference/react-dom/createPortal) instead of `render`.
@@ -101,13 +101,13 @@ export default function App() {
101
101
102
102
</Sandpack>
103
103
104
-
Usually you shouldn't need to call `render`again or to call it in more places. From this point on, React will be managing the DOM of your application. To update the UI, your components will [use state.](/reference/react/useState)
104
+
通常、`render`を再度呼び出したり複数の場所で呼び出したりする必要はありません。この時点から、React はアプリケーションの DOM を管理します。UI を更新するには、コンポーネントが [state を使用します](/reference/react/useState)。
If your page [isn't fully built with React](/learn/add-react-to-an-existing-project#using-react-for-a-part-of-your-existing-page), call `render`for each top-level piece of UI managed by React.
You can call`render`more than once on the same DOM node. As long as the component tree structure matches up with what was previously rendered, React will [preserve the state.](/learn/preserving-and-resetting-state) Notice how you can type in the input, which means that the updates from repeated `render`calls every second are not destructive:
186
+
同じ DOM ノードに対して`render`を複数回呼び出すことができます。コンポーネントツリーの構造が以前にレンダーされたものと一致していれば、React は [state を保持します](/learn/preserving-and-resetting-state)。以下の例で入力フィールドにタイプできることに着目してください。つまり毎秒 `render`が繰り返し呼び出されていますが、更新により DOM が破壊されていないということです。
187
187
188
188
<Sandpack>
189
189
@@ -215,4 +215,4 @@ export default function App({counter}) {
215
215
216
216
</Sandpack>
217
217
218
-
It is uncommon to call `render`multiple times. Usually, you'll [update state](/reference/react/useState) inside your components instead.
0 commit comments