React-tutorial Quiz 2

React-tutorial Quiz 2

Last Updated :
Discuss
Comments

Question 1

What is the main purpose of using PropTypes in React?

  • To style React components

  • To check the type of props at runtime

  • To fetch data from APIs

  • To improve rendering performance

Question 2

Which of the following correctly validates a name prop as a required string using PropTypes?

  • name: PropTypes.string.optional

  • name: PropTypes.string.required

  • name: PropTypes.string.isRequired

  • name: string.required

Question 3

What is "prop drilling" in React?

  • Passing props through context

  • Passing props from parent to deeply nested child components

  • Using Redux to manage state

  • Replacing props with hooks

Question 4

Which of the following is a drawback of prop drilling?

  • Components become tightly coupled

  • Easier state sharing

  • Faster rendering

  • Enhanced encapsulation

Question 5

Why is it important to provide a key prop when rendering lists in React?

  • To display data in alphabetical order

  • To improve network performance

  • To help React identify which items changed, added, or removed

  • To apply styles to each item

Question 6

What will this code output?

const items = ['A', 'B'];

return (

<ul>

{items.map((item, index) => <li key={index}>{item}</li>)}

</ul>

);

  • A list with items A and B

  • Error due to missing keys

  • Nothing will render

  • Only the first item renders

Question 7

What problem does the Context API solve in React?

  • Component styling

  • Avoiding prop drilling by sharing data globally

  • Making API requests

  • Optimizing component rendering

Question 8

What is the role of a Provider in the Context API?

  • To fetch external data

  • To define initial component styles

  • To allow children to consume context values

  • To optimize rendering speed

Question 9

What is the main reason for using Redux in a React application?

  • Component styling

  • Static file optimization

  • Centralized state management

  • Animation control

Question 10

In Redux, what is the “store”?

  • A UI component

  • A container that holds application state

  • A collection of React hooks

  • A database

There are 10 questions to complete.

Take a part in the ongoing discussion