React Interview Questions Hindi mein

React कोर्स के 25 सवाल, हर सवाल के सही जवाब और explanation के साथ। जवाब देखने से पहले ख़ुद सोचें।

React Fundamentals

1. What does "declarative" mean in React?

  1. React only works on servers
  2. You manually change each DOM node
  3. You describe what the UI should look like for the current state, and React updates the DOM
  4. Components cannot have inputs
जवाब देखें

जवाब: You describe what the UI should look like for the current state, and React updates the DOM

UI is a function of state.

पाठ: The React Mental Model

2. Which attribute name is correct in JSX for a CSS class?

  1. className
  2. class
  3. cssClass
  4. styleClass
जवाब देखें

जवाब: className

JSX uses DOM property names.

पाठ: JSX

3. What does a framework like Next.js add on top of React?

  1. Nothing at all
  2. A different language
  3. A replacement for JavaScript
  4. Routing, data loading and server rendering
जवाब देखें

जवाब: Routing, data loading and server rendering

React is the UI layer; frameworks add app structure.

पाठ: Setting Up a React Project

Components, Props and Rendering Lists

4. Can a child component change the props it receives?

  1. Yes, freely
  2. No, props are read-only; change state in the owner instead
  3. Only strings can be changed
  4. Only on the server
जवाब देखें

जवाब: No, props are read-only; change state in the owner instead

Data flows down; events flow up.

पाठ: Components and Props

5. What is the children prop?

  1. A list of child processes
  2. The content nested between a component's opening and closing tags
  3. Only text strings
  4. The component's state
जवाब देखें

जवाब: The content nested between a component's opening and closing tags

Composition through children.

पाठ: Children and Composition

6. What should you use as the key for list items fetched from an API?

  1. The item's text length
  2. Math.random()
  3. Always the array index
  4. A stable unique id from the data
जवाब देखें

जवाब: A stable unique id from the data

Stable identity across renders.

पाठ: Lists, Keys and Conditional Rendering

State and Events

7. Where can hooks like useState be called?

  1. At the top level of a component or custom hook, never inside conditions or loops
  2. Anywhere, including inside if statements
  3. Only inside event handlers
  4. Only in class components
जवाब देखें

जवाब: At the top level of a component or custom hook, never inside conditions or loops

The rules of hooks keep call order stable.

पाठ: useState and Event Handlers

8. What does calling setCount(count + 1) three times in one click do?

  1. Throws an error
  2. Increases by 3
  3. Increases count by 1, because count is the same snapshot each time
  4. Resets count to 0
जवाब देखें

जवाब: Increases count by 1, because count is the same snapshot each time

Use setCount(c => c + 1) for sequential updates.

पाठ: Batching and Updater Functions

9. Why might mutating a state array not update the screen?

  1. React forbids arrays
  2. Arrays cannot be state
  3. The reference is unchanged, so React sees no change
  4. Mutation is too fast
जवाब देखें

जवाब: The reference is unchanged, so React sees no change

New references signal changes.

पाठ: Updating Objects and Arrays Immutably

10. Two sibling components need the same state. Where should it live?

  1. In their closest common parent, passed down as props
  2. Duplicated in both siblings
  3. In a global variable
  4. In the DOM
जवाब देखें

जवाब: In their closest common parent, passed down as props

Lift state up.

पाठ: Lifting State Up and Derived Values

Effects

11. When does React run an effect's cleanup function?

  1. Before the first render
  2. Only on page reload
  3. Never
  4. Before re-running the effect and when the component unmounts
जवाब देखें

जवाब: Before re-running the effect and when the component unmounts

Cleanup undoes setup.

पाठ: useEffect, Dependencies and Cleanup

12. What problem does the ignore flag in a fetch effect solve?

  1. Network errors
  2. A slow, outdated response overwriting newer data
  3. Slow rendering
  4. Missing keys
जवाब देखें

जवाब: A slow, outdated response overwriting newer data

Discard stale results.

पाठ: Fetching Data Without Race Conditions

13. Which case does NOT need an effect?

  1. Subscribing to a WebSocket
  2. Computing a full name from first and last name props
  3. Setting up a timer
  4. Integrating a non-React map widget
जवाब देखें

जवाब: Computing a full name from first and last name props

Derive values during render.

पाठ: When You Do Not Need an Effect

Forms and Complex State

14. What makes an input "controlled"?

  1. It uses a ref only
  2. It has a CSS class
  3. It is inside a form tag
  4. Its value comes from React state and changes go through onChange
जवाब देखें

जवाब: Its value comes from React state and changes go through onChange

State is the source of truth.

पाठ: Controlled Forms and Validation

15. What is a reducer?

  1. A pure function that takes state and an action and returns new state
  2. A function that mutates the DOM
  3. A component that renders lists
  4. A network request
जवाब देखें

जवाब: A pure function that takes state and an action and returns new state

Pure and testable.

पाठ: useReducer for Complex State

16. What does useActionState provide?

  1. A database
  2. A CSS framework
  3. The latest result of an action, a wrapped action, and a pending flag
  4. A router
जवाब देखें

जवाब: The latest result of an action, a wrapped action, and a pending flag

Built-in submit state handling.

पाठ: Form Actions in React 19

Sharing Data and Reusing Logic

17. What problem does context solve?

  1. Styling components
  2. Fetching data from APIs
  3. Passing data through many intermediate components (prop drilling)
  4. Speeding up every render
जवाब देखें

जवाब: Passing data through many intermediate components (prop drilling)

Share values with a subtree.

पाठ: Context

18. Do two components using the same custom hook share its state?

  1. No, each call gets its own independent state
  2. Yes, always
  3. Only on the server
  4. Only if they are siblings
जवाब देखें

जवाब: No, each call gets its own independent state

Hooks share logic, not state.

पाठ: Custom Hooks

19. What happens when you change ref.current?

  1. The page reloads
  2. The component always re-renders
  3. React throws an error
  4. The value changes but the component does not re-render
जवाब देखें

जवाब: The value changes but the component does not re-render

Refs are not reactive.

पाठ: Refs: DOM Access and Mutable Values

Performance and Correctness

20. Why does memo not help when you pass an inline arrow function as a prop?

  1. memo ignores functions
  2. A new function is created each render, so props are never equal
  3. Arrow functions cannot be props
  4. memo only works on classes
जवाब देखें

जवाब: A new function is created each render, so props are never equal

Stabilise references with useCallback.

पाठ: memo, useMemo and useCallback

21. What happens when a component's key changes?

  1. Nothing
  2. React unmounts it and mounts a new instance with fresh state
  3. Only its CSS changes
  4. React throws an error
जवाब देखें

जवाब: React unmounts it and mounts a new instance with fresh state

Keys define identity.

पाठ: Keys and Component Identity

22. Which errors do error boundaries catch?

  1. Syntax errors in other files
  2. Errors in event handlers
  3. Network errors in fetch calls by default
  4. Errors thrown while rendering components below them
जवाब देखें

जवाब: Errors thrown while rendering components below them

Use try/catch for handlers and async code.

पाठ: Error Boundaries

Testing, Structure and a Checklist

23. What should component tests focus on?

  1. What users see and can do
  2. Internal state variable names
  3. The number of hooks
  4. CSS class order
जवाब देखें

जवाब: What users see and can do

Behavioural tests survive refactors.

पाठ: Testing Components

24. Why organise code by feature rather than by file type?

  1. React requires it
  2. It makes files larger
  3. Related components, hooks and tests stay together and change together
  4. It removes the need for tests
जवाब देखें

जवाब: Related components, hooks and tests stay together and change together

Cohesion makes change easier.

पाठ: Project Structure and Tooling

25. Which item belongs on a React review checklist?

  1. Use array index keys for reorderable lists
  2. Mutate state arrays with push
  3. Effects list complete dependencies and clean up subscriptions
  4. Store every derived value in state
जवाब देखें

जवाब: Effects list complete dependencies and clean up subscriptions

Correct effects, immutable state, stable keys.

पाठ: A React Code Review Checklist

← कोर्स पर वापस जाएँ