this is my code
import { notification } from "antd";
const openNotificationWithIcon = (type: string, message: string, err: string) => {
if(type == 'success' || type == 'warning')
notification[type] = ({ message: message, description: err}) *//error here*
return;
};
export default openNotificationWithIcon;
but it has an error at message
Type '{ message: string; description: string; }' is not assignable to type '((args: ArgsProps) => void) & ((args: ArgsProps) => void)'.
Object literal may only specify known properties, and 'message' does not exist in type '((args: ArgsProps) => void) & ((args: ArgsProps) => void)'
I have seen in antd that message required ReactNode type and I fix but it not happend
It seems like the type of notificitaion['success' | 'warning'] is a function. This means that you need to call it instead of assigning.
So proper way to use it would be
import { notification } from "antd";
const openNotificationWithIcon = (type: string, message: string, err: string) => {
if(type == 'success' || type == 'warning')
notification[type]({ message: message, description: err});
return;
};
export default openNotificationWithIcon;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.