#How to prevent page reload on action / query

5 messages · Page 1 of 1 (latest)

wispy jewel
#

I use lazy loading, defining preload function, deferStream, and I can see visibly the data added in real time to the page but it forcefully refreshes the page
How do I stop this? I didn't think server actions were meant to do this anyways


const addMenuItemToDatabase = action(async (formData: FormData) => {
  "use server";
  ...
return reload({
      revalidate: queryMenuItems.keyFor(formData.get("userId")!.toString()),
    });
});
export const route = {
  preload() {
    return queryMenuItems(useSessionContext().userData.id);
  },
} satisfies RouteDefinition;

and then a simple server query

wispy jewel
#

Ok well it work in a prod. server but not dev. That's all.

gray gull
#

like you might be importing a server module and its not being tree-shaken well

wispy jewel