Try to search your question here, if you can't find : Ask Any Question Now ?

How does bind automatically pass the event argument to an event handler?

HomeCategory: stackoverflowHow does bind automatically pass the event argument to an event handler?
Avatarrupesh asked 4 months ago

The React docs page on Handling Events states:

<button onClick={(e) => this.deleteRow(id, e)}>Delete Row</button>
<button onClick={this.deleteRow.bind(this, id)}>Delete Row</button>

In both cases, the e argument representing the React event will be
passed as a second argument after the ID. With an arrow function, we
have to pass it explicitly, but with bind any further arguments are
automatically forwarded.

So, when using bind, the event is is passed as an argument to the event handler in the callback–how/why does that work?

1 Answers
Best Answer
AvatarMannu answered 4 months ago
Your Answer

14 + 13 =

Popular Tags

WP Facebook Auto Publish Powered By : XYZScripts.com