Intended outcome:
when in a loading state, data is {} when it should be undefined:
const { data, loading } = useQuery(...)
if (loading === true) {
console.log(!!data) // this is `true`
}
Actual outcome:
data is {}
this is particularly bad if you're using a truth-y check on data to see if the query has completed:
const { data } = useQuery(...)
if (data) {
return <div>{data.user.name}</div> // this will pass in typescript, but fail at runtime
}
How to reproduce the issue:
AFAIK run any useQuery hook
Version
3.0.0
React Apollo 3.1.0 is now available, and includes https://github.com/apollographql/react-apollo/pull/3388. Thanks!
Most helpful comment
3388