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 enable asynchronous event handling in React components
To directly manipulate the DOM without using React's virtual DOM
What are Synthetic Events in React?
Native browser events directly exposed by the DOM
Events related to state changes within a React component
Events triggered only by synthetic user actions (like bot interactions)
React's custom event objects that wrap native events
When would it be more appropriate to consider using an uncontrolled component in a React form?
When integrating with a third-party library that requires direct access to form elements.
When you need real-time validation and immediate feedback to the user.
When you prefer a more imperative approach and direct DOM manipulation.
When dealing with a large, complex form where performance optimization is critical.
What does JSX ultimately get transpiled into?
JSON
Plain JavaScript
HTML
CSS
Which of the following is a common approach for implementing form validation in React?
Using HTML5 form validation attributes.
Utilizing a dedicated form validation library.
Writing custom validation functions within the component.
All of the above.
What is the purpose of using key prop in JSX elements within a list?
key
To associate event handlers with specific elements.
To define the order in which elements should be displayed.
To give each element a unique identifier for styling purposes.
To help React efficiently update and re-render lists.
How can you access the element that triggered an event within a React event handler?
Using this keyword inside the event handler
this
As a property of the event object (e.g., event.target)
event.target
React doesn't provide a way to access the triggering element
By passing the element as an argument to the event handler
How do you represent an empty tag in JSX, like an <img> tag?
<img></>
<img></img>
How does the useEffect Hook in functional components relate to lifecycle methods in class components?
useEffect
useEffect combines the functionality of componentDidMount, componentDidUpdate, and componentWillUnmount.
componentDidMount
componentDidUpdate
componentWillUnmount
There is no relationship between useEffect and lifecycle methods.
useEffect is a replacement for componentDidMount only.
useEffect is only used for data fetching.
How do you prevent a useEffect hook from running on every render?
By using componentDidMount instead
By not passing a dependency array
By passing an empty array [] as the second argument to useEffect
[]
By wrapping the useEffect call in a conditional statement