Why might {isOpen && <Modal />}
be preferred over {isOpen ? <Modal /> : null}
?
It’s more explicit
It produces smaller bundle size
It avoids null checks in React’s reconciliation
Both are functionally identical, but &&
is cleaner
This question is part of this quiz :
Conditional Rendering In ReactReact | Conditional Rendering | Question 5