Skip to content

armgit / umami

Public Imported from GitHub
0

Umami is a privacy-first web and product analytics platform. Traffic, campaigns, behavior, conversions, and revenue in one place. No cookies, no surveillance, self-hosted or in the cloud.

feature(components): prop-type DropDown

Alexander Kleinb75ad8eec57f
diff --git a/components/common/DropDown.js b/components/common/DropDown.js
index 3b3be39e4..00d20e34d 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({
</div>
);
}
+
+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;