Skip to content

Instantly share code, notes, and snippets.

@spacenick
Created February 19, 2016 16:00
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 spacenick/5cd7213f8c7fed3d957e to your computer and use it in GitHub Desktop.
Save spacenick/5cd7213f8c7fed3d957e to your computer and use it in GitHub Desktop.
accordion
class Tab extends React.Component {
static propTypes = {
active,
title,
children
};
render() {
return ...
}
}
class Accordion extends React.Component {
static propTypes = {
children: React.PropTypes.func,
}
render() {
return this.props.children(Tab)
}
}
// La ou tu as besoin du accordion
class MaPage extends React.Component {
render() {
return (
<Accordion>
{(AccordionTab) => {
<AccordionTab title="Premier Tab" active={true}>
Contenu premier tab
</AccordionTab>
<AccordionTab title="Second Tab">
Contenu second tab
</AccordionTab>
})
<Accordion>
)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment