What are Synthetic Events in React?
Native browser events directly exposed by the DOM
Events triggered only by synthetic user actions (like bot interactions)
React's custom event objects that wrap native events
Events related to state changes within a React component
How do uncontrolled components in React handle form data?
By storing the data in a global state management library.
By relying on data binding between the form and component state.
By sending an HTTP request to the server on every input change.
By using refs to directly access and manage DOM values.
What is the purpose of form validation in React?
To style form elements based on user input.
To send data to the server for validation.
To automatically submit the form when all fields are filled.
To ensure data integrity and prevent invalid submissions.
What is the primary purpose of components in React?
To handle user interactions
To manage application state
To directly manipulate the DOM
To break down the UI into independent, reusable pieces
What's a common way to bind event handlers in React class components?
Using arrow functions in the render method
render
Using bind in the constructor
bind
Both 'Using bind in the constructor' and 'Using arrow functions in the render method'
Calling addEventListener within the componentDidMount lifecycle method
addEventListener
componentDidMount
What is the purpose of using the event.preventDefault() method within a form submission handler in React?
event.preventDefault()
To validate the form data before submission.
To clear the form data after submission.
To submit the form data asynchronously without using AJAX.
To prevent the browser from refreshing the page.
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
By directly using event.target or event.currentTarget
event.target
event.currentTarget
React doesn't provide access to the original DOM event; it's completely abstracted.
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 deprecated in React, and uncontrolled components are the recommended approach.
Controlled components are suitable for simple forms, while uncontrolled components are ideal for complex forms.
Controlled components rely on React's state management for form data, while uncontrolled components use DOM references.
What is the correct syntax for a functional component in React?
const Welcome = () => { ... };
class Welcome extends React.Component { ... }
let Welcome = (props) => { ... }
function Welcome(props) { ... }
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 define the order in which elements should be displayed.
To help React efficiently update and re-render lists.