Javascript 当其他进程正在运行时,React Native onPress无法触发
我使用FlatList来呈现我的列表,每个列表项都是可点击的;但是,当我单击该项时,在加载所有内容之前,它不会工作 看起来,当其他项目仍在渲染时,在所有内容都完全加载之前,您无法执行操作或事件 这是我的密码:Javascript 当其他进程正在运行时,React Native onPress无法触发,javascript,react-native,Javascript,React Native,我使用FlatList来呈现我的列表,每个列表项都是可点击的;但是,当我单击该项时,在加载所有内容之前,它不会工作 看起来,当其他项目仍在渲染时,在所有内容都完全加载之前,您无法执行操作或事件 这是我的密码: return ( <FlatList refreshing={this.props.refreshLoading} horizontal={false} initialNumToRender={20} max
return (
<FlatList
refreshing={this.props.refreshLoading}
horizontal={false}
initialNumToRender={20}
maxToRenderPerBatch={20}
showsVerticalScrollIndicator={true}
numColumns={2}
onEndReachedThreshold={0.1}
bounces={true}
keyExtractor={(item) => item}
data={userList}
renderItem={(item) => {
return (
<UserCard
index={item.item[1]}
userInfo={item.item[1]}
contentSize={this.state.contentSize}
navigation={this.props.navigation}/>
)
}}
onEndReached={this.onLoadMore}
onRefresh={this.onRefresh}
/>
);
返回(
项目}
数据={userList}
renderItem={(项目)=>{
返回(
)
}}
onEndReached={this.onLoadMore}
onRefresh={this.onRefresh}
/>
);
有没有合适的方法来处理它?这是因为Javascript线程被屏幕上的渲染阻塞了。一旦该批行的渲染完成,它将为单击事件打开线程。此渲染成批进行,可以对其进行调整 请参阅Github上的问题 基本上,您可以使用列表上的
initialNumToRender
和maxToRenderPerBatch
参数,直到您得到适合自己的参数,并且在渲染时不会显得紧张(如果值太低,它将以增量方式渲染列表,这可能看起来很奇怪-称为填充率)
您可以在react native docs中了解这些参数:
非常感谢您的回复,我将查看这些链接。马上回来