Open yarapolana opened 8 months ago
Hi @yarapolana , thank you so much!
I think the issue has something to do with the fact that you're spreading the toastHeaders like that, headers are not normal JS objects so they don't really act the same, what happens if you return headers: toastHeaders?
@AlemTuzlak You are welcome I tried and have the same result, only appears after refresh. I have other headers for auth cookie thats why I had to spread them otherwise auth wouldn't work.
not working
{
headers: toastHeaders
}
Hi @yarapolana, I am facing the same issue as well with multiple headers. Do you have a solution for this yet?
Do you guys mind creating a minimum repro so I can check it out
also would you mind trying using this:
export function combineHeaders(...headers: Array<ResponseInit["headers"] | null | undefined>) {
const combined = new Headers();
for (const header of headers) {
if (!header) {
continue;
}
for (const [key, value] of new Headers(header).entries()) {
combined.append(key, value);
}
}
return combined;
}
headers: combineHeaders(toastHeaders,otherHeaders)
@AlemTuzlak I found out what my issue was.
On the root.tsx
file I am using export const shouldRevalidate = () => false
if I comment out this line everything works, I used Object.assign
, tried combinedHeaders and it also works but only with the line commented out.
Now how can I still use shouldRevalidate and the toast?
Same issue here. Using the latest Remix without shouldRevalidate
in the root. Works in dev but has the issue when deployed to production.
I am also seeing this issue. Always appears twice on refresh and is never evicted from the cookie.
I am also using cookie-based auth, which i am checking prior to getting to this toast stage, so perhaps the issue lies therein
Might be related to https://github.com/remix-run/remix/issues/5647#issuecomment-2254685869
@grundmanise This might be the actual cause of it but that might be solved when single fetch is released and the API is changed. Unfortunately I can't do much to help without a reliable repro to help figure it out, but if it's caused by a race-condition in Remix there's really not much I could do. I believe you guys are having an issue but I have no idea how to solve it unfortunately 😢
Hi I followed the initial steps to get the toast going with sonner see below, but it is not working. Expected behaviour: Toast to work when being called.
What is happening: Toast gets called on refresh twice, and doesn't get cleared, if I refresh it continues to get called.
Is something else missing?
from route
from root
using
Edit: Just wanted to say congrats with the lib though, fantastic explanation on the blog.