Repository navigation
Rendering a zod "refine" error within shadcn toast #1859
Replies: 1 comment
|
You diagnosed the exact two symptoms accurately: React StrictMode and render-phase side effects. Here is what is happening under the hood and how to handle it idiomatically. Why this happens1. Why 2 toasts appear (and why they multiply on hot reload)In React, the render phase of any component (including the
2. Why the number
|
Uh oh!
There was an error while loading. Please reload this page.
I have this form subscriber that works perfectly fine just rendering the error text:
If I try the following though, it renders 2 toasts:
Finally, this is the zod schema with the refine:
PS. This also renders the number 2, and the more I "hot reload" the number increases in increments of 2: ej. next number would be 4.
Does this have to do with the whole react "StrictMode" or am I missing something.
This is my first time using TanstackForm so I could also be missunderstanding something.
All reactions