createZustandStoreController
function createZustandStoreController<TStore, T>( store, select, set): StoreController<T>;Defined in: packages/core/src/state/createExternalStoreAdapter.ts:27
Binds one slice of an existing Zustand store as a StoreController, to pass as a
component’s *Store prop. For a store holding just that one value, use
createControllableStore instead.
Type Parameters
Section titled “Type Parameters”| Type Parameter |
|---|
TStore |
T |
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
store |
ZustandLikeStore<TStore> |
A Zustand store the consumer already owns. |
select |
(state) => T |
Reads the slice out of the store’s state. |
set |
(store, value) => void |
Writes a new value (or an updater function) back into the store. |
Returns
Section titled “Returns”Example
Section titled “Example”const viewportStore = createZustandStoreController( appStore, (s) => s.msaViewport, (store, next) => store.setState((s) => ({ msaViewport: typeof next === "function" ? next(s.msaViewport) : next, })),);<MultipleSequenceAlignment msa={data} viewportStore={viewportStore} />