import React, { useEffect, useMemo } from 'react'; import Icon from '../Icon/index'; import { Select } from 'antd'; import { CaretDownOutlined } from '@ant-design/icons'; import { useRecoilState } from 'recoil'; import { searchValue } from '../../store/page'; const { Option } = Select; function LargeScreenComponentSelect(props: ILargeScreenComponentSelect) { const { value, list = [], change, styles, noList, layoutList, switchIcon } = props; const [, setInputValue] = useRecoilState(searchValue); //元件列表的input的value useEffect(() => { setInputValue(''); }, [value]); const Dom = useMemo(() => { return (
{Array.isArray(layoutList) && layoutList.length > 0 && layoutList.map((item, index) => { if (item === 'select') { return ( ); } else if (item === 'switch') { return typeof switchIcon === 'string' ? ( change?.('selectIcon', switchIcon)} /> ) : ( switchIcon ); } })}
); }, [value, list, styles, switchIcon]); return Dom; } export default LargeScreenComponentSelect; export interface ILargeScreenComponentSelect { value?: string; list?: IList[]; change?: Function; styles?: React.CSSProperties; noList?: string; layoutList?: string[]; switchIcon?: string | React.ReactNode; } export interface IList { key: string; name: string; imgUrl?: string; }