Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save pflevy/c741d0c00a95bfc2ac6bc700df225974 to your computer and use it in GitHub Desktop.
Save pflevy/c741d0c00a95bfc2ac6bc700df225974 to your computer and use it in GitHub Desktop.
Using React.Fragment with conditional rendering.
const MyComponent = (props) => {
return (
<>
{props.fullHeader ? (
<>
<h2>{entry.header}</h2>
<h3>{entry.subheader}</h3>
</>
) : (
<span>
{entry.header} {entry.subheader}
</span>
)}
</>
);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment