Skip to content

useApolloClientDevTools should not throw when given undefined as client #41

@MorganDavid

Description

@MorganDavid

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions