The context of the store.
Optional
select: (state: TState) => TSelectionA function to select a subset of the state. Can prevent unnecessary re-renders.
The store instance.
Basic usage:
import { useStoreContext } from "@fransek/statekit";
import { StoreContext } from "./store";
function Counter() {
const {
state: { count },
actions: { increment, decrement, reset },
} = useStoreContext(StoreContext);
return (
<div>
<div>{count}</div>
<button onClick={decrement}>-</button>
<button onClick={increment}>+</button>
<button onClick={reset}>Reset</button>
</div>
);
}
A hook used to access a store context created with
createStoreContext
.