Skip to content

Commit 3b46858

Browse files
authored
call setConfig outside of useEffect (#3314)
1 parent d9ca25e commit 3b46858

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

wormhole-connect/src/AppRouter.tsx

+6-2
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ interface Props {
4242
config?: WormholeConnectConfig;
4343
}
4444

45+
let _HAS_SET_CONFIG = false;
46+
4547
// since this will be embedded, we'll have to use pseudo routes instead of relying on the url
4648
function AppRouter(props: Props) {
4749
const { classes } = useStyles();
@@ -53,7 +55,7 @@ function AppRouter(props: Props) {
5355
//
5456
// We don't allow config changes afterwards because they could lead to lots of
5557
// broken and undesired behavior.
56-
React.useEffect(() => {
58+
if (!_HAS_SET_CONFIG) {
5759
if (!isEmptyObject(props.config)) {
5860
setConfig(props.config);
5961
dispatch(clearTransfer());
@@ -63,7 +65,9 @@ function AppRouter(props: Props) {
6365
type: 'load',
6466
config: props.config,
6567
});
66-
}, []);
68+
69+
_HAS_SET_CONFIG = true;
70+
}
6771

6872
const route = useSelector((state: RootState) => state.router.route);
6973
const prevRoute = usePrevious(route);

wormhole-connect/src/config/events.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,15 @@ import {
99
export function wrapEventHandler(
1010
integrationHandler?: WormholeConnectEventHandler,
1111
): TriggerEventHandler {
12+
const host =
13+
typeof window === 'undefined' ? undefined : window.location?.host;
14+
1215
return function (event: WormholeConnectEventCore) {
1316
const eventWithMeta: WormholeConnectEvent = {
1417
meta: {
1518
version: CONNECT_VERSION,
1619
hash: CONNECT_GIT_HASH,
17-
host: window?.location?.host,
20+
host,
1821
},
1922
...event,
2023
};

wormhole-connect/src/telemetry/types.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ export interface WormholeConnectEventMeta {
9999
meta: {
100100
version: string;
101101
hash: string;
102-
host: string;
102+
host?: string;
103103
};
104104
}
105105

0 commit comments

Comments
 (0)