DEV Community

Cover image for React - JSX Conditional
Sandro Jhuliano Cagara
Sandro Jhuliano Cagara

Posted on • Edited on

React - JSX Conditional

Instead of

const MyComponent = () => { return isTrue ? <p>True!</p> : null }; 
Enter fullscreen mode Exit fullscreen mode

Use short-circuit evaluation

const MyComponent = () => { return isTrue && <p>True!</p> }; 
Enter fullscreen mode Exit fullscreen mode

Top comments (0)