input type='radio'인 버튼 클릭하기
const [inputStatus, setInputStatus] = useState('');
//name값을 받아와서 state를 변경해주는 함수
const handleClickButton = buttonId => {
setInputStatus(buttonId);
};
return(
<input
name="first"
checked={
//inputStatus가 name값인 first이면 true가 되면서 checked됨, 즉 상태와 정해준 이름이 같으면 true
inputStatus === 'first'}
//onClick을 하면 handleClickButton함수가 실행되면서 args로 name값인 first가 넘어간다
onClick={() => handleClickButton('first')}
/>
<label For="radio">개별발송(준비중)</label>
<input
name="second"
checked={inputStatus === 'second'}
onClick={() => handleClickButton('second')}
/>
<label htmlFor="radio">대량발송(준비중)</label>
<input
name="third"
checked={inputStatus === 'third'}
onClick={() => handleClickButton('third')}
/>
<label htmlFor="radio">보관</label>
);
<label HtmlFor='radio'> Radio </label>