How can you access the original DOM event object in a React event handler?
Through the nativeEvent property of the synthetic event object
nativeEvent
By using a ref to the DOM element and accessing its event listeners
React doesn't provide access to the original DOM event; it's completely abstracted.
By directly using event.target or event.currentTarget
event.target
event.currentTarget
How do uncontrolled components in React handle form data?
By using refs to directly access and manage DOM values.
By relying on data binding between the form and component state.
By sending an HTTP request to the server on every input change.
By storing the data in a global state management library.
What is the primary purpose of components in React?
To directly manipulate the DOM
To manage application state
To break down the UI into independent, reusable pieces
To handle user interactions
What are props in React?
Functions to update the UI
Internal data of a component
Lifecycle methods of a component
Arguments passed to a component
What is the primary role of 'Synthetic Events' in React?
To enable asynchronous event handling in React components
To provide a cross-browser consistent interface for handling DOM events
To prevent default browser actions for all events
To directly manipulate the DOM without using React's virtual DOM
When a component's state or props change, React decides whether to update the actual DOM. What is this process called?
State reconciliation
Virtual DOM diffing
Lifecycle management
Component rehydration
What will happen if you update the state directly in a class component instead of using this.setState()?
this.setState()
An error will be thrown
The state will be updated, but the component won't re-render
The application will crash
The component will re-render automatically
What is the purpose of event.preventDefault() in React event handling?
event.preventDefault()
To detach the event handler after it has been executed once
To cancel the event entirely and prevent any further actions
To prevent the default behavior of the event (like form submission)
To stop the event from bubbling up the component tree
How do class components in React typically handle events?
Using inline arrow functions directly in the JSX
By defining methods on the class that act as event handlers
Class components cannot handle events; only functional components can
By relying on external state management libraries for event handling
Which of the following is NOT a valid way to bind an event handler in a React class component?
Directly passing the method: onClick={this.handleClick}
onClick={this.handleClick}
Using addEventListener directly on the DOM element
addEventListener
Binding in the constructor: this.handleClick = this.handleClick.bind(this)
this.handleClick = this.handleClick.bind(this)
Using an arrow function in the callback: onClick={() => this.handleClick()}
onClick={() => this.handleClick()}