Skip to content

Instantly share code, notes, and snippets.

@sirgallifrey
Created August 3, 2017 04:04
Show Gist options
  • Save sirgallifrey/f83148f53f35d67739ca8f63a9be5078 to your computer and use it in GitHub Desktop.
Save sirgallifrey/f83148f53f35d67739ca8f63a9be5078 to your computer and use it in GitHub Desktop.
props.children composition
import React from 'react';
function Card (props) {
return (
<div className={`card ${props.className}`}>
{ props.children }
</div>
);
}
import React from 'react';
import Card from './card';
function Dashboard (props) {
return (
<div>
<Card>
<h1>Título do card</h1>
<p>Texto</p>
</Card>
<Card>
<img src="/some/image.png"/>
<h2>Car com imagem</h2>
</Card>
</div>
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment