-
Notifications
You must be signed in to change notification settings - Fork 619
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: only display provided chains in ChainModal #1156
fix: only display provided chains in ChainModal #1156
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
@greg-schrammel is attempting to deploy a commit to the rainbowdotme Team on Vercel. A member of the Team first needs to authorize it. |
const stopSwitching = useCallback(() => { | ||
setSwitchingToChain(null); | ||
onClose(); | ||
}, [onClose]); | ||
|
||
useEffect(() => { | ||
if (!activeConnector) { | ||
return; | ||
} | ||
|
||
const stopSwitching = () => { | ||
setSwitchingToChain(null); | ||
onClose(); | ||
}; | ||
|
||
let provider: any; | ||
activeConnector?.getProvider?.().then((provider_: any) => { | ||
provider = provider_; | ||
provider.on('chainChanged', stopSwitching); | ||
}); | ||
|
||
return () => { | ||
provider?.removeListener('chainChanged', stopSwitching); | ||
}; | ||
}, [activeConnector, onClose, stopSwitching]); | ||
|
||
useEffect(() => { | ||
if (networkError && networkError.name === 'UserRejectedRequestError') { | ||
stopSwitching(); | ||
} | ||
}, [networkError, stopSwitching]); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm pretty sure this is the same as this
const { chains, pendingChainId, reset, switchNetwork } = useSwitchNetwork({
onSettled: () => {
reset(); // reset mutation variables (eg. pendingChainId)
onClose();
},
});
didn't find any differences in my testing, but easy to revert if the useEffects where proposital
Looking good 👌 |
No dependency changes detected. Learn more about Socket for GitHub ↗︎ 👍 No dependency changes detected in pull request |
done! I'm not good with changeset messages, open to rephrasing |
f685782
to
35e653d
Compare
I have a specific use case where the app is optimism only, but we provide a embedded socket.tech bridge widget
I don't want to confuse users enabling all chains to be connected thru the modal, but they must be supported and only switch when bridge asks to
if I do this:
I expect to see this
but get this instead
we could replace the
provideRainbowKitChains
inuseRainbowKitChains
with a map likethis refactor (that's not in this pr) would make the second screenshot have the chain logos