Packages
react
Readme

@latticexyz/react

Functions

useComponentValue

useComponentValue<S>(component, entityIndex, defaultValue): ComponentValue<S>

Type parameters

NameType
Sextends Schema

Parameters

NameType
componentComponent<S, Metadata, undefined>
entityIndexundefined | EntityIndex
defaultValueComponentValue<S, undefined>

Returns

ComponentValue<S>

Defined in

useComponentValue.ts:14 (opens in a new tab)

useComponentValue<S>(component, entityIndex): ComponentValue<S> | undefined

Type parameters

NameType
Sextends Schema

Parameters

NameType
componentComponent<S, Metadata, undefined>
entityIndexundefined | EntityIndex

Returns

ComponentValue<S> | undefined

Defined in

useComponentValue.ts:20 (opens in a new tab)


useDeprecatedComputedValue

useDeprecatedComputedValue<T>(computedValue): T

Deprecated

See https://github.com/latticexyz/mud/issues/339 (opens in a new tab)

Type parameters

Name
T

Parameters

NameType
computedValueIComputedValue<T> & { observe_: any }

Returns

T

Defined in

useDeprecatedComputedValue.ts:5 (opens in a new tab)


useEntityQuery

useEntityQuery(fragments, options?): EntityIndex[]

Returns all matching EntityIndexes for a given entity query, and triggers a re-render as new query results come in.

Parameters

NameTypeDescription
fragmentsQueryFragment<Schema>[]Query fragments to match against, executed from left to right.
options?Object-
options.updateOnValueChange?booleanFalse - re-renders only on entity array changes. True (default) - also on component value changes.

Returns

EntityIndex[]

Set of entities matching the query fragments.

Defined in

useEntityQuery.ts:18 (opens in a new tab)


useObservableValue

useObservableValue<T>(observable, defaultValue): T

Type parameters

Name
T

Parameters

NameType
observableObservable<T>
defaultValueT

Returns

T

Defined in

useObservableValue.ts:4 (opens in a new tab)

useObservableValue<T>(observable): T | undefined

Type parameters

Name
T

Parameters

NameType
observableObservable<T>

Returns

T | undefined

Defined in

useObservableValue.ts:6 (opens in a new tab)