Skip to content

Commit

Permalink
fix(frontend): eliminate hydration errors
Browse files Browse the repository at this point in the history
interestingly enough, lazily loading animatepresence/lazymotion will lead to hydration errors
  • Loading branch information
AritroSaha10 committed Jun 10, 2024
1 parent b69c1f0 commit 66c2368
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 87 deletions.
143 changes: 68 additions & 75 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
"eslint-config-next": "13.4.12",
"firebase": "^10.1.0",
"fns": "^1.0.0",
"framer-motion": "^10.16.1",
"next": "^14.0.0",
"framer-motion": "^10.18.0",
"next": "^14.2.3",
"nextjs-google-analytics": "^2.3.3",
"postcss": "8.4.27",
"react": "18.2.0",
Expand Down
14 changes: 4 additions & 10 deletions frontend/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@ import { Poppins } from "next/font/google";
import { QueryClient } from "react-query";

import "@/styles/globals.css";
import { AnimatePresence, LazyMotion } from "framer-motion";

const FirebaseAuthProvider = dynamic(() =>
import("@/components/FirebaseAuthContext").then((mod) => mod.FirebaseAuthProvider),
);
const QueryClientProvider = dynamic(() => import("react-query").then((mod) => mod.QueryClientProvider));
const ThemeProvider = dynamic(() => import("@material-tailwind/react").then((mod) => mod.ThemeProvider));
const AnimatePresence = dynamic(() => import("framer-motion").then((mod) => mod.AnimatePresence));
const LazyMotion = dynamic(() => import("framer-motion").then((mod) => mod.LazyMotion));
const GoogleAnalytics = dynamic(() => import("nextjs-google-analytics").then((mod) => mod.GoogleAnalytics));
const GoogleOAuthProvider = dynamic(() => import("@react-oauth/google").then((mod) => mod.GoogleOAuthProvider));

Expand All @@ -33,15 +32,10 @@ export default function App({ Component, pageProps }: AppProps) {
<QueryClientProvider client={queryClient}>
<GoogleOAuthProvider clientId={process.env.NEXT_PUBLIC_GCLOUD_CLIENT_ID ?? ""}>
<FirebaseAuthProvider>
<LazyMotion
features={domMax}
strict
>
<LazyMotion features={domMax} strict>
<AnimatePresence mode="wait">
<>
<GoogleAnalytics trackPageViews />
<Component {...pageProps} />
</>
<GoogleAnalytics trackPageViews />
<Component {...pageProps} />
</AnimatePresence>
</LazyMotion>
</FirebaseAuthProvider>
Expand Down

0 comments on commit 66c2368

Please sign in to comment.