I am getting this warning when I run the below code.How can I remove the error?
Thank you.
Warning: Failed form propType: You provided a
valueprop to a form field without anonChangehandler. This will render a read-only field. If the field should be mutable usedefaultValue. Otherwise, set eitheronChangeorreadOnly. Check the render method oftest.
var test = React.createClass({
getInitialState : function(){
return {
number : 10,
checked: [],
selected : []
};
},
componentWillMount : function(){
},
moreAilment : function (){
var temp = this.state.number + 5;
this.setState({number:temp});
},
handleChangechk: function (e){
const target = e.target;
const value = target.type === 'checkbox' ? target.checked : target.value;
const name = target.name;
var checkedCopy = this.state.checked.slice();
var selectedCopy = this.state.selected.slice();
if(value===true) {
checkedCopy[name] = true;
selectedCopy [name] = name; }
else {
checkedCopy[name] = false;
selectedCopy [name] = ''; }
this.setState({
checked: checkedCopy,
selected: selectedCopy });
},
render : function() {
var ailmentsList = [];
var selectedList= [];
for (var i = 0; i < this.state.number; i++) {
ailmentsList.push(<span ><input type="checkbox" checked={!!this.state.checked[i]} onChange={(e)=> {this.handleChangechk(e)}} /><span ></span><label> Asthma {i}</label></span>);
if(this.state.selected[i])
{
selectedList.push(this.state.selected[i]);
}
};
return(
<div className>
{selectedList}
</div>
);
}
});