diff --git a/lib/shared/identity-client-context.js b/lib/shared/identity-client-context.js --- a/lib/shared/identity-client-context.js +++ b/lib/shared/identity-client-context.js @@ -5,7 +5,7 @@ import type { IdentityServiceClient } from '../types/identity-service-types.js'; export type IdentityClientContextType = { - +identityClient: ?IdentityServiceClient, + +identityClient: IdentityServiceClient, }; const IdentityClientContext: React.Context = diff --git a/native/identity-service/identity-service-context-provider.react.js b/native/identity-service/identity-service-context-provider.react.js --- a/native/identity-service/identity-service-context-provider.react.js +++ b/native/identity-service/identity-service-context-provider.react.js @@ -60,7 +60,7 @@ return { deviceID, userID, accessToken }; }, []); - const client = React.useMemo(() => { + const client = React.useMemo(() => { return { deleteUser: async () => { const { deviceID, userID, accessToken } = await getAuthMetadata(); diff --git a/web/grpc/identity-service-context-provider.react.js b/web/grpc/identity-service-context-provider.react.js --- a/web/grpc/identity-service-context-provider.react.js +++ b/web/grpc/identity-service-context-provider.react.js @@ -3,7 +3,6 @@ import * as React from 'react'; import { IdentityClientContext } from 'lib/shared/identity-client-context.js'; -import type { IdentityServiceClient } from 'lib/types/identity-service-types.js'; import { IdentityServiceClientWrapper } from './identity-service-client-wrapper.js'; import { useSelector } from '../redux/redux-utils.js'; @@ -13,7 +12,6 @@ }; function IdentityServiceContextProvider(props: Props): React.Node { const { children } = props; - const [client, setClient] = React.useState(); const userID = useSelector(state => state.currentUserInfo?.id); const accessToken = useSelector(state => state.commServicesAccessToken); @@ -21,7 +19,7 @@ state => state.cryptoStore?.primaryIdentityKeys.ed25519, ); - React.useEffect(() => { + const client = React.useMemo(() => { let authLayer = null; if (userID && deviceID && accessToken) { authLayer = { @@ -30,7 +28,7 @@ commServicesAccessToken: accessToken, }; } - setClient(new IdentityServiceClientWrapper(authLayer)); + return new IdentityServiceClientWrapper(authLayer); }, [accessToken, deviceID, userID]); const value = React.useMemo(