Skip to content

Commit

Permalink
fix(FormList): handle onPress errors gracefully in RenderSectionItems
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert27 committed Dec 12, 2024
1 parent 39975ef commit a847de6
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/components/Universal/FormList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,22 @@ const RenderSectionItems: React.FC<{
}> = ({ items, privacyHidden, rowStyle }) => {
const { styles, theme } = useStyles(stylesheet)

const handlePress = (onPress?: () => Promise<void> | void): void => {
if (onPress != null) {
Promise.resolve(onPress()).catch((error) => {
console.error(error)
})
}
}

return (
<View style={styles.blockCard}>
{items.map((item, index) => (
<React.Fragment key={index}>
<Pressable
onPress={item.onPress}
onPress={() => {
handlePress(item.onPress)
}}
style={({ pressed }) => [
{
opacity: pressed ? 0.9 : 1,
Expand Down

0 comments on commit a847de6

Please sign in to comment.