'How do I append another field in the ReactJS conditional statement?
I would like to append a <br/> tag between the record.customerName and the record.customerGender in the conditional statement but it is giving me the <br/> instead of a real break? How do I append a break between the 2 frields? Thanks
{customeData.map(record =>{
return(<React.Fragment>{record._id == items._id? record.customerName + '<br/>' + record.customerGender:""}</React.Fragment>)
})}
Solution 1:[1]
Try this, much simpler.
{customeData.map(record => (
record._id === items._id && (
<>
{record.customerName}
<br />
{record.customerGender}
</>
)
))}
I've also taken the liberty of cleaning up your code a little.
If you need an explanation regarding some factors of the cleanups, or if something doesn't work properly, please let me know.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
