Persist
With persist
keyword, you can make changes on form persistent. This can be useful when you want to preserve prop values on browser refreshes, share filled form as link, share some filter settings etc.
Keyword
Type
type
'query'
, 'localStorage'
What type of storage to use.
key
string
(optional)
Under what key to store value. If not set prop path is used.
For example key: 'abc'
will be set in query as ?abc=123
loadMap
$eval
(optional)
Mapper when retrieving the data from the persistence.
storeMap
$eval
(optional)
Mapper when storing the data to persistence.
Example
When prop value is changed it will be also saved into URL under query key my-key
. When the form is opened again URL query will be checked if the value can be retrieved.
Array edge cases
You can not use persists on array prop children, since all children will have the same key. Exception is a static array where you can manually set different keys. But you can easily set persist on array level or parent object.
Wrong
All array items will have same key, this is probably not what you need.
Correct
If you need to make array persistent, set persist
keyword on array level.
Correct
If you have static array, you can set your own keys for items in that case storage is stable.
Last updated
Was this helpful?