jaydenseric / graphql-react

A GraphQL client for React using modern context and hooks APIs that is lightweight (< 4 kB) but powerful; the first Relay and Apollo alternative with server side rendering.
https://npm.im/graphql-react
MIT License
718 stars 22 forks source link

Prevent a React dev warning when a loading Query component is unmounted #10

Closed jaydenseric closed 6 years ago

jaydenseric commented 6 years ago

If you unmount a Query component (specifically the GraphQLQuery component within it) while it is still loading a query, you see a React dev warning like this:

screen shot 2018-09-26 at 3 23 12 pm

This is because a setState call happens after the request is complete to update the loading state as false, see here. This should be prevented from happening after the component has unmounted.

xjamundx commented 6 years ago

I'm doing a thing where I use the Redirect component from @reach/router and see this a lot.

jaydenseric commented 6 years ago

Yep, it's annoying but at least harmless. I hope to be able to get to it this weekend; I've recently been busy soft-launching https://enamor.app (which BTW happens to use graphql-react ✌️).

jaydenseric commented 6 years ago

🚢 Fixed in v3.