[英]Nested conditional rendering in jsx React
im attempting to have a nested if condition within the jsx itself.我试图在 jsx 本身中有一个嵌套的 if 条件。 here is a sample of my code:
这是我的代码示例:
{this.props.customerInformation?
<Descriptions title="Customer Information" bordered>
{this.props.customerInformation.customer_status.label}</Descriptions.Item>
</Descriptions>
:
<Button> Create a new customer </Button>
}
What im attempting to do is to add another condition within the top condition, which would look something like that:我试图做的是在顶级条件中添加另一个条件,看起来像这样:
{this.props.customerInformation?
<Descriptions title="Customer Information" bordered>
<Descriptions.Item>
{this.props.customerInformation.customer_status.label}
</Descriptions.Item>
<Description.Item>
{this.props.customerInformation.poc?
<Descriptions title="poc" >
{this.props.customerInformation.poc}
<Descriptions.Item>
</Descriptions>
:
<Button> Create a new customer </Button>
}
add brackets to wrap your code.添加括号来包装您的代码。
{this.props.customerInformation?
(<Descriptions title="Customer Information" bordered>
{this.props.customerInformation.customer_status.label}
</Descriptions.Item>
</Descriptions>)
:
(<Button> Create a new customer </Button>)
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.