简体   繁体   中英

Nested conditional rendering in jsx React

im attempting to have a nested if condition within the jsx itself. 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>)
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM