mardi 2 janvier 2018

Is it possible to set DefaultCheck with function? React

I have a component which get props a:[] b:[] values might be 1, 2, 3, 4

I have 8 checkboxes with name="a" and "b" with value="1" , "2","3" and "4" respectively

is it possible to set the defaultChecked with function? something like

<input name="a" type="checkbox" value="1" defaultChecked={this.checkIt.bind(this,name,value)} />

checkIt(this,name.value) {
if (this.props.name.indexOf(value)>=0)
{
   return true;
}
return false;
}




Aucun commentaire:

Enregistrer un commentaire