Skip to content

Commit 890f5bb

Browse files
committed
update
1 parent 783dcd9 commit 890f5bb

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

src/routes/reference/lifecycle/on-cleanup.mdx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,33 +44,32 @@ Cleanup function registered on the current reactive scope.
4444

4545
- **Type:** `T`
4646

47-
Returns the same function that was passed in.
47+
Returns `fn` unchanged.
4848

4949
## Behavior
5050

5151
- In a component, the cleanup runs when that component is unmounted.
5252
- In a tracking scope such as [`createEffect`](/reference/basic-reactivity/create-effect), [`createMemo`](/reference/basic-reactivity/create-memo), or [`createRoot`](/reference/reactive-utilities/create-root), the cleanup runs when that scope is disposed or re-executes.
5353
- Multiple cleanup functions run when the owning scope is cleaned up.
54-
- On the server, cleanup also runs when server-side reactive branches are disposed.
54+
- On the server, cleanup also runs when server-side owners or reactive branches are disposed.
5555

5656
## Examples
5757

5858
### Remove an event listener
5959

6060
```tsx
61-
import { createSignal, onCleanup } from "solid-js";
61+
import { onCleanup } from "solid-js";
6262

6363
const Component = () => {
64-
const [count, setCount] = createSignal(0);
65-
const handleClick = () => setCount((value) => value + 1);
64+
const handleClick = () => console.log("clicked");
6665

6766
document.addEventListener("click", handleClick);
6867

6968
onCleanup(() => {
7069
document.removeEventListener("click", handleClick);
7170
});
7271

73-
return <main>Document has been clicked {count()} times</main>;
72+
return <main>Listening for document clicks</main>;
7473
};
7574
```
7675

0 commit comments

Comments
 (0)