Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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 :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

You can’t just throw raw HTML into JSX expressions.

Use JSX properly. Put your string variables in expressions, and generate your elements with JSX tags.

(record) => {
    return (record._id == items._id) ?
        <>
            {record.customerName}
            <br />
            {record.customerGender}
        </> :
        "";
}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading