【问题标题】:DeleteButton redirecting to show viewDeleteButton 重定向到显示视图
【发布时间】:2020-11-09 09:24:47
【问题描述】:

我目前正在开发一个 React Admin 应用程序。

我在编辑视图中添加了一个DeleteButton,如下所示:

<Edit {...props} undoable={false}>
  <SimpleForm
    toolbar={<InternalUserEditToolbar />}
    validate={handleValidate}
  >
    <InternalUserForm />
  </SimpleForm>
</Edit>

DeleteButtonInternalUserEditToolbar 中:

<Toolbar {...props} className={classes.toolbar}>
  <SaveButton disabled={props.pristine}/>
  <DeleteButton
    basePath={props.basePath}
    undoable={false}
  />
</Toolbar>

问题是,当我单击删除按钮时,用户被正确删除,但我被重定向到所述用户的显示视图。这会导致错误,因为用户不再存在。

我检查了basePath 的值正确。即使通过在DeleteButton 的props 中指定redirect="list",行为仍然相同。

我在这里做错了吗?

【问题讨论】:

  • 您是否在使用某种第三方组件库?什么是 DeleteButton,为什么它会将您重定向到任何地方?
  • 我没有使用任何第三方组件库。 DeleteButton 是 React Admin 提供的用于删除资源的按钮:marmelab.com/react-admin/CreateEdit.html#toolbar。它重定向,因为那是行为。
  • 我的意思是我没有使用问题中指定的 React Admin 以外的第三方组件库。抱歉解释不好
  • 为什么要在&lt;DeleteButton&gt; 上设置basePath? react-admin 自己做的,你不应该需要这个。
  • 我在想这种行为可能来自错误的basePath,但不管有没有basePath,它仍然是一样的。

标签: javascript reactjs react-admin


【解决方案1】:

您是否尝试过使用FromWithRedirect? react-admin 文档说你可以在这个组件中提供重定向逻辑here

【讨论】:

    猜你喜欢
    • 2013-06-26
    • 1970-01-01
    • 2016-09-14
    • 1970-01-01
    • 1970-01-01
    • 2016-02-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多