react-apollo-hooks icon indicating copy to clipboard operation
react-apollo-hooks copied to clipboard

data is no longer defined in 0.5.0 before data is loaded

Open greggb opened this issue 6 years ago • 2 comments

In v0.4.5 the following code would load without error:

const {
    data: { subData, moreSubData }, // we want these keys specifically
    loading,
} = useQuery(someQuery);

In v0.5.0 that code errors with Uncaught TypeError: Cannot read property 'subData' of undefined. It's solved by pulling those keys out of data after checking for loading.

This really starts to hurt if we have multiple queries where data is already defined in a previous query. Was it an intentional change to support the official projects behavior?

greggb avatar Aug 09 '19 15:08 greggb

same issue for me.

is there any reason for this change?

jngcii avatar Aug 24 '19 01:08 jngcii

Looking for an update on this behavior.

mekhami avatar Sep 09 '19 17:09 mekhami