@refinedev/core 4.38.4 → 4.39.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,79 @@
1
1
  # @refinedev/core
2
2
 
3
+ ## 4.39.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#4914](https://github.com/refinedev/refine/pull/4914) [`91a4d0da9f1`](https://github.com/refinedev/refine/commit/91a4d0da9f180ae358a448c7d187cee44f8c2299) Thanks [@yildirayunlu](https://github.com/yildirayunlu)! - feat: add [`optimisticUpdateMap`](https://refine.dev/docs/api-reference/core/hooks/data/useUpdateMany/#optimisticupdatemap) prop to the `useUpdate` and `useUpdateMany` hooks
8
+
9
+ `list`, `many` and `detail` are the keys of the `optimisticUpdateMap` object. To automatically update the cache, you should pass `true`. If you don't want to update the cache, you should pass `false`.
10
+
11
+ If you wish to customize the cache update, you have the option to provide functions for the `list`, `many`, and `detail` keys. These functions will be invoked with the `previous` data, `values`, and `id` parameters. Your responsibility is to return the updated data within these functions.
12
+
13
+ ```tsx
14
+ const { mutate } = useUpdateMany();
15
+
16
+ mutate({
17
+ //...
18
+ mutationMode: "optimistic",
19
+ optimisticUpdateMap: {
20
+ list: true,
21
+ many: true,
22
+ detail: (previous, values, id) => {
23
+ if (!previous) {
24
+ return null;
25
+ }
26
+
27
+ const data = {
28
+ id,
29
+ ...previous.data,
30
+ ...values,
31
+ foo: "bar",
32
+ };
33
+
34
+ return {
35
+ ...previous,
36
+ data,
37
+ };
38
+ },
39
+ },
40
+ });
41
+ ```
42
+
43
+ feat: add [`optimisticUpdateMap`](https://refine.dev/docs/api-reference/core/hooks/data/useUpdateMany/#optimisticupdatemap) prop to the `useForm` hook
44
+
45
+ ```tsx
46
+ const { formProps, saveButtonProps } = useForm({
47
+ mutationMode: "optimistic",
48
+ optimisticUpdateMap: {
49
+ list: true,
50
+ many: true,
51
+ detail: (previous, values, id) => {
52
+ if (!previous) {
53
+ return null;
54
+ }
55
+
56
+ const data = {
57
+ id,
58
+ ...previous.data,
59
+ ...values,
60
+ foo: "bar",
61
+ };
62
+
63
+ return {
64
+ ...previous,
65
+ data,
66
+ };
67
+ },
68
+ },
69
+ });
70
+ ```
71
+
72
+ ### Patch Changes
73
+
74
+ - [#4903](https://github.com/refinedev/refine/pull/4903) [`e327cadc011`](https://github.com/refinedev/refine/commit/e327cadc011ce8696d7149252e1ad308005b1eff) Thanks [@yildirayunlu](https://github.com/yildirayunlu)! - feat: add [`invalidateOnUnmount`](https://refine.dev/docs/api-reference/core/hooks/useForm/#invalidateonunmount) prop to [`useForm`](https://refine.dev/docs/api-reference/core/hooks/useForm) hook.
75
+ From now on, you can use the [`invalidateOnUnmount`](https://refine.dev/docs/api-reference/core/hooks/useForm/#invalidateonunmount) prop to invalidate queries upon unmount.
76
+
3
77
  ## 4.38.4
4
78
 
5
79
  ### Patch Changes