React JS MCQs with answers Page - 23

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 can you prevent a component from rendering in React?

  • (A) Return null from the render method or functional component
  • (B) Call event.preventDefault()
  • (C) Use componentDidMount lifecycle method
  • (D) Remove the component from the DOM manually

A

Admin • 832.27K Points
Coach

Q. Which of these is NOT a valid way to create a React component?

  • (A) function MyComponent() { return <div />; }
  • (B) class MyComponent extends React.Component {}
  • (C) const MyComponent = () => <div />;
  • (D) createComponent(() => <div />);

A

Admin • 832.27K Points
Coach

Q. What is the difference between controlled and uncontrolled components in React?

  • (A) Controlled components have their value controlled by React state, uncontrolled components manage their own state
  • (B) Controlled components are class components, uncontrolled are functional
  • (C) Controlled components do not have state, uncontrolled do
  • (D) There is no difference

A

Admin • 832.27K Points
Coach

Q. How can you optimize performance by avoiding unnecessary re-renders in React?

  • (A) Use React.memo for functional components and shouldComponentUpdate for class components
  • (B) Avoid using props
  • (C) Disable JavaScript
  • (D) Use inline styles

A

Admin • 832.27K Points
Coach

Q. What does the term 'prop drilling' mean in React?

  • (A) Passing props through many levels of components unnecessarily
  • (B) Drilling holes in the UI
  • (C) Using CSS selectors in props
  • (D) Deep cloning props

A

Admin • 832.27K Points
Coach

Q. Which React feature helps avoid prop drilling?

  • (A) Context API
  • (B) useState
  • (C) useEffect
  • (D) Redux

A

Admin • 832.27K Points
Coach

Q. What is the correct syntax to create a React Fragment?

  • (A) <> ... </>
  • (B) <fragment> ... </fragment>
  • (C) <React.Fragment> ... </React.Fragment>
  • (D) Both option1 and option3

A

Admin • 832.27K Points
Coach

Q. What is the purpose of the useCallback hook?

  • (A) To memoize functions to prevent unnecessary re-creations
  • (B) To memoize values
  • (C) To manage state
  • (D) To fetch data

A

Admin • 832.27K Points
Coach

Q. Which of the following is a feature of React?

  • (A) Virtual DOM
  • (B) Direct DOM manipulation
  • (C) Two-way data binding
  • (D) Server-side rendering only

A

Admin • 832.27K Points
Coach

Q. What is the difference between useEffect and useLayoutEffect?

  • (A) useLayoutEffect fires synchronously after all DOM mutations, useEffect fires asynchronously after paint
  • (B) useEffect is only for class components
  • (C) useLayoutEffect is deprecated
  • (D) There is no difference