Common Mistakes in Conditional Rendering

TL;DR

Logical AND operator (&&)

Be especially mindful of the usage of the number 0 when using &&. Common situation: Decide whether or not to print an array based on whether it's empty.

Incorrect Usage

  1. Red: Renders 0

Solutions

  1. Convert to Boolean

    1. Green: Check if greater than 0

    2. Green: Use double negation !!

  2. Orange: Use Logical OR operator (||)