import classnames from 'classnames'; import CSSTransitionGroup from 'react-addons-css-transition-group'; import React from 'react'; const methodsToBind = [ 'componentDidMount', 'componentWillUnmount', 'getDropdownMenu', 'onItemSelect', 'onDropdownClick', 'onExternalClick' ]; export default class SortDropdown extends React.Component { constructor() { super(); this.state = { isExpanded: false }; methodsToBind.forEach((method) => { this[method] = this[method].bind(this); }); } componentDidMount() { window.addEventListener('click', this.onExternalClick); } componentWillUnmount() { window.removeEventListener('click', this.onExternalClick); } getDropdownMenu() { let menuItems = this.props.menuItems.map(function(property, index) { let classes = classnames({ 'dropdown__item': true, 'is-selected': this.props.selectedItem.property === property.property }) return (