submit form without reloading

Hello! I have come across a few situations where I want to use the actions but don't want it to trigger a reload of the route for client side purposes - but I can't seem to figure it out now that Solid Router overwrites the native form element. I'm not using SolidStart - just vanila Solid/Router with Tauri. In alpha SS it was pretty easy due to the invalidate helper but I'm finding it pretty hard in the README to figure out a similar functionality? Is this to be expected and now if you want to use native forms - you are forced into the server-like route reload with using actions? Just trying to understand the new flow of things? Thanks!
6 Replies
caseybaggz
caseybaggzOP10mo ago
revalidate doesn't seem to do anything as I've tried it every way I can think of? 🤷‍♀️
mdynnl
mdynnl10mo ago
could you show some code? e.g how you're using the helpers and connecting them
caseybaggz
caseybaggzOP10mo ago
I'm literally just doing what is on the README. But, I guess this was more about the philosophy of when to use form and actions in each use case? So, I've noticed if I don't use them, the route doesn't reload, so I'm guessing that when you want the magic of dynamically updating everything without having to keep track of it (like on a server) - then form/actions are your friend. But, when you need to keep a client side store and not refresh everything (i.e. realtime usage) - they are not your friend. I'm still guessing this is in response to the update in the Router to utilize the native form element? Maybe I'm missing something though? OK - so you can use form just use the onSubmit and preventDefault with no action to not auto-reload the route.
mdynnl
mdynnl10mo ago
https://stackblitz.com/edit/vitejs-vite-tbg9wy?file=src%2FApp.tsx i admit i haven't been catching up with stuff recently, but is it this? i think most examples in solid router's README are missing contexts though you mentioned about preventing auto reload behavior if that's what you want, i think you can just throw inside the action and if you want to reload (revalidate) some cache, do something like throw revalidate('key') added more examples that might help to the above stackblitz
caseybaggz
caseybaggzOP10mo ago
Oh, interesting. throw void 0 looks like what i want exacly but how strange of a code read? Maybe I'll PR a new interface that is something like skipRevalidate or something? 🤔 That definitely works but there is still a caveat that because it's an action it re-triggers any createResource .
mdynnl
mdynnl10mo ago
that's probably because the component that createResource is in is re-rendering as a consequence of revalidation
Want results from more Discord servers?
Add your server