react-expandable-context
v0.1.0
Published
React components to make anything expandable
Downloads
5
Maintainers
Readme
react-expandable-context
React components to make anything to be expandable
Installation
npm i react-expandable-context
yarn add react-expandable-context
Usage
import Expandable from 'react-expandable-context';
function MyComponent(props) {
return (
<Expandable>
<Expandable.Section id={'first'}>
{({ handleClick, expanded }) => (
<>
<a id={'link'} onClick={handleClick}>
Header
</a>
<div id={'section-body'} expanded={expanded ? 'true' : 'false'}>
lorem
</div>)
</>
)}
</Expandable.Section>
<Expandable.Section id={'second'}>
{({ handleClick, expanded }) => (
<>
<a id={'link'} onClick={handleClick}>
Header
</a>
<div id={'section-body'} expanded={expanded ? 'true' : 'false'}>
lorem
</div>)
</>
)}
</Expandable.Section>
</Expandable>
);
}