1
- import React , { useCallback , useContext , useEffect } from 'react' ;
1
+ import React , { useCallback , useContext , useEffect , useRef } from 'react' ;
2
2
import { useDispatch , useSelector } from 'react-redux' ;
3
3
import { makeStyles } from 'tss-react/mui' ;
4
4
@@ -42,14 +42,14 @@ interface Props {
42
42
config ?: WormholeConnectConfig ;
43
43
}
44
44
45
- let _HAS_SET_CONFIG_SSG = false ;
46
-
47
45
// since this will be embedded, we'll have to use pseudo routes instead of relying on the url
48
46
function AppRouter ( props : Props ) {
49
47
const { classes } = useStyles ( ) ;
50
48
const dispatch = useDispatch ( ) ;
51
49
const routeContext = useContext ( RouteContext ) ;
52
50
51
+ const hasSetSsgConfig = useRef ( false ) ;
52
+
53
53
// We update the global config once when WormholeConnect is first mounted, if a custom
54
54
// config was provided.
55
55
//
@@ -58,7 +58,6 @@ function AppRouter(props: Props) {
58
58
const loadConfig = useCallback ( ( customConfig : WormholeConnectConfig ) => {
59
59
if ( ! isEmptyObject ( customConfig ) ) {
60
60
setConfig ( customConfig ) ;
61
- dispatch ( clearTransfer ( ) ) ;
62
61
}
63
62
64
63
config . triggerEvent ( {
@@ -67,12 +66,12 @@ function AppRouter(props: Props) {
67
66
} ) ;
68
67
} , [ ] ) ;
69
68
70
- if ( ! _HAS_SET_CONFIG_SSG ) {
69
+ if ( ! hasSetSsgConfig . current ) {
71
70
// This runs once in SSG step (server-side pre-rendering)
72
71
if ( props . config ) {
73
72
loadConfig ( props . config ) ;
74
73
}
75
- _HAS_SET_CONFIG_SSG = true ;
74
+ hasSetSsgConfig . current = true ;
76
75
}
77
76
78
77
useEffect ( ( ) => {
0 commit comments