Skip to content

e.item? #2974

Answered by GianlucaGuarini
senica asked this question in Q&A
Discussion options

You must be logged in to vote

Riot.js 2 introducing the feature you like was released 8 years ago when es6 was not widely supported and ie9 was still a thing. Adding custom properties to an event object in 2022/23 is not the best option we have. Your code can be simply updated as it follows without relying on any magic Riot.js pattern:

<div each={sock in socks}><button onclick={(event) => change(event, sock)}>Change</button></div>
<script>
  export default{
    change(e, sock){
      console.log(sock) 
   }
  }
</script>

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by senica
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants