e.item? #2974
-
It's been a while since I've used riot for a project. Want to take another look at it and using Riot 7 and trying to get used to the changes. In events within a loop, you used to be able to access the data using e.item.. That seems gone, but I can't find anything in the docs and nothing in the migration guide that would indicate the suggested change. Are we expected to use
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
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> |
Beta Was this translation helpful? Give feedback.
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: