为创建和编辑视图添加自定义成功和错误消息

Adding custom success and error messages for the create and edit views

所以在文档中它说只是在编辑组件上添加一个带有 onSuccess / onFailure 函数的道具,我已经做到了,但是导航到页面进行编辑会抛出这样的错误: Warning: Unknown event handler property `onSuccess`. It will be ignored.

代码在这里:

export const AffiliateEdit = (props) => {
  const notify = useNotify();
  const onSuccess = () => {
    notify('Affiliate saved successfully');
  }

  return (
    <Edit {...props} onSuccess={onSuccess}>
      <SimpleForm redirect="list">
        <ColorInput source="color" />
        <TextInput source="name" validate={[required()]} />
        <ReferenceInput
          source="network_id"
          reference="networks"
          validate={[required()]}
        >
          <SelectInput optionText="name" />
        </ReferenceInput>
        <TextInput
          source="reference"
          validate={[required()]}
          helperText="Please use all lower case, no spaces or underscores e.g affiliatename"
        />
      </SimpleForm>
    </Edit>
  )
};

文档参考:https://marmelab.com/react-admin/CreateEdit.html

Nvm 弄明白了,只需要更新 react-admin 哈哈