From 75d6535402425cdf78fbea1ec166549c4a20b4c2 Mon Sep 17 00:00:00 2001
From: dan <dan.abramov@gmail.com>
Date: Wed, 3 Apr 2024 19:11:29 +0100
Subject: Remove Button error boundary (#3372)

---
 src/components/Button.tsx | 50 +++++++++--------------------------------------
 1 file changed, 9 insertions(+), 41 deletions(-)

(limited to 'src/components/Button.tsx')

diff --git a/src/components/Button.tsx b/src/components/Button.tsx
index 67c33fa0c..ece1ad6b0 100644
--- a/src/components/Button.tsx
+++ b/src/components/Button.tsx
@@ -14,7 +14,6 @@ import {
 import LinearGradient from 'react-native-linear-gradient'
 import {Trans} from '@lingui/macro'
 
-import {logger} from '#/logger'
 import {android, atoms as a, flatten, tokens, useTheme} from '#/alf'
 import {Props as SVGIconProps} from '#/components/icons/common'
 import {normalizeTextStyles} from '#/components/Typography'
@@ -405,51 +404,20 @@ export function Button({
         </View>
       )}
       <Context.Provider value={context}>
-        <ButtonTextErrorBoundary>
-          {/* @ts-ignore */}
-          {typeof children === 'string' || children?.type === Trans ? (
-            /* @ts-ignore */
-            <ButtonText>{children}</ButtonText>
-          ) : typeof children === 'function' ? (
-            children(context)
-          ) : (
-            children
-          )}
-        </ButtonTextErrorBoundary>
+        {/* @ts-ignore */}
+        {typeof children === 'string' || children?.type === Trans ? (
+          /* @ts-ignore */
+          <ButtonText>{children}</ButtonText>
+        ) : typeof children === 'function' ? (
+          children(context)
+        ) : (
+          children
+        )}
       </Context.Provider>
     </Pressable>
   )
 }
 
-export class ButtonTextErrorBoundary extends React.Component<
-  React.PropsWithChildren<{}>,
-  {hasError: boolean; error: Error | undefined}
-> {
-  public state = {
-    hasError: false,
-    error: undefined,
-  }
-
-  public static getDerivedStateFromError(error: Error) {
-    return {hasError: true, error}
-  }
-
-  public componentDidCatch(error: Error, errorInfo: React.ErrorInfo) {
-    logger.error('ButtonTextErrorBoundary caught an error', {
-      message: error.message,
-      errorInfo,
-    })
-  }
-
-  public render() {
-    if (this.state.hasError) {
-      return <ButtonText>ERROR</ButtonText>
-    }
-
-    return this.props.children
-  }
-}
-
 export function useSharedButtonTextStyles() {
   const t = useTheme()
   const {color, variant, disabled, size} = useButtonContext()
-- 
cgit 1.4.1

