Learn React Js MCQs
Prepare React Js MCQs (Multiple choice Questions) for exam and job interviews.
How do you memoize a value in React?
1) Using `useState`
2) Using `useEffect`
3) Using `useMemo`
4) Using `useRef`
Answer : Option 3
What is the purpose of `React.Fragment`?
1) To create refs
2) To group a list of children without adding extra nodes to the DOM
3) To handle side effects
4) To optimize performance
Answer : Option 2
How do you create a custom hook in React?
1) By creating a function that uses React hooks
2) Using `useState`
3) Using `useEffect`
4) Using `useRef`
Answer : Option 1
What is the purpose of `useRef`?
1) To manage state
2) To create a mutable object that persists across renders
3) To handle side effects
4) To optimize performance
Answer : Option 2
How do you handle component lifecycle in functional components?
1) Using `useState`
2) Using `useEffect`
3) Using `useRef`
4) Using `useReducer`
Answer : Option 2
What is the purpose of `useState`?
1) To manage state in functional components
2) To handle side effects
3) To create refs
4) To optimize performance
Answer : Option 1
How do you handle side effects in functional components?
1) Using `useState`
2) Using `useEffect`
3) Using `useRef`
4) Using `useReducer`
Answer : Option 2
What is the purpose of `React.memo`?
1) To create refs
2) To optimize rendering by memoizing a component
3) To handle side effects
4) To manage state
Answer : Option 2
How do you create a higher-order component?
1) By wrapping a component with another function
2) Using `useState`
3) Using `useEffect`
4) Using `React.forwardRef`
Answer : Option 1
What is the purpose of `React.lazy`?
1) To manage state
2) To code-split components and load them lazily
3) To create refs
4) To handle side effects
Answer : Option 2