You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When changing the query passed to useQuery before the previous query has loaded, the new query is requested and doesn't stay in a loading state forever.
constqueries={one: gql` query AllPeopleWithoutName { people { id } } `,two: gql` query AllPeopleWithName { people { id name } } `};functionApp(){const[query,setQuery]=useState("one");const{ data, error, loading }=useQuery(queries[query]);return(<div><buttondisabled={query==="two"}onClick={()=>{setQuery("two");}}>
Change Query
</button><pre>{JSON.stringify({ data, error, loading },null,2)}</pre></div>);}
Actual outcome:
When changing the query passed to useQuery before the previous query has loaded, the new query is never requested and stays in a loading state forever.
How to reproduce the issue:
If you click the button in the sandbox below before the first query finishes, the second query is never requested and it stays in the loading state forever.
If you wait until the first query loads and then click the button to change the query, the second one loads fine.
Intended outcome:
When changing the query passed to useQuery before the previous query has loaded, the new query is requested and doesn't stay in a loading state forever.
Actual outcome:
When changing the query passed to useQuery before the previous query has loaded, the new query is never requested and stays in a loading state forever.
How to reproduce the issue:
If you click the button in the sandbox below before the first query finishes, the second query is never requested and it stays in the loading state forever.
If you wait until the first query loads and then click the button to change the query, the second one loads fine.
https://codesandbox.io/s/musing-forest-z0crg?file=/src/index.js
Versions
This issue didn't occur in 3.3.21 and started occurring in 3.4.0
The text was updated successfully, but these errors were encountered: