Skip to content

Commit

Permalink
feat: add useEffect to _app.tsx to clear error whenever Component cha…
Browse files Browse the repository at this point in the history
…nges
  • Loading branch information
BCerki committed Mar 30, 2022
1 parent c1a1680 commit 32f6968
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion app/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { getInitialPreloadedQuery, getRelayProps } from "relay-nextjs/app";
import { getClientEnvironment } from "../lib/relay/client";
import BCGovTypography from "components/BCGovTypography";
import SessionExpiryHandler from "components/Session/SessionExpiryHandler";
import { Suspense, useState } from "react";
import { Suspense, useEffect, useState } from "react";
import * as Sentry from "@sentry/react";
import ErrorFallback from "./500";
import { ErrorContext } from "contexts/ErrorContext";
Expand All @@ -23,6 +23,9 @@ const initialPreloadedQuery = getInitialPreloadedQuery({
function MyApp({ Component, pageProps }: AppProps) {
const [error, setError] = useState(null);
const value = { error, setError };
useEffect(() => {
setError(null);
}, [Component]);

const relayProps = getRelayProps(pageProps, initialPreloadedQuery);
const env = relayProps.preloadedQuery?.environment ?? clientEnv!;
Expand Down

0 comments on commit 32f6968

Please sign in to comment.