我是react-native
新手。
只是有关FlatList
renderItem
Component
性能和内存使用的问题。
在renderItem
Component
以下的哪个中,性能更快,并且对于较大的列表而言,哪一个对内存友好?
1:
class MyListItem extends React.PureComponent {
render() {
return (
<View style={{width: '100%', height: 60}}>
{
this.props.size === 30 ?
(
<View style={{width: 30, height: 30}}>
<Text>test</Text>
</View>
)
:
null
}
<View>...</View>
</View>
)
}
}
2:
class MyListItem extends React.PureComponent {
render() {
return (
<View style={{width: '100%', height: 60}}>
<View style={{width: this.props.size, height: this.props.size}}>
<Text>test</Text>
</View>
<View>...</View>
</View>
)
}
}
谢谢。
答案 0 :(得分:0)
Second第二个速度更快并且对内存友好,因为它不会检查任何条件,因此与first相比,它的性能更快。 您可以使用FlatList,这比两者都要好。