React Developer
100+ React Developer Interview Questions and Answers

Asked in Amdocs

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
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

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
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

Asked in Samsung

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
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

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?
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

Asked in Amdocs

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
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

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
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




Asked in Capgemini Engineering

Q. What are Hooks in React? Name the ones you have used in your project.
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

Asked in Virtusa Software Services

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.
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 🌟

Asked in ValueLabs

Q. What is Context API in React? Is there a need to have an initial state in Context API?
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

Q. How do you avoid re-rendering a component? Explain the use of the useEffect second parameter and shouldComponentUpdate.
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

Asked in BMP Technologies

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

Asked in Ernst & Young

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

Asked in Capgemini Engineering

Q. What are the features of ES6?
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

Asked in Capgemini Engineering

Q. What are Higher Order Functions and Higher Order Components? Give examples.
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

Asked in Capgemini Engineering

Q. How does Event Loop works? What are Event Queue and Event Stack?
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

Q. What are refs? How will you use it for getting input value? Explain with code.
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

Q. Do reducers need to have an initial state compulsorily?
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

Q. What are the ways to handle Errors in React?
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

Asked in Bajaj Finserv

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

Q. What is the minimum coverage for an app? How much code do you push to production/master branch while deployment?
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.

Asked in Ernst & Young

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'

Asked in Virtusa Software Services

Q. What are export types in ReactJS?
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
Asked in Patona Technologies

Q. How do you hide API URLs? How to manage different URLs for different staging environment?
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

Asked in Ernst & Young

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

Asked in Ernst & Young

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

Asked in Ernst & Young

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

Asked in OodlesTechnologies

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.

Asked in Wissen Infotech

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.
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

Q. Explain Redux-Saga middleware. How do you Dispatch actions from components in Redux?
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

Q. Will React re-render the whole page or just a part of it?
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.
Interview Questions of Similar Designations
Interview Experiences of Popular Companies





Top Interview Questions for React Developer Related Skills



Reviews
Interviews
Salaries
Users

