import React, { useState, useEffect } from 'react'; import { View } from 'react-native'; import RadioButton from '../RadioButton'; import { RadioGroupProps } from './types'; const RadioGroup = ({ onChange, defaultValue, size, containerStyle, labelStyle, children, style, }: RadioGroupProps) => { const [selectedValue, setSelectedValue] = useState(defaultValue); useEffect(() => onChange(selectedValue!), [selectedValue]); return ( {children?.map((radioButton, index) => ( setSelectedValue(value)} selected={radioButton.props?.value === selectedValue} /> ))} ); }; RadioGroup.defaultProps = { size: 'sm', }; export default RadioGroup;