Skip to content
Roomful is in public beta — install with the @beta tag. Share feedback →

Function: useSharedState()

@roomful/react


@roomful/react / useSharedState

useSharedState<T, TPresence>(key, options): readonly [T, Dispatch<SetStateAction<T>>]

Defined in: react/src/index.ts:653

Binds a shared state value to React state semantics.

T

The shared state value type.

TPresence extends PresenceData = PresenceData

The room presence shape.

string

The logical binding key used to enforce a single shared-state binding per room.

StateOptions<T>

The shared-state configuration.

readonly [T, Dispatch<SetStateAction<T>>]

The current shared state value and a React-style setter.