Created
February 19, 2016 16:00
-
-
Save spacenick/5cd7213f8c7fed3d957e to your computer and use it in GitHub Desktop.
accordion
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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