I’m experiencing a strange behaviour in my QwikCity application where pending actions update the DOM of a new route after navigation, replacing the new route’s contents with the contents of the previous route.
Here’s a simplified example of my code:
export const useDeleteTask = routeAction$(async (data) => {
await new Promise((resolve) => setTimeout(resolve, 3000));
const index = db.tasks.findIndex((task) => task.id === String(data.id));
if (index > -1) {
db.tasks.splice(index, 1);
}
});
// ...
<button onClick$={async () => await deleteTask.submit({ id: task.id })}>
Delete
</button>
If say I am on route /
and press the “Delete” button, then navigate to the /otherroute
, after 3 seconds, the contents of /otherroute
is replaced by the content of the /
route.
Am I doing something wrong here or is it how Qwik works?