My Blog

React Interview Questions

React Interview Questions and Answers | Dinesh Teja

React Interview Questions and Answers

A complete React interview preparation page covering beginner, intermediate, advanced, and expert-level questions with simple and interview-ready answers.

Interview Tips

  • Understand concepts, don’t memorize.
  • Give real examples.
  • Be confident while explaining.
  • Keep answers simple and structured.
  • If you don’t know, say honestly.

Beginner Level React Interview Questions

Basic Concepts
1. What is React?

React is a JavaScript library used to build user interfaces, especially single-page applications.

2. Why do we use React?

React is used to build reusable UI components, manage dynamic data, and create fast and interactive web applications.

3. What is a component in React?

A component is a reusable piece of UI. It can display content and handle logic independently.

4. What is JSX?

JSX stands for JavaScript XML. It allows us to write HTML-like code inside JavaScript.

5. What is the difference between functional component and class component?

Functional components are simple JavaScript functions. Class components use ES6 classes. Today, functional components are more commonly used.

6. What are props in React?

Props are inputs passed from parent component to child component. They are used to send data.

7. What is state in React?

State is used to store data that can change inside a component and update the UI when changed.

8. What is the difference between props and state?

Props are passed from parent to child and are read-only. State is managed inside the component and can be changed.

9. What is an event in React?

An event in React is an action like click, change, submit, or mouseover handled using event handlers.

10. What is virtual DOM?

Virtual DOM is a lightweight copy of the real DOM. React uses it to update only the changed parts efficiently.

Intermediate Level React Interview Questions

Practical Understanding
11. What is useState in React?

useState is a React Hook used to create and manage state in functional components.

12. What is useEffect in React?

useEffect is a Hook used to handle side effects such as API calls, subscriptions, and DOM updates.

13. What is the dependency array in useEffect?

The dependency array controls when the effect runs. If it is empty, the effect runs once after initial render.

14. What is conditional rendering in React?

Conditional rendering means showing different UI based on conditions using if, ternary operator, or logical operators.

15. What is list rendering in React?

List rendering means displaying multiple items using methods like map().

16. Why do we use keys in React lists?

Keys help React identify which list items changed, added, or removed, making updates faster and more accurate.

17. What is lifting state up in React?

Lifting state up means moving shared state to the nearest common parent so multiple child components can use it.

18. What is controlled component in React?

A controlled component is a form element whose value is managed by React state.

19. What is uncontrolled component in React?

An uncontrolled component stores form data in the DOM instead of React state, usually accessed with refs.

20. What is React Fragment?

React Fragment is used to group multiple elements without adding extra nodes to the DOM.

Advanced Level React Interview Questions

Real-World Scenarios
21. What is useRef in React?

useRef is used to access DOM elements directly or store mutable values without causing re-render.

22. What is useMemo in React?

useMemo is used to memoize expensive calculations so they do not run on every render unnecessarily.

23. What is useCallback in React?

useCallback is used to memoize functions so the same function reference can be reused between renders.

24. What is React Router?

React Router is a library used for navigation between pages or views in a React application.

25. What is the difference between client-side routing and server-side routing?

Client-side routing changes views without reloading the page. Server-side routing loads a new page from the server for each route.

26. What is Context API in React?

Context API is used to share data across components without passing props manually through every level.

27. What is prop drilling?

Prop drilling means passing props through multiple nested components even when intermediate components do not need them.

28. What is lazy loading in React?

Lazy loading means loading components only when needed, improving application performance and initial load time.

29. What is React.memo?

React.memo is used to prevent unnecessary re-rendering of a component when its props do not change.

30. What is the difference between useEffect and useLayoutEffect?

useEffect runs after the browser paints the screen. useLayoutEffect runs before the browser paints.

Expert Level React Interview Questions

Problem-Solving & Strategy
31. How do you optimize performance in React?

I optimize performance by using memoization, lazy loading, proper key usage, splitting components, avoiding unnecessary re-renders, and managing state efficiently.

32. What causes unnecessary re-rendering in React?

Unnecessary re-rendering can happen because of frequent state changes, parent re-renders, new object or function references, and improper component structure.

33. What is reconciliation in React?

Reconciliation is the process React uses to compare the new virtual DOM with the previous one and update the real DOM efficiently.

34. What are higher-order components in React?

A higher-order component is a function that takes a component and returns a new enhanced component.

35. What is custom hook in React?

A custom hook is a reusable JavaScript function that uses React Hooks to share logic between components.

36. How do you handle forms in React?

Forms are handled using controlled components, state management, validation, and submit handlers.

37. How do you make API calls in React?

API calls are commonly made inside useEffect using fetch or libraries like Axios.

38. How do you handle errors in React applications?

Errors can be handled using try-catch for async code, proper validation, conditional rendering, and error boundaries for component errors.

39. What is an error boundary in React?

An error boundary is a React component used to catch JavaScript errors in child components and show fallback UI.

40. What is the role of state management libraries in React?

State management libraries like Redux or Zustand help manage shared and complex application state more clearly in large projects.

Rapid-Fire React Interview Questions

  • What is React?
  • What is JSX?
  • What is a component?
  • What are props?
  • What is state?
  • What is useEffect?
  • What is virtual DOM?
  • What is Context API?

Commonly Asked Tricky React Interview Questions

1. Is React a framework?

No. React is a JavaScript library for building user interfaces.

2. Can props be changed inside a child component?

No. Props are read-only. A child component should not modify them directly.

3. Does changing state always re-render the component?

Yes, usually state updates trigger re-render, but React may optimize and batch updates in some cases.

4. Can we use Hooks inside loops or conditions?

No. Hooks should always be called at the top level of a React function component or custom hook.

5. Is key available as a prop inside child component?

No. The key prop is used internally by React and is not directly accessible inside the child component.

Scroll to Top