Skip to content

Commit

Permalink
remove Header and Footer from _app - alter _app to work with new page…
Browse files Browse the repository at this point in the history
… layouts
  • Loading branch information
Spencer-Sch committed Nov 14, 2023
1 parent 861f534 commit cb0b395
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions packages/nextjs/pages/_app.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,28 @@
import { useEffect, useState } from "react";
import { ReactElement, ReactNode, useEffect, useState } from "react";
import type { AppProps } from "next/app";
import { RainbowKitProvider, darkTheme, lightTheme } from "@rainbow-me/rainbowkit";
import "@rainbow-me/rainbowkit/styles.css";
import type { NextPage } from "next";
import NextNProgress from "nextjs-progressbar";
import { Toaster } from "react-hot-toast";
import { useDarkMode } from "usehooks-ts";
import { WagmiConfig } from "wagmi";
import { Footer } from "~~/components/Footer";
import { Header } from "~~/components/Header";
import { BlockieAvatar } from "~~/components/scaffold-eth";
import { useNativeCurrencyPrice } from "~~/hooks/scaffold-eth";
import { useGlobalState } from "~~/services/store/store";
import { wagmiConfig } from "~~/services/web3/wagmiConfig";
import { appChains } from "~~/services/web3/wagmiConnectors";
import "~~/styles/globals.css";

const ScaffoldEthApp = ({ Component, pageProps }: AppProps) => {
export type NextPageWithLayout<P = Record<string, never>, IP = P> = NextPage<P, IP> & {
getLayout?: (page: ReactElement) => ReactNode;
};

type AppPropsWithLayout = AppProps & {
Component: NextPageWithLayout;
};

const ScaffoldEthApp = ({ Component, pageProps }: AppPropsWithLayout) => {
const price = useNativeCurrencyPrice();
const setNativeCurrencyPrice = useGlobalState(state => state.setNativeCurrencyPrice);
// This variable is required for initial client side rendering of correct theme for RainbowKit
Expand All @@ -32,6 +39,8 @@ const ScaffoldEthApp = ({ Component, pageProps }: AppProps) => {
setIsDarkTheme(isDarkMode);
}, [isDarkMode]);

const getLayout = Component.getLayout || (page => page);

return (
<WagmiConfig config={wagmiConfig}>
<NextNProgress />
Expand All @@ -40,13 +49,7 @@ const ScaffoldEthApp = ({ Component, pageProps }: AppProps) => {
avatar={BlockieAvatar}
theme={isDarkTheme ? darkTheme() : lightTheme()}
>
<div className="flex flex-col min-h-screen">
<Header />
<main className="relative flex flex-col justify-center flex-1">
<Component {...pageProps} />
</main>
<Footer />
</div>
<div className="flex flex-col min-h-screen">{getLayout(<Component {...pageProps} />)}</div>
<Toaster />
</RainbowKitProvider>
</WagmiConfig>
Expand Down

0 comments on commit cb0b395

Please sign in to comment.