@refinedev/core@4.28.0
版本发布时间: 2023-07-18 20:46:28
refinedev/refine最新发布版本:@refinedev/supabase@5.9.4(2024-09-03 19:48:37)
Minor Changes
-
#4652
96af6d25b7a
Thanks @alicanerdurmaz! - feat: addederrros
field toHttpError
type. From now on, you can passerrors
field toHttpError
. This field will be used to update theuseForm
's error state.export interface ValidationErrors { [field: string]: | string | string[] | boolean | { key: string; message: string }; } export interface HttpError extends Record<string, any> { message: string; statusCode: number; errors?: ValidationErrors; }
Usage example:
import { HttpError } from "@refinedev/core"; const App = () => { return ( <Refine routerProvider={routerProvider} dataProvider={{ // ... update: async () => { // assume that the server returns the following error const error: HttpError = { message: "An error occurred while updating the record.", statusCode: 400, //This field will be used to update the `useForm`'s error state errors: { title: [ "Title is required.", "Title should have at least 5 characters.", ], "category.id": ["Category is required."], status: true, content: { key: "form.error.content", message: "Content is required.", }, }, }; return Promise.reject(error); }, }} > {/* ... */} </Refine> ); };
Refer to the server-side form validation documentation for more information. →
-
#4652
96af6d25b7a
Thanks @alicanerdurmaz! - feat: addeddisableServerSideValidation
to the refine options for globally disabling server-side validation.import { Refine } from "@refinedev/core"; <Refine options={{ disableServerSideValidation: true, }} > // ... </Refine>;
-
#4591
f8891ead2bd
Thanks @yildirayunlu! - feat:autoSave
feature for useForm hook now acceptautoSave
object.enabled
is a boolean value anddebounce
is a number value in milliseconds.debounce
is optional and default value is1000
.autoSaveProps
is an object that containsdata
,error
andstatus
values.data
is the saved data,error
is the error object andstatus
is the status of the request.status
can beloading
,error
,idle
andsuccess
.const { autoSaveProps } = useForm({ autoSave: { enabled: true, debounce: 2000, // not required, default is 1000 }, });
Patch Changes
-
#4659
3af99896101
Thanks @salihozdemir! - chore: fix tsdoc description ofonCancel
property on following hooks:-
useUpdate
-
useUpdateMany
-
useDelete
-
useDeleteMany
-
-
#4665
3442f4bd00a
Thanks @yildirayunlu! - feat: addfalse
return type onSuccessErrorNotification
This issue has been fixed in this PR, where the
successNotification
anderrorNotification
methods can now returnfalse
when a callback function is given. This allows the conditional notification to be displayed.const { mutate } = useCreate<IPost>({}); mutate({ resource: "posts", values: { title: "Hello World", status: "published", }, successNotification: (data) => { if (data?.data.status === "published") { return { type: "success", message: "Post published", }; } return false; }, });