onCleanup
Registers fn to run when the component's instance is disposed, without running it on mount.
Usage
Tie a side effect to state
import { Text, effect, onCleanup, signal } from 'kuito';
export function Connection(props: { connect: (room: string) => () => void }) {
const room = signal('general');
effect(() => {
const disconnect = props.connect(room.value);
return disconnect;
});
onCleanup(() => console.log('Connection screen disposed'));
return <Text>{`Connected to ${room.value}`}</Text>;
}Signatures
(fn: () => void, name?: string): voidParameters
| Name | Type | Required | Description |
|---|---|---|---|
fn | () => void | Yes | — |
name | string | No | — |
Returns
void
Generated from the public TypeScript declarations: signatures, props and defaults come from the checked source, descriptions from its JSDoc. No defaults are invented.