React JS MCQs with answers Page - 19

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. How do you prevent a form submission from refreshing the page in React?

  • (A) By calling event.preventDefault() in the submit handler
  • (B) By using type='button' on the submit button
  • (C) By removing the form tag
  • (D) By using useState hook

A

Admin • 832.27K Points
Coach

Q. Which is a valid way to apply inline styles in React?

  • (A) style='color: red;'
  • (B) style={{ color: 'red' }}
  • (C) style={color: red}
  • (D) style='color:red;'

A

Admin • 832.27K Points
Coach

Q. What will the following JSX compile to?
<div>Hello, {name}</div>

  • (A) Creates a div with static text
  • (B) Creates a div with the value of variable name inserted
  • (C) Throws an error if name is undefined
  • (D) Nothing is rendered

A

Admin • 832.27K Points
Coach

Q. How do you conditionally render a component in React?

  • (A) Using if-else statements outside JSX
  • (B) Using ternary operators inside JSX
  • (C) Using logical && operator inside JSX
  • (D) All of the above

A

Admin • 832.27K Points
Coach

Q. What is the correct way to update state based on the previous state?

  • (A) setState(newState)
  • (B) setState(prevState => newState)
  • (C) this.state = newState
  • (D) state = newState

A

Admin • 832.27K Points
Coach

Q. Which of these hooks is used for complex state logic or multiple related states?

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

A

Admin • 832.27K Points
Coach

Q. Which package is typically used to enable routing in React applications?

  • (A) react-navigation
  • (B) react-router-dom
  • (C) redux-router
  • (D) react-router-native

A

Admin • 832.27K Points
Coach

Q. Which of these is a controlled component in React?

  • (A) An input element with value controlled by React state
  • (B) An input element with defaultValue attribute
  • (C) An input element with no value attribute
  • (D) An uncontrolled input

A

Admin • 832.27K Points
Coach

Q. What does the React.Fragment component do?

  • (A) Renders a hidden div
  • (B) Allows grouping multiple children without adding extra nodes
  • (C) Creates a portal
  • (D) Creates a context provider

A

Admin • 832.27K Points
Coach

Q. How can you optimize a React component to prevent unnecessary re-renders?

  • (A) Using PureComponent or React.memo
  • (B) Always calling setState
  • (C) Removing keys from list items
  • (D) Avoid using useEffect

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