2 ms·
JSX is awesome. It's just JavaScript, you can do whatever you want... return ( <Foo> { selected ? <Bar /> : null } </Foo> ); or let children = []; if
by halis 10y ago
JSX is awesome. It's just JavaScript, you can do whatever you want...
return (
<Foo>
{ selected ? <Bar /> : null }
</Foo>
);
or
let children = [];
if (selected) children.push(<Bar />);
if (blah) children.push(<Blah />);
return (
<Foo>
{ children }
</Foo>
);
or
const bar = selected ? <Bar /> : null;
return (
<Foo>
{ bar }
</Foo>
);
- petre 10y agoOur Perl5 CGI.pm codebase used to look like that (html + logic). Fortunately we switched it over to Mojolicious and it became manageable. Not going back there thank you.