TinyBase logoTinyBase β

useValue

The useValue hook returns a reactive object reflecting the value of a Value in a Store, and registers a listener so that any changes to that Value will update .current.

useValue(
  valueId: MaybeGetter<string>,
  storeOrStoreId?: MaybeGetter<undefined | StoreOrStoreId>,
): {current: ValueOrUndefined}
TypeDescription
valueIdMaybeGetter<string>

The Id of the Value (or a getter returning it).

storeOrStoreId?MaybeGetter<undefined | StoreOrStoreId>

The Store to use (plain value or getter), or its Id.

returns{current: ValueOrUndefined}

A reactive object with a current ValueOrUndefined property.

Since

v8.1.0