Skip to content

Commit ffede2d

Browse files
committed
update
1 parent caa8736 commit ffede2d

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

src/routes/reference/reactive-utilities/get-owner.mdx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ type Owner = unknown;
3030
function getOwner(): Owner | null;
3131
```
3232

33+
The concrete owner shape is internal and is primarily useful with [`runWithOwner`](/reference/reactive-utilities/run-with-owner).
34+
3335
## Parameters
3436

3537
`getOwner` does not take any parameters.
@@ -42,6 +44,7 @@ Returns the current owner or `null` when no owner is active.
4244

4345
## Behavior
4446

47+
- `getOwner` returns the current owner and does not create or modify ownership.
4548
- Owners determine cleanup and context lookup for descendant computations.
4649
- A computation created inside the current scope becomes part of the current owner tree unless ownership is overridden.
4750
- Components are not computations and do not create owner nodes themselves.
@@ -57,11 +60,13 @@ import { getOwner, runWithOwner } from "solid-js";
5760

5861
const owner = getOwner();
5962

60-
queueMicrotask(() => {
61-
runWithOwner(owner, () => {
62-
console.log("owner restored");
63+
if (owner) {
64+
queueMicrotask(() => {
65+
runWithOwner(owner, () => {
66+
console.log("owner restored");
67+
});
6368
});
64-
});
69+
}
6570
```
6671

6772
## Related

0 commit comments

Comments
 (0)