Daily Shaarli

All links of one day in a single page.

February 2, 2025

Use ternaries rather than && in JSX
thumbnail

What problems can happen when you use && to conditionally render content in JSX

I was reading the Quick Start - React and they mention:

If you prefer more compact code, you can use the conditional ? operator. Unlike if, it works inside JSX.
When you don’t need the else branch, you can also use a shorter logical && syntax.

But this article explains why we should always use the conditional ? operator instead.