useLiveState
useLiveState<
Schema>(handle):LiveStateView<ReadonlyLiveState<output<Schema>>>
A live state as the page shows it, kept at each revision while the
component is mounted: a banner for “double coins this weekend”, in a
room game and a game played alone alike. The initial state while it
loads. A room game’s systems read readLiveState instead, the state the
room applied.
Type Parameters
Section titled “Type Parameters”| Type Parameter |
|---|
Schema extends ZodMiniType<unknown, unknown, $ZodTypeInternals<unknown, unknown>> |
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
handle |
LiveStateHandle<string, Schema> |
Returns
Section titled “Returns”LiveStateView<ReadonlyLiveState<output<Schema>>>
Example
Section titled “Example”const { state } = useLiveState(events);return state.doubleCoins ? <Text>Double coins!</Text> : null;