【问题标题】:Can you disable the React-Admin Undo feature in config?你可以在配置中禁用 React-Admin Undo 功能吗?
【发布时间】:2019-07-18 19:43:44
【问题描述】:

撤消功能非常棒,但它可能会导致开发周期效率低下。

有没有一种简单的方法可以让我们在暂存环境中禁用它,或者至少降低超时时间?

【问题讨论】:

    标签: react-admin


    【解决方案1】:

    Edit 和 Create 组件支持 undoable 参数。所以你可以这样做<Edit {...props} undoable={false} > 来禁用特定表单的撤消功能

    【讨论】:

      【解决方案2】:

      当我正确理解文档和 src 时,您必须覆盖通知组件才能更改 autoHideDuration。 这是通知对用户可见的时间,延迟后,请求被发送到 api。

      当您将其设置为 0 时,请求应几乎立即发送。
      来自documentation - Theming - Notifications

      您可以覆盖通知组件,例如更改 通知持续时间。它默认为 4000,即 4 秒,并且 您可以使用 autoHideDuration 属性覆盖它。例如,到 创建一个默认为 5 秒的自定义通知组件:

      // in src/MyNotification.js
      import { Notification } from 'react-admin';
      
      const MyNotification = props => <Notification {...props}autoHideDuration={5000} />;
      
      export default MyNotification;
      

      【讨论】:

      • 嗨,我需要将通知自定义为我自己的。知道吗?提前致谢。
      • 根据我的经验,有必要编写一些函数并与 react-admin 连接
      【解决方案3】:

      undoable 只能设置在Edit 组件上,而不能设置在Create 组件上。

      通过添加自定义变量来处理来自创建页面的formProps,以检查道具确实来自“创建”页面还是来自服务器。

      要自定义CreateEdit 页面的通知,您可以将successMessage 属性传递给组件

      successMessage="Item created successfully" //or use translate
      

      More about 'successMessage' can be found here - React Documentation

      【讨论】:

        猜你喜欢
        • 2023-03-06
        • 2011-07-09
        • 1970-01-01
        • 1970-01-01
        • 2021-02-04
        • 2022-12-06
        • 2019-06-02
        • 1970-01-01
        • 2021-03-31
        相关资源
        最近更新 更多