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

useApolloClientDevTools should not throw when given undefined as client #41

Open
MorganDavid opened this issue May 22, 2024 · 0 comments

Comments

@MorganDavid
Copy link

our usecase requires loading client in a useEffect after some data has loaded. e.g.

  useEffect(() => {
    (async () => {
      const _persistor = cachePersistorFactory(cache);
      await _persistor.restore();
      const _client = clientFactory(cache, loginProviderRef);
      setCachePersistor(_persistor);
      setClient(_client);
    })();
  }, [loginProviderRef]);

This means we can't use this hook because it throws an error when client is undefined (on the first render) and it's not possible to render hooks conditionally.

Expected Behaviour:
useApolloClientDevTools does nothing if client is undefined.

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