I'm rendering a list of contacts, each of which has a clickable icon that triggers a set state. Here's the FlatList version:
<FlatList
data={this.state.contacts}
renderItem={({item, index}) => <Contact
contact={item}
image={this.getImage(item)}
active={item.id in this.state.active}
toggleActive={this.toggleActive} />}
keyExtractor={(item, idx) => idx.toString()}
refreshing={false} />
And here's the ScrollView version:
<ScrollView style={styles.scroll}>
{this.state.contacts.map(c => (
<Contact key={c.id}
contact={c}
image={this.getImage(c)}
active={c.id in this.state.active}
toggleActive={this.toggleActive} />
))}
</ScrollView>
The Contact
component and all else remains constant between these two, only the type of scroll container (FlatList vs ScrollView) changes. However, the ScrollView maintains a snappy 60 FPS, while the FlatList drops to ~10 FPS on the JS thread after setState is called. Is this expected behavior, or am I missing something / doing something wrong?