# useReaction

`useReaction(setup, dependencies?, options?)` owns an imperative setup and its
optional cleanup for one mounted component hook slot. Setup runs in Complete
only after a successful render. Synchronous signal reads inside setup become
reaction dependencies without making the component a render consumer.

The dependency array lists captured non-signal values and uses `Object.is`.
Before replacement or final release, Pibbl clears and invokes the exact current
cleanup once. Signal writes are forbidden during setup and cleanup.

Related type:
[`PibblReactionOptions`](/reference/types/canvas-runtime/#pibblreactionoptions).

## API details from source

<span id="api-useReaction"></span>

Owns one Complete-phase imperative reaction for a mounted hook slot.

```ts
useReaction: (setup: () => void | (() => void), dependencies?: readonly unknown[], options?: PibblReactionOptions) => void
```

Related API: [useReaction](/reference/hooks/use-reaction/), [PibblReactionOptions](/reference/types/canvas-runtime/#pibblreactionoptions).

### Parameters

- **`setup`** — Setup callback; its optional returned cleanup runs when replaced or disposed.

- **`dependencies`** — Values controlling when setup is repeated.

- **`options`** — Optional diagnostic name for this reaction. See [PibblReactionOptions](/reference/types/canvas-runtime/#pibblreactionoptions).

### See also

[PibblReactionOptions](/reference/types/canvas-runtime/#pibblreactionoptions)

[View source — packages/core/src/lib/hooks/use-reaction.ts:74](/source/packages/core/src/lib/hooks/use-reaction-ts/#L74)

## Implementation guidance for agents

Read the [Authoring, signals, and lifecycle companion](/agents/topics/lifecycle/) for ownership, adaptation, failure modes, and verification. [Agent start](/agents/) provides the version-selection workflow.

## Complete minimal examples

- [Component-owned state and reactions](/minimal-examples/lifecycle/hooks/): Click to update a signal, derive a value, and publish an imperative effect after commit. [Plain source](/minimal/lifecycle/hooks.tsx)
## Interactive examples

- [Stirred Ink](/examples/stirred-ink/) · [Full page](/experience/stirred-ink/)
## Documentation version

Documentation built with @pibbl/core 0.0.2, revision 272a94a. ALPHA — NOT FOR PRODUCTION USE.
