From beac1711a10a0af648be8ed4d32f7403cf3ad21d Mon Sep 17 00:00:00 2001 From: Nick Adamson Date: Thu, 14 Dec 2023 11:20:16 -0800 Subject: [PATCH] =?UTF-8?q?=E2=8F=AA=EF=B8=8F=20(docs):=20add=20back=20com?= =?UTF-8?q?ments=20lost=20in=20merge?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/context/GRPCProvider.tsx | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/context/GRPCProvider.tsx b/src/context/GRPCProvider.tsx index b6e5abd..35e2188 100644 --- a/src/context/GRPCProvider.tsx +++ b/src/context/GRPCProvider.tsx @@ -27,18 +27,19 @@ const getInterceptors = (logger: ReturnType) => { return [loggerInterceptor]; }; +// Create gRPC-web transport with the given configuration. const getWebTransport = (endpoint: string) => createGrpcWebTransport({ baseUrl: endpoint, - credentials: 'include', // necessary for authentication to be set + credentials: 'include', // Necessary for authentication to be set. }); /** * Props for the GRPCProvider component. */ export interface GRPCProviderProps extends PropsWithChildren { - endpoint?: string; - useDefaultReactQueryProvider?: boolean; + endpoint?: string; // Optional - overrides endpoint to use for the gRPC-web transport. + useDefaultReactQueryProvider?: boolean; // Whether to use the default React Query Provider. } /** @@ -49,12 +50,13 @@ export interface GRPCProviderProps extends PropsWithChildren { * @returns The component wrapped with the TransportProvider and optionally the QueryClientProvider. */ export function GRPCProvider({ - endpoint = GRPC_ENDPOINT, - useDefaultReactQueryProvider = true, + endpoint = GRPC_ENDPOINT, // Default to the Production Trade-API endpoint. + useDefaultReactQueryProvider = true, // Default to true to use the QueryClientProvider. children, }: GRPCProviderProps) { const logger = useLogger(); // Use the logger context. const transport: Transport = useMemo(() => { + // Memoize the transport to avoid unnecessary re-renders. return { ...getWebTransport(endpoint), interceptors: getInterceptors(logger),