I've always found these approaches to writing conditions in JSX to be terrible. Wouldn't it be nice if JavaScript were an expression-oriented language? Then you could just write: {if (gallery.length) { }} There has been a "do expressions" proposal [0] for many years, which addresses this (though it is more verbose). I hope it will be accepted some day. [0] https://github.com/tc39/proposal-do-expressions
“{number && } renders 0 instead of nothing. Use {number > 0 && } instead.”
Functional JSX would look like:
const isNumber = number > 0;
{isNumber && }
You can similarly do things like:
const isVisible = condition1 && (condition2 || condition3) || guard(props.input1);
{isVisible && }
The functional paradigm and some basic code factoring can make quick work of conditional JSX