score:5

Accepted answer

it's a matter of timing.

when you use bind, the arguments map on to the function you are binding in the order you bind them followed by any that are passed to the new function.

when you use an arrow function, you are explicitly passing them in the order you determine.

your function expects event to be the first argument, so when you use an arrow you function you pass event, person.id. however, when you bind you pass person.id (the first argument) and when the function is called with event you pass that (as the second argument).

this means you arguments end up the wrong way around.

since you only have person.id when you call bind and you don't get event until later, the only way you can use bind for this is to change the original function so it accepts the arguments in a different order.

namechangehandler = (personid, event) => {

Related Query

More Query from same tag