1681-engine / react / useJsonSelector
Function: useJsonSelector() ​
ts
function useJsonSelector<S, T>(useHook, select): T;Defined in: src/react/useJsonSelector.ts:14
Selects a small, plain piece of a store by its content: the selector's result is compared as JSON, so a store that hands out a fresh array or object for unchanged content — a game's player state pushed several times a second in a fight — re-renders nothing that reads it, and the value returned keeps its reference until the content changes. Only for small data (a few ids, a list of buffs): the JSON is written once per store change.
Type Parameters ​
| Type Parameter |
|---|
S |
T |
Parameters ​
| Parameter | Type |
|---|---|
useHook | SelectingHook<S> |
select | (state) => T |
Returns ​
T