I'm trying to set up radioButtons in my react application using the react-toolbox radio buttons https://github.com/react-toolbox/react-toolbox/tree/dev/components/radio.
This is my code:
import {RadioGroup, RadioButton} from 'react-toolbox/lib/radio';
class ClientsEdit extends Component {
constructor(props) {
super(props);
this.bindLibs();
this.state = {
counterType: 1
};
}
// Some other functions
render() {
return (
<div>
<RadioGroup name='counterType' value={this.state.counterType} onChange={this.handleRadioButtonChange}>
<RadioButton label={t('clients:new.numeric')} value={1}/>
<RadioButton label={t('clients:new.alphanumeric')} value={2}/>
</RadioGroup>
</div>
);
}
bindLibs= () => {
// ...
this.handleRadioButtonChange = handleRadioButtonChange.bind(this);
}
}
There are two problems:
- No radioButton is checked although I'm declaring
this.state.counterType
to be 1 - When trying to change the state (by clicking) the onChange isn't triggered
Using Strings instead of integers doesn't solve the problem either. What am I doing wrong here? Thanks!