反应语义ui渲染调用函数来获取输出

时间:2018-04-27 02:38:15

标签: javascript reactjs semantic-ui

我需要一点帮助以下内容。谁能告诉我这里做错了什么?当我从渲染中调用renderRow时,我没有得到输出。谢谢!

renderRow() {
  const { Row, Cell } = Table;
  return this.props.registeredAccounts.map(address => {
      return 
        <Row>
          <Cell>{address}</Cell>
          <Cell>minimum payment</Cell>
        </Row>
  })
}

render(){
  const { Header, Row, HeaderCell, Body } = Table;

  return (
    <Layout>
      <h3>Registered Accounts</h3>
      <Table>
        <Header>
          <Row>
            <HeaderCell>Address</HeaderCell>
            <HeaderCell>Minimum Payment</HeaderCell>
          </Row>
        </Header>
        <Body>
          {this.renderRow()}
        </Body>
      </Table>
    </Layout>
  )
}

1 个答案:

答案 0 :(得分:0)

这是因为您在一行上使用了return。将html包装在括号中,或将<Row>标记移至return行。就像现在一样,你实际上是在返回null

renderRow() {
  const { Row, Cell } = Table;
  return this.props.registeredAccounts.map(address => {
      return (
        <Row>
          <Cell>{address}</Cell>
          <Cell>minimum payment</Cell>
        </Row>
      )
  })
}