Skip to content

Commit

Permalink
[fix] invalidate data after form submit (#6254)
Browse files Browse the repository at this point in the history
Fixes #6240
  • Loading branch information
Rich-Harris authored Aug 25, 2022
1 parent 0074d10 commit 4199b28
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/moody-plums-mate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'create-svelte': patch
---

Invalidate data after form submission
2 changes: 1 addition & 1 deletion packages/create-svelte/templates/default/src/lib/form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export function enhance(

const url = new URL(form.action);
url.search = url.hash = '';
invalidate(url.href);

This comment has been minimized.

Copy link
@Mlocik97

Mlocik97 Aug 25, 2022

Contributor

if we are not using url at all, do we need previous 2 lines?

invalidate();
} else if (error) {
error({ data, form, error: null, response });
} else {
Expand Down
2 changes: 1 addition & 1 deletion packages/kit/types/ambient.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ declare module '$app/navigation' {
opts?: { replaceState?: boolean; noscroll?: boolean; keepfocus?: boolean; state?: any }
): Promise<void>;
/**
* Causes any `load` functions belonging to the currently active page to re-run if they `fetch` the resource in question, or re-fetches data from a page endpoint if the invalidated resource is the page itself. If no argument is given, all resources will be invalidated. Returns a `Promise` that resolves when the page is subsequently updated.
* Causes any `load` functions belonging to the currently active page to re-run if they `fetch` the resource in question. If no argument is given, all resources will be invalidated. Returns a `Promise` that resolves when the page is subsequently updated.
* @param dependency The invalidated resource
*/
export function invalidate(dependency?: string | ((href: string) => boolean)): Promise<void>;
Expand Down

0 comments on commit 4199b28

Please sign in to comment.