ConnorFTW / discord-bot-creator

Create your Discord bot in less than 30 minutes.
https://discord-bot-creator.app/
Other
20 stars 6 forks source link

Avoiding arrow or bind funtions #26

Open rajoriaakash opened 3 years ago

rajoriaakash commented 3 years ago

Tried to fix the issue #19

rajoriaakash commented 3 years ago

But why would I need to declare onSelect when it's already declared?

m5x5 commented 3 years ago

Well if it is already declared then just make sure to extend the declaration by an arrow function outside the JSX attribute. The problem with having functions declared inside JSX is that it'll create a new function with every render. And if you just remove the arrow function that is declared and call onSelect(index) directly, this will not be called when onSelect is being triggered, but when it re-renders.