From 803223ecb0e61a7887bebb0c7cbeca0854548296 Mon Sep 17 00:00:00 2001 From: Kmaschta Date: Thu, 28 Nov 2019 17:54:21 +0100 Subject: [PATCH] Allow to extend useEditController `useCreateController` accepts a onSuccess and a onFailure props, but `useEditController` don't So, I made this PR to have the same behavior for both of them --- packages/ra-core/src/controller/useEditController.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/ra-core/src/controller/useEditController.ts b/packages/ra-core/src/controller/useEditController.ts index 0fda10c7bca..842d105b398 100644 --- a/packages/ra-core/src/controller/useEditController.ts +++ b/packages/ra-core/src/controller/useEditController.ts @@ -92,12 +92,12 @@ const useEditController = (props: EditProps): EditControllerProps => { ); const save = useCallback( - (data: Partial, redirectTo = 'list') => + (data: Partial, redirectTo = 'list', { onSuccess, onFailure } = {}) => update( { payload: { data } }, { action: CRUD_UPDATE, - onSuccess: () => { + onSuccess: onSuccess ? onSuccess : () => { notify( successMessage || 'ra.notification.updated', 'info', @@ -108,7 +108,7 @@ const useEditController = (props: EditProps): EditControllerProps => { ); redirect(redirectTo, basePath, data.id, data); }, - onFailure: error => + onFailure: onFailure ? onFailure : error => notify( typeof error === 'string' ? error