When you want to create a signal within a component context.
There are two ways to read a global signal within a component:
ReactiveText (recommended) for fine-grained reactivityuseSignal works just like createSignal on a local component scale.
There are two ways to read the signal value based on your preferred method:
Both options are valid and more performant than native React state. However, only
the pure accessor can be passed into ReactiveText.
With Cerberus Signals, how you set the state no longer matters. You are free to use mutation or immutability. Both results will yield the same high performant and reliable reactivity.
The second value of the Tuple is the Setter function.
The setter API is the exact same as the createSignal Setter and accepts any type
of setting value or callback.
useSignal accepts the following options:
| Params | Required | Description |
|---|---|---|
initialValue | false | The initial value to set for the accessor. |
useSignal returns a SignalTuple<T> Array of the following values:
| Index | Type | Description |
|---|---|---|
| 0 | T | The latest value of the accessor. |
| 1 | Setter<T> | A function to update the signal value. |
| 2 | Accessor<T> | A function that returns the latest value when called. |
0
0Render Count:
10
0Render Count:
10
0Render Count:
1