-
-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can you show toasts from loaders using a Link #26
Comments
Hmm, so I can do this by passing in |
I wondered if single-fetch might be the answer, here - but it seems to be even odder… It now seems to call the root on every load, but now it appears to call the last toast, not the current one 🤯 Screen.Recording.2024-09-12.at.07.50.14.movEDIT: I guess that makes sense because the root loader runs first, so the new toast has not been set 🤔 |
Root re-runs under certain conditions, not all of em, page navigations do not always trigger it, I think if you DON'T have a loader on the page you're navigating to it doesn't re-trigger |
In this case (see example) all routes have a loader… but the root loader does not run in classic mode with client-side navigation, and in single fetch it seems like the root loader runs first so it gets the previous toast! I’m struggling to think how this could work and it feels like reading the loaderData in each route component and triggering the notification that way is the only solution to this problem. |
well another thing you could do is add an onClick handler to the Link component, eg: <Link to="/somewhere" onClick={() =>showToast()} /> |
In our case we are showing toasts based on responses to APIs called in the loader, e.g. a 404 error calling a resource. This feels like an unsolvable problem with the session flash approach |
I have noticed the toasts do not show if you navigate to a page with a Link component because it does not seem like the root loader re-runs. Is this correct?
Example repo: https://github.com/MattyBalaam/remix-toast-loader-test
My use case is to show a toast message if some low-priority api data resources do not load.
The text was updated successfully, but these errors were encountered: