Skip to content

Commit

Permalink
logic to rerender
Browse files Browse the repository at this point in the history
  • Loading branch information
catosaurusrex2003 committed Nov 17, 2024
1 parent 305eca0 commit 27b3ab9
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions library/src/containers/ApplicationErrorHandler/ErrorBoundary.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { useEffect, useState } from 'react';
import { ReactNode } from 'react';
import { ErrorBoundary, FallbackProps } from 'react-error-boundary';
import { ErrorObject } from '../../types';
Expand All @@ -23,8 +23,16 @@ function fallbackRender({ error }: FallbackProps) {
}

const AsyncApiErrorBoundary = ({ children }: Props) => {
const [key, setKey] = useState(0);

useEffect(() => {
setKey((prevKey) => prevKey + 1);
}, [children]);

return (
<ErrorBoundary fallbackRender={fallbackRender}>{children}</ErrorBoundary>
<ErrorBoundary key={key} fallbackRender={fallbackRender}>
{children}
</ErrorBoundary>
);
};

Expand Down

0 comments on commit 27b3ab9

Please sign in to comment.