React JS MCQs with answers Page - 22

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.27K Points
Coach

Q. What is the main difference between props and state?

  • (A) Props are immutable, state is mutable
  • (B) Props are mutable, state is immutable
  • (C) Both are immutable
  • (D) Both are mutable

A

Admin • 832.27K Points
Coach

Q. Which React hook lets you optimize expensive calculations by caching their results?

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

A

Admin • 832.27K Points
Coach

Q. How do you update state in a class component?

  • (A) By calling this.setState()
  • (B) By assigning directly to this.state
  • (C) By calling setState() without this
  • (D) By using useState hook

A

Admin • 832.27K Points
Coach

Q. What does the React.StrictMode component do?

  • (A) Helps find potential problems by running additional checks
  • (B) Styles components
  • (C) Makes components render faster
  • (D) Replaces Error Boundaries

A

Admin • 832.27K Points
Coach

Q. How can you pass a function as a prop in React?

  • (A) Just pass the function reference in the props object
  • (B) Call the function and pass the return value
  • (C) Use eval() to bind the function
  • (D) Functions cannot be passed as props

A

Admin • 832.27K Points
Coach

Q. What will happen if you update the state directly without using setState in a class component?

  • (A) The component will not re-render
  • (B) The component will re-render
  • (C) It will throw an error
  • (D) State will be reset

A

Admin • 832.27K Points
Coach

Q. What is JSX in React?

  • (A) A syntax extension that looks like HTML and is used with React
  • (B) A JavaScript library for routing
  • (C) A CSS preprocessor
  • (D) A database query language

A

Admin • 832.27K Points
Coach

Q. Which lifecycle method is invoked immediately after a component is mounted in React class components?

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

A

Admin • 832.27K Points
Coach

Q. What hook would you use to manage state in a functional component?

  • (A) useState
  • (B) useEffect
  • (C) useContext
  • (D) useReducer

A

Admin • 832.27K Points
Coach

Q. What is the purpose of the useReducer hook in React?

  • (A) To manage complex state logic with reducers
  • (B) To perform side effects
  • (C) To memoize functions
  • (D) To access context

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