What is the purpose of form validation in React?
To ensure data integrity and prevent invalid submissions.
To send data to the server for validation.
To style form elements based on user input.
To automatically submit the form when all fields are filled.
When a component's state or props change, React decides whether to update the actual DOM. What is this process called?
Virtual DOM diffing
Lifecycle management
Component rehydration
State reconciliation
What is the recommended approach for handling events in React class components?
Event handling is not typically done within React class components
Define event handlers as separate methods within the class and bind them in the constructor
Use global event listeners to manage events outside the component
Define event handlers as inline arrow functions within the render method
How can you display validation errors to the user in React?
By directly manipulating the DOM to insert error messages.
By using a third-party library specifically for error display.
By conditionally rendering error messages based on validation results.
By relying solely on browser console logs for error reporting.
How do you represent an empty tag in JSX, like an <img> tag?
<img></img>
<img></>
What's the difference between JSX attributes and HTML attributes?
JSX attributes can only be strings, while HTML attributes can be any data type.
JSX attributes are used for styling, while HTML attributes are for functionality.
There is no difference, they are the same.
JSX attributes are written in camelCase, while HTML attributes are lowercase.
How can you access the original DOM event object in a React event handler?
By directly using event.target or event.currentTarget
event.target
event.currentTarget
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.
Through the nativeEvent property of the synthetic event object
nativeEvent
How can you display validation errors to the user in a React form?
By logging errors to the console for debugging purposes.
By using browser alerts to notify the user of invalid input.
By relying solely on HTML5's built-in validation error messages.
What is the primary characteristic of a controlled component in React?
It uses external libraries for form handling.
It directly manipulates the DOM to update form values.
It maintains its own internal state for form data.
It relies on the browser to manage form data.
What is the primary role of 'Synthetic Events' in React?
To prevent default browser actions for all events
To directly manipulate the DOM without using React's virtual DOM
To enable asynchronous event handling in React components
To provide a cross-browser consistent interface for handling DOM events