How to use aframe-react events properly in .map?

205 Views Asked by At

I'm trying to render images and each images should be clickable. I tried to write a code below. However, the click events fires when a user access to the component. Can you explain why is it happening?

the code that I wrote is here

1

There are 1 best solutions below

0
Munkhtegsh.M Munkhbat On

When I use a callback function, it worked out!

events={{click: () => this.props.addToCart(item.product_id)}}