mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-06-01 03:20:46 +08:00
Update test to set state on change
This commit is contained in:
@@ -1,15 +1,20 @@
|
||||
import * as React from 'react';
|
||||
import { Radio, RadioGroup } from "react-radio-group";
|
||||
|
||||
class ReactRadioGroup extends React.Component<RadioGroup.RadioGroupProps> {
|
||||
handleChange: RadioGroup.RadioGroupProps['onChange'] = value => {
|
||||
console.log(value);
|
||||
class ReactRadioGroup extends React.Component<RadioGroup.RadioGroupProps, { selectedValue: React.InputHTMLAttributes<HTMLInputElement>['value'] }> {
|
||||
state = {
|
||||
selectedValue: 2,
|
||||
};
|
||||
|
||||
handleChange: RadioGroup.RadioGroupProps['onChange'] = selectedValue => {
|
||||
console.log(selectedValue);
|
||||
this.setState({ selectedValue });
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<div>
|
||||
<RadioGroup name="radioGroup" onChange={this.handleChange} selectedValue={2}>
|
||||
<RadioGroup name="radioGroup" onChange={this.handleChange} selectedValue={this.state.selectedValue}>
|
||||
<Radio id="Option A" value="a" />
|
||||
<Radio id="Option B" value={2} />
|
||||
<Radio id="Option C" value={["hello"]} disabled />
|
||||
|
||||
Reference in New Issue
Block a user