1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00
Whymarrh Whitby 4f0a205369
Use eslint@6.8.0 (#8978)
* Use eslint@6.8.0
* yarn lint:fix
2020-07-14 12:50:41 -02:30

64 lines
1.4 KiB
JavaScript

import React, { useCallback } from 'react'
import PropTypes from 'prop-types'
import classnames from 'classnames'
const Dropdown = ({ className, disabled, onChange, options, selectedOption, style, title }) => {
const _onChange = useCallback(
(event) => {
event.preventDefault()
event.stopPropagation()
onChange(event.target.value)
},
[onChange],
)
return (
<select
className={classnames('dropdown', className)}
disabled={disabled}
title={title}
onChange={_onChange}
style={style}
value={selectedOption}
>
{
options.map((option) => {
return (
<option
key={option.value}
value={option.value}
>
{ option.name || option.value }
</option>
)
})
}
</select>
)
}
Dropdown.propTypes = {
className: PropTypes.string,
disabled: PropTypes.bool,
title: PropTypes.string,
onChange: PropTypes.func.isRequired,
options: PropTypes.arrayOf(
PropTypes.exact({
name: PropTypes.string,
value: PropTypes.string.isRequired,
}),
).isRequired,
selectedOption: PropTypes.string,
style: PropTypes.object,
}
Dropdown.defaultProps = {
className: undefined,
disabled: false,
title: undefined,
selectedOption: null,
style: undefined,
}
export default Dropdown