update
"the react way" of doing that is to add the defaultChecked={true}
to the needed input. Other ways are listed below.
I actually faced the same situation. What I did was to find the input
tag in the componentDidMount
lifecycle method of the parent React component and set the checked
attribute then.
If we speak about vanilla JS you can find the first radio input using querySelector. Like so:
var Form = React.createClass({
componentDidMount: function(){
this.getDOMNode().querySelector('[type="radio"]').checked = "checked";
},
render: function(){
//your render here
}
});
If you use jQuery, this can be done like this:
...
$(this.getDOMNode()).find('[type="radio"]').eq(0).prop("checked", true);
...
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…