-
Notifications
You must be signed in to change notification settings - Fork 0
fix: chain group picker #10
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
Conversation
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.
Pull Request Overview
This pull request fixes a wallet selection state management issue in the RainbowKit library by resetting the selected chain group when navigating to the chain group selection step, preventing unintended state persistence across navigation.
- Updated package version from
2.2.7to2.2.8 - Added state reset logic for both desktop and mobile wallet connection flows
- Ensures
selectedChainGroupIdis cleared when entering theSelectChainGroupstep
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
MobileOptions.tsx |
Added conditional logic to reset selectedChainGroupId when entering chain group selection |
DesktopOptions.tsx |
Added similar state reset logic for desktop wallet connection flow |
package.json |
Bumped version to reflect the bug fix changes |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| if ( | ||
| walletStep === MobileWalletStep.SelectChainGroup && | ||
| selectedChainGroupId | ||
| ) { | ||
| setSelectedChainGroupId(undefined); | ||
| } |
Copilot
AI
Oct 10, 2025
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.
This state update in the component body will cause an infinite re-render loop. The setSelectedChainGroupId(undefined) call will trigger a re-render, which will execute this condition again. Move this logic inside a useEffect hook with appropriate dependencies.
| if ( | |
| walletStep === MobileWalletStep.SelectChainGroup && | |
| selectedChainGroupId | |
| ) { | |
| setSelectedChainGroupId(undefined); | |
| } | |
| useEffect(() => { | |
| if ( | |
| walletStep === MobileWalletStep.SelectChainGroup && | |
| selectedChainGroupId | |
| ) { | |
| setSelectedChainGroupId(undefined); | |
| } | |
| }, [walletStep, selectedChainGroupId]); |
| if (walletStep === WalletStep.SelectChainGroup && selectedChainGroupId) { | ||
| setSelectedChainGroupId(undefined); | ||
| } |
Copilot
AI
Oct 10, 2025
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.
This state update in the component body will cause an infinite re-render loop. The setSelectedChainGroupId(undefined) call will trigger a re-render, which will execute this condition again. Move this logic inside a useEffect hook with appropriate dependencies.
| if (walletStep === WalletStep.SelectChainGroup && selectedChainGroupId) { | |
| setSelectedChainGroupId(undefined); | |
| } | |
| useEffect(() => { | |
| if (walletStep === WalletStep.SelectChainGroup && selectedChainGroupId) { | |
| setSelectedChainGroupId(undefined); | |
| } | |
| }, [walletStep, selectedChainGroupId]); |
e48eb99 to
eb5d5d8
Compare
eb5d5d8 to
7742209
Compare
This pull request updates the
@stakekit/rainbowkitpackage version and introduces a fix for wallet selection behavior in both desktop and mobile connection options. The main improvement ensures that theselectedChainGroupIdis reset when navigating to the chain group selection step, preventing unintended state persistence.Version update:
2.2.7to2.2.8inpackage.jsonto reflect the new changes.State management fixes:
DesktopOptions.tsx, added logic to resetselectedChainGroupIdwhen the user navigates to theSelectChainGroupstep, ensuring the correct selection state.MobileOptions.tsx, applied the same fix for mobile by resettingselectedChainGroupIdwhen the user is at theSelectChainGroupstep.