Minor Changes
-
#4914
91a4d0da9f1
Thanks @yildirayunlu! - feat: addoptimisticUpdateMap
prop to theuseUpdate
anduseUpdateMany
hookslist
,many
anddetail
are the keys of theoptimisticUpdateMap
object. To automatically update the cache, you should passtrue
. If you don't want to update the cache, you should passfalse
.If you wish to customize the cache update, you have the option to provide functions for the
list
,many
, anddetail
keys. These functions will be invoked with theprevious
data,values
, andid
parameters. Your responsibility is to return the updated data within these functions.const { mutate } = useUpdateMany(); mutate({ //... mutationMode: "optimistic", optimisticUpdateMap: { list: true, many: true, detail: (previous, values, id) => { if (!previous) { return null; } const data = { id, ...previous.data, ...values, foo: "bar", }; return { ...previous, data, }; }, }, });
feat: add
optimisticUpdateMap
prop to theuseForm
hookconst { formProps, saveButtonProps } = useForm({ mutationMode: "optimistic", optimisticUpdateMap: { list: true, many: true, detail: (previous, values, id) => { if (!previous) { return null; } const data = { id, ...previous.data, ...values, foo: "bar", }; return { ...previous, data, }; }, }, });
Patch Changes
- #4903
e327cadc011
Thanks @yildirayunlu! - feat: addinvalidateOnUnmount
prop touseForm
hook.
From now on, you can use theinvalidateOnUnmount
prop to invalidate queries upon unmount.