React Developer
100+ React Developer Interview Questions and Answers
We are suffering from the Second wave of Covid-19. The Government is trying to increase its vaccination drives. Ninja wants to help the Government to plan an effective method to help increase v...read more
Take two numbers as input and swap them and print the swapped values.
Input Format:
The first line of input contains a single integer 't', representing the total number of test cases. The second...read more
React Developer Interview Questions and Answers for Freshers
You are given an array/list ARR consisting of N integers. Your task is to find all the distinct triplets present in the array which adds up to a given number K.
An array is said to have a...read more
You are given an array consisting of 'N' positive integers where each integer is either 0 or 1 or 2. Your task is to sort the given array in non-decreasing order.
Note :
1. The array consists of only ...read more
Ninja is in the mood for a walk over the city, but being a ninja he prefers jumping over building roofs instead of walking through the streets.
The height of the buildings in his ...read more
Q6. 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
Share interview questions and help millions of jobseekers 🌟
Q7. 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
Q1. Introduction
Q2. Discussion on Projects.
Q3. Why do you want to join this company?
I want to join this company because of its reputation in the industry and the opportunities it offers for growth and learning.
The company has a strong reputation in the industry and is known for its innovative projects.
I have researched the company and found that it has a great work culture and values its employees.
I am impressed by the company's commitment to using cutting-edge technologies like React.
The company offers opportunities for growth and learning, which aligns wit...read more
React Developer Jobs
Q9. 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:
Q10. How do you avoid re-rendering of a component? With useEffect second parameter, should ComponentUpdate
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
What are the differences between functional and class components?
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
Q12. 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
Q13. 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
Q14. 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.
Q15. 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
How can we structure the top level directories in Redux?
We were asked to send our personal details like email, reg no, mobile number using an api.
Q18. 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
Q19. 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.
Q20. 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
Q21. 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
Q22. Do Reducer 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 };
What are the states of promise object?
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.
What are the differences between a class component and functional component?
Q25. 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.
Q26. 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
Q27. Will React re-render 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.
What is the difference between slice and splice?
Does const variable makes the value immutable?
No, const does not make the value immutable.
const only makes the variable itself immutable, not the value it holds.
For objects and arrays, const prevents reassignment but allows mutation of properties or elements.
To make a value truly immutable, you can use Object.freeze() or other techniques.
Q30. How Promise works? What is Promise.all. Write code for both.
Promises are a way to handle asynchronous operations in JavaScript. Promise.all is used to execute multiple promises concurrently.
Promises represent a value that may not be available yet
They have three states: pending, fulfilled, and rejected
Promise.all takes an array of promises and returns a new promise that resolves when all promises in the array have resolved
If any promise in the array is rejected, the returned promise is rejected with the reason of the first promise that...read more
What is a first class function?
What are stateless and stateful components?
Which libraries you have used with React?
What is status code 404, 200,etc?
What should a web developer know to build a website like html, css, js?
What should be the main focus of website?
Q34. What are Hooks in React? Explain useState, useEffect hooks.
Hooks are functions that allow you to use state and other React features without writing a class.
useState is a hook that allows you to add state to functional components.
useEffect is a hook that allows you to perform side effects in functional components.
Hooks can only be used in functional components.
Hooks must be called at the top level of a functional component.
Hooks can be used to replace lifecycle methods in class components.
Q35. Difference between Let, Const and Var. Write code and explain.
Let, Const, and Var are used to declare variables in JavaScript with different scoping and reassignment abilities.
Var has function scope and can be redeclared and reassigned.
Let has block scope and can be reassigned but not redeclared.
Const has block scope and cannot be reassigned or redeclared.
Q36. How can you optimize a React App?
Optimizing a React app involves reducing bundle size, using lazy loading, and optimizing rendering performance.
Reduce bundle size by code splitting and using dynamic imports
Use lazy loading to load components only when needed
Optimize rendering performance by using shouldComponentUpdate and PureComponent
Use React.memo to memoize functional components
Avoid unnecessary re-renders by using useMemo and useCallback
Use performance profiling tools like React DevTools and Chrome DevTo...read more
Q37. What are Hooks? What all Hooks have you used in your project?
Hooks are functions that allow you to use state and other React features without writing a class.
useState() - for managing state in functional components
useEffect() - for performing side effects in functional components
useContext() - for consuming context in functional components
useReducer() - for managing complex state in functional components
useCallback() - for memoizing functions in functional components
useMemo() - for memoizing values in functional components
useRef() - fo...read more
How Relay is different from Redux?
What are the advantages of using Redux?
Q40. What is Lazy Loading, Suspense. How do they work?
Lazy Loading and Suspense are techniques used to improve performance by loading components and data only when needed.
Lazy Loading delays the loading of non-critical resources until they are needed, reducing initial load time.
Suspense allows components to wait for data to load before rendering, improving user experience.
Lazy Loading and Suspense can be used together to optimize performance and user experience.
Example: A website with a large image gallery can use Lazy Loading t...read more
Explain promises and it's 3 states .
Highlight the key differences between mapStateToProps() and mapDispatchToProps()?
What is a higher order function
Q44. Features of ES6. Explain Spread Operator and Rest Parameter by writing code. Give example for Object Destructuring.
ES6 features: Spread Operator, Rest Parameter, Object Destructuring
Spread Operator: allows an iterable to be expanded into individual elements
Rest Parameter: allows a function to accept an indefinite number of arguments as an array
Object Destructuring: allows extracting properties from an object and assigning them to variables
Q45. How to implement Responsiveness in App as per screen sizes?
Responsiveness in app can be achieved using CSS media queries and responsive design principles.
Use CSS media queries to apply different styles based on screen sizes
Design the app layout to be flexible and adapt to different screen sizes
Use responsive units like percentages and viewport units for sizing elements
Test the app on different devices and screen sizes to ensure responsiveness
Q46. What is the significance of 'this' keyword in JS?
The 'this' keyword in JS refers to the object that is currently executing the code.
The value of 'this' depends on how a function is called.
In a method, 'this' refers to the object that the method belongs to.
In a regular function, 'this' refers to the global object (window in a browser).
In an event handler, 'this' refers to the element that triggered the event.
The value of 'this' can be explicitly set using call(), apply(), or bind() methods.
What are callbacks?
What is reconciliation?
How is state changed in redux?
What are Custom Hooks?
Custom Hooks are reusable functions in React that allow you to extract logic from components.
Custom Hooks are functions that start with the word 'use' and can call other Hooks if needed.
They are used to share stateful logic between components without using higher-order components or render props.
Custom Hooks can be used to handle common tasks like fetching data, managing form state, or subscribing to events.
They promote code reusability and make it easier to separate concerns...read more
Interview Questions of Similar Designations
Top Interview Questions for React Developer Related Skills
Interview experiences of popular companies
Calculate your in-hand salary
Confused about how your in-hand salary is calculated? Enter your annual salary (CTC) and get your in-hand salary
Reviews
Interviews
Salaries
Users/Month