The Ultimate List of React Interview Questions

React JS, commonly referred to as React, is a popular JavaScript library for building user interfaces, particularly for single-page applications where the goal is to create a fast, interactive, and dynamic user experience.

React JS MCQ

Developed and maintained by Facebook, React allows developers to create reusable UI components, manage the state of applications efficiently, and build large-scale applications with ease.

In this article, we will share some React JS MCQ questions with answers that helps you to prepare for your next interview.

Multiple Choice Questions with Answers

Q1. Which method in React is used to update the state of a component?

  • updateState()
  • setState()
  • refreshState()
  • changeState()
View Answer

setState()


Q2. Using which of the following command can prevent default behaviour at in react?

  • preventDefault()
  • prevent()
  • avoidDefault()
  • None of the above
View Answer

preventDefault()


Q3. How do you pass data to a child component in React?

  • Using states
  • Using props
  • Using context
  • Using hooks
View Answer

Using Props


Q4. Which hook is used to handle side effects in a functional component?

  • useState
  • useEffect
  • useReducer
  • useContext
View Answer

useEffect


Q5. What is used to handle code-splitting?

  • React.memo
  • React.lazy
  • React.fallback
  • React.context
View Answer

React.lazy


Q6. What is the purpose of useCallback in React?

  • To manage component state
  • To prevent unnecessary re-renders of functions
  • To handle side effects
  • To create ref objects
View Answer

To prevent unnecessary re-renders of functions


Q7. What will happen if you call setState() with the same state repeatedly?

  • It will re-render the component each time
  • It will cause an error
  • React will skip the re-render if the state is the same
  • It will log a warning to the console
View Answer

React will skip the re-render if the state is the same


Q8. How can you prevent a function from being recreated on every render?

  • By using useMemo
  • By using useCallback
  • By using useRef
  • By using useEffect
View Answer

By using useCallback


Q9. Which of the following is used to describe more about React application ?

  • Declarative
  • Integrated
  • Closed
  • Impressive
View Answer

Declarative


Q10. Which hook would you use to persist a value across renders without causing re-renders?

  • useState
  • useMemo
  • useCallback
  • useRef
View Answer

useRef


Q11. What is the return type of useState hook?

View Answer

An array with two elements


Q12. When does the function passed to useEffect run?

  • After every render
  • Before every render
  • Only on mount
  • Only on unmount
View Answer

After every render


Q13. What can you pass as a second argument to useEffect to control when it runs?

  • A string
  • An array
  • An object
  • A function
View Answer

An array


Q14. Which hook is used to dispatch actions in a functional component?

  • useState
  • useEffect
  • useReducer
  • useContext
View Answer

useReducer


Q15. What is the purpose of the dependency array in useEffect?

  • To specify the initial state
  • To determine when to run the effect
  • To create context values
  • To prevent re-renders
View Answer

To determine when to run the effect


Q16. What is the default value of the props parameter in a React component?

  • null
  • undefined
  • An empty array
  • An empty object
View Answer

An empty object


Q17. How do you handle events in React?

  • Using HTML event attributes
  • Using JavaScript event listeners
  • Using React event handlers
  • Using CSS event properties
View Answer

Using React event handlers


Q18. What is a synthetic event in React?

  • A native browser event
  • An event created by the React library
  • An event used for debugging
  • An event triggered by CSS
View Answer

An event created by the React library


Q19. How do you handle asynchronous operations in a React component?

  • Using setTimeout
  • Using async/await or promises within useEffect
  • Using synchronous code
  • Using the componentDidUpdate lifecycle method
View Answer

Using async/await or promises within useEffect


Q20. What is the main difference between useEffect and useLayoutEffect?

  • useEffect runs synchronously, useLayoutEffect runs asynchronously
  • useEffect runs after paint, useLayoutEffect runs before paint
  • useEffect is for side effects, useLayoutEffect is for DOM mutations
  • useEffect and useLayoutEffect are interchangeable
View Answer

useEffect runs after paint, useLayoutEffect runs before paint


Q21. What is ReactJS mainly used for building?

  • Database
  • Connectivity
  • User Interface
  • Design Platform
View Answer

User Interface


Q22. What is ref used for ?

  • To bind the function
  • To call a function
  • To directly access the DOM node
  • To refer to another JS file
View Answer

To directly access the DOM node


Q23. How many elements can a valid react component return?

  • 1
  • 2
  • 3
  • 4
View Answer

1


Q24. A state in React.js is also known as?

  • The internal storage of a component
  • External storage of the component
  • Permanent storage
  • All of the above
View Answer

The internal storage of a component