Toast not working properly
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Needs clarification
- Activity status
- Stale
- Tech stack
- react, typescript
- Domain
- full-stack
Research direction
Start with the route action and root loader/useEffect entry points shown in the report, then trace how the toast response and headers are consumed by Sonner. Reproduce the refresh flow and verify that the error toast appears once after the action and is not shown again on subsequent refreshes.
Written by the indexing model from the issue text.
Description
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
// ... imports
export const action = async ({ request }: ActionFunctionArgs) => {
return jsonWithError(null, 'There are errors in the form')
}
from root
// ... imports
export const loader = async ({ request }: LoaderFunctionArgs) => {
// ... otherHeaders logic
const { toast, headers: toastHeaders } = await getToast(request)
return json(
{
toast
},
{
headers: {
// ...otherHeaders,
...toastHeaders
}
}
)
}
export default function Home() {
const { toast: serverToast } = useLoaderData<typeof loader>()
useEffect(() => {
console.log('serverToast', serverToast)
if (serverToast?.type === 'success') {
toast.success(serverToast.message)
}
if (serverToast?.type === 'error') {
toast.error(serverToast.message)
}
}, [serverToast])
return (
<html lang="en">
<head>
<Meta />
<title>Basic Example With Remix Toast</title>
<Links />
</head>
<body>
{children}
<Toaster />
<ScrollRestoration />
<Scripts />
</body>
</html>
)
}
using
devDeps
@remix-run/dev -> 2.8.1
@remix-run/eslint-config -> 2.8.1
deps
@remix-run/serve -> 2.8.1
@remix-run/react -> 2.8.1
@remix-run/node -> 2.8.1
sonner -> 1.4.0
Edit: Just wanted to say congrats with the lib though, fantastic explanation on the blog.
- Dominant language
- TypeScript
- Stars
- 260
- Forks
- 15
- PR merge metrics
- No merged PRs in 30d
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- No contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from code-forge-io/remix-toast
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
code-forge-io/remix-toast#52 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 38/100
code-forge-io/remix-toast#50 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
code-forge-io/remix-toast#42 · 4 comments · 3 reactions ·
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
code-forge-io/remix-toast#41 · 8 comments ·
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
code-forge-io/remix-toast#37 · 1 comment · 1 reaction ·
All issues in code-forge-io/remix-toast
Similar issues
-
area:cli area:security bug priority:medium
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
"code source" and "numerique.gouv" links: "new window" mention duplicated in the accessible nameOpenaccessibility
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
numerique-gouv/lasuite-landingpage#315 ·
Maintainers usually reply within 1 day
-
needs:triage
Difficulty 1/5 Under an hour Newbie friendliness 92/100
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 72/100
HyeokjaeChoi/vaultme#585 ·
Maintainers usually reply within 1 day
-
enhancement priority/P2
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
beettlle/pi-smart-router#200 ·