【发布时间】:2018-04-11 12:36:30
【问题描述】:
我有一个有按钮的表格,按钮有onClick() 函数,我正在将一个方法传递给onclick,但是ids 在一个数组中。
我可以console.log 喜欢props.requests[0].objectId。
const actionButton = (published) => {
if (props.userType === 'crick') {
if (props.data.verified) {
return published === true ? <Label>Published</Label> : <Button basic onClick={() => scoreAction(// Have to pass ids here)} >Publish</Button>;
}
}
}
而表格来自上面的代码。
<Table.Body>
{props.loanRequests.map((value, i) =>
(<Table.Row key={i}>
<Table.Cell> {value.cric.name} </Table.Cell>
<Table.Cell> {value.runs} </Table.Cell>
<Table.Cell> {actionButton(value.published)} </Table.Cell>
</Table.Row>))}
</Table.Body>
如何将 id 数组传递给按钮的 onclick 函数方法。
注意:语义 UI 正在使用中。
【问题讨论】:
-
问题已更新。
-
那些ID在哪里?
标签: javascript jquery arrays reactjs semantic-ui