Fix Providers QueryClient lifecycle and client-only mount gating#66
Fix Providers QueryClient lifecycle and client-only mount gating#66SIDDHANTCOOKIE wants to merge 2 commits into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughProviders now lazily creates a per-instance QueryClient and tracks mount state; it passes the mount flag into Changes
Sequence Diagram(s)sequenceDiagram
participant App as App (renders)
participant Providers as Providers
participant QueryClient as QueryClient (instance)
participant Wagmi as WagmiProvider
participant QueryProv as QueryClientProvider
participant Rainbow as RainbowKitProvider
App->>Providers: mount
Providers->>QueryClient: create via useState(() => new QueryClient())
Providers->>Providers: useEffect -> set mounted = true
Providers->>Wagmi: render with reconnectOnMount = mounted
Providers->>QueryProv: wrap children with QueryClientProvider(QueryClient)
QueryProv->>Rainbow: wrap children
Rainbow->>App: children + Toaster rendered
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Suggested labels
Poem
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@components/providers.tsx`:
- Line 18: The Providers component currently returns null when the local state
variable mounted is false, which hides the entire app shell; change it so only
wallet-dependent initialization is gated: keep rendering the full Providers tree
(including Navbar, main, Footer) regardless of mounted, and move the
wallet-specific logic or client-only wallet providers (references: Providers
component, mounted state, any useWallet/WalletProvider instances) behind the
mounted check or into a child component that renders after mount; alternatively
relocate wallet providers lower in the tree so SSR output is preserved while
still deferring client-only wallet initialization.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: 4c45379d-8498-481e-9433-df4bda28097a
📒 Files selected for processing (1)
components/providers.tsx
Addressed Issues:
Closes #42
This PR applies only the requested changes in
components/providers.tsxto fix two critical issues:QueryClientanti-patternconst queryClient = new QueryClient();useStateimport from ReactProviderswith:const [queryClient] = useState(() => new QueryClient());indexedDB is not definederror (Wagmi/RainbowKit)const [mounted, setMounted] = useState(false);useEffect(() => { setMounted(true); }, []);if (!mounted) return null;<WagmiProvider>tree now renders only after client mount.Scope is strictly limited to
components/providers.tsxwith no other file changes.Screenshots/Recordings:
TODO: If applicable, add screenshots or recordings that demonstrate the interface before and after the changes.
Additional Notes:
AI Usage Disclosure:
We encourage contributors to use AI tools responsibly when creating Pull Requests. While AI can be a valuable aid, it is essential to ensure that your contributions meet the task requirements, build successfully, include relevant tests, and pass all linters. Submissions that do not meet these standards may be closed without warning to maintain the quality and integrity of the project. Please take the time to understand the changes you are proposing and their impact. AI slop is strongly discouraged and may lead to banning and blocking. Do not spam our repos with AI slop.
Check one of the checkboxes below:
I have used the following AI models and tools: GPT
Checklist
Summary by CodeRabbit