Open In App

React Interview Questions and Answers (2025) – Intermediate Level

Last Updated : 24 Feb, 2025
Comments
Improve
Suggest changes
Like Article
Like
Share
Report
News Follow

ReactJS is an open-source JavaScript library that is used for building user interfaces in a declarative and efficient way. It is a component-based front-end library responsible only for the view layer of an MVC (Model View Controller) architecture. React is used to create modular user interfaces and it promotes the development of reusable UI components that display dynamic data.

To prepare for React job interviews in 2025, mastering intermediate-level React concepts is very important. This article covers some of the most commonly asked React interview questions and answers, designed specifically for developers looking to sharpen their skills. From hooks and state management to performance optimization and React architecture, these questions will help you gain the confidence to tackle interviews and secure your next React developer role.

Whether you are a fresher or an experienced professional with 2 – 10 years of experience, these React Interview Questions give you all the confidence you need to ace your next technical interview.

Before proceeding to learn ReactJS Interview Questions and Answers – Intermediate Level, you can first go through complete ReactJS Tutorial, and ReactJS Interview Questions and Answers – Beginner Level.

React Intermediate Interview Questions (2025)

This set contains the intermediate-level questions asked in the interview.

1. What is conditional rendering in React?

When there are multiple components in react and we want to render components according to our preference and some conditions then we use conditional rendering. In conditional rendering, a condition is specified and if the condition is passed then this component is rendered.

{isLoggedIn == false ? <DisplayLoggedOut /> : <DisplayLoggedIn />}

Here if the boolean isLoggedIn is false then DisplayLoggedOut component will be rendered otherwise DisplayLoggedIn component will be rendered.

2. What is react router?

React Router is a standard library for routing in React. It enables the navigation among views of various components in a React Application, allows changing the browser URL, and keeps the UI in sync with the URL.

To install react router type the following command.

npm i react-router-dom

3. Explain the components of a react-router

The main components of a react-router are:

  1. Router(usually imported as BrowserRouter):  It is the parent component that is used to store all of the other components. Everything within this will be part of the routing functionality
  2. Switch: The switch component is used to render only the first route that matches the location rather than rendering all matching routes.
  3. Route: This component checks the current URL and displays the component associated with that exact path. All routes are placed within the switch components.
  4. Link: The Link component is used to create links to different routes.

4. Explain the lifecycle methods of components

A React Component can go through four stages of its life as follows. 

  • Initialization: This is the stage where the component is constructed with the given Props and default state. This is done in the constructor of a Component Class.
  • Mounting: Mounting is the stage of rendering the JSX returned by the render method itself.
  • Updating: Updating is the stage when the state of a component is updated and the application is repainted.
  • Unmounting: As the name suggests Unmounting is the final step of the component lifecycle where the component is removed from the page.

5. Explain the methods used in mounting phase of components

Mounting is the phase of the component lifecycle when the initialization of the component is completed and the component is mounted on the DOM and rendered for the first time on the webpage. he mounting phase consists of two such predefined functions as described below

6. What is this.setState function in React?

We use the setState() method to change the state object. It ensures that the component has been updated and calls for re-rendering of the component. The state object of a component may contain multiple attributes and React allows using setState() function to update only a subset of those attributes as well as using multiple this.setState() methods to update each attribute value independently.

7.  What is the use of ref in React?

Refs are a function provided by React to access the DOM element and the React element that you might have created on your own. They are used in cases where we want to change the value of a child component, without making use of props and all. They have wide functionality as we can use callbacks with them.

The syntax to use ref is

const node = this.myCallRef.current;

8. What are hooks in React?

Hooks are a new addition in React 16.8. They let developers use state and other React features without writing a class. Hooks doesn’t violate any existing React concepts. Instead, Hooks provide a direct API to react concepts such as props, state, context, refs and life-cycle

9. Explain the useState hook in React?

The most used hook in React is the useState() hook. It allows functional components to manipulate DOM elements before each render. Using this hook we can declare a state variable inside a function but only one state variable can be declared using a single useState() hook. Whenever the useState() hook is used, the value of the state variable is changed and the new variable is stored in a new cell in the stack.

We have to import this hook in React using the following syntax

import {useState} from 'react'

10. Explain the useEffect hook in react?

The useEffect hook in React eliminates the side effect of using class based components. It is used as an alternative to componentDidUpdate() method. The useEffect hook accepts two arguments where second argument is optional. 

useEffect(function, dependency)

The dependency decides when the component will be updated again after rendering.

11. What is React Fragments?

when we are trying to render more than one root element we have to put the entire content inside the ‘div’ tag which is not loved by many developers. So since React 16.2 version, Fragments were introduced, and we use them instead of the extraneous ‘div’ tag. The following syntax is used to create fragment in react.

<React.Fragment>  
    <h2>Child-1</h2>   
    <p> Child-2</p>   
</React.Fragment>  

12. What is a react developer tool?

React Developer Tools is a Chrome DevTools extension for the React JavaScript library. A very useful tool, if you are working on React.js applications. This extension adds React debugging tools to the Chrome Developer Tools. It helps you to inspect and edit the React component tree that builds the page, and for each component, one can check the props, the state, hooks, etc.

13. How to use styles in ReactJS?

CSS modules are a way to locally scope the content of your CSS file. We can create a CSS module file by naming our CSS file as App.modules.css and then it can be imported inside App.js file using the special syntax mentioned below:

import styles from './App.module.css';

14. Explain styled components in React?

Styled-component Module allows us to write CSS within JavaScript in a very modular and reusable way in React. Instead of having one global CSS file for a React project, we can use styled-component for enhancing the developer experience. It also removes the mapping between components and styles – using components as a low-level styling construct

The command to install styled components is

npm i styled-components

Using the below code we can custom style a button in React

import styled from 'styled-components'

const Button = styled.div`
    width : 100px ;
    cursor: pointer ;
    text-decoration : none;
`

export default Button;

15. What is prop drilling and its disadvantages?

Prop drilling is basically a situation when the same data is being sent at almost every level due to requirements in the final level. The problem with Prop Drilling is that whenever data from the Parent component will be needed, it would have to come from each level, Regardless of the fact that it is not needed there and simply needed in last.

16. What are controlled and uncontrolled components in react?

A controlled component is a component which is managed by its parent component and its value is updated using props whereas uncontrolled components maintain their own state and data flow is done inside the component only unlike controlled components which pass data from parent to child 

17. What is useRef hook in react?

The useRef is a hook that allows to directly create a reference to the DOM element in the functional component. The useRef returns a mutable ref object. This object has a property called .current. The value is persisted in the refContainer.current property. These values are accessed from the current property of the returned object. 

const refContainer = useRef(initialValue);

18. Explain the componentDidMount method in React?

The componentDidMount method in React is a lifecycle method that is called after the component has been rendered to the DOM. It is commonly used to trigger actions like data fetching, setting up subscriptions, or manipulating the DOM. This method runs only once, immediately after the initial rendering, making it a good place for initialization tasks.

19. Difference between ES6 and ES5 syntax in React

The difference in different syntax is shown in the below table

FeatureES5ES6
Importing Reactvar React = require(‘react’); import React from ‘react’;
Exporting Componentsmodule.exports = Component;export default Component;
function declarationvar sum = function(x, y) { return x + y; };const sum = (x, y) => x + y;

Class Components

var MyComponent = React.createClass({ … });

class MyComponent extends React.Component { … }

State Initialization

this.state = { count: 0 };

state = { count: 0 }; (Class Fields)

Binding Methods

this.handleClick = this.handleClick.bind(this);

No binding required with arrow functions

20. What are synthetic event in React?

Synthetic events in React are a cross-browser wrapper around the browser’s native events. They normalize events so that they have consistent properties across different browsers, ensuring that React applications behave consistently.

21. What is the context API in React?

The Context API is a way to manage and share global data like themes, authentication states, or language preferences in a React application. It provides a way to avoid prop drilling by making values accessible to any component, no matter how deeply nested.

Syntax

const MyContext = React.createContext(defaultValue);

To provide and consume values in a component:

<MyContext.Provider value={/* some value */}>  
    <MyComponent />
</MyContext.Provider>

22. How can you optimize the performance of a React application?

Some ways to optimize React performance include:

  • Use React.memo: Prevents re-rendering of components if props haven’t changed.
  • Use lazy loading and code splitting: Split your app into smaller bundles and load them only when necessary.
  • Use useCallback and useMemo hooks: Cache functions and values that don’t need to be recalculated on every render.
  • Avoid unnecessary re-renders: Minimize the state and prop changes that lead to re-renders.

23. What is the purpose of the useCallback hook in React?

The useCallback hook returns a memoized version of a function that only changes if one of its dependencies changes. It is used to optimize performance by preventing unnecessary re-creations of functions on each render, especially useful when passing functions as props to child components.

const memoizedCallback = useCallback(() => {
    // function logic
}, [dependencies]);

24. What are Higher-Order Components (HOCs) in React?

A Higher-Order Component (HOC) is a function that takes a component and returns a new component with added functionality. It is used for code reuse, such as adding common features like authentication checks, logging, or lifecycle management.

function withAuth(Component) {
    return function (props) {
        if (!isAuthenticated) {
            return <Redirect to="/login" />;
        }
        return <Component {...props} />;
    };
}

25. What is the purpose of useReducer hook in React?

The useReducer hook is used for managing more complex state logic in React components. It is similar to useState, but it is better suited for handling actions that update state based on the current state and action types.

const [state, dispatch] = useReducer(reducer, initialState);

const reducer = (state, action) => {
    switch (action.type) {
        case 'increment':
            return { count: state.count + 1 };
        default:
            return state;
    }
};

26. What is a React Portals?

Portals provide a way to render a child component into a DOM node that exists outside the parent component’s DOM hierarchy. Portals are useful for rendering modals, tooltips, and other overlay components.

ReactDOM.createPortal(
      <div>Portal Content</div>,
 document.getElementById('portal-root')
);

27. Explain “Virtual DOM” in React.

The Virtual DOM is a lightweight in-memory representation of the actual DOM. React uses the Virtual DOM to optimize updates to the actual DOM. When the state of a component changes, React first updates the Virtual DOM, compares it with the previous version (diffing), and then updates only the parts of the real DOM that have changed, improving performance.

28. What are keys in React and why are they important?

In React, keys are unique identifiers used for tracking elements in a list or an array. They help React efficiently update and reconcile the component tree by identifying which items have changed, been added, or removed.

const items = ['Apple', 'Banana', 'Orange'];
return (
    <ul>
        {items.map((item, index) => <li key={index}>{item}</li>)}
  </ul>
);

29. What is the difference between React.PureComponent and React.Component?

React.PureComponent is a base class for React components that implements a shallow comparison of props and state to determine if a re-render is necessary. This optimization can improve performance by preventing unnecessary renders.

  • React.Component: Requires manual checks for prop or state changes to trigger re-renders.
  • React.PureComponent: Automatically implements shouldComponentUpdate() with a shallow comparison of props and state.

30. What are the differences between Server-Side Rendering (SSR) and Client-Side Rendering (CSR) in React, and when would you use each?

SSR renders React components on the server for faster load times and better SEO, while CSR renders on the client after JavaScript loads, leading to slower initial rendering. SSR is commonly used in Next.js.

Conclusion

Mastering intermediate-level React concepts is crucial for excelling in interviews and securing a React developer role. Understanding hooks, performance optimization techniques, routing, lifecycle methods, and other core concepts will help you build efficient and maintainable applications.

ReactJS-interview-Questions-and-answers-Intermediate-Level

React Interview Questions and Answers (2025) – Intermediate Level

React Interview Questions and Answers – FAQs

Who should read “React Interview Questions and Answers (2025) – Intermediate Level”?

This article is perfect for developers with 2-3 years of experience who are preparing for React-related technical interviews. It is also helpful for intermediate-level React developers looking to enhance their skills or refresh their knowledge before an interview.

What will I learn from reading this article?

You will learn key React concepts such as hooks, state management, performance optimization, lifecycle methods, and routing. This will help you gain a deeper understanding of React’s core features and prepare you for React interview questions.

How can this guide help in interview preparation?

It provides over 30 intermediate-level React questions, along with concise answers and practical examples. This guide ensures that you are prepared for a wide range of React-related interview scenarios.

Is this article suitable for beginners?

While the focus is on intermediate-level concepts, beginners who already have a basic understanding of React can also benefit by expanding their knowledge and gaining confidence in React development.

Should I read this article if I already have experience with React?

Yes! This article is a great resource for developers with experience in React who want to strengthen their interview preparation, review important concepts, and dive into more advanced features of React.

How should I use this guide for my interview prep?

Go through each question and answer, practice the concepts by building small projects or solving coding challenges, and simulate mock interviews. This will help you refine your skills and build confidence for the interview.



Next Article

Similar Reads

three90RightbarBannerImg