当我从另一个屏幕上按返回键时,向下滚动平面列表在4秒钟内不起作用,但是touch元素起作用了。在那之后,一切正常。在Debug中,当我从另一个屏幕按回去时,看到异步功能没有再次执行,但是我看到组件仍在屏幕中,并且该屏幕没有再次重新加载。 ‘出什么问题了?
我尝试了willfocus,但对我不起作用
render(){return (
<View style={styles.container}>
<StatusBar
barStyle="light-content"
hidden={false}
backgroundColor="#a9161e"
translucent={false}
networkActivityIndicatorVisible={true}
/>
<FetchingIndicator isFetching={this.state.isFetching} message='Eventos...'
color='#D32C26' backdropColor={'white'} messageStyle={styles.textIndicator}/>
<FlatList
data={this.state.datasource}
showsVerticalScrollIndicator={false}
renderItem={this.renderItem}
keyExtractor={(item, index) => index.toString()} />
</View>
);}
renderItem = ({ item }) => { return (
<View style={styles.itemView}>
<TouchableOpacity
onPress={()=>this.props.navigation.navigate('DetalleEvento',{IdEvento: item.did_evento})}
>
<Image source={{ uri: item.hbanner }} style={styles.imageView} />
</TouchableOpacity>
<View style={styles.detalleView}>
<View style={styles.textView}>
<Text>
{item.ede_evento}
</Text>
<Text>
Inicio: {item.ffh_inicio}
</Text>
<Text>
Fin: {item.gfh_fin}
</Text>
</View>
<TouchableOpacity style={styles.btnView}
onPress={()=>this.props.navigation.navigate('Agenda',{IdRegistro: item.bid_registro})}
>
<Text>Programar</Text>
</TouchableOpacity>
</View>
</View>
);}
componentDidMount() {
this.Eventos();
this.setState({ isFetching: true });
this.props.navigation.setParams({ handleLogout: () => this.Logout() })
this.willFocusSubscription = this.props.navigation.addListener(
'willFocus',
() => {
this.Eventos();
this.setState({ isFetching: true });
this.props.navigation.setParams({ handleLogout: () => this.Logout() })
}
);}
componentWillUnmount() {
this.willFocusSubscription.remove();
}