What is the purpose of using key prop in JSX elements within a list?
key
To associate event handlers with specific elements.
To help React efficiently update and re-render lists.
To give each element a unique identifier for styling purposes.
To define the order in which elements should be displayed.
What will happen if you update the state directly in a React component?
The component will re-render, and the state change will be reflected correctly.
Nothing will happen; the state will remain unchanged.
The component will re-render, but the state change won't be reflected.
An error will be thrown, and the application will crash.
What is the primary role of 'Synthetic Events' in React?
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
To enable asynchronous event handling in React components
How do you represent an empty tag in JSX, like an <img> tag?
<img></>
<img></img>
What is the recommended approach for handling events in React class components?
Define event handlers as separate methods within the class and bind them in the constructor
Define event handlers as inline arrow functions within the render method
Use global event listeners to manage events outside the component
Event handling is not typically done within React class components
What is the primary use case for the useEffect hook?
useEffect
To render components conditionally
To perform side effects like data fetching, DOM manipulation, or subscriptions
To manage state within a component
To handle form submissions
What's a common way to bind event handlers in React class components?
Using bind in the constructor
bind
Using arrow functions in the render method
render
Calling addEventListener within the componentDidMount lifecycle method
addEventListener
componentDidMount
Both 'Using bind in the constructor' and 'Using arrow functions in the render method'
What is a key advantage of using a controlled component for a file input in React?
Improved browser compatibility for file uploads.
Automatic upload of the file to the server.
Simplified styling of the file input element.
Direct access to the file data in the component's state.
Which of the following JSX expressions is INVALID?
<span>This is incorrect {</span>
What is the primary characteristic of a controlled component in React?
It maintains its own internal state for form data.
It uses external libraries for form handling.
It directly manipulates the DOM to update form values.
It relies on the browser to manage form data.