Skip to content

Conditions in JSX

To render JSX conditionally, instead of:

const sampleComponent = () => {
  return isTrue ? <p>True!</p> : null;
};

Use short-circuit evaluation

const sampleComponent = () => {
  return isTrue && <p>True!</p>;
};