You’re running into exactly the kind of “overreactivity” issue Convex talks about: the query is correctly reacting to the slug change, but that’s not what you want for UX. You have a few options, all based on patterns in the docs and Stack posts.
1. Buffer / stabilize the query result
Use a custom hook that keeps returning the last non‑undefined value instead of flipping to undefined immediately when arguments change. This avoids the brief “no game found” state while you handle navigation.
The pattern is described as useStableQuery:[Overreacting impact]
import { useRef } from "react";
import { useQuery } from "convex/react";
export const useStableQuery = ((name, ...args) => {
const result = useQuery(name, ...args);
const stored = useRef(result);
if (result !== undefined) {
stored.current = result;
}
return stored.current;
}) as typeof useQuery;
Then in your editor:
const game = useStableQuery(api.games.getBySlug, { slug });
Now when you submit the slug change:
- Run the mutation that updates the slug.
useStableQuery keeps returning the old game object while the new query runs.
- You immediately navigate/redirect to the new route.
- On the new route, you mount a fresh query for the new slug.
This is exactly the “less reactive” behavior the article suggests for filter/param‑driven UIs to avoid jarring loading/error flashes.[Overreacting recap]