The Notification always appear flash twice after save at Edit page
The Notification always appear flash twice after save at Edit page
5 Replies
Hi @tingadev. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
Based on the knowledge sources provided, there are a couple of potential reasons for the notification appearing twice after saving on the Edit page in refine. Let me explain:
1. React StrictMode:
If you're using React's StrictMode, this behavior is expected in development mode. React.StrictMode intentionally renders components twice to identify potential issues. This is not a bug, but a feature of React's development mode. As mentioned in the FAQ documentation (https://refine.dev/docs/guides-concepts/faq/#why-are-api-calls-triggering-twice), this double rendering helps identify unsafe lifecycles, unexpected side effects, and deprecated APIs.
2. Notification Provider Implementation:
There was a reported issue related to duplicate notifications in the Material UI implementation of refine. As described in a GitHub issue (https://github.com/refinedev/refine/issues/3392), the notification pop-up was appearing twice when navigating to an edit resource page where the resource ID didn't exist in the database. This was due to the
useQuery
's onError
function being called when it wasn't intended.
To address this issue, you could try the following:
1. Check if you're using React.StrictMode. If so, this behavior is expected in development mode and should not occur in production.
2. Ensure you're using the latest version of refine and its packages, as the issue might have been resolved in a newer version.
3. If the problem persists, you might want to consider passing a unique key to the notification props explicitly, as suggested in another GitHub issue comment (https://github.com/refinedev/refine/issues/6269#issuecomment-1583056621).
If none of these solutions work, it would be helpful to create a minimal reproducible example and report it to the refine GitHub repository for further investigation.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@761921731505946634> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
like-gold•3mo ago
Hello @tingadev, we need more detail about the problem for debugging. Which UI provider you are using? what is the version?
deep-jadeOP•3mo ago
Hi @Alican Erdurmaz, Im using
"@refinedev/core": "4.51.1"
and @refinedev@antd : 5.37.4
,
When Im staying at Edit page, after save successfully always show 2 notification popup
The first one is flashed
The second appear after that
Its will work normal if I set mutationMode is optimistic
like-gold•3mo ago
I tested on these examples:
- https://github.com/refinedev/refine/tree/main/examples/with-nextjs
- https://github.com/refinedev/refine/tree/main/examples/base-antd
It's shows only once. If you provide reproducible example I'm happy to debug