React Developer

100+ React Developer Interview Questions and Answers

Updated 14 Jul 2025
search-icon

Asked in Amdocs

4d ago

Q. Swap Two Numbers Problem Statement

Given two integers a and b, your task is to swap these numbers and output the swapped values.

Input:

The first line contains a single integer 't', representing the number of t...read more
Ans.

Swap two numbers 'a' and 'b' and output the swapped values.

  • Create a temporary variable to store one of the numbers

  • Assign the value of 'a' to 'b' and the temporary variable to 'a'

  • Output the swapped values as 'b' followed by 'a'

Asked in Cisco

6d ago

Q. Covid Vaccination Distribution Problem

As the Government ramps up vaccination drives to combat the second wave of Covid-19, you are tasked with helping plan an effective vaccination schedule. Your goal is to ma...read more

Ans.

Maximize the number of vaccines administered on a specific day while adhering to certain rules.

  • Given n days, maxVaccines available, and a specific dayNumber, distribute vaccines to maximize on dayNumber

  • Administer positive number of vaccines each day with a difference of 1 between consecutive days

  • Ensure sum of vaccines distributed does not exceed maxVaccines

  • Output the maximum number of vaccines administered on dayNumber for each test case

React Developer Interview Questions and Answers for Freshers

illustration image

Asked in Samsung

6d ago

Q. Triplets with Given Sum Problem

Given an array or list ARR consisting of N integers, your task is to identify all distinct triplets within the array that sum up to a specified number K.

Explanation:

A triplet i...read more

Ans.

The task is to find all distinct triplets in an array that sum up to a specified number.

  • Iterate through the array and use nested loops to find all possible triplets.

  • Keep track of the triplets that sum up to the target number.

  • Handle cases where no triplet exists for a given target sum.

Asked in ValueLabs

2d ago

Q. How do you connect a component to Redux store? Which function in Redux is used to connect to store? What are the parameters in connect?

Ans.

To connect a component to Redux store, we use the connect function from the react-redux library.

  • Import the connect function from react-redux.

  • Use the connect function to wrap the component and connect it to the Redux store.

  • The connect function takes two parameters: mapStateToProps and mapDispatchToProps.

  • mapStateToProps is a function that maps the state from the Redux store to the component's props.

  • mapDispatchToProps is an optional function that maps the dispatch function to th...read more

Are these interview questions helpful?

Asked in Amdocs

6d ago

Q. Sort Array Problem Statement

Given an array consisting of 'N' positive integers where each integer is either 0, 1, or 2, your task is to sort the given array in non-decreasing order.

Input:

Each input starts wi...read more
Ans.

Sort an array of positive integers consisting of 0, 1, and 2 in non-decreasing order.

  • Use a counting sort approach to count the occurrences of 0s, 1s, and 2s in the array.

  • Update the array with the counts of 0s, 1s, and 2s in order to achieve the sorted array.

  • Ensure to handle the constraints of the input array elements being 0, 1, or 2.

  • Example: Input: [0, 2, 1, 2, 0], Output: [0, 0, 1, 2, 2]

Asked in Amazon

6d ago

Q. Furthest Building You Can Reach

In this problem, Ninja prefers jumping over building roofs rather than walking through the streets. The heights of the buildings in his city are represented by an array HEIGHTS, ...read more

Ans.

Given heights of buildings, bricks, and ladders, find the farthest building Ninja can reach using them optimally.

  • Iterate through the buildings and calculate the difference in heights between consecutive buildings.

  • Use bricks or ladders to cover the height difference when needed.

  • Keep track of the farthest building Ninja can reach based on available bricks and ladders.

  • Return the index of the farthest building Ninja can reach.

React Developer Jobs

Robert Bosch Engineering and Business Solutions Private Limited logo
JAVA AWS React developer 5-8 years
Robert Bosch Engineering and Business Solutions Private Limited
4.1
Bangalore / Bengaluru
SopraSteria logo
Python/React Developer 3-5 years
SopraSteria
3.8
Noida
Infosys Limited logo
Java Fullstack (React) Developer 3-5 years
Infosys Limited
3.6
Hyderabad / Secunderabad
1d ago

Q. What are Hooks in React? Name the ones you have used in your project.

Ans.

Hooks are a feature introduced in React 16.8 that allow developers to use state and other React features in functional components.

  • useState() - for managing state in functional components

  • useEffect() - for performing side effects in functional components

  • useContext() - for accessing context in functional components

  • useReducer() - for managing complex state and actions in functional components

  • useCallback() - for memoizing functions in functional components

  • useMemo() - for memoizing...read more

Q. Write a React Class component. Convert this Class to a Functional Component. How can you pass prop from parent to child component? Write code.

Ans.

Answer to a React Developer interview question about class and functional components and passing props.

  • Class component: class MyComponent extends React.Component {}

  • Functional component: const MyComponent = (props) => {}

  • Passing props from parent to child:

Share interview questions and help millions of jobseekers 🌟

man-with-laptop

Asked in ValueLabs

2d ago

Q. What is Context API in React? Is there a need to have an initial state in Context API?

Ans.

Context API is a way to share data between components without passing props down manually.

  • Context API provides a way to pass data through the component tree without having to pass props down manually at every level.

  • It is useful for sharing data that needs to be accessed by many components at different levels of the tree.

  • Initial state can be set in Context API using the createContext() function.

  • There is no need to have an initial state in Context API, but it can be useful in s...read more

Asked in Cognizant

1d ago

Q. How do you avoid re-rendering a component? Explain the use of the useEffect second parameter and shouldComponentUpdate.

Ans.

To avoid re-rendering, use shouldComponentUpdate or React.memo

  • Use shouldComponentUpdate to compare current and next props/state

  • Use React.memo to memoize functional components

  • Use useMemo to memoize expensive computations

  • Use useCallback to memoize event handlers

  • Use PureComponent for class components

5d ago
Q. What are the differences between functional and class components in React?
Ans.

Functional components are simpler and easier to test, while class components have more features and lifecycle methods.

  • Functional components are written as JavaScript functions, while class components are written as ES6 classes.

  • Functional components are stateless and do not have their own internal state, while class components can have state.

  • Functional components do not have lifecycle methods, while class components have lifecycle methods like componentDidMount and componentDi...read more

1d ago
Q. Can you explain promises in JavaScript and describe its three states?
Ans.

Promises in JavaScript represent the eventual completion (or failure) of an asynchronous operation.

  • Promises are objects that represent the eventual completion (or failure) of an asynchronous operation.

  • They have three states: pending, fulfilled, or rejected.

  • A pending promise is one that hasn't been fulfilled or rejected yet.

  • A fulfilled promise is one that has been successful.

  • A rejected promise is one that has encountered an error.

  • Promises help in handling asynchronous operatio...read more

5d ago

Q. What are the features of ES6?

Ans.

ES6 introduces new syntax and features to JavaScript, enhancing code readability and functionality.

  • Arrow Functions: Shorter syntax for function expressions. Example: const add = (a, b) => a + b;

  • Template Literals: Multi-line strings and string interpolation. Example: const greeting = `Hello, ${name}!`;

  • Destructuring Assignment: Unpacking values from arrays or properties from objects. Example: const [a, b] = [1, 2];

  • Default Parameters: Allow named parameters to be initialized wit...read more

6d ago

Q. What are Higher Order Functions and Higher Order Components? Give examples.

Ans.

Higher Order Functions are functions that take other functions as arguments or return functions as their results.

  • Higher Order Functions can be used to create reusable code by abstracting common functionality into a separate function.

  • They can also be used to implement functional programming concepts like currying and composition.

  • Example: Array.prototype.map() is a higher order function that takes a callback function as an argument and applies it to each element of an array, re...read more

4d ago

Q. How does Event Loop works? What are Event Queue and Event Stack?

Ans.

Event Loop is a mechanism that allows JavaScript to handle asynchronous operations.

  • Event Loop is a continuous process that checks the Event Queue and moves events to the Event Stack.

  • Event Queue holds all the events that are waiting to be processed.

  • Event Stack holds the events that are currently being processed.

  • When the Event Stack is empty, the Event Loop checks the Event Queue for new events.

  • JavaScript uses Event Loop to handle asynchronous operations like setTimeout(), setI...read more

Asked in Cognizant

6d ago

Q. What are refs? How will you use it for getting input value? Explain with code.

Ans.

Refs are a way to access DOM nodes or React components directly. They can be used to get input values.

  • Refs provide a way to access DOM nodes or React components directly.

  • They are commonly used to get input values or trigger imperative animations.

  • Refs can be created using the `createRef()` method or by using a callback function.

  • To get the value of an input using refs, you can assign a ref to the input element and access its value property.

Asked in ValueLabs

2d ago

Q. Do reducers need to have an initial state compulsorily?

Ans.

Yes, it is mandatory for Reducer to have an initial state.

  • Initial state defines the starting point of the state tree.

  • It helps in defining the shape of the state tree.

  • It is used to set default values for the state properties.

  • It is also used to reset the state to its initial values.

  • Example: const initialState = { count: 0 };

  • Example: const initialState = { name: '', age: 0 };

Asked in Cognizant

4d ago

Q. What are the ways to handle Errors in React?

Ans.

Error handling in React can be done using try-catch blocks, error boundaries, and handling asynchronous errors.

  • Use try-catch blocks to handle synchronous errors

  • Use error boundaries to catch errors in child components

  • Handle asynchronous errors using promises or async/await

  • Use third-party libraries like Sentry or Bugsnag for better error tracking

  • Display user-friendly error messages to improve user experience

1d ago
Q. What is the difference between TRUNCATE and DELETE in a database management system?
Ans.

TRUNCATE is a DDL command that removes all records from a table, while DELETE is a DML command that removes specific records.

  • TRUNCATE is faster than DELETE as it does not log individual row deletions.

  • TRUNCATE resets the auto-increment value of the table, while DELETE does not.

  • TRUNCATE cannot be rolled back, but DELETE can be rolled back using transactions.

  • TRUNCATE does not trigger any triggers associated with the table, while DELETE does.

Asked in ValueLabs

3d ago

Q. What is the minimum coverage for an app? How much code do you push to production/master branch while deployment?

Ans.

Minimum coverage for an app and code pushed to production/master branch while deployment.

  • Minimum coverage for an app depends on the project requirements and complexity.

  • Generally, a coverage of 80% or higher is considered good.

  • Code pushed to production/master branch should be thoroughly tested and reviewed.

  • Continuous integration and deployment can help automate this process.

  • Examples of tools for code coverage include Jest, Istanbul, and Enzyme.

1d ago
Q. How can we structure the top-level directories in Redux?
Ans.

Top-level directories in Redux should be structured based on functionality and feature modules.

  • Separate directories for actions, reducers, and components

  • Group related functionality together in separate directories

  • Use feature modules to encapsulate related actions, reducers, and components

  • Example: 'actions', 'reducers', 'components', 'utils', 'constants'

Q. What are export types in ReactJS?

Ans.

Export types in ReactJS allow components, functions, and variables to be accessed and used in other files.

  • Exporting a component allows it to be imported and used in other files

  • Exporting a function allows it to be imported and used in other files

  • Exporting a variable allows it to be imported and used in other files

1d ago

Q. How do you hide API URLs? How to manage different URLs for different staging environment?

Ans.

API URLs can be hidden by using environment variables and managing different URLs for different staging environments.

  • Use environment variables to store API URLs

  • Create separate environment files for different staging environments

  • Set the appropriate API URL in the environment file for each staging environment

  • Access the API URL from the environment variable in the code

4d ago
Q. What are the differences between a class component and a functional component in ReactJS?
Ans.

Class components are ES6 classes that extend from React.Component and have access to state and lifecycle methods, while functional components are simple functions that take props as arguments and return JSX.

  • Class components are defined using ES6 classes and extend from React.Component

  • Functional components are simple functions that take props as arguments and return JSX

  • Class components have access to state and lifecycle methods, while functional components do not

  • Functional com...read more

5d ago
Q. What are the differences between stateless and stateful components in ReactJS?
Ans.

Stateless components do not have internal state, while stateful components have internal state.

  • Stateless components are functional components that do not have internal state.

  • Stateful components are class components that have internal state.

  • Stateless components are simpler and easier to test.

  • Stateful components are more complex and can hold and update internal state.

  • Example: Stateless component - const Button = () => <button>Click me</button>

  • Example: Stateful component - class...read more

5d ago
Q. What are the key differences between mapStateToProps() and mapDispatchToProps() in Redux?
Ans.

mapStateToProps() is used to access the Redux state in a component, while mapDispatchToProps() is used to dispatch actions to update the state.

  • mapStateToProps() is used to access the Redux state and return data as props for a component.

  • mapDispatchToProps() is used to dispatch actions to update the Redux state.

  • mapStateToProps() is a function that takes the current state as an argument and returns an object with props that will be passed to the component.

  • mapDispatchToProps() is...read more

3d ago
Q. What are the states of a promise object in JavaScript?
Ans.

The states of a promise object are pending, fulfilled, or rejected.

  • A promise starts in the pending state.

  • When a promise is resolved, it transitions to the fulfilled state.

  • If a promise encounters an error, it transitions to the rejected state.

  • Once a promise is settled (fulfilled or rejected), it cannot transition to any other state.

1d ago

Q. What is React? Why do we use it? Make a form with 3 different child components and pass props from the parent. There should be Select box, an Input field and a Submit Button.

Ans.

React is a JavaScript library used for building user interfaces.

  • React allows for reusable components and efficient rendering.

  • It uses a virtual DOM to update only the necessary parts of the UI.

  • React is popular for its simplicity and flexibility.

  • Examples of companies using React include Facebook, Instagram, and Airbnb.

Asked in ValueLabs

1d ago

Q. Explain Redux-Saga middleware. How do you Dispatch actions from components in Redux?

Ans.

Redux-Saga is a middleware for Redux that handles side effects. Actions can be dispatched from components using mapDispatchToProps.

  • Redux-Saga is used to handle side effects like API calls and asynchronous actions.

  • It uses generator functions to make asynchronous code look synchronous.

  • Sagas listen for specific actions and perform tasks based on those actions.

  • To dispatch actions from components, use mapDispatchToProps to connect the component to the Redux store.

  • Then call the act...read more

Asked in ValueLabs

1d ago

Q. Will React re-render the whole page or just a part of it?

Ans.

React re-renders just the part of the page that has changed, thanks to its virtual DOM.

  • React uses a virtual DOM to track changes in the UI.

  • When a component's state or props change, React compares the virtual DOM with the real DOM and updates only the necessary parts.

  • This approach improves performance by minimizing the number of DOM manipulations.

  • React's diffing algorithm efficiently determines the minimal set of changes needed to update the UI.

1
2
3
4
5
Next

Interview Experiences of Popular Companies

TCS Logo
3.6
 • 11.1k Interviews
Accenture Logo
3.7
 • 8.7k Interviews
Infosys Logo
3.6
 • 7.9k Interviews
Cognizant Logo
3.7
 • 5.9k Interviews
Capgemini Logo
3.7
 • 5.1k Interviews
View all
Interview Tips & Stories
Interview Tips & Stories
Ace your next interview with expert advice and inspiring stories
React Developer Interview Questions
Share an Interview
Stay ahead in your career. Get AmbitionBox app
play-icon
play-icon
qr-code
Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+

Reviews

10L+

Interviews

4 Cr+

Salaries

1.5 Cr+

Users

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2025 Info Edge (India) Ltd.

Follow Us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter
Profile Image
Hello, Guest
AmbitionBox Employee Choice Awards 2025
Winners announced!
awards-icon
Contribute to help millions!
Write a review
Write a review
Share interview
Share interview
Contribute salary
Contribute salary
Add office photos
Add office photos
Add office benefits
Add office benefits