React JS MCQs with answers Page - 2

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 • 832.01K Points
Coach

Q. Which lifecycle method is invoked immediately after a component is mounted?

  • (A) componentWillMount
  • (B) componentDidMount
  • (C) componentDidUpdate
  • (D) componentWillUpdate

A

Admin • 832.01K Points
Coach

Q. Which hook is used to store a mutable value that does not cause re-render?

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

A

Admin • 832.01K Points
Coach

Q. Which company developed React?

  • (A) Google
  • (B) Facebook
  • (C) Twitter
  • (D) Microsoft

A

Admin • 832.01K Points
Coach

Q. What is the correct syntax to handle an event in React?

  • (A) onclick={handleClick}
  • (B) onClick=handleClick()
  • (C) onClick={handleClick}
  • (D) onclick=handleClick()

A

Admin • 832.01K Points
Coach

Q. What does the useEffect hook return?

  • (A) Nothing
  • (B) A function for rendering
  • (C) A cleanup function
  • (D) A state value

A

Admin • 832.01K Points
Coach

Q. What is the second argument of useEffect used for?

  • (A) To provide initial value
  • (B) To define dependencies
  • (C) To define return type
  • (D) To prevent rendering

A

Admin • 832.01K Points
Coach

Q. Which of the following is true about React keys?

  • (A) They should be random
  • (B) They should be strings only
  • (C) They must be unique among siblings
  • (D) They must be global

A

Admin • 832.01K Points
Coach

Q. What will happen if you change the state directly without setState or useState?

  • (A) The component will update
  • (B) The component will not re-render
  • (C) An error will occur
  • (D) React will auto-detect changes

A

Admin • 832.01K Points
Coach

Q. How can props be made optional in a functional component?

  • (A) By setting default values
  • (B) By using useEffect
  • (C) By passing null
  • (D) By skipping render

A

Admin • 832.01K Points
Coach

Q. What does the 'key' prop help React identify?

  • (A) The source of the event
  • (B) The value of a form
  • (C) Which items have changed
  • (D) The root element

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