How to prevent page reload from action? #391
-
I'm using Tauri with vanilla Solid/Router and am trying to use an action to submit a form for a chat feature but the action keeps triggering a page refresh and calling the cache function? I know in (super) Beta Solid-Start, there was the I've tried using To be clear, I'm wanting to call the action on a form submit, but prevent a page refresh since I'm managing a client state for real-time updates. Am I missing something here? Help! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 6 replies
-
and then prevent the default submit action and instead on submit do
|
Beta Was this translation helpful? Give feedback.
-
The revalidate is exposed through the response helpers now. So the action returns a response option that we basically handle through headers. See: https://github.com/solidjs/solid-router?tab=readme-ov-file#action If you don't want anything to revalidate send some garbage string through.. like In any case the page shouldn't refresh as our form handling prevents it. Unless you are handling form submit yourself in case you need to |
Beta Was this translation helpful? Give feedback.
@ryansolid ok, I figured it out. It was 200% my fault and I'm so so sorry for wasting your time. But, I think this is a great lesson for people who might find this thread.
TL;DR - I had
createAsync
/cache
vomit 🤮Basically, I was thinking (due to the naming convention) that if the
cache
functions ran once within 5m or so, it would just return the data and not make server calls. However, I noticed this was incorrect watching my network tab.To your point -
action
triggerscache
which by nature triggers thecreateAsync
.Answer
After analyzing my codebase, I updated my "root context" to hold a few more values that I now know I need in a lot of diff routes. Thus, I was able to eliminate a ton of