Skip to content

Instantly share code, notes, and snippets.

@ferrannp
Last active October 21, 2019 05:03
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ferrannp/63cd431654798c53e6aa72adf5a4caea to your computer and use it in GitHub Desktop.
Save ferrannp/63cd431654798c53e6aa72adf5a4caea to your computer and use it in GitHub Desktop.
const Dropdown = (props) => (
<div className='dropdown'>
<button onClick={props.onToggle}>
Selected option: {props.data[props.optionSelected]}
</button>
<ul className={props.isOpen ? 'active':null}>
{
props.data.map((item, i) => {
return (
<li key={i} className={i === props.optionSelected ? 'selected':null}
onClick={() => props.onSelect(i)}>
{item}
</li>
)
})
}
</ul>
</div>
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment