import React from 'react' import ArrowDown from './arrowdown' export default class extends React.Component { constructor(props) { super() this.state = { listVisible: false, selected: props.selected || props.list[0] } this.select = this.select.bind(this) this.toggle = this.toggle.bind(this) } select(item) { this.setState({ selected: item }) } toggle() { this.setState({ listVisible: !this.state.listVisible }) } renderListItems() { return this.props.list.map((item, i) => (
{ item.name }
)) } render() { return (
{ this.state.selected.name }
{ this.renderListItems() }
) } }