Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

react native how to pass id from list to function

render(){
    return(
      <ul id="todo">
      {this.state.items.map((item,i) => 
        <li className='list-group-item' key={i} data-id={item.id}>{item.name}
        <button onClick={() => this.yourfunc(item.id)}>X</button>
        </li>
      )}
      </ul>
    ) 
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #react #native #pass #id #list #function
ADD COMMENT
Topic
Name
2+1 =