React JS MCQs with answers Page - 12

Here, you will find a collection of MCQ questions on React JS. Go through these questions to enhance your preparation for upcoming examinations and interviews.

To check the correct answer, simply click the View Answer button provided for each question.

Have your own questions to contribute? Click the button below to share your MCQs with others!

+ Add Question

A

Admin • 831.35K Points
Coach

Q. Which attribute is used in React to give CSS classes?

  • (A) class
  • (B) className
  • (C) css
  • (D) styleName

A

Admin • 831.35K Points
Coach

Q. What is the main advantage of using keys in React lists?

  • (A) Faster search
  • (B) Easy sorting
  • (C) Helps React identify which items have changed
  • (D) Avoids duplicate rendering

A

Admin • 831.35K Points
Coach

Q. Which method is used to change the state in a React class component?

  • (A) this.setChange()
  • (B) this.changeState()
  • (C) this.setState()
  • (D) this.updateState()

A

Admin • 831.35K Points
Coach

Q. How many elements can a React component return?

  • (A) Only one element
  • (B) Only two elements
  • (C) Multiple elements using an array or fragment
  • (D) None

A

Admin • 831.35K Points
Coach

Q. Which of the following is used for performance optimization in React?

  • (A) React.delay()
  • (B) React.cache()
  • (C) React.memo()
  • (D) React.optimize()

A

Admin • 831.35K Points
Coach

Q. How do you pass data from parent to child component in React?

  • (A) Using setState
  • (B) Using props
  • (C) Using refs
  • (D) Using context

A

Admin • 831.35K Points
Coach

Q. What will `useEffect(() => {}, [])` do?

  • (A) Run after every render
  • (B) Run only once after the initial render
  • (C) Never run
  • (D) Run before every render

A

Admin • 831.35K Points
Coach

Q. Which hook is best for accessing DOM elements directly?

  • (A) useEffect
  • (B) useMemo
  • (C) useRef
  • (D) useState

A

Admin • 831.35K Points
Coach

Q. What is a React fragment?

  • (A) A single root element
  • (B) A placeholder for props
  • (C) A tool for debugging
  • (D) A way to group elements without extra nodes

A

Admin • 831.35K Points
Coach

Q. Which React component lifecycle method is called before rendering?

  • (A) componentDidMount
  • (B) componentWillUnmount
  • (C) render
  • (D) getDerivedStateFromProps

Add MCQ in this Category

If you want to share an MCQ question in this category, it's a great idea! It will be helpful for many other students using this website.

Share Your MCQ