@refinedev/core 4.38.4 → 4.40.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,153 @@
1
1
  # @refinedev/core
2
2
 
3
+ ## 4.40.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
+
77
+ ## 4.39.0
78
+
79
+ ### Minor Changes
80
+
81
+ - [#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
82
+
83
+ `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`.
84
+
85
+ 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.
86
+
87
+ ```tsx
88
+ const { mutate } = useUpdateMany();
89
+
90
+ mutate({
91
+ //...
92
+ mutationMode: "optimistic",
93
+ optimisticUpdateMap: {
94
+ list: true,
95
+ many: true,
96
+ detail: (previous, values, id) => {
97
+ if (!previous) {
98
+ return null;
99
+ }
100
+
101
+ const data = {
102
+ id,
103
+ ...previous.data,
104
+ ...values,
105
+ foo: "bar",
106
+ };
107
+
108
+ return {
109
+ ...previous,
110
+ data,
111
+ };
112
+ },
113
+ },
114
+ });
115
+ ```
116
+
117
+ feat: add [`optimisticUpdateMap`](https://refine.dev/docs/api-reference/core/hooks/data/useUpdateMany/#optimisticupdatemap) prop to the `useForm` hook
118
+
119
+ ```tsx
120
+ const { formProps, saveButtonProps } = useForm({
121
+ mutationMode: "optimistic",
122
+ optimisticUpdateMap: {
123
+ list: true,
124
+ many: true,
125
+ detail: (previous, values, id) => {
126
+ if (!previous) {
127
+ return null;
128
+ }
129
+
130
+ const data = {
131
+ id,
132
+ ...previous.data,
133
+ ...values,
134
+ foo: "bar",
135
+ };
136
+
137
+ return {
138
+ ...previous,
139
+ data,
140
+ };
141
+ },
142
+ },
143
+ });
144
+ ```
145
+
146
+ ### Patch Changes
147
+
148
+ - [#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.
149
+ From now on, you can use the [`invalidateOnUnmount`](https://refine.dev/docs/api-reference/core/hooks/useForm/#invalidateonunmount) prop to invalidate queries upon unmount.
150
+
3
151
  ## 4.38.4
4
152
 
5
153
  ### Patch Changes