Loading

Quipoin Menu

Learn • Practice • Grow

react / Passing Arguments to Events
mcq
Direction: Choose the correct option

Q1.

How can you pass an argument to an event handler in React?
A. <button onClick={this.handleClick(id)}>
B. <button onClick={this.handleClick.bind(this, id)}>
C. <button onClick={() => this.handleClick(id)}>
D. Both B and C
Direction: Choose the correct option

Q2.

In an arrow function event handler like onClick={() => handleClick(id)}, what is the event object?
A. It is the first argument
B. It is passed automatically as the second argument
C. It is lost
D. It must be explicitly passed
Direction: Choose the correct option

Q3.

Using .bind, how do you access the event?
A. The event is the first argument
B. You cannot access the event
C. Use event.bind
D. The event is automatically passed after the bound arguments
Direction: Choose the correct option

Q4.

What is the output if you have: and handleClick(arg, e) { console.log(arg, e); }?
A. 'a' and undefined
B. Error
C. undefined and event
D. 'a' and the event object
Direction: Choose the correct option

Q5.

Which approach avoids creating a new function on every render when passing arguments?
B. Using a data-attribute and reading from event
C. Arrow function in render
D. bind in render