Skip to content

Commit 27d282f

Browse files
authored
Refactor ExpandableSection to use conditional Container component for improved readability (#3749)
1 parent 653cdd5 commit 27d282f

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/components/expandableSection/index.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,15 @@ function ExpandableSection(props: ExpandableSectionProps) {
9595
);
9696
};
9797

98+
const Container = onPress ? TouchableOpacity : View;
99+
98100
if (shouldShowSectionHeader) {
99101
return (
100102
<View style={styles.hidden}>
101103
{top && renderChildren()}
102-
<TouchableOpacity onPress={onPress} testID={testID} accessibilityState={accessibilityState}>
104+
<Container onPress={onPress} testID={testID} accessibilityState={accessibilityState}>
103105
{sectionHeader}
104-
</TouchableOpacity>
106+
</Container>
105107
{!top && renderChildren()}
106108
</View>
107109
);

0 commit comments

Comments
 (0)