Skip to content

Instantly share code, notes, and snippets.

@hedgerh
Last active August 15, 2019 03:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hedgerh/1d6ba4175c8fefd6c100264a7b1ec582 to your computer and use it in GitHub Desktop.
Save hedgerh/1d6ba4175c8fefd6c100264a7b1ec582 to your computer and use it in GitHub Desktop.
// prefer this
const ExamplePage = () => {
return (
<>
<div>
<h1>Card 1!</h1>
<h2>A simple card!</h2>
</div>
<div>
<h1>Card 2!</h1>
<h2>Some subtitle!</h2>
</div>
<div>
<h1>Card 3!</h1>
<span>This has an extra line!</span>
</div>
</>
);
}
// over this
const SimpleCard = ({ title, subtitle, extra }) => {
return (
<div>
{title && <h1>{title}</h1>}
{subtitle && <h2>{subtitle}</h2>}
{extra && <span>{extra}</span>}
</div>
);
};
const ExamplePage = () => {
return (
<>
<SimpleCard
title='Card 1!'
subtitle='A simple card!'
/>
<SimpleCard
title='Card 2!'
subtitle='Some subtitle!'
/>
<SimpleCard
title='Card 3!'
extra='This has an extra line!'
/>
</>
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment