React Fundamentals

0% completed

Previous
Next
Quiz
Question 1
How do you handle an event in a React component?
A
By adding an event listener using document.addEventListener()
B
By defining an event handler function and passing it to an event attribute like onClick
C
By using the handleEvent() method provided by React
D
By modifying the DOM directly inside componentDidMount()
Question 2
Which of the following is the correct way to pass arguments to an event handler in React?
A
<button onClick={handleClick(event)}>Click Me</button>
B
<button onClick={handleClick(5)}>Click Me</button>
C
<button onClick={() => handleClick(5)}>Click Me</button>
D
<button onClick={handleClick}>Click Me</button>
Question 3
How can you prevent the default behavior of an event in React?
A
By returning false from the event handler
B
By calling event.stopPropagation()
C
By calling event.preventDefault() inside the event handler
D
By setting event.defaultPrevented = true
Question 4
Which event is triggered when a user clicks on a button in React?
A
onHover
B
onChange
C
onSubmit
D
onClick

.....

.....

.....

Like the course? Get enrolled and start learning!
Previous
Next