import React, { useMemo } from 'react'; import { List, Radio as RadioSource } from 'antd-mobile'; import { ListProps } from 'antd-mobile/es/list'; import { RadioItemProps } from 'antd-mobile/es/radio/RadioItem'; import { toOptions } from '../tool'; import { TInputNotRequired, TOptionsProps } from '../types'; const { RadioItem } = RadioSource; export type TRadioOption = RadioItemProps & { value: number | string; label: React.ReactNode; }; export type TRadioProps = TInputNotRequired & TOptionsProps & ListProps; /** * 单选框 */ export const Radio: React.FC = ({ options = [], value, onChange, ...props }) => { const radioOptions = useMemo(() => toOptions(options), [JSON.stringify(options)]); return ( {radioOptions.map(({ label, value: val, ...i }) => ( {label} ))} ); };