Skip to content

1681-engine / react / useStore

Function: useStore() ​

Call Signature ​

ts
function useStore<T>(store): T;

Defined in: src/react/useStore.ts:8

Reads an engine Store (createStore) in a component and renders again when what it reads changes. select must return something stable (a field, a number), not a new object each call, or React renders forever.

Type Parameters ​

Type Parameter
T extends object

Parameters ​

ParameterType
storeStore<T>

Returns ​

T

Call Signature ​

ts
function useStore<T, S>(store, select): S;

Defined in: src/react/useStore.ts:9

Reads an engine Store (createStore) in a component and renders again when what it reads changes. select must return something stable (a field, a number), not a new object each call, or React renders forever.

Type Parameters ​

Type Parameter
T extends object
S

Parameters ​

ParameterType
storeStore<T>
select(state) => S

Returns ​

S

Released under the MIT License.