@pinia/root / pinia / mapWritableState
mapWritableState()
Allows using state and getters from one store without using the composition API (setup()) by generating an object to be spread in the computed field of a component.
Param
store to map from
Param
array or object
Call Signature
function mapWritableState<Id, S, G, A, KeyMapper>(useStore, keyMapper): _MapWritableStateObjectReturn<S, G, KeyMapper>;Same as mapState() but creates computed setters as well so the state can be modified. Differently from mapState(), only state properties can be added.
Type Parameters
Id
Id extends string
S
S extends StateTree
G
G
A
A
KeyMapper
KeyMapper extends Record<string, _MapWritableStateKeys<S, G>>
Parameters
useStore
StoreDefinition<Id, S, G, A>
store to map from
keyMapper
KeyMapper
object of state properties
Returns
_MapWritableStateObjectReturn<S, G, KeyMapper>
Call Signature
function mapWritableState<Id, S, G, A, Keys>(useStore, keys): Pick<_MapWritableStateReturn<S, G, Keys>, Keys>;Allows using state and getters from one store without using the composition API (setup()) by generating an object to be spread in the computed field of a component.
Type Parameters
Id
Id extends string
S
S extends StateTree
G
G
A
A
Keys
Keys extends string | number | symbol
Parameters
useStore
StoreDefinition<Id, S, G, A>
store to map from
keys
readonly Keys[]
array of state properties
Returns
Pick<_MapWritableStateReturn<S, G, Keys>, Keys>

