Skip to content

Commit be08077

Browse files
authored
Merge pull request #633 from reactjs/tr/lazy
Translate "lazy"
2 parents 82e79d0 + 3c81d03 commit be08077

File tree

1 file changed

+26
-26
lines changed

1 file changed

+26
-26
lines changed

src/content/reference/react/lazy.md

+26-26
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ title: lazy
44

55
<Intro>
66

7-
`lazy` lets you defer loading component's code until it is rendered for the first time.
7+
`lazy` を使うことで、あるコンポーネントが初めてレンダーされるまで、そのコードの読み込みを遅延させることができます。
88

99
```js
1010
const SomeComponent = lazy(load)
@@ -16,63 +16,63 @@ const SomeComponent = lazy(load)
1616

1717
---
1818

19-
## Reference {/*reference*/}
19+
## リファレンス {/*reference*/}
2020

2121
### `lazy(load)` {/*lazy*/}
2222

23-
Call `lazy` outside your components to declare a lazy-loaded React component:
23+
`lazy` をコンポーネントの外部で呼び出し、遅延読み込みされる React コンポーネントを宣言します。
2424

2525
```js
2626
import { lazy } from 'react';
2727

2828
const MarkdownPreview = lazy(() => import('./MarkdownPreview.js'));
2929
```
3030

31-
[See more examples below.](#usage)
31+
[さらに例を見る](#usage)
3232

33-
#### Parameters {/*parameters*/}
33+
#### 引数 {/*parameters*/}
3434

35-
* `load`: A function that returns a [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) or another *thenable* (a Promise-like object with a `then` method). React will not call `load` until the first time you attempt to render the returned component. After React first calls `load`, it will wait for it to resolve, and then render the resolved value as a React component. Both the returned Promise and the Promise's resolved value will be cached, so React will not call `load` more than once. If the Promise rejects, React will `throw` the rejection reason for the nearest Error Boundary to handle.
35+
* `load`: [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) または *thenable*`then` メソッドを持つ Promise のようなオブジェクト)を返す関数。返されたコンポーネントを初めてレンダーしようとするときまで React は `load` を呼び出しません。React が初めて `load` を呼び出した後、それが解決 (resolve) するのを待ち、解決した値を React コンポーネントとしてレンダーします。返された Promise と解決済みの値は両方ともキャッシュされるため、React `load` を 2 度以上呼び出しません。Promise が reject された場合、React はその理由を `throw` し、最も近いエラーバウンダリで処理できるようにします。
3636

37-
#### Returns {/*returns*/}
37+
#### 戻り値 {/*returns*/}
3838

39-
`lazy` returns a React component you can render in your tree. While the code for the lazy component is still loading, attempting to render it will *suspend.* Use [`<Suspense>`](/reference/react/Suspense) to display a loading indicator while it's loading.
39+
`lazy` は、ツリー内でレンダーできる React コンポーネントを返します。遅延コンポーネントのコードがまだ読み込まれていない間、レンダーしようとするとサスペンド (suspend) します。[`<Suspense>`](/reference/react/Suspense) を使用して、読み込み中にローディングインジケータを表示します。
4040

4141
---
4242

43-
### `load` function {/*load*/}
43+
### `load` 関数 {/*load*/}
4444

45-
#### Parameters {/*load-parameters*/}
45+
#### 引数 {/*load-parameters*/}
4646

47-
`load` receives no parameters.
47+
`load` は引数を受け取りません。
4848

49-
#### Returns {/*load-returns*/}
49+
#### 返り値 {/*load-returns*/}
5050

51-
You need to return a [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) or some other *thenable* (a Promise-like object with a `then` method). It needs to eventually resolve to a valid React component type, such as a function, [`memo`](/reference/react/memo), or a [`forwardRef`](/reference/react/forwardRef) component.
51+
[Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) または何らかの *thenable*`then` メソッドを持つ Promise のようなオブジェクト)を返す必要があります。最終的に有効な React コンポーネント型、例えば関数、[`memo`](/reference/react/memo)、または [`forwardRef`](/reference/react/forwardRef) コンポーネントに解決される必要があります。
5252

5353
---
5454

55-
## Usage {/*usage*/}
55+
## 使用法 {/*usage*/}
5656

57-
### Lazy-loading components with Suspense {/*suspense-for-code-splitting*/}
57+
### サスペンスを使ったコンポーネントの遅延読み込み {/*suspense-for-code-splitting*/}
5858

59-
Usually, you import components with the static [`import`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import) declaration:
59+
通常、コンポーネントは静的な [`import`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import) 宣言を使ってインポートします。
6060

6161
```js
6262
import MarkdownPreview from './MarkdownPreview.js';
6363
```
6464

65-
To defer loading this component's code until it's rendered for the first time, replace this import with:
65+
このコンポーネントのコードの読み込みを、初めてレンダーされるときまで遅延させるには、このインポートを以下のように置き換えます。
6666

6767
```js
6868
import { lazy } from 'react';
6969

7070
const MarkdownPreview = lazy(() => import('./MarkdownPreview.js'));
7171
```
7272

73-
This code relies on [dynamic `import()`,](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/import) which might require support from your bundler or framework.
73+
このコードは[ダイナミック `import()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/import) を用いており、あなたのバンドラやフレームワークからのサポートが必要かもしれません。
7474

75-
Now that your component's code loads on demand, you also need to specify what should be displayed while it is loading. You can do this by wrapping the lazy component or any of its parents into a [`<Suspense>`](/reference/react/Suspense) boundary:
75+
コンポーネントのコードがオンデマンドで読み込まれるようになったので、読み込みの最中には何を表示するべきかを指定する必要があります。これは、遅延コンポーネントまたはその親のいずれかを [`<Suspense>`](/reference/react/Suspense) バウンダリでラップすることで行うことができます。
7676

7777
```js {1,4}
7878
<Suspense fallback={<Loading />}>
@@ -81,7 +81,7 @@ Now that your component's code loads on demand, you also need to specify what sh
8181
</Suspense>
8282
```
8383

84-
In this example, the code for `MarkdownPreview` won't be loaded until you attempt to render it. If `MarkdownPreview` hasn't loaded yet, `Loading` will be shown in its place. Try ticking the checkbox:
84+
この例では、`MarkdownPreview` のコードはレンダーしようとするまで読み込まれません。もし `MarkdownPreview` がまだ読み込まれていない場合、その代わりに `Loading` が表示されます。チェックボックスをオンにしてみてください。
8585

8686
<Sandpack>
8787

@@ -175,17 +175,17 @@ body {
175175

176176
</Sandpack>
177177

178-
This demo loads with an artificial delay. The next time you untick and tick the checkbox, `Preview` will be cached, so there will be no loading state. To see the loading state again, click "Reset" on the sandbox.
178+
このデモは人為的に遅延させて読み込まれます。もう一度チェックボックスをオフにしてからオンにすると、`Preview` はキャッシュされているので、ローディング状態は表示されません。再度ローディング状態を表示するには、サンドボックスの "Reset" をクリックしてください。
179179

180-
[Learn more about managing loading states with Suspense.](/reference/react/Suspense)
180+
[サスペンスを使ったローディング状態の管理についてもっと学ぶ](/reference/react/Suspense)
181181

182182
---
183183

184-
## Troubleshooting {/*troubleshooting*/}
184+
## トラブルシューティング {/*troubleshooting*/}
185185

186-
### My `lazy` component's state gets reset unexpectedly {/*my-lazy-components-state-gets-reset-unexpectedly*/}
186+
### `lazy` コンポーネントの state が予期せずリセットされる {/*my-lazy-components-state-gets-reset-unexpectedly*/}
187187

188-
Do not declare `lazy` components *inside* other components:
188+
`lazy` コンポーネントを他のコンポーネントの*内部*で宣言しないでください。
189189

190190
```js {4-5}
191191
import { lazy } from 'react';
@@ -197,7 +197,7 @@ function Editor() {
197197
}
198198
```
199199

200-
Instead, always declare them at the top level of your module:
200+
代わりに、常にモジュールのトップレベルで宣言してください。
201201

202202
```js {3-4}
203203
import { lazy } from 'react';

0 commit comments

Comments
 (0)