【发布时间】:2020-02-03 06:43:07
【问题描述】:
UNSAFE_componentWillMount(){
this.props.EmployeeFetch();
}
renderRow(employee){
return <ListItem employee={employee}/>;
}
render(){
return(
<FlatList style={{flex:1,height:100}}
data = {this.props.employees}
/>
);
}
}
const mapStateToProps=state=>{
const employees = _.map(state.employees,(val,uid)=>{
return {...val,uid};
});
return {employees};
}
export default connect(mapStateToProps, {EmployeeFetch})(EmployeeList);
我在这里从 firebase 获取数据。起初它是空的,过了一段时间数据来了。那么,我将如何使用 Flatlist 和 componentWillRecieveProps() 重新渲染新数据?
【问题讨论】:
-
您使用的是哪个数据库或实时数据库
-
实时数据库
-
也使用 react-redux 来管理状态。
标签: reactjs firebase react-native redux react-redux