How can I reset radio button to default state or clear all selected radio buttons. CODE
Asked
Active
Viewed 324 times
1 Answers
1
You could implement your onReset
method in this way to clear (or reset) all selected radio buttons in your form:
onReset = () => {
// Extract out cards from your state
var cards = this.state.cards
// Iterate each card..
cards.forEach(card => {
// Iterate each card option..
card.options.forEach(option => {
// Reset selected value of option
option.selected = false
})
})
// Apply "reset" card state to your component to cause a re-render
this.setState({ cards : cards })
}
Here is a running sample for you to see in action: https://stackblitz.com/edit/react-ujmlcz?file=index.js

Dacre Denny
- 29,664
- 5
- 45
- 65
-
Hey budy. Can u help me with this problem please [link](https://stackoverflow.com/questions/52157601/react-onclick-lisitem-display-the-data-of-selected-lisitem-from-json). Trying to fetch selected data onclick listitem but it is fetching all the data. – contact dummy Sep 04 '18 at 01:37
-
@contactdummy yes, I've just provided you an answer - hope that helps – Dacre Denny Sep 04 '18 at 02:27