Skip to content

Commit 35e1af5

Browse files
Updated JS code syntax
1 parent a5aa80e commit 35e1af5

File tree

1 file changed

+30
-27
lines changed

1 file changed

+30
-27
lines changed

Anti-Patterns/Nested-Virtualization-anti-pattern.md

Lines changed: 30 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -84,33 +84,36 @@ Here is the view of the solution
8484

8585
Here is the final code with **ListHeaderComponent** props function
8686

87-
// Header function
88-
function gearHeader() {
89-
return (
90-
<View style={styles.titleHolder}>
91-
<Text style={styles.myGearText}>My Gear</Text>
92-
93-
<View style={styles.iconRow}>
94-
<TouchableOpacity
95-
onPress={() => openCameraCameraRoll(IMAGE_FOR.FIELD_GEAR)}>
96-
<Icon name={'camera'} type={'entypo'} size={25} color="grey" />
97-
</TouchableOpacity>
98-
</View>
99-
</View>
100-
)
101-
}
102-
103-
// FlatList "ListHeaderComponent" props
104-
return (
105-
<FlatList
106-
data={gearPhotos}
107-
keyExtractor={(item) => item._id}
108-
numColumns={3}
109-
ListHeaderComponent={gearHeader}
110-
showsVerticalScrollIndicator={false}
111-
renderItem={renderItem}
112-
/>
113-
)
87+
```javascript
88+
// Header function
89+
function gearHeader() {
90+
return (
91+
<View style={styles.titleHolder}>
92+
<Text style={styles.myGearText}>My Gear</Text>
93+
94+
<View style={styles.iconRow}>
95+
<TouchableOpacity
96+
onPress={() => openCameraCameraRoll(IMAGE_FOR.FIELD_GEAR)}
97+
>
98+
<Icon name={"camera"} type={"entypo"} size={25} color="grey" />
99+
</TouchableOpacity>
100+
</View>
101+
</View>
102+
);
103+
}
104+
105+
// FlatList "ListHeaderComponent" props
106+
return (
107+
<FlatList
108+
data={gearPhotos}
109+
keyExtractor={(item) => item._id}
110+
numColumns={3}
111+
ListHeaderComponent={gearHeader}
112+
showsVerticalScrollIndicator={false}
113+
renderItem={renderItem}
114+
/>
115+
);
116+
```
114117

115118
## What next?
116119

0 commit comments

Comments
 (0)