import React, { useState, useEffect } from 'react';

interface Props {
    onChange: (name: string, value: string,) => void;
    type: string,
    name: string,
    label: string,
    value: string,
  }

export const RadioButton: React.FC<Props> = ({type, name, label, onChange, value }) => {
    const [variable, setVariable] = useState(0);
    const change = (e) => {
        setVariable(e.target.value);
        props.updateData(e.target.value);
    }
    return(
        <div className='fieldset'>
            {props.masImg.map((name, num) => <>
                <input
                    type="radio"
                    name="radio"
                    className='radioButton'
                    value={num}
                    onChange={(e) =>change(e) }
                    checked={variable == num}
                /> </>
            )}
        </div>
    )
}

export default RadioButton;