3 ms·
It's strange to me to embed conditions in attributes - particularly the v-else case in a different tag. It requires several visual scans of the block of code to
by straye 10y ago
It's strange to me to embed conditions in attributes - particularly the v-else case in a different tag. It requires several visual scans of the block of code to determine what's going on.
In my opinion the following requires less cognitive overhead:
function Home(props) {
var query = props.location.query.home ?
( <p>You specified a home query: { props.location.query.home }</p> )
: ( <p>No home query was specified.</p> );
return (
<div>
<h2>HELLO</h2>
<p>Duis a turpis sed lacus dapibus elementum sed eu lectus.</p>
{query}
</div>
);
}
- straye 10y agoThis also works: function Home(props) { return ( <div> <h2>HELLO</h2> <p>Duis a turpis sed lacus dapibus elementum sed eu lectus.</p> { props.location.query.home ? ( <p>You specified a home query: { props.location.query.home }</p> ) : ( <p>No home query was specified.</p> ) } </div> ); }