3 ms·
It's not so bad. It's just plain JavaScript conditional logic which any JavaScript developer can understand. It's certainly not worth missing out on the entire
by steve_taylor 9y ago
It's not so bad. It's just plain JavaScript conditional logic which any JavaScript developer can understand. It's certainly not worth missing out on the entire framework and ecosystem over this one little thing that you'd get used to doing pretty quickly.
One thing I don't like, though:
const sampleComponent = () => {
return isTrue && <p>True!</p>
};
If isTrue is 0, React will render 0. If isTrue is NaN, React will render NaN. Best to cast the conditional to boolean when using short-circuit evaluation:
const sampleComponent = () => {
return !!isTrue && <p>True!</p>
};