react.useSignal
useSignal<T>(initialValue): Signal<T>
React hook that creates and memoizes a persistent Signal tied to the component lifecycle.
| Name | Description |
|---|---|
T |
The type of value held by the signal. |
| Name | Type | Description |
|---|---|---|
initialValue |
T |
Initial value of the signal. |
Signal<T>
A reactive Signal instance.
Remarks
Automatically subscribes the host component to re-render whenever the signal's .value mutates.
Example