Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent infinite loop with useQuery #216

Open
chanm003 opened this issue Oct 29, 2019 · 0 comments
Open

Prevent infinite loop with useQuery #216

chanm003 opened this issue Oct 29, 2019 · 0 comments

Comments

@chanm003
Copy link

I am using 'apollo-link-error' to centrally log errors to the console. But I wanted to also from that same location in the code, use 'react-toast-notifications' to render an error message to the end user. The issue is that this second library changes state higher up on the component tree, and forces re-renders down the component tree, resulting in toast notifications being sent in an infinite loop.

Following code example works:
https://codesandbox.io/s/blissful-hypatia-9qsoy?fontsize=14

The below GQL is valid and works as I intend:

const GET_ITEMS = gql`
  {
    continents {
      name
    }
  }
`;

but if you were to alter the GQL to simulate a network or GQL error, to something invalid as shown below, my issue can be replicated:

const GET_ITEMS = gql`
  {
    invalidGQL {
      name
    }
  }
`;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant