Comment

Comment by molf

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) {
       <Gallery slides={gallery}>
    }}
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

parent molf 4 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton