The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
[fix] Fix white screen when error handled by AppErrorBoundary (#5017)
Marie3e60c0050cce
diff --git a/packages/twenty-front/src/modules/error-handler/components/AppErrorBoundary.tsx b/packages/twenty-front/src/modules/error-handler/components/AppErrorBoundary.tsxindex 8f38b9e8e2a..ecd37e8e266 100644--- a/packages/twenty-front/src/modules/error-handler/components/AppErrorBoundary.tsx+++ b/packages/twenty-front/src/modules/error-handler/components/AppErrorBoundary.tsx@@ -1,6 +1,5 @@import { ErrorInfo, ReactNode } from 'react';import { ErrorBoundary } from 'react-error-boundary';-import { ThemeProvider, useTheme } from '@emotion/react';import { GenericErrorFallback } from '@/error-handler/components/GenericErrorFallback';@@ -9,16 +8,12 @@ export const AppErrorBoundary = ({ children }: { children: ReactNode }) => {// TODO: log error to Sentry};- const theme = useTheme();-return (- <ThemeProvider theme={theme}>- <ErrorBoundary- FallbackComponent={GenericErrorFallback}- onError={handleError}- >- {children}- </ErrorBoundary>- </ThemeProvider>+ <ErrorBoundary+ FallbackComponent={GenericErrorFallback}+ onError={handleError}+ >+ {children}+ </ErrorBoundary>);};diff --git a/packages/twenty-front/src/modules/error-handler/components/GenericErrorFallback.tsx b/packages/twenty-front/src/modules/error-handler/components/GenericErrorFallback.tsxindex 73b9a64c615..87f84036911 100644--- a/packages/twenty-front/src/modules/error-handler/components/GenericErrorFallback.tsx+++ b/packages/twenty-front/src/modules/error-handler/components/GenericErrorFallback.tsx@@ -1,5 +1,7 @@import { FallbackProps } from 'react-error-boundary';-import { IconRefresh } from 'twenty-ui';+import { ThemeProvider, useTheme } from '@emotion/react';+import isEmpty from 'lodash.isempty';+import { IconRefresh, THEME_LIGHT } from 'twenty-ui';import { Button } from '@/ui/input/button/components/Button';import AnimatedPlaceholder from '@/ui/layout/animated-placeholder/components/AnimatedPlaceholder';@@ -16,23 +18,26 @@ export const GenericErrorFallback = ({error,resetErrorBoundary,}: GenericErrorFallbackProps) => {+ const theme = useTheme();return (- <AnimatedPlaceholderEmptyContainer>- <AnimatedPlaceholder type="errorIndex" />- <AnimatedPlaceholderEmptyTextContainer>- <AnimatedPlaceholderEmptyTitle>- Server’s on a coffee break- </AnimatedPlaceholderEmptyTitle>- <AnimatedPlaceholderEmptySubTitle>- {error.message}- </AnimatedPlaceholderEmptySubTitle>- </AnimatedPlaceholderEmptyTextContainer>- <Button- Icon={IconRefresh}- title="Reload"- variant={'secondary'}- onClick={() => resetErrorBoundary()}- />- </AnimatedPlaceholderEmptyContainer>+ <ThemeProvider theme={isEmpty(theme) ? THEME_LIGHT : theme}>+ <AnimatedPlaceholderEmptyContainer>+ <AnimatedPlaceholder type="errorIndex" />+ <AnimatedPlaceholderEmptyTextContainer>+ <AnimatedPlaceholderEmptyTitle>+ Server’s on a coffee break+ </AnimatedPlaceholderEmptyTitle>+ <AnimatedPlaceholderEmptySubTitle>+ {error.message}+ </AnimatedPlaceholderEmptySubTitle>+ </AnimatedPlaceholderEmptyTextContainer>+ <Button+ Icon={IconRefresh}+ title="Reload"+ variant={'secondary'}+ onClick={() => resetErrorBoundary()}+ />+ </AnimatedPlaceholderEmptyContainer>+ </ThemeProvider>);};