mercredi 26 avril 2017

how to get index of selected checkbox or Name of List Item whose checkbox is selecetd?

I am trying to create a List in which every ListItem has checkbox attached.

<List>
           {
             name.map((row,index) =>(
               <ListItem
                 key={index}
                 leftCheckbox={<Checkbox onCheck={checkBoxSelect.bind(this, index)}/>}


               >
               {name[index]}
               </ListItem>
             ))
           }
         </List>

following is the onCheck function

checkBoxSelect(event, index){
    console.log(index);
}

but it's not giving me index, following is the value on console.

Proxy {dispatchConfig: Object, _targetInst: ReactDOMComponent, nativeEvent: 
MouseEvent, type: "change", target: input…}

how can I get correct index?




Aucun commentaire:

Enregistrer un commentaire