Skip to content

Commit

Permalink
Refactored defaultMenuRenderer file
Browse files Browse the repository at this point in the history
  • Loading branch information
yuri-sakharov committed Dec 21, 2017
1 parent 5791fb9 commit b35f8d0
Showing 1 changed file with 23 additions and 5 deletions.
28 changes: 23 additions & 5 deletions src/utils/defaultMenuRenderer.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import classNames from 'classnames';
import PropTypes from 'prop-types';
import React from 'react';

function menuRenderer ({
const menuRenderer = ({
focusedOption,
focusOption,
inputValue,
instancePrefix,
labelKey,
onFocus,
onOptionRef,
onSelect,
Expand All @@ -18,11 +18,11 @@ function menuRenderer ({
selectValue,
valueArray,
valueKey,
}) {
}) => {
let Option = optionComponent;

return options.map((option, i) => {
let isSelected = valueArray && valueArray.some(x => x[valueKey] == option[valueKey]);
let isSelected = valueArray && valueArray.some(x => x[valueKey] === option[valueKey]);
let isFocused = option === focusedOption;
let optionClass = classNames(optionClassName, {
'Select-option': true,
Expand Down Expand Up @@ -53,6 +53,24 @@ function menuRenderer ({
</Option>
);
});
}
};

menuRenderer.propTypes = {
focusOption: PropTypes.func,
focusedOption: PropTypes.object,
inputValue: PropTypes.string,
instancePrefix: PropTypes.string,
onFocus: PropTypes.func,
onOptionRef: PropTypes.func,
onSelect: PropTypes.func,
optionClassName: PropTypes.string,
optionComponent: PropTypes.func,
optionRenderer: PropTypes.func,
options: PropTypes.array,
removeValue: PropTypes.func,
selectValue: PropTypes.func,
valueArray: PropTypes.array,
valueKey: PropTypes.string,
};

export default menuRenderer;

0 comments on commit b35f8d0

Please sign in to comment.