Saya cukup baru dalam bereaksi dan ingin memasukkan respons json yang saya dapatkan dari api ke tabel desain semut yang kosong dan saya tidak tahu cara melakukannya?
saya telah memetakan id dengan nama tetapi juga ingin semua kolom lainnya dan ke dalam format tabel desain semut.
Tanggapan JSON
[
{
"id": 9685,
"name": "Mukesh Rai",
"count of sub": 3,
"count of int": 2,
"count of po": null
},
{
"id": 2085,
"name": "Abhyudaya Singh Panwar",
"count of sub": 1049,
"count of int": 17,
"count of po": 5
},
{
"id": 7087,
"name": "Amit Kumar Sharma",
"count of sub": 363,
"count of int": 68,
"count of po": 10
},
{
"id": 2100,
"name": "Aditya Kumar",
"count of sub": 724,
"count of int": 5,
"count of po": 1
}
]
berkas komponen
componentDidMount(){
axios.get("http://127.0.0.1:8000/marketer_details/")
.then(response=>{
console.log(response)
this.setState({posts: response.data})
})
.catch(error=> {
console.log(error)
})
}
render() {
const { posts } = this.state
return(
<div>
List of Posts
{
posts.length ?
posts.map(post => <div key = {post.id}>{post.name}</div>) :
null
}
</div>
)
//Ingin semua kolom lainnya juga
render(){
const columns = [
{
title: 'Name',
dataIndex: 'name',
key: 'name',
width: '30%',
...this.getColumnSearchProps('name'),
},
{
title: 'Count of Submissions',
dataIndex: 'Count',
key: 'sub',
width: '20%',
...this.getColumnSearchProps('sub'),
},
{
title: 'Count of Interviews',
dataIndex: 'Count',
key: 'int',
...this.getColumnSearchProps('int'),
},
{
title: 'Count of PO',
dataIndex: 'Count',
key: 'po',
...this.getColumnSearchProps('po'),
},
];
return <Table columns={columns} dataSource={this.state.posts} />;
}
}
}
export default App
Saya tidak dapat memahami bagaimana pemetaan berganda dapat dilakukan terhadap setiap baris kolom.
return
untuk fungsi tersebut? - person Agney   schedule 17.06.2019