Skip to content

Commit 538b3cf

Browse files
committed
Emphasize dev-only nature
1 parent 898e568 commit 538b3cf

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

src/content/reference/react/captureOwnerStack.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Experimental versions of React may contain bugs. Don't use them in production.
1616

1717
<Intro>
1818

19-
`captureOwnerStack` reads the current Owner Stack and returns it as a string if available.
19+
`captureOwnerStack` reads the current Owner Stack in development and returns it as a string if available.
2020

2121
```js
2222
const stack = captureOwnerStack();
@@ -56,6 +56,10 @@ function Component() {
5656
If no Owner Stack is available, it returns an empty string.
5757
Outside of development builds, `null` is returned.
5858

59+
#### Caveats {/*caveats*/}
60+
61+
- Owner Stacks are only available in development. `captureOwnerStack` will always return `null` outside of development.
62+
5963
## Owner Stack vs Component Stack {/*owner-stack-vs-component-stack*/}
6064

6165
The Owner Stack is different from the Component Stack available error handlers like [`errorInfo.componentStack` in `onUncaughtError`](/reference/react-dom/client/hydrateRoot#show-a-dialog-for-uncaught-errors).
@@ -162,3 +166,15 @@ const root = hydrateRoot(
162166
);
163167
root.render(<App />);
164168
```
169+
170+
## Troubleshooting {/*troubleshooting*/}
171+
172+
### The Owner Stack is `null` {/*the-owner-stack-is-null*/}
173+
174+
`captureOwnerStack` was called outside of development builds.
175+
For performance reasons, React will not keep track of Owners in production.
176+
177+
### The Owner Stack is empty {/*the-owner-stack-is-empty*/}
178+
179+
The call of `captureOwnerStack` happened outside of a React controlled function e.g. in a `setTimeout` callback.
180+
During render, Effects, Events, and React error handlers (e.g. `hydrateRoot#options.onCaughtError`) Owner Stacks should be available.

0 commit comments

Comments
 (0)