feature/IO-3725-RPS-Changes - Deprecations / Bug fixes
This commit is contained in:
24
src/util/antdFeedback.js
Normal file
24
src/util/antdFeedback.js
Normal file
@@ -0,0 +1,24 @@
|
||||
import { message as staticMessage, notification as staticNotification } from "antd";
|
||||
|
||||
let messageApi = staticMessage;
|
||||
let notificationApi = staticNotification;
|
||||
|
||||
const createApiProxy = (getApi) =>
|
||||
new Proxy(
|
||||
{},
|
||||
{
|
||||
get(_target, prop) {
|
||||
const api = getApi();
|
||||
const value = api[prop];
|
||||
return typeof value === "function" ? value.bind(api) : value;
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
export const configureAntdFeedback = ({ message, notification }) => {
|
||||
if (message) messageApi = message;
|
||||
if (notification) notificationApi = notification;
|
||||
};
|
||||
|
||||
export const antdMessage = createApiProxy(() => messageApi);
|
||||
export const antdNotification = createApiProxy(() => notificationApi);
|
||||
Reference in New Issue
Block a user