radio buttons are not working with react
See original GitHub issueI render html using react like this:
var RegisterBox = React.createClass({
clickOk:function(e) {
e.preventDefault();
},
render:function(){
return (
<div className="row">
<form className="col s12">
<div className="row">
<div className="input-field col s12">
<input placeholder="input your nickname" id="nickname" type="text" className="validate" />
<label for="nickname">input your nickname</label>
</div>
</div>
<div className="row">
<div className="input-field col s12">
<input id="password1" type="password" className="validate" />
<label for="password">set pwd</label>
</div>
</div>
<div className="row">
<div className="input-field col s12">
<input id="password2" type="password" className="validate" />
<label for="password">repeat pwd</label>
</div>
</div>
<div className="row">
<div className="col s6">
<input name="contactm" type="radio" id="email1" value="email" defaultChecked />
<label for="email">use email</label>
</div>
<div className="col s6">
<input name="contactm" type="radio" id="tel" value="tel" />
<label for="tel">use mobile</label>
</div>
</div>
<div className="row">
<div className="input-field col s12">
<input id="email" type="email" className="validate" />
<label for="email">Email</label>
</div>
</div>
<div className="row">
<button className="btn waves-effect waves-light" name="action" onClick={this.clickOk}>register
</button>
</div>
</form>
</div>
)
}
})
ReactDOM.render(
<RegisterBox />,
document.getElementById('content')
);
The radio buttons, however, are not working. When I click the other radio button, there is nothing happening.
Issue Analytics
- State:
- Created 7 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
reactjs - Radio button not working - Stack Overflow
Warning: RadioButton contains an input of type radio with both checked and defaultChecked props. Input elements must be either controlled or ...
Read more >How to work with radio buttons in React - DEV Community
In this article, we will see how to render radio buttons in react and how to know which radio button is selected. First,...
Read more >How to Use Radio Buttons in ReactJS | Pluralsight
Radio buttons let a user choose a single option from a list of multiple radio buttons and submit its value. · For example,...
Read more >Radio Buttons In React.js
It's clear that our <input> component has 2 states to render: selected radio button and unselected radio button. Let's make our Application component...
Read more >How to create a React Radio Button - Robin Wieruch
Follow on Facebook. A short React tutorial by example for beginners about using a radio button in React. First of all, a radio...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
This is super late. I stumbled upon this due to my own issues but I believe the problems with this was using
for
instead ofhtmlFor
for the label attribute.for
is not recognized in React.did this ever got resolved? In my React app I have issues working with checkboxes and radio buttons. they get rendered well but never fire an event. because the input is never clicked.