-
Notifications
You must be signed in to change notification settings - Fork 420
Open
Description
Currently, handleRadio(event) looks like this:
let obj = {}
obj[event.target.value] = event.target.checked // true
this.setState({radioGroup: obj})
This won't work as written. Since obj is an empty object, the radio buttons in the group besides the one checked will have a value of undefined after this.setState(). The handler should be written as:
let obj = Object.assign(this.state.radioGroup) // prevents undefined
/* iterate through object and set all to false since only one radio
can be checked at a time.*/
for (const radio in obj) { obj[radio] = false }
obj[event.target.value] = true
this.setState({radioGroup: obj})
Metadata
Metadata
Assignees
Labels
No labels