react-admin 中的 showNotification 不起作用,仍然

showNotification in react-admin doesn't work, Still

https://codesandbox.io/s/simple-6nzp0 请参阅 /src/posts/postEdit.js 第 73 行。 没有显示通知。

你能在沙箱上添加一个工作代码吗?

尽管还有其他讨论: https://github.com/marmelab/react-admin/issues/3402 他们都没有工作。

我需要沙盒上的工作代码,这样我就知道我错过了什么。

谢谢。

showNotification 是一个 redux 动作创建者。它创建操作对象但不分派它。

您必须 connect 需要显示通知的组件并使用已连接的调度程序。

在这里,我建议您将按钮提取到一个单独的组件中:

import { connect } from 'react-redux';
import { showNotification } from 'react-admin';

const MyButton = connect(undefined, { showNotification })(props => (
    <button
        onClick={() => {
            props.showNotification("xxx");
            // return false;
        }}
    >
        Click -----
    </button>
))

然后在您的编辑组件中使用此按钮