Type of the stored value
Type of the stored value
OptionalinitialValue: TThe current value of the state.
Reading this property is always safe and does not trigger side effects.
Timestamp (milliseconds since epoch) of the last time the state was changed via .set().
Useful for dependency tracking or knowing when the value was last mutated.
Adds a number to the current value (only available when T is number).
Convenience method that calls .set(get() + added).
Behaves exactly like .set() regarding refresh overhead.
Value to add
Optional control over refresh
Optionalrecall?: booleanForce refresh (default: false)
Multiplies the current value by a number (only available when T is number).
Convenience method that calls .set(get() * multiplier).
Behaves exactly like .set() regarding refresh overhead.
Value to multiply by
Updates the state value.
If the new value differs from the current one (strict !== comparison),
and either recall: true is passed or alwaysRecall was set at creation,
this triggers a component refresh.
Refreshing re-runs the entire component function, re-binds hooks, and may re-mount/unmount children — avoid in hot paths.
The new state value
Read-only view of a piece of state managed by
useState.Remarks
Performance critical warning Frequent
.set()calls insideuseTick/usePaintloops will cause expensive component re-execution (refresh). → UseuseSelforuseReffor position, velocity, timers, counters, etc. → ReserveuseStatefor infrequent structural changes (health → 0, level up, isDead, etc.).See