Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React Admin: onSuccess does not work properly on <Edit> Component

onSuccess function does not work properly on react-admin,

my code:

const onSuccess = () => {
   redirect('list', props.basePath);
};


<Edit 
  onFailure={onFailure}  
  onSuccess={onSuccess}  
  title="Ediar Usuário" 
  {...props} 
>
  <SimpleForm 
     variant="standard" 
     toolbar={<CustomToolbar />} 
  >
</Edit>

On the first time, it works perfectly but at second time, nothing happens.

Do not even trigger the save event

like image 885
user3646212 Avatar asked Oct 16 '22 02:10

user3646212


2 Answers

I don't know if this is applicable to your use case but setting undoable to false on Edit component works

like image 139
Jasper Bernales Avatar answered Oct 19 '22 01:10

Jasper Bernales


I am suffering from the same problem.

Jasper Bernales's tip was effective.

I've changed my code from :

<Edit
      onSuccess={onSuccess}
      {...props}
    >

to :

<Edit
      onSuccess={onSuccess}
      undoable={false}
      {...props}
    >

then ...it works!

It seems like a problem caused by forcing "useRedirect" or "useRefresh" to interfere with the delay scheduled by "undoable".The document seems to need an update to this part. just check this out from React-Admin Docs.:

You can disable this behavior by setting undoable={false}. With that setting, clicking on the Delete button displays a confirmation dialog. Both the Save and the Delete actions become blocking and delay the refresh of the screen until the data provider responds.

like image 42
Hyungju Moon Avatar answered Oct 19 '22 02:10

Hyungju Moon