React native 反应本机条件呈现临时显示内容
我的渲染函数中有一个条件。当不满足if语句时,它会在else块显示之前临时显示React native 反应本机条件呈现临时显示内容,react-native,React Native,我的渲染函数中有一个条件。当不满足if语句时,它会在else块显示之前临时显示 render() { let renderedContent = null if (this.props.tabLabel === 'Schedule' && this.getReportsForTab(this.props.reports).length === 0) { renderedContent = ( <View style={style
render() {
let renderedContent = null
if (this.props.tabLabel === 'Schedule' && this.getReportsForTab(this.props.reports).length === 0) {
renderedContent = (
<View style={styles.addInspectionContainer}>
<Button block primary style={styles.button} onPress={() => this.props.onAddReport()}>Add Inspection</Button>
</View>
)
} else {
renderedContent = (
<ListView
dataSource={this.state.dataSource}
renderRow={this.renderReport}
renderSectionHeader={this.renderSectionHeader}
/>
)
}
return renderedContent
}
render(){
让renderedContent=null
if(this.props.tabLabel=='Schedule'&&this.getReportsForTab(this.props.reports).length==0){
渲染内容=(
this.props.onAddReport()}>添加检查
)
}否则{
渲染内容=(
)
}
返回呈现内容
}
这不应该发生。有没有办法解决这个问题?我最终解决了这个问题。当页面未完全加载时显示if块。我在if语句中添加了this.props.loaded:
if (this.props.loaded && this.props.tabLabel === 'Schedule' && this.getReportsForTab(this.props.reports).length === 0)
实际的问题是什么?@zvona当执行else块时,它不应该显示if块代码。如何使其不显示if块代码?例如,当this.props.tabLabel===='completed'时,只应显示else块。现在,if块在else块显示之前显示几秒钟