Skip to content

Commit

Permalink
feat: add error boundaries and loading states to provider setup
Browse files Browse the repository at this point in the history
  • Loading branch information
devin-ai-integration[bot] committed Nov 13, 2024
1 parent 9973f17 commit fc12cfc
Showing 1 changed file with 26 additions and 13 deletions.
39 changes: 26 additions & 13 deletions components/ScaffoldEthAppWithProviders.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,22 @@ import { BlockieAvatar } from "~~/components/scaffold-eth";
import { ProgressBar } from "~~/components/scaffold-eth/ProgressBar";
import { useInitializeNativeCurrencyPrice } from "~~/hooks/scaffold-eth";
import { wagmiConfig } from "~~/services/web3/wagmiConfig";
import ErrorBoundary from "~~/components/ErrorBoundary";

import "@rainbow-me/rainbowkit/styles.css";

const ScaffoldEthApp = ({ children }: { children: React.ReactNode }) => {
useInitializeNativeCurrencyPrice();

return (
<>
<ErrorBoundary>
<div className="flex flex-col min-h-screen">
<Header />
<main className="relative flex flex-col flex-1">{children}</main>
<Footer />
</div>
<Toaster />
</>
</ErrorBoundary>
);
};

Expand All @@ -45,17 +48,27 @@ export const ScaffoldEthAppWithProviders = ({ children }: { children: React.Reac
setMounted(true);
}, []);

if (!mounted) {
return (
<div className="flex items-center justify-center min-h-screen">
<div className="animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900"></div>
</div>
);
}

return (
<WagmiProvider config={wagmiConfig}>
<QueryClientProvider client={queryClient}>
<ProgressBar />
<RainbowKitProvider
avatar={BlockieAvatar}
theme={mounted ? (isDarkMode ? darkTheme() : lightTheme()) : lightTheme()}
>
<ScaffoldEthApp>{children}</ScaffoldEthApp>
</RainbowKitProvider>
</QueryClientProvider>
</WagmiProvider>
<ErrorBoundary>
<WagmiProvider config={wagmiConfig}>
<QueryClientProvider client={queryClient}>
<ProgressBar />
<RainbowKitProvider
avatar={BlockieAvatar}
theme={isDarkMode ? darkTheme() : lightTheme()}
>
<ScaffoldEthApp>{children}</ScaffoldEthApp>
</RainbowKitProvider>
</QueryClientProvider>
</WagmiProvider>
</ErrorBoundary>
);
};

0 comments on commit fc12cfc

Please sign in to comment.