Documentation Index
Fetch the complete documentation index at: https://mintlify.com/sanchedev/tiny-engine/llms.txt
Use this file to discover all available pages before exploring further.
useSignal creates a piece of reactive state inside a component. It returns a getter and a setter: calling the getter reads the current value and registers a reactive dependency, while calling the setter writes a new value and notifies every effect or computed that depended on the previous read.
Signature
Parameters
The initial value of the signal. Inferred as the generic type
T.Return value
A two-element tuple[getter, setter]:
| Element | Type | Description |
|---|---|---|
getter | SignalGetter<T> — () => T | Call with no arguments to read the current value. Reading inside JSX props or useEffect / useComputed registers a reactive dependency. |
setter | SignalSetter<T> — (value: T) => void | Call with a new value to update the signal and schedule any dependent effects or re-renders. |
Example
A health bar that reactively adjusts itsgrayscale and brightness filters as health changes:
HealthBar.tsx
Updating state based on the previous value
Becausegetter is a plain function, you can compose it directly:
counter.tsx
Calling
getter() (the first element of the tuple) inside a JSX prop expression — e.g. opacity={() => health() / 100} — creates a live reactive dependency. The prop will re-evaluate automatically whenever health is updated. If you pass a plain value like opacity={health() / 100} the expression is evaluated once at render time and will not update reactively.