如何在 Edit 中提供到 SimpleForm 的自定义重定向?

How to provide a custom redirect to a SimpleForm inside Edit?

编辑后,我按照惯例在列表上重定向。

但是,我需要在列表中提供额外的参数 URL。

有没有办法在 SimpleForm/Edit 上 "cheat" 自定义重定向?

这是我的代码的相关部分:

const ProviderUserEditActions = ({ basePath, data }) => {
  if (! data) return null
  return (
    <CardActions style={cardActionStyle}>
        <ListButton basePath={basePath+'?'+queryString.stringify({providerId:data.providerId, providerName:data.providerName})} />
        <RefreshButton />
    </CardActions>
  );
}

export const ProviderUserEdit = (props) => (
    <Edit actions={<ProviderUserEditActions/>} title={<ProviderUserEditTitle />} {...props}>
        {/*redirect=false will cause the loosing of the URL parameters :(
          but this is the "least worst", because otherwise it would redirect to
          'list' but without URL parameters it will completely crash...
          we hope that someday we will be able to provide our own redirect
          function
          */}
        <SimpleForm redirect={false}>
            <TextInput source="name" />
            <TextInput source="email" />
            <TextInput source="phone" />
            <BooleanInput source="activated" />
        </SimpleForm>
    </Edit>
);

它没有记录,所以我会创建一个问题来将它添加到文档中,但是你可以指定一个路径作为 redirect prop:

<SimpleForm redirect={`/list?myParam=${myValue}`}>

参见:https://github.com/marmelab/react-admin/blob/master/packages/ra-core/src/util/resolveRedirectTo.js