I am using antd notification component as follows
import { notification } from "antd";
const Notification = ({ msg, type, clearMsg }) => {
return (
<div>
{notification[type]({
description: msg,
})}
{clearMsg()}
</div>
);
};
export default Notification;
And I am simply using it anywhere I need a notification to pop-up. For instance after API response failure:
const onSubmit = async (e) => {
try {
const res = await login(data);
if (res.message) {
setError({ state: true, msg: res.message });
}
} catch (err) {
console.log(err);
}
};
And then depending on error state, I am showing the Notification in the return body as following:
{ error.state ?
<Notification
type="error"
msg="some msg"
clearMsg={() => setError({state: false, msg: ""})} :
null
}
But simultaneously two pop-ups appear instead of just one, can anyone guide on why I am getting this behaviour?