From 19fced9d5e6548cab3c37af375b8398d78b2c57d Mon Sep 17 00:00:00 2001 From: David Colon <38386583+Da-Colon@users.noreply.github.com> Date: Wed, 21 Feb 2024 10:03:43 -0500 Subject: [PATCH] move providers out of App directory --- app/layout.tsx | 47 +++----------------------------- src/providers/Providers.tsx | 54 +++++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+), 44 deletions(-) create mode 100644 src/providers/Providers.tsx diff --git a/app/layout.tsx b/app/layout.tsx index 7bde3d06da..c49bffdac5 100644 --- a/app/layout.tsx +++ b/app/layout.tsx @@ -1,25 +1,13 @@ 'use client'; -import { ApolloProvider } from '@apollo/client'; -import { ChakraProvider } from '@chakra-ui/react'; -import { theme } from '@decent-org/fractal-ui'; import '@fontsource/ibm-plex-mono'; import '@fontsource/ibm-plex-sans'; -import { midnightTheme, RainbowKitProvider } from '@rainbow-me/rainbowkit'; import 'i18next'; import { ReactNode, useEffect } from 'react'; -import { ToastContainer } from 'react-toastify'; import 'react-toastify/dist/ReactToastify.min.css'; -import { WagmiConfig } from 'wagmi'; -import { ModalProvider } from '../src/components/ui/modals/ModalProvider'; -import Layout from '../src/components/ui/page/Layout'; -import { ErrorFallback } from '../src/components/ui/utils/ErrorFallback'; import { APP_NAME } from '../src/constants/common'; -import graphQLClient from '../src/graphql'; -import { FractalErrorBoundary, initErrorLogging } from '../src/helpers/errorLogging'; -import { AppProvider } from '../src/providers/App/AppProvider'; -import { NetworkConfigProvider } from '../src/providers/NetworkConfig/NetworkConfigProvider'; -import { chains, wagmiConfig } from '../src/providers/NetworkConfig/rainbow-kit.config'; +import { initErrorLogging } from '../src/helpers/errorLogging'; +import Providers from '../src/providers/Providers'; export default function RootLayout({ children }: { children: ReactNode }) { useEffect(() => { @@ -90,36 +78,7 @@ export default function RootLayout({ children }: { children: ReactNode }) { {APP_NAME} - - }> - - - - - - - - {children} - - - - - - - - + {children} ); diff --git a/src/providers/Providers.tsx b/src/providers/Providers.tsx new file mode 100644 index 0000000000..4a871cdbfb --- /dev/null +++ b/src/providers/Providers.tsx @@ -0,0 +1,54 @@ +'use client'; +import { ApolloProvider } from '@apollo/client'; +import { ChakraProvider } from '@chakra-ui/react'; +import { theme } from '@decent-org/fractal-ui'; +import { RainbowKitProvider, midnightTheme } from '@rainbow-me/rainbowkit'; +import { ReactNode, useEffect } from 'react'; +import { ToastContainer } from 'react-toastify'; +import { WagmiConfig } from 'wagmi'; +import { ModalProvider } from '../components/ui/modals/ModalProvider'; +import Layout from '../components/ui/page/Layout'; +import { ErrorFallback } from '../components/ui/utils/ErrorFallback'; +import graphQLClient from '../graphql'; +import { FractalErrorBoundary, initErrorLogging } from '../helpers/errorLogging'; +import { AppProvider } from './App/AppProvider'; +import { NetworkConfigProvider } from './NetworkConfig/NetworkConfigProvider'; +import { wagmiConfig, chains } from './NetworkConfig/rainbow-kit.config'; + +export default function Providers({ children }: { children: ReactNode }) { + useEffect(() => { + initErrorLogging(); + }, []); + return ( + + }> + + + + + + + + {children} + + + + + + + + + ); +}