Learn React Js MCQs
Prepare React Js MCQs (Multiple choice Questions) for exam and job interviews.
How do you use a custom hook in React?
1) By importing it and using it like any other hook
2) By extending `React.Component`
3) By using `useState`
4) By using `useEffect`
Answer : Option 1
What is the purpose of `useDeferredValue` hook in React?
1) To manage state
2) To defer updating a value until after a higher priority update
3) To create a new context
4) To handle side effects
Answer : Option 2
How do you pass data to a component in React?
1) Using `useState`
2) Using props
3) Using context
4) Using refs
Answer : Option 2
What is the purpose of the `useDebugValue` hook?
1) To handle side effects
2) To optimize performance
3) To display custom hook debugging information in React DevTools
4) To create a new context
Answer : Option 3
How do you handle asynchronous operations in React?
1) Using `setState`
2) Using `useEffect` with async functions
3) Using `useState`
4) Using `context`
Answer : Option 2
What is the purpose of `React.forwardRef`?
1) To handle side effects
2) To pass refs through a component to its children
3) To manage state
4) To create a new context
Answer : Option 2
How do you update a ref in a functional component?
1) Using `useRef`
2) Using `setState`
3) Using `useEffect`
4) Using `createRef`
Answer : Option 1
What does the `useReducer` hook return?
1) A context and a reducer
2) A ref and a callback
3) State and a dispatch function
4) A memoized value
Answer : Option 3
How do you handle error boundaries in functional components?
1) Using `useEffect`
2) Using `useErrorBoundary`
3) Using `componentDidCatch`
4) Using `try-catch`
Answer : Option 2
What is the purpose of `React.lazy`?
1) To manage state
2) To handle side effects
3) To code-split components and load them lazily
4) To create a new context
Answer : Option 3