What is the primary purpose of components in React?
To directly manipulate the DOM
To break down the UI into independent, reusable pieces
To handle user interactions
To manage application state
What is the typical approach for handling form submission in React?
Using the browser's default form submission mechanism.
Submitting the form using AJAX without any event handling.
Preventing default behavior and handling submission logic within an event handler.
Using a third-party library to handle all form-related tasks.
What is the purpose of using key prop in JSX elements within a list?
key
To give each element a unique identifier for styling purposes.
To define the order in which elements should be displayed.
To associate event handlers with specific elements.
To help React efficiently update and re-render lists.
What is the correct syntax for a functional component in React?
function Welcome(props) { ... }
let Welcome = (props) => { ... }
class Welcome extends React.Component { ... }
const Welcome = () => { ... };
Which of the following JSX expressions is INVALID?
<span>This is incorrect {</span>
What is the purpose of form validation in React?
To send data to the server for validation.
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.
What is the purpose of the useState hook in React?
useState
To handle user input events
To manage and update the state of a functional component
To fetch data from an API
To style components dynamically
Which of the following is a key difference between functional components and class components in React?
Functional components are written in JavaScript, while class components use TypeScript
Functional components are used for complex UI logic, while class components are for simple elements
Functional components cannot receive props, while class components can
Functional components are stateless, while class components can have state
What is the correct way to embed a JavaScript expression inside JSX?
{ expression }
{{ expression }}
expression
( expression )
What happens if a prop is not provided to a component with a default prop defined?
The default prop value is used
An error is thrown
The prop will be undefined
The component will not render