What happens if a prop is not provided to a component with a default prop defined?
The prop will be undefined
An error is thrown
The component will not render
The default prop value is used
What is the second argument of the useEffect Hook used for?
useEffect
It defines the effect to be executed.
It indicates the effect should be executed only once, like componentDidMount.
componentDidMount
It provides access to the previous state and props.
It specifies a list of dependencies that trigger the effect when they change.
How can you display validation errors to the user in a React form?
By conditionally rendering error messages based on validation results.
By logging errors to the console for debugging purposes.
By relying solely on HTML5's built-in validation error messages.
By using browser alerts to notify the user of invalid input.
What is the correct syntax for defining default props in a functional component in React?
export default function MyComponent(props = { name: 'John' }) { }
defaultProps = { name: 'John' }(MyComponent);
function MyComponent(props) { props.defaultProps = { name: 'John' }; }
MyComponent.defaultProps = { name: 'John' };
Which type of component in React is primarily used for presenting data and does not manage its own state?
State Component
Class Component
Functional Component
Higher-Order Component
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 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.
By using a ref to the DOM element and accessing its event listeners
In React functional components, how do you typically handle events?
Events are not handled in functional components, only in class components
Using inline event handlers directly in JSX
By defining methods inside the component class
By creating separate event listener functions outside the component
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 correct way to embed a JavaScript expression inside JSX?
{ expression }
( expression )
{{ expression }}
expression
What is the recommended approach for handling events in React class components?
Define event handlers as inline arrow functions within the render method
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
Event handling is not typically done within React class components