在函数内创建多行jsx

时间:2018-02-20 11:25:04

标签: reactjs jsx

我正在尝试创建多行jsx变量

returnedElem = <StyledRemovedAnnotationDiv>
      <p>{this.state.deletedAnnotation.objectRemoved.prediction}</p>
      <button
        className="btn btn-danger"
        onClick={() => this.undoDelete(tax, deletedObj)}
      >
        Undo
      </button>
    </StyledRemovedAnnotationDiv>,

但这不起作用。请指导我。

1 个答案:

答案 0 :(得分:2)

尝试用大括号包装:

&#13;
&#13;
returnedElem = (
  <StyledRemovedAnnotationDiv>
      <p>{this.state.deletedAnnotation.objectRemoved.prediction}</p>
      <button
        className="btn btn-danger"
        onClick={() => this.undoDelete(tax, deletedObj)}
      >
        Undo
      </button>
  </StyledRemovedAnnotationDiv>
)
&#13;
&#13;
&#13;