Better HN
topnewbestaskshowjobs
Log inSign up

leomelin

1 karma · joined Feb 3, 2016 (10y ago) · 1 submissions

Submissions

comment 10y ago · link · parent

How do you avoid the e => fn() here in stateless functional component? This is very common case and I can't see other workaround than to use redux mapStateToProps, or without redux maybe mapProps from recompose. Or to use something stupid like writing the item.id into data-attr-id on the li -element and digging out the id -value in the event handler...

  const List = props => 
    <ul>
      props.items.map(item =>
        <li onClick={e => props.itemClicked(item.id)}>{item.name}</li>
      )
    </ul>