如何使用 reactjs 在不显示按钮的情况下显示内容?

How to show the content without showing button using reactjs?

我的 objective 是在我们点击 emailid 时只显示电子邮件组件(而不是显示按钮 "show modal")。我的意思是当我们点击电子邮件 ID 时,模式应该弹出而不是显示按钮 "show modal"。谁能帮我解决这个问题?

代码如下:

<Table.Body>
  <Table.Row>
    <Table.Cell>First Name</Table.Cell>
    <Table.Cell>
      <Link to="/Email">abc@yahoo.com</Link>
    </Table.Cell>
    <Table.Cell>01-01-2020</Table.Cell>
  </Table.Row>
</Table.Body>

完整代码如下:“https://codesandbox.io/s/so-answer-60873116-98xnt

谁能帮我解决这个问题?

您想添加一个 open 状态并在关闭时重定向到根目录,同时使用 Modal 组件的 open 属性:

<Container>
  <Modal
    open={this.state.open}
    onClose={() => {
      this.setState({ open: false });
    }}
  >
   ...
  </Modal>
  {!this.state.open && <Redirect to={`/`} />}
</Container>

See sandbox attached