Learn React Js MCQs
Prepare React Js MCQs (Multiple choice Questions) for exam and job interviews.
What does `React.Children.map` do?
1) Maps over the children of a component
2) Maps over an array
3) Creates a ref
4) Handles side effects
Answer : Option 1
How do you pass data from child to parent component?
1) By using callback functions passed as props
2) By using context
3) By using state
4) By using refs
Answer : Option 1
What is the purpose of `forwardRef`?
1) To forward refs to child components
2) To manage state
3) To handle side effects
4) To create contexts
Answer : Option 1
How do you implement lazy loading in React?
1) By using `React.lazy` and `Suspense`
2) By using `useEffect`
3) By using `useState`
4) By creating global variables
Answer : Option 1
What does the `key` prop help with?
1) To identify elements in lists for performance
2) To manage state
3) To create refs
4) To handle events
Answer : Option 1
How do you handle component updates in React?
1) By using lifecycle methods or hooks
2) By using global variables
3) By using state only
4) By using refs
Answer : Option 1
What is the purpose of `useLayoutEffect`?
1) To perform effects after DOM mutations
2) To manage state
3) To create refs
4) To handle side effects
Answer : Option 1
How can you handle multiple inputs in a form?
1) By using controlled components with state
2) By using uncontrolled components
3) By using global variables
4) By using refs
Answer : Option 1
What is the role of the `renderProps` pattern?
1) To share code between components using a function as a child
2) To manage state
3) To handle side effects
4) To create refs
Answer : Option 1
How do you set default values for props?
1) By using `defaultProps`
2) By using `useEffect`
3) By using state
4) By using refs
Answer : Option 1