Skip to content

Commit c53c1eb

Browse files
committed
fix: Guard reo client methods
1 parent bc54b8d commit c53c1eb

File tree

3 files changed

+5
-7
lines changed

3 files changed

+5
-7
lines changed

src/features/auth/SignIn.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export function SignIn() {
5555

5656
const company = parseCompanyFromEmail(data.email);
5757
if (company) {
58-
reoClient.identify({
58+
reoClient?.identify?.({
5959
username: data.email,
6060
type: 'email',
6161
company,

src/integrations/reo/reo.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
import { useEffect } from 'react';
22
import { loadReoScript, ReoClient } from 'reodotdev';
33

4-
export let reoClient: ReoClient = {
5-
identify: () => undefined,
6-
};
4+
export let reoClient: ReoClient | undefined;
75

86
export function useReo() {
97
useEffect(() => {
108
if (import.meta.env.VITE_REO_DEV_CLIENT_ID && import.meta.env.VITE_REO_DEV_CLIENT_ID !== '0') {
119
loadReoScript({ clientID: import.meta.env.VITE_REO_DEV_CLIENT_ID })
12-
.then((Reo) => reoClient = Reo.init({ clientID: import.meta.env.VITE_REO_DEV_CLIENT_ID }));
10+
.then((Reo) => reoClient = Reo?.init?.({ clientID: import.meta.env.VITE_REO_DEV_CLIENT_ID }));
1311
}
1412
}, []);
1513
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
declare module 'reodotdev' {
22
export function loadReoScript({ clientID: string }): Promise<{
3-
init: ({ clientID: string }) => ReoClient;
3+
init: null | (({ clientID: string }) => ReoClient);
44
}>;
55

66
export interface ReoClient {
7-
identify: (person: { username: string; type: string; company: string; }) => void;
7+
identify: null | ((person: { username: string; type: string; company: string; }) => void);
88
}
99
}

0 commit comments

Comments
 (0)