From b75ad8eec57fd8a6cdee30d1db533f56cb97f99b Mon Sep 17 00:00:00 2001 From: Alexander Klein Date: Tue, 16 Feb 2021 12:57:18 +0100 Subject: [PATCH] feature(components): prop-type DropDown --- components/common/DropDown.js | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/components/common/DropDown.js b/components/common/DropDown.js index 3b3be39e..00d20e34 100644 --- a/components/common/DropDown.js +++ b/components/common/DropDown.js @@ -1,4 +1,5 @@ import React, { useState, useRef } from 'react'; +import PropTypes from 'prop-types'; import classNames from 'classnames'; import Menu from './Menu'; import useDocumentClick from 'hooks/useDocumentClick'; @@ -6,13 +7,7 @@ import Chevron from 'assets/chevron-down.svg'; import styles from './Dropdown.module.css'; import Icon from './Icon'; -export default function DropDown({ - value, - className, - menuClassName, - options = [], - onChange = () => {}, -}) { +function DropDown({ value, className, menuClassName, options = [], onChange = () => {} }) { const [showMenu, setShowMenu] = useState(false); const ref = useRef(); const selectedOption = options.find(e => e.value === value); @@ -52,3 +47,18 @@ export default function DropDown({ ); } + +DropDown.propTypes = { + value: PropTypes.any, + className: PropTypes.string, + menuClassName: PropTypes.string, + options: PropTypes.arrayOf( + PropTypes.shape({ + value: PropTypes.any.isRequired, + label: PropTypes.node, + }), + ), + onChange: PropTypes.func, +}; + +export default DropDown;