Learn React Js MCQs
Prepare React Js MCQs (Multiple choice Questions) for exam and job interviews.
What is the purpose of `useLayoutEffect`?
1) To handle side effects after DOM mutations
2) To manage state
3) To optimize performance
4) To create refs
Answer : Option 1
How do you create a controlled component in React?
1) By using `state` to manage its value
2) By using `useRef`
3) By using `useEffect`
4) By using `context`
Answer : Option 1
What is the purpose of the `React.StrictMode` component?
1) To activate additional checks and warnings for its descendants
2) To optimize performance
3) To handle side effects
4) To manage state
Answer : Option 1
What is the use of `React.createContext`?
1) To create a context for state management
2) To handle side effects
3) To create refs
4) To optimize performance
Answer : Option 1
How do you handle errors in React?
1) Using `Error Boundaries`
2) Using `try-catch`
3) Using `console.log`
4) Using `useEffect`
Answer : Option 1
What is the purpose of `useContext`?
1) To access context data in a functional component
2) To manage state
3) To create refs
4) To handle side effects
Answer : Option 1
How do you memoize a component in React?
1) Using `React.memo`
2) Using `useState`
3) Using `useEffect`
4) Using `useRef`
Answer : Option 1
What does `useDebugValue` do?
1) Helps to display a label for custom hooks in React DevTools
2) Manages state
3) Handles side effects
4) Creates refs
Answer : Option 1
What is the purpose of `useImperativeHandle`?
1) To customize the instance value that is exposed when using `ref`
2) To manage state
3) To create refs
4) To handle side effects
Answer : Option 1
How do you pass a function as a prop in React?
1) By passing it like any other prop
2) By using context
3) By using state
4) By creating a ref
Answer : Option 1