import React, { useState, createRef } from 'react'; import { useOutsideClick } from '../app/hooks'; import '../assets/styles/elements/_GenericDropdown.scss'; type GenericDropdownType = { label?: string innerLabel?: string description?: string } & React.PropsWithChildren const GenericDropdown: React.FC = ( { label, innerLabel, description, children, }: GenericDropdownType ) => { const [ isActive, setActive ] = useState( false ); const [ isVisible, setVisible ] = useState( false ); const ref = createRef(); useOutsideClick( ref, () => { setActive( false ); setVisible( false ); } ); const handleMenu = () => { setActive( ! isActive ); setTimeout( () => { setVisible( ! isVisible ); }, 100 ); }; return (
{ label }
{ innerLabel }
{ children }
{ description &&

{ description }

}
); }; export default React.memo( GenericDropdown );