TanStackT
TanStack12mo ago
13 replies
moderate-tomato

Invalidate route without reseting scroll

In my page I have a button which programmatically invalidate the current route:

const handleDelete = async () => {
  const response = await mutation.mutate(data.id);
  
  await router.invalidate({ sync: true, filter: (d) => d.fullPath === Route.fullPath });
};


It does work, but my scroll resets and goes to the top of the page. Is there a way to keep the scroll position or a better approach?

Thank you
Was this page helpful?