Learn React Js MCQs
Prepare React Js MCQs (Multiple choice Questions) for exam and job interviews.
What is the purpose of `useEffect` cleanup function?
1) To clean up side effects when the component unmounts
2) To update state
3) To create refs
4) To handle events
Answer : Option 1
How can you handle multiple state updates in React?
1) By using `useReducer`
2) By using `useEffect`
3) By using `useState`
4) By using context
Answer : Option 1
What is the use of `React.StrictMode`?
1) To activate additional checks and warnings
2) To optimize performance
3) To manage state
4) To handle side effects
Answer : Option 1
How do you create a context in React?
1) By using `React.createContext`
2) By using `useState`
3) By using `useEffect`
4) By using `props`
Answer : Option 1
What is the main benefit of using Redux with React?
1) To manage global state
2) To optimize performance
3) To handle side effects
4) To create refs
Answer : Option 1
How do you handle conditional rendering in React?
1) By using JavaScript expressions
2) By using CSS
3) By using refs
4) By using props
Answer : Option 1
What does `React.PureComponent` do?
1) Prevents unnecessary re-renders
2) Manages state
3) Handles side effects
4) Creates refs
Answer : Option 1
How do you access props in a functional component?
1) By using the function parameter
2) By using `this.props`
3) By using `context`
4) By using `refs`
Answer : Option 1
What is the purpose of `setState` in React?
1) To update the state and trigger re-renders
2) To manage props
3) To handle side effects
4) To create refs
Answer : Option 1
How do you create a ref in React?
1) By using `React.createRef` or `useRef`
2) By using `setState`
3) By using `props`
4) By using `useEffect`
Answer : Option 1