Skip to content

Commit 3f27507

Browse files
authored
Merge pull request #835 from reactjs/tr/captureOwnerStack
Translate "captureOwnerStack"
2 parents 95415ec + 7445d34 commit 3f27507

File tree

1 file changed

+33
-33
lines changed

1 file changed

+33
-33
lines changed

src/content/reference/react/captureOwnerStack.md

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ The `captureOwnerStack` API is currently only available in React's Canary and ex
1010

1111
<Intro>
1212

13-
`captureOwnerStack` reads the current Owner Stack in development and returns it as a string if available.
13+
`captureOwnerStack` は、開発環境で現在のオーナスタック (Owner Stack) を読み取り、利用可能な場合は文字列として返します。
1414

1515
```js
1616
const stack = captureOwnerStack();
@@ -22,11 +22,11 @@ const stack = captureOwnerStack();
2222

2323
---
2424

25-
## Reference {/*reference*/}
25+
## リファレンス {/*reference*/}
2626

2727
### `captureOwnerStack()` {/*captureownerstack*/}
2828

29-
Call `captureOwnerStack` to get the current Owner Stack.
29+
`captureOwnerStack` を呼び出して、現在のオーナスタックを取得します。
3030

3131
```js {5,5}
3232
import * as React from 'react';
@@ -39,33 +39,33 @@ function Component() {
3939
}
4040
```
4141

42-
#### Parameters {/*parameters*/}
42+
#### 引数 {/*parameters*/}
4343

44-
`captureOwnerStack` does not take any parameters.
44+
`captureOwnerStack` は引数を受け取りません。
4545

46-
#### Returns {/*returns*/}
46+
#### 返り値 {/*returns*/}
4747

48-
`captureOwnerStack` returns `string | null`.
48+
`captureOwnerStack` `string | null` を返します。
4949

50-
Owner Stacks are available in
51-
- Component render
52-
- Effects (e.g. `useEffect`)
53-
- React's event handlers (e.g. `<button onClick={...} />`)
54-
- React error handlers ([React Root options](/reference/react-dom/client/createRoot#parameters) `onCaughtError`, `onRecoverableError`, and `onUncaughtError`)
50+
オーナスタックは、以下の状況で利用できます。
51+
- コンポーネントのレンダー中
52+
- エフェクト(`useEffect` など)内
53+
- React のイベントハンドラ内(`<button onClick={...} />` など)
54+
- React のエラーハンドラ([React ルートオプション](/reference/react-dom/client/createRoot#parameters) `onCaughtError``onRecoverableError``onUncaughtError` など)
5555

56-
If no Owner Stack is available, `null` is returned (see [Troubleshooting: The Owner Stack is `null`](#the-owner-stack-is-null)).
56+
オーナスタックが利用できない場合は `null` が返されます([トラブルシューティング:オーナスタックが `null` になる](#the-owner-stack-is-null) を参照)。
5757

58-
#### Caveats {/*caveats*/}
58+
#### 注意点 {/*caveats*/}
5959

60-
- Owner Stacks are only available in development. `captureOwnerStack` will always return `null` outside of development.
60+
- オーナスタックは開発環境でのみ利用できます。開発環境以外では `captureOwnerStack` は常に `null` を返します。
6161

6262
<DeepDive>
6363

64-
#### Owner Stack vs Component Stack {/*owner-stack-vs-component-stack*/}
64+
#### オーナスタックとコンポーネントスタックの違い {/*owner-stack-vs-component-stack*/}
6565

66-
The Owner Stack is different from the Component Stack available in React error handlers like [`errorInfo.componentStack` in `onUncaughtError`](/reference/react-dom/client/hydrateRoot#show-a-dialog-for-uncaught-errors).
66+
オーナスタックは、React のエラーハンドラで利用できるコンポーネントスタック(例:[`onUncaughtError` 内での `errorInfo.componentStack`](/reference/react-dom/client/hydrateRoot#show-a-dialog-for-uncaught-errors))とは異なります。
6767

68-
For example, consider the following code:
68+
例えば、次のコードを考えてみましょう。
6969

7070
<Sandpack>
7171

@@ -158,8 +158,8 @@ createRoot(document.createElement('div'), {
158158

159159
</Sandpack>
160160

161-
`SubComponent` would throw an error.
162-
The Component Stack of that error would be
161+
`SubComponent` でエラーがスローされるとします。
162+
そのエラーのコンポーネントスタックは次のようになります。
163163

164164
```
165165
at SubComponent
@@ -170,23 +170,23 @@ at React.Suspense
170170
at App
171171
```
172172

173-
However, the Owner Stack would only read
173+
一方、オーナスタックは次のようになります。
174174

175175
```
176176
at Component
177177
```
178178

179-
Neither `App` nor the DOM components (e.g. `fieldset`) are considered Owners in this Stack since they didn't contribute to "creating" the node containing `SubComponent`. `App` and DOM components only forwarded the node. `App` just rendered the `children` node as opposed to `Component` which created a node containing `SubComponent` via `<SubComponent />`.
179+
このスタックでは、`App` DOM コンポーネント(例:`fieldset`)は「オーナ」扱いとなりません。それらは `SubComponent` を「作成」したわけではなく、ノードを単に転送しただけだからです。`Component``<SubComponent />` というマークアップを通じて `SubComponent` ノードを作成しているのに対し、`App``children` を単にレンダーしているだけです。
180180

181-
Neither `Navigation` nor `legend` are in the stack at all since it's only a sibling to a node containing `<SubComponent />`.
181+
また、`Navigation` `legend` も、`<SubComponent />` を含むノードの兄弟であるためスタックには含まれません。
182182

183-
`SubComponent` is omitted because it's already part of the callstack.
183+
`SubComponent` はすでにコールスタックに含まれているため、オーナスタックには表示されません。
184184

185185
</DeepDive>
186186

187-
## Usage {/*usage*/}
187+
## 使用法 {/*usage*/}
188188

189-
### Enhance a custom error overlay {/*enhance-a-custom-error-overlay*/}
189+
### カスタムのエラーオーバーレイの機能強化 {/*enhance-a-custom-error-overlay*/}
190190

191191
```js [[1, 5, "console.error"], [4, 7, "captureOwnerStack"]]
192192
import { captureOwnerStack } from "react";
@@ -205,7 +205,7 @@ console.error = function patchedConsoleError(...args) {
205205
};
206206
```
207207

208-
If you intercept <CodeStep step={1}>`console.error`</CodeStep> calls to highlight them in an error overlay, you can call <CodeStep step={2}>`captureOwnerStack`</CodeStep> to include the Owner Stack.
208+
<CodeStep step={1}>`console.error`</CodeStep> の呼び出しをインターセプトしてエラーオーバーレイとして表示する場合、<CodeStep step={2}>`captureOwnerStack`</CodeStep> を呼び出してオーナスタックを含めることができます。
209209

210210
<Sandpack>
211211

@@ -385,13 +385,13 @@ export default function App() {
385385

386386
</Sandpack>
387387

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

390-
### The Owner Stack is `null` {/*the-owner-stack-is-null*/}
390+
### オーナスタックが `null` になる {/*the-owner-stack-is-null*/}
391391

392-
The call of `captureOwnerStack` happened outside of a React controlled function e.g. in a `setTimeout` callback, after a `fetch` call or in a custom DOM event handler. During render, Effects, React event handlers, and React error handlers (e.g. `hydrateRoot#options.onCaughtError`) Owner Stacks should be available.
392+
`captureOwnerStack` の呼び出しが React 管理外の関数(`setTimeout` のコールバック、`fetch` の後、カスタム DOM イベントハンドラなど)で行われています。レンダー中、エフェクト内、React 管理のイベントハンドラやエラーハンドラ(例:`hydrateRoot#options.onCaughtError`)内では、オーナスタックが利用できるはずです。
393393

394-
In the example below, clicking the button will log an empty Owner Stack because `captureOwnerStack` was called during a custom DOM event handler. The Owner Stack must be captured earlier e.g. by moving the call of `captureOwnerStack` into the Effect body.
394+
以下の例では、`captureOwnerStack` の呼び出しがカスタム DOM イベントハンドラ内で行われているため、ボタンをクリックしてもログに出力されるオーナスタックは空になります。オーナスタックの取得は、呼び出しをエフェクト本体に移動するなどして先に取得しておく必要があります。
395395
<Sandpack>
396396

397397
```js
@@ -435,9 +435,9 @@ export default function App() {
435435

436436
</Sandpack>
437437

438-
### `captureOwnerStack` is not available {/*captureownerstack-is-not-available*/}
438+
### `captureOwnerStack` 関数にアクセスできない {/*captureownerstack-is-not-available*/}
439439

440-
`captureOwnerStack` is only exported in development builds. It will be `undefined` in production builds. If `captureOwnerStack` is used in files that are bundled for production and development, you should conditionally access it from a namespace import.
440+
`captureOwnerStack` は開発ビルドでのみエクスポートされます。本番ビルドでは `undefined` になります。開発・本番両方でバンドルされるファイルで `captureOwnerStack` を使う場合は、名前付きインポートではなく名前空間インポートを使い、条件付きでアクセスするようにしてください。
441441

442442
```js
443443
// Don't use named imports of `captureOwnerStack` in files that are bundled for development and production.

0 commit comments

Comments
 (0)