How can you display validation errors to the user in React?
By using a third-party library specifically for error display.
By relying solely on browser console logs for error reporting.
By directly manipulating the DOM to insert error messages.
By conditionally rendering error messages based on validation results.
What is the purpose of form validation in React?
To style form elements based on user input.
To ensure data integrity and prevent invalid submissions.
To automatically submit the form when all fields are filled.
To send data to the server for validation.
What is the purpose of using key prop in JSX elements within a list?
key
To associate event handlers with specific elements.
To give each element a unique identifier for styling purposes.
To help React efficiently update and re-render lists.
To define the order in which elements should be displayed.
In React, what is the primary method for handling events in functional components?
React components don't handle events directly; you must use a library.
Using inline event handlers like onClick={handleClick}
onClick={handleClick}
Using the addEventListener method like in vanilla JavaScript
addEventListener
Defining separate event handler methods within the component
How does the useEffect Hook in functional components relate to lifecycle methods in class components?
useEffect
There is no relationship between useEffect and lifecycle methods.
useEffect is only used for data fetching.
useEffect combines the functionality of componentDidMount, componentDidUpdate, and componentWillUnmount.
componentDidMount
componentDidUpdate
componentWillUnmount
useEffect is a replacement for componentDidMount only.
What is the primary purpose of components in React?
To break down the UI into independent, reusable pieces
To directly manipulate the DOM
To manage application state
To handle user interactions
What is the primary difference between controlled and uncontrolled components in React forms?
Controlled components directly manipulate the DOM, while uncontrolled components use React's state management.
Controlled components are suitable for simple forms, while uncontrolled components are ideal for complex forms.
Controlled components are deprecated in React, and uncontrolled components are the recommended approach.
Controlled components rely on React's state management for form data, while uncontrolled components use DOM references.
What is the purpose of the componentWillUnmount() lifecycle method?
componentWillUnmount()
To handle user interactions like button clicks.
To render the component for the first time.
To update the state based on changes in props.
To perform any necessary cleanup operations before a component is removed from the DOM.
Which of the following JSX expressions is INVALID?
<span>This is incorrect {</span>
What is the primary role of 'Synthetic Events' in React?
To enable asynchronous event handling in React components
To directly manipulate the DOM without using React's virtual DOM
To provide a cross-browser consistent interface for handling DOM events
To prevent default browser actions for all events