I have a router state "refetch" that triggers the component to refetch its data (instead of using the cached one), but when it's done, I'd like to toggle that state back to avoid an infinite loop. What is the best way to change state parameters? Or this approach is wrong?
const { state } = useLocation<{ refetch: boolean }>()
const query = useQuery<....>()
useEffect(() => {
if (state.refetch) {
query.refetch()
state.refetch = false // feels wrong to me
}
}, [query, state])