πŸ“Š React Js
Q. What is the significance of the dependency array in useEffect?
  • (A) It determines when the effect should re-run
  • (B) It stores state values
  • (C) It defines event listeners
  • (D) It holds refs
πŸ’¬ Discuss
βœ… Correct Answer: (A) It determines when the effect should re-run

Explanation: Effect runs again only if dependencies change.

πŸ“Š React Js
Q. Which React feature helps improve performance by preventing unnecessary re-renders?
  • (A) React.memo
  • (B) React.StrictMode
  • (C) React.Fragment
  • (D) React.PureComponent
πŸ’¬ Discuss
βœ… Correct Answer: (A) React.memo

Explanation: React.memo memoizes functional components.

πŸ“Š React Js
Q. What is the difference between React.Component and React.PureComponent?
  • (A) PureComponent implements shouldComponentUpdate with a shallow prop and state comparison
  • (B) Component is only for functional components
  • (C) PureComponent cannot have state
  • (D) Component automatically memoizes
πŸ’¬ Discuss
βœ… Correct Answer: (A) PureComponent implements shouldComponentUpdate with a shallow prop and state comparison

Explanation: PureComponent avoids re-renders if props/state do not change shallowly.

πŸ“Š React Js
Q. How do you handle errors in React components?
  • (A) Using error boundaries with componentDidCatch lifecycle method
  • (B) Using try-catch in render
  • (C) Using useEffect hook
  • (D) React handles errors automatically
πŸ’¬ Discuss
βœ… Correct Answer: (A) Using error boundaries with componentDidCatch lifecycle method

Explanation: Error boundaries catch rendering errors and display fallback UI.

πŸ“Š React Js
Q. What is the purpose of the useReducer hook?
  • (A) To manage complex state logic using a reducer function
  • (B) To replace useState completely
  • (C) To fetch data asynchronously
  • (D) To access DOM elements
πŸ’¬ Discuss
βœ… Correct Answer: (A) To manage complex state logic using a reducer function

Explanation: useReducer is similar to Redux reducers but for local state.

πŸ“Š React Js
Q. What does the useEffect hook’s cleanup function do?
  • (A) Runs when the component unmounts or before re-running the effect
  • (B) Sets initial state
  • (C) Updates props
  • (D) Fetches data
πŸ’¬ Discuss
βœ… Correct Answer: (A) Runs when the component unmounts or before re-running the effect

Explanation: Cleanup helps avoid memory leaks and stale subscriptions.

πŸ“Š React Js
Q. Which command creates a new React application using Create React App?
  • (A) npx create-react-app app-name
  • (B) npm init react-app app-name
  • (C) npm react create app-name
  • (D) create-react app app-name
πŸ’¬ Discuss
βœ… Correct Answer: (A) npx create-react-app app-name

Explanation: This command scaffolds a new React project.

πŸ“Š React Js
Q. What does the 'children' prop represent in React?
  • (A) Any nested elements or components passed between opening and closing tags
  • (B) The parent component
  • (C) The component's state
  • (D) The component's methods
πŸ’¬ Discuss
βœ… Correct Answer: (A) Any nested elements or components passed between opening and closing tags

Explanation: children lets components render nested content dynamically.