Element doesn't get selected
thierryfornetti opened this issue · 2 comments
After updating from version 0.1.10 to 0.2.0, when I click on an item the circle doesn't get updated with the dot. The selected dot is always the one specified in the prop selectedIndex
.
The element is selected, it's just a graphic issue.
I think the problem is the commit ef5d5c7
componentWillReceiveProps(nextProps){
this.setState({
selectedIndex: nextProps.selectedIndex
})
}
Selected index is a fixed value, so you always draw that, from the readme
selectedIndex: initialize selected index of radio group
I'm using React 15.4.2 and React Native 0.42.3
I apologize for inconvenience.
You're right. The problem come from commit ef5d5c7. Because someone need to update radio button programmatically by change 'selectedIndex' value to new index or to null (for clear radio button).
The solution for v.0.2.0 will be keep selectedIndex in state and update from onSelect
<RadioGroup
//...other props
selectedIndex={this.state.selectedIndex}
onSelect={this.onSelect}
>
//...radio buttons
</RadioGroup>
onSelect(index, value){
this.setState({
selectedIndex: index
})
}
Btw. you can upgrade flexi-radio-button to v.0.2.1 and do not thing with the code.
So, Thank you for your collaborate and sorry again.
Cheer.
Ok, I tested my code that worked with version v0.1.10 and now works with versione v0.2.1.
So right now the property selectedIndex has 2 roles:
- with a fixed value it's the default selected item
- when the value change it's the currently selected item
Looks great, you should just update the readMe in the Configuration section. Thanks!