import React from "@modules/react"; import RadioIcon from "@ui/icons/radio"; const {useState, useCallback} = React; export default function Radio({name, value, options, onChange}) { const [index, setIndex] = useState(options.findIndex(o => o.value === value)); const change = useCallback((e) => { const newIndex = parseInt(e.target.value); const newValue = options[newIndex].value; onChange?.(newValue); setIndex(newIndex); }, [options, onChange]); function renderOption(opt, i) { const isSelected = index === i; return ; } return
{options.map(renderOption)}
; }