As a counter-point for short circuit evaluation, I've mostly switched over to it for conditionally rendering things in JSX. I stuck to ternary for years but have gradually switched over.
I'd now say that:
return ( <section> {isLoading && <LoadingMessage/>} {/* ... */} </section> )
is at least as clear as:
return ( <section> {isLoading ? <LoadingMessage/> : null} {/* ... */} </section> )
I agree, for things like JSX (which still look uncomfortable to me even after a few years) it is still readable - provided you keep things simple.
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
As a counter-point for short circuit evaluation, I've mostly switched over to it for conditionally rendering things in JSX. I stuck to ternary for years but have gradually switched over.
I'd now say that:
is at least as clear as:
I agree, for things like JSX (which still look uncomfortable to me even after a few years) it is still readable - provided you keep things simple.