Skip to content

Commit ff496a5

Browse files
committed
update
1 parent 4909ac8 commit ff496a5

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

src/routes/reference/reactive-utilities/run-with-owner.mdx

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,12 @@ Function executed under `owner`.
5252

5353
- **Type:** `T | undefined`
5454

55-
Returns the value produced by `fn`.
55+
Returns the value produced by `fn`, or `undefined` when an error is routed through Solid's error handling.
5656

5757
## Behavior
5858

59-
- Computations created inside `fn` are attached to the provided owner.
60-
- Context lookup inside `fn` walks the provided owner tree.
61-
- Ownership affects cleanup and context resolution.
62-
- Ownership does not restore dependency tracking across asynchronous boundaries.
59+
- During the synchronous execution of `fn`, `runWithOwner` restores the provided owner for cleanup, context lookup, and descendant computations created inside `fn`.
60+
- `runWithOwner` does not restore dependency tracking because the current tracking listener is cleared while `fn` runs.
6361
- Code after the first `await` in an `async` function runs without reactive dependency tracking.
6462

6563
## Examples
@@ -71,15 +69,17 @@ import { createEffect, getOwner, runWithOwner, useContext } from "solid-js";
7169

7270
const owner = getOwner();
7371

74-
setTimeout(() => {
75-
runWithOwner(owner, () => {
76-
const value = useContext(FooContext);
72+
if (owner) {
73+
setTimeout(() => {
74+
runWithOwner(owner, () => {
75+
const value = useContext(FooContext);
7776

78-
createEffect(() => {
79-
console.log(value);
77+
createEffect(() => {
78+
console.log(value);
79+
});
8080
});
81-
});
82-
}, 1000);
81+
}, 1000);
82+
}
8383
```
8484

8585
## Related

0 commit comments

Comments
 (0)