The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
Added a mechanism to reset error boundary on page change. (#5913)
Lucas Bordeau76bcf3134136
diff --git a/packages/twenty-front/src/modules/error-handler/components/GenericErrorFallback.tsx b/packages/twenty-front/src/modules/error-handler/components/GenericErrorFallback.tsxindex 87f84036911..2109891aca1 100644--- a/packages/twenty-front/src/modules/error-handler/components/GenericErrorFallback.tsx+++ b/packages/twenty-front/src/modules/error-handler/components/GenericErrorFallback.tsx@@ -1,4 +1,6 @@+import { useEffect, useState } from 'react';import { FallbackProps } from 'react-error-boundary';+import { useLocation } from 'react-router-dom';import { ThemeProvider, useTheme } from '@emotion/react';import isEmpty from 'lodash.isempty';import { IconRefresh, THEME_LIGHT } from 'twenty-ui';@@ -11,6 +13,7 @@ import {AnimatedPlaceholderEmptyTextContainer,AnimatedPlaceholderEmptyTitle,} from '@/ui/layout/animated-placeholder/components/EmptyPlaceholderStyled';+import { isDeeplyEqual } from '~/utils/isDeeplyEqual';type GenericErrorFallbackProps = FallbackProps;@@ -18,7 +21,18 @@ export const GenericErrorFallback = ({error,resetErrorBoundary,}: GenericErrorFallbackProps) => {+ const location = useLocation();++ const [previousLocation] = useState(location);++ useEffect(() => {+ if (!isDeeplyEqual(previousLocation, location)) {+ resetErrorBoundary();+ }+ }, [previousLocation, location, resetErrorBoundary]);+const theme = useTheme();+return (<ThemeProvider theme={isEmpty(theme) ? THEME_LIGHT : theme}><AnimatedPlaceholderEmptyContainer>