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

ReactJS one-liner if else return more than one children

I want to render more than one children inside of one-liner if else statement. I use ReactJS and MUI. How do I return/render more than one element (an icon and a string with text inside of it)?

<Button type="submit">
{isTyping ? "QISALD" : <OpenInNewIcon/> "LİNKƏ KEÇİD ET"}
</Button>

*isTyping is a state with a boolean value.

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

>Solution :

You can use a fragment like here:

<Button type="submit">
{isTyping ? "QISALD" : <><OpenInNewIcon/> "LİNKƏ KEÇİD ET"</>}
</Button>
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