From b0a377919066fa169d403f815b5c99692fe98135 Mon Sep 17 00:00:00 2001 From: Joshua Rogers Date: Tue, 3 Feb 2026 20:16:35 +0800 Subject: [PATCH] Runtime guard for invalid buttonType indexing (prevents crash + normalizes prop) (cherry picked from commit 79d23999de7ac1a3863e881737dc746829d14e97) --- src/AddToWalletButton.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/AddToWalletButton.tsx b/src/AddToWalletButton.tsx index 5ce1b05..f062750 100644 --- a/src/AddToWalletButton.tsx +++ b/src/AddToWalletButton.tsx @@ -32,7 +32,8 @@ const BUTTON_DIMENSIONS = { function AddToWalletButton({style, buttonStyle = 'black', buttonType = 'basic', borderRadius = 4, onPress}: Props) { const flattenedStyle = StyleSheet.flatten(style) || {}; - const currentDimensions = BUTTON_DIMENSIONS[buttonType][Platform.OS as 'ios' | 'android']; + const safeButtonType: ButtonType = buttonType === 'badge' ? 'badge' : 'basic'; + const currentDimensions = BUTTON_DIMENSIONS[safeButtonType][Platform.OS as 'ios' | 'android']; const {width = currentDimensions.width, height = currentDimensions.height, ...rest} = flattenedStyle; return ( @@ -55,7 +56,7 @@ function AddToWalletButton({style, buttonStyle = 'black', buttonType = 'basic', style={styles.fill} buttonStyle={buttonStyle} borderRadius={borderRadius} - buttonType={buttonType} + buttonType={safeButtonType} /> );