0
0
Fork 0

Rewrite RadioButton component as FC (#24897)

This commit is contained in:
たいち ひ 2023-05-08 18:12:53 +09:00 committed by GitHub
parent a65d2d1045
commit 76264e3fe8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 30 additions and 35 deletions

View file

@ -0,0 +1,30 @@
import React from 'react';
import classNames from 'classnames';
type Props = {
value: string;
checked: boolean;
name: string;
onChange: (event: React.ChangeEvent<HTMLInputElement>) => void;
label: React.ReactNode;
};
export const RadioButton: React.FC<Props> = ({ name, value, checked, onChange, label }) => {
return (
<label className='radio-button'>
<input
name={name}
type='radio'
value={value}
checked={checked}
onChange={onChange}
/>
<span className={classNames('radio-button__input', { checked })} />
<span>{label}</span>
</label>
);
};
export default RadioButton;