From c7e7aaabc12edde7834e3f20ee5decf63d96b5e9 Mon Sep 17 00:00:00 2001 From: Tony D'Addeo Date: Wed, 8 Apr 2026 15:01:06 -0500 Subject: [PATCH] Defer docs wagmi config creation Amp-Thread-ID: https://ampcode.com/threads/T-019d6e8e-e71a-73fe-a330-af49b3aed413 Co-authored-by: Amp --- src/components/Providers.tsx | 17 ++++++++++------- src/wagmi.config.ts | 4 ++-- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/components/Providers.tsx b/src/components/Providers.tsx index c58f489f..8ef50f98 100644 --- a/src/components/Providers.tsx +++ b/src/components/Providers.tsx @@ -2,7 +2,7 @@ import { QueryClient, QueryClientProvider } from '@tanstack/react-query' import { Json } from 'ox' -import type React from 'react' +import * as React from 'react' import { WagmiProvider } from 'wagmi' import * as WagmiConfig from '../wagmi.config' import { DemoContextProvider } from './DemoContext' @@ -15,11 +15,6 @@ const queryClient = new QueryClient({ }, }) -const config = WagmiConfig.getConfig() -const mipdConfig = WagmiConfig.getConfig({ - multiInjectedProviderDiscovery: true, -}) - export default function Providers({ children, mipd, @@ -27,8 +22,16 @@ export default function Providers({ children: React.ReactNode mipd?: boolean }) { + const config = React.useMemo( + () => + WagmiConfig.getConfig({ + multiInjectedProviderDiscovery: Boolean(mipd), + }), + [mipd], + ) + return ( - + {children} diff --git a/src/wagmi.config.ts b/src/wagmi.config.ts index dd49bc67..a9e8ef42 100644 --- a/src/wagmi.config.ts +++ b/src/wagmi.config.ts @@ -99,7 +99,7 @@ export namespace getConfig { export type Options = Partial> } -export const config = getConfig() +export type Config = ReturnType export const queryClient = new QueryClient() @@ -123,6 +123,6 @@ export function useWebAuthnConnector() { declare module 'wagmi' { interface Register { - config: typeof config + config: Config } }