Quiz about React-tutorial Quiz 2

React-tutorial Quiz 2

Last Updated :
Discuss
Comments

Question 1

What is the main purpose of using PropTypes in React?

  • A

    To style React components

  • B

    To check the type of props at runtime

  • C

    To fetch data from APIs

  • D

    To improve rendering performance

Question 2

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

  • A

    name: PropTypes.string.optional

  • B

    name: PropTypes.string.required

  • C

    name: PropTypes.string.isRequired

  • D

    name: string.required

Question 3

What is "prop drilling" in React?

  • A

    Passing props through context

  • B

    Passing props from parent to deeply nested child components

  • C

    Using Redux to manage state

  • D

    Replacing props with hooks

Question 4

Which of the following is a drawback of prop drilling?

  • A

    Components become tightly coupled

  • B

    Easier state sharing

  • C

    Faster rendering

  • D

    Enhanced encapsulation

Question 5

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

  • A

    To display data in alphabetical order

  • B

    To improve network performance

  • C

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

  • D

    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

    A list with items A and B

  • B

    Error due to missing keys

  • C

    Nothing will render

  • D

    Only the first item renders

Question 7

What problem does the Context API solve in React?

  • A

    Component styling

  • B

    Avoiding prop drilling by sharing data globally

  • C

    Making API requests

  • D

    Optimizing component rendering

Question 8

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

  • A

    To fetch external data

  • B

    To define initial component styles

  • C

    To allow children to consume context values

  • D

    To optimize rendering speed

Question 9

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

  • A

    Component styling

  • B

    Static file optimization

  • C

    Centralized state management

  • D

    Animation control

Question 10

In Redux, what is the “store”?

  • A

    A UI component

  • B

    A container that holds application state

  • C

    A collection of React hooks

  • D

    A database

There are 10 questions to complete.

Take a part in the ongoing discussion