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

Dollar sign and quotes in return component

i create a use state in my react component like that:

const [loading, setLoading] = React.useState(false);

and in one project in return of component i saw something like this

<ListItemButton sx={{ color: `${loading && 'yellow'}` }}>

I can’t find how that `${x && 'x' }` syntax works
Can someone explain to me or show me the documentation of this?

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 :

It’s logical AND ( && ) operator, and next thing will execute incase if true condition

let yellow = true;
console.log( yellow && "Yellow color" )

let blue = false;

console.log( blue && "Blue color" )
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