-
Notifications
You must be signed in to change notification settings - Fork 160
refactor(tokenselector): 14 - atom-based architecture & prop drilling removal #6663
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
base: feat/token-selector-13
Are you sure you want to change the base?
Conversation
- Move token list view state to `tokenListViewAtom` using Jotai - Remove prop drilling through `SelectTokenModal` -> `TokensContent` -> `TokensVirtualList` - Extract `SelectTokenModalShell` to reduce LOC in `SelectTokenModal/index.tsx` - Implement `useHydrateAtoms` + `useLayoutEffect` for flicker-free state sync - Add `useResetTokenListViewState` for clean unmounts - Remove TODO from `types.ts`
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the ✨ Finishing touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…rops - Move atom hydration from SelectTokenModal to controllerAtomHydration hook - Split controllerState.ts into cohesive hooks (tokenData, tokenSelection, widgetUI) - Reduce SelectTokenModal props from 27 to ~17 (remove data props, keep UI callbacks) - Gate hydration by shouldRender to prevent unnecessary updates - Update Cosmos fixtures to use atom provider
1e60c6e to
01342a5
Compare
Summary
Major refactor of the Token Selector architecture to improve performance, maintainability, and user experience. This PR introduces a Jotai-based state management system, eliminates deep prop drilling, and implements a cleaner controller-view pattern.
🏗 Architecture & State Management
tokenListViewAtomto manage view state (tokens, loading, search, context).SelectTokenModaltocontrollerAtomHydrationhook.SelectTokenModalprops from ~35 to ~21 (UI/callbacks only, organized into logical interfaces).shouldRenderto prevent unnecessary updates.controllerState.tsinto cohesive hooks:tokenDataHooks.ts(Data sources)tokenSelectionHooks.ts(Selection logic)widgetUIState.ts(UI handlers)useHydrateAtoms+useLayoutEffectpattern for seamless state synchronization.⚡️ Performance & Cleanup
TokensContent,TokensVirtualList, andTokenSearchResultsnow read directly from atoms instead of receiving drilled props.useResetTokenListViewStateto ensure state clears properly on widget close.SelectTokenModalShellandTokenColumnContentto reduce re-renders and file size.displayLpTokenListsandonClearRecentTokensare properly hydrated/passed to avoid state drift.📱 UI/UX Improvements
MobileChainSelectorandMobileChainPanelPortalfor better mobile navigation.ChainPanelandChainsSelectorwith improved styling and logic.Test Plan
displayLpTokenLists)SelectTokenModal/index.cosmos.tsxto useCosmosAtomProvider.