Skip to content

Commit 8b2fc8f

Browse files
committed
source asset custom config fix
1 parent 91cf670 commit 8b2fc8f

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

wormhole-connect/src/views/Bridge/Bridge.tsx

+13-7
Original file line numberDiff line numberDiff line change
@@ -131,22 +131,28 @@ function Bridge() {
131131
}, [fromChain, toChain, receiving.address, dispatch]);
132132

133133
useEffect(() => {
134+
let active = true;
134135
const computeSrcTokens = async () => {
135136
const supported = await RouteOperator.allSupportedSourceTokens(
136137
config.tokens[destToken],
137138
fromChain,
138139
toChain,
139140
);
140-
dispatch(setSupportedSourceTokens(supported));
141-
const selectedIsSupported = isSupportedToken(token, supported);
142-
if (!selectedIsSupported) {
143-
dispatch(setToken(''));
144-
}
145-
if (supported.length === 1 && token === '') {
146-
dispatch(setToken(supported[0].key));
141+
if (active) {
142+
dispatch(setSupportedSourceTokens(supported));
143+
const selectedIsSupported = isSupportedToken(token, supported);
144+
if (!selectedIsSupported) {
145+
dispatch(setToken(''));
146+
}
147+
if (supported.length === 1 && token === '') {
148+
dispatch(setToken(supported[0].key));
149+
}
147150
}
148151
};
149152
computeSrcTokens();
153+
return () => {
154+
active = false;
155+
};
150156
// IMPORTANT: do not include token in dependency array
151157
}, [route, fromChain, destToken, dispatch]);
152158

0 commit comments

Comments
 (0)