absent-sapphire•3h ago
how to use antd notification for custom apis in page
how to use antd notification for custom apis in page
2 Replies
Hi @jakshire01. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
To use Ant Design notifications for custom API calls in a Refine page, you should:
1. Set up Refine with Ant Design's notification provider
Make sure your app is wrapped with the Ant Design theme and the
The
If you use Refine's data hooks like
- Set up
Make sure your app is wrapped with the Ant Design theme and the
useNotificationProvider
from @refinedev/antd
is passed to the notificationProvider
prop of <Refine />
:
Ant Design Introduction - Notifications
2. Use the useNotification
hook in your pageThe
useNotification
hook gives you access to the open
and close
methods for notifications. You can call these methods after your custom API logic:
Built-in Notification Providers - Ant Design Example
3. (Optional) Customize notifications in data hooksIf you use Refine's data hooks like
useCustomMutation
for your API, you can pass successNotification
and errorNotification
props to customize notifications:
useCustomMutation - successNotification and errorNotification
Summary:- Set up
notificationProvider={useNotificationProvider}
in <Refine />
.
- Use useNotification
in your page to show notifications after custom API calls.
- Or, use successNotification
/errorNotification
in Refine data hooks for automatic notifications.
This approach ensures your notifications are consistent with Ant Design and fully integrated with Refine.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@418995770205929473> Kapa.ai is still learning and improving, please let me know how I did by reacting below.