Set value and label of Radio.
1() => <Radio value="China" label="China" />2
Set defaultChecked of Radio.
1() => <Radio value="China" defaultChecked label="China" />2
1() => {2 const onChange = (val) => {3 console.log(val);4 };5 return (6 <>7 <RadioGroup onChange={onChange}>8 <Radio label="China" value="China" />9 <Radio label="USA" value="USA" />10 </RadioGroup>11 </>12 );13}14
1() => {2 const [value, setValue] = React.useState('China');3 const toggle = () => {4 if (value === 'USA') {5 setValue('China');6 } else {7 setValue('USA');8 }9 };10 const onChange = (val) => {11 console.log(val);12 };13 return (14 <>15 <RadioGroup value={value} onChange={onChange}>16 <Radio label="China" value="China" />17 <Radio label="USA" value="USA" />18 </RadioGroup>19 <div>20 <Button onClick={toggle}>Switch</Button>21 </div>22 </>23 );24}25