我正在尝试从服务器获取数据,然后经过一些解析,将其呈现在组件的表中。但问题是服务器的响应太晚了,我的表格没有显示。如何从服务器和模板同步我的数据?
谢谢
class TFSBuilds extends React.Component {
constructor(){
super(props);
this.state = {
builds: []
};
}
componentDidMount() {
AzureService.send("ObCloud").then((data)=>{
let groupedData = this.groupBy(data.value, obj => obj.definition.id)
this.createChartObjects(groupedData)
});
}
createChartObjects(groupedRecords) {
const arr = [];
for (let [k, v] of groupedRecords) {
if(v && k){
this.state.builds.push(v[0]);
}
}
return arr;
}
render() {
const { builds } = this.state
if (builds.length <= 0) { return null }
return (
<div className = "build-status" >
<table className="table table-hover">
<thead>
<tr>
<th scope="col">By</th>
<th scope="col">When</th>
<th scope="col">Status</th>
</tr>
</thead>
<tbody>
{
builds.map(el =>
<tr>
<th scope="row">{el.requestedBy.displayName}</th>
<td>{el.requestedBy.date}</td>
<td>{el.requestedBy.status}</td>
</tr>)
}
</tbody>
</table>
</div>
)
}
}
慕尼黑8549860
当年话下
相关分类