Reactjs Developer

200+ Reactjs Developer Interview Questions and Answers

Updated 13 Dec 2024

Popular Companies

search-icon

Q1. Implement counter such that it has 2 buttons to increment and decrement the values and also add a input field such that, whatever input is given, the value should be to that and value should should be decreased...

read more
Ans.

Implement a counter with increment and decrement buttons and an input field to set the value.

  • Create a state variable to hold the counter value

  • Use onClick event handlers for the buttons to increment and decrement the counter

  • Use onChange event handler for the input field to update the counter value

  • Set the initial value of the counter to 0

  • Validate the input value to ensure it is a number

Q2. What are Call, apply and bind methods, what is currying in JavaScript, closure , promises, hoisting, event Loop, restructuring.

Ans.

Call, apply, and bind are methods used to manipulate the context of a function. Currying is a technique to transform a function with multiple arguments into a sequence of functions with single arguments. Closure is a feature that allows a function to access variables from its outer scope. Promises are objects used for asynchronous programming. Hoisting is a behavior where variable and function declarations are moved to the top of their containing scope. Event loop is a mechan...read more

Reactjs Developer Interview Questions and Answers for Freshers

illustration image

Q3. How do you make a page responsive. Bootstrap layouts and alerts

Ans.

To make a page responsive, use Bootstrap layouts and alerts.

  • Use Bootstrap's grid system to create responsive layouts

  • Use media queries to adjust the layout based on screen size

  • Use Bootstrap's responsive utility classes to hide/show elements on different devices

  • Use Bootstrap's responsive navigation components for mobile-friendly menus

  • Use Bootstrap's responsive images to ensure they scale properly

  • Use Bootstrap's responsive embeds for videos and other media

  • Use Bootstrap's respons...read more

Q4. what is ES6 feature small coding on how let,var,const works javascript set , closure (closure with different let scenarios) difference between function and class component use of sort destructure to insert elem...

read more
Ans.

Questions related to ReactJS development including ES6 features, lifecycle, custom hooks, and deployment.

  • ES6 features include let, const, arrow functions, and destructuring

  • Function components are simpler and class components have state and lifecycle methods

  • Sort method is used to sort arrays based on a given criteria

  • Browser router is used for client-side routing in React applications

  • Custom hooks are reusable functions that can be used across multiple components

  • Webpack is a mod...read more

Are these interview questions helpful?

Q5. Write code for functional component to call an API and show a list from the response (given by the interviewer)

Ans.

Code for functional component to call API and show list from response

  • Use useEffect hook to call API on component mount

  • Use useState hook to store API response

  • Map through response data to display list

  • Handle loading and error states

Q6. What are higher-order functions in JS

Ans.

Higher-order functions are functions that take one or more functions as arguments or return a function as their result.

  • Higher-order functions can be used to create reusable code by abstracting common patterns.

  • They enable functional programming paradigms like currying and composition.

  • Examples of higher-order functions in JavaScript include map, filter, and reduce.

Share interview questions and help millions of jobseekers 🌟

man-with-laptop

Q7. How to modularize code in ReactJs, How to perform test, what is typescript and how it's different.

Ans.

Modularizing code in ReactJs involves breaking down the application into smaller components for better organization and reusability.

  • Create separate components for different parts of the UI

  • Use props to pass data and functions between components

  • Use state to manage component-specific data

  • Use React Router to handle routing and navigation

  • Use CSS modules or styled-components for component-specific styling

  • Use Redux or Context API for state management across components

  • Perform unit te...read more

Q8. Factors on which numbers of cars will be there in your state and what will be the number in round figure.

Ans.

The number of cars in a state depends on factors such as population, income, and infrastructure.

  • Population density affects the number of cars on the road.

  • Higher income levels lead to more car ownership.

  • Availability of public transportation can decrease the number of cars.

  • Infrastructure, such as highways and parking, can also impact car usage.

  • The number of cars in a state can vary greatly depending on these factors.

  • In round figures, the number of cars in a state could range fr...read more

Reactjs Developer Jobs

React JS Developer 5-10 years
Tata Consultancy Services
3.7
Chennai
React JS Developer 5-8 years
Infosys Limited
3.7
Pune
React JS Developer 3-5 years
Infosys Limited
3.7
Bangalore / Bengaluru

Q9. presentation component vs functional component in React.js

Ans.

Presentation components are class components that handle rendering, while functional components are simpler and handle stateless rendering.

  • Presentation components are also known as container components.

  • Functional components are also known as stateless components.

  • Presentation components are used for complex UI logic and state management.

  • Functional components are used for simple UI logic and stateless rendering.

  • Functional components are easier to test and maintain.

  • Example of pr...read more

Q10. What is a single page appliction?

Ans.

A single page application is a web application that loads once and dynamically updates the content without refreshing the page.

  • Loads once and dynamically updates content

  • No page refreshes

  • Uses JavaScript frameworks like React to handle routing and rendering

  • Improves user experience by providing a seamless and responsive interface

Q11. What is hoisting in JS

Ans.

Hoisting is a JavaScript behavior where variable and function declarations are moved to the top of their containing scope.

  • Hoisting applies to both variable and function declarations.

  • Variable declarations are hoisted but not their initializations.

  • Function declarations are fully hoisted, allowing them to be called before they are declared.

  • Hoisting does not apply to variables declared with let or const.

  • Hoisting can lead to unexpected behavior if not understood properly.

Q12. Coding Question, Find largest element in array without sort, find sum of all element in array, find count of each element in array like how many times each element occurred in array?

Ans.

Find largest element, sum of all elements, and count of each element in array without sorting.

  • To find the largest element, iterate through the array and keep track of the maximum value.

  • To find the sum of all elements, iterate through the array and add each element to a running total.

  • To find the count of each element, use a hashmap to store the count of each element as you iterate through the array.

Q13. How are data passed from children to parents in react component?

Ans.

Data can be passed from children to parents in React components by using callback functions.

  • Use callback functions to pass data from child components to parent components

  • Parent component passes a function as a prop to child component

  • Child component calls the function with the data as an argument to pass data to parent component

Q14. how would you validate the form using HTML? How do you validate the phone number with the country code?

Ans.

Form validation can be done using HTML attributes like required, pattern, and maxlength. Phone number validation with country code can be achieved using regex.

  • Use the 'required' attribute to make fields mandatory

  • Use the 'pattern' attribute with regex to validate input format

  • Use the 'maxlength' attribute to limit the number of characters in a field

  • For phone number validation with country code, use regex to match the desired format. For example, /^\+[0-9]{1,3}-[0-9]{3}-[0-9]{7}...read more

Q15. Difference between var, let, and const in JS

Ans.

var is function scoped, let and const are block scoped.

  • var can be redeclared and updated within its scope

  • let can be updated but not redeclared within its scope

  • const cannot be updated or redeclared once declared

  • let and const are not hoisted like var

  • const must be initialized during declaration

Q16. 1. Fetch data from api and display in UI list format

Ans.

Answering how to fetch data from API and display in UI list format for Reactjs Developer interview.

  • Use fetch or axios to fetch data from API

  • Store the data in state or Redux store

  • Map through the data and display in UI list format

  • Handle loading and error states

  • Example: fetch('https://api.example.com/data').then(response => response.json()).then(data => setData(data))

  • Example: {data.map(item =>

  • {item.name}
  • )}

Q17. what are the new features in react 16?

Ans.

React 16 introduced new features like React Fiber, Error Boundaries, Portals, and improved server-side rendering.

  • React Fiber is a new reconciliation engine that improves performance and enables incremental rendering.

  • Error Boundaries allow developers to catch and handle errors in components.

  • Portals provide a way to render children into a different DOM subtree.

  • Improved server-side rendering with support for streaming and faster rendering.

  • React 16 also introduced new lifecycle m...read more

Q18. What is the difference between CSS and SASS? what is the use of Sass

Ans.

SASS is a preprocessor scripting language that is interpreted into CSS, offering more features and flexibility.

  • SASS is a preprocessor for CSS, allowing for variables, nesting, and mixins to be used in stylesheets.

  • SASS code needs to be compiled into CSS before being used in a web project.

  • SASS helps in writing cleaner and more organized CSS code, making it easier to maintain and update styles.

  • CSS is the styling language used for web development, while SASS is a tool that extend...read more

Q19. What is closures, Hoisting with example Semantic elements

Ans.

Closures and hoisting are important concepts in JavaScript.

  • Closures refer to the ability of a function to access variables in its outer scope even after the function has returned.

  • Hoisting is the behavior of moving variable and function declarations to the top of their respective scopes.

  • Example of closures: function outer() { let x = 10; function inner() { console.log(x); } return inner; } const innerFunc = outer(); innerFunc(); // Output: 10

  • Example of hoisting: console.log(x)...read more

Q20. tell me the output 1)a = 20; console.log(a); var a; 2)b=10; console.log(b); let b; 3)let a =5; if(a<5){ let b = " a lessthen 5"; }else{ let b = "b is grater then 5"; } console.log(b);

Ans.

The output for the given code snippets will be: 1) 20 2) ReferenceError: Cannot access 'b' before initialization 3) ReferenceError: b is not defined

  • In the first snippet, variable 'a' is declared using 'var' after it is assigned a value, so it logs 20 without any issues.

  • In the second snippet, variable 'b' is declared using 'let' after it is assigned a value, so it throws a ReferenceError as 'b' is accessed before initialization.

  • In the third snippet, variable 'b' is declared us...read more

Q21. What is redux and when to use it and when not to use it?

Ans.

Redux is a predictable state container for JavaScript apps. It is used to manage application state in a centralized way.

  • Use Redux when you have complex state management needs in your application.

  • Redux is helpful for large applications with many components that need access to the same state.

  • Avoid using Redux for simple applications with minimal state management requirements.

  • Consider using React's built-in state management for smaller applications or components.

  • Redux can be use...read more

Q22. Explain UseMemo, UseCallback, UseEffect uses, and lifecycle method in the class component.

Ans.

Explanation of React hooks and lifecycle methods

  • useMemo is used to memoize expensive computations and avoid unnecessary re-renders

  • useCallback is used to memoize functions and avoid unnecessary re-renders of child components

  • useEffect is used to perform side effects such as fetching data or updating the DOM

  • Lifecycle methods in class components are used to manage component state and perform side effects

  • ComponentDidMount is called after the component is mounted and is used to fet...read more

Q23. How would be dealing with an issue which was caused due to others?

Ans.

I would approach the issue by identifying the root cause and collaborating with the team to find a solution.

  • Identify the root cause of the issue

  • Collaborate with the team to find a solution

  • Communicate effectively with all parties involved

  • Take ownership of the issue and work towards a resolution

  • Document the issue and the steps taken to resolve it

Q24. how api call handle in redux and how can you get and display user name from redux

Ans.

API calls in Redux are typically handled using middleware like Redux Thunk. User name can be retrieved from Redux state and displayed in components.

  • Use Redux Thunk middleware to make API calls in Redux

  • Dispatch actions to update Redux state with API response data

  • Access user name from Redux state in components to display it

Q25. what is difference between var let and const give me an explanation on what block scope

Ans.

var, let, and const are used to declare variables in JavaScript. var has function scope, let has block scope, and const is a constant with block scope.

  • var has function scope, meaning it is accessible throughout the function it is declared in.

  • let has block scope, meaning it is only accessible within the block it is declared in.

  • const is similar to let in terms of block scope, but the value cannot be reassigned.

Q26. What are lifecycle methods of react? How we can achieve same in functional components?

Ans.

React lifecycle methods are methods that are invoked at different stages of a component's life cycle.

  • Some lifecycle methods include componentDidMount, componentDidUpdate, componentWillUnmount, etc.

  • In functional components, we can achieve similar functionality using useEffect hook.

  • For example, useEffect with an empty dependency array can mimic componentDidMount, while useEffect with dependencies can mimic componentDidUpdate.

Q27. What are there components and how it works it custom hook?

Ans.

Components are reusable UI elements in React, while custom hooks are functions that allow you to reuse stateful logic across components.

  • Components are building blocks of a React application, encapsulating UI elements and logic.

  • Custom hooks are JavaScript functions that allow you to extract and reuse stateful logic from components.

  • Components can be functional or class-based, while custom hooks are always functions.

  • Example: A custom hook for handling form input validation logic...read more

Q28. What is redux ? Explain its architecture ? How many parameters are there in connect method ?

Ans.

Redux is a predictable state container for JavaScript apps. It helps manage application state in a single immutable store.

  • Redux is a state management library for JavaScript applications.

  • It follows a unidirectional data flow architecture.

  • Redux architecture consists of actions, reducers, store, and middleware.

  • Actions are payloads of information that send data from the application to the store.

  • Reducers specify how the application's state changes in response to actions.

  • Store hold...read more

Q29. What is virtual DOM in react?

Ans.

Virtual DOM is a lightweight copy of the actual DOM used for efficient rendering in React.

  • Virtual DOM is a JavaScript object that represents the actual DOM.

  • It allows React to update only the necessary parts of the UI, improving performance.

  • Changes made to the virtual DOM are compared with the previous version to determine what needs to be updated.

  • React then updates the actual DOM with the minimum required changes.

  • Virtual DOM is created using React.createElement() or JSX.

  • React...read more

Q30. What is the difference between rem and em in css? How to hide something in CSS?

Ans.

rem and em are both units in CSS for defining font sizes, with rem being relative to the root element and em being relative to the parent element.

  • rem stands for 'root em' and is relative to the font size of the root element (usually the tag)

  • em stands for 'element em' and is relative to the font size of the parent element

  • To hide something in CSS, you can use the display property with a value of 'none' or the visibility property with a value of 'hidden'

  • Example: To hide an eleme...read more

Q31. How to manage state between sibling component with using redux and local storage?

Ans.

State can be managed between sibling components using Redux and local storage.

  • Create a Redux store to manage the state

  • Define actions and reducers to update the state

  • Connect the sibling components to the Redux store

  • Use local storage to persist the state between page reloads

Q32. What is the difference between states and props ?

Ans.

States are mutable data managed within a component, while props are immutable data passed from parent to child components.

  • States are managed within a component and can be changed using setState method

  • Props are passed from parent to child components and are immutable

  • States are used for internal component data management, while props are used for passing data between components

  • Example: A counter component may have a state for the count value, while receiving a prop for the incr...read more

Q33. Write down the code from that API to integrate pagination on scrolling

Ans.

Code for integrating pagination on scrolling in Reactjs API

  • Use Intersection Observer API to detect when the user has scrolled to the bottom of the page

  • Fetch the next set of data from the server using an API call

  • Update the state with the new data and render it on the page

Q34. What is React / JSX / React DOM / Virtual DOM / Functional vs Class ?

Ans.

React is a JavaScript library for building user interfaces. JSX is a syntax extension for JavaScript. React DOM is a package for DOM manipulation. Virtual DOM is a lightweight copy of the actual DOM. Functional components are stateless and Class components are stateful.

  • React is a JavaScript library for building user interfaces

  • JSX is a syntax extension for JavaScript that allows writing HTML-like code in JavaScript

  • React DOM is a package for DOM manipulation

  • Virtual DOM is a lig...read more

Q35. Wht is is higher order component and can you write one ?

Ans.

Higher order component is a function that takes a component and returns a new component with additional functionality.

  • HOC is a design pattern in React

  • It allows code reuse, logic abstraction and composition

  • It can be used for cross-cutting concerns like authentication, logging, etc.

  • Example: WithAuth HOC that adds authentication logic to a component

  • Example: withRouter HOC that adds routing props to a component

Q36. What is the checklist for improving performance of React application?

Ans.

Checklist for improving performance of React application

  • Use React.memo or PureComponent for optimizing rendering

  • Avoid unnecessary re-renders by using shouldComponentUpdate or React.memo

  • Use code splitting to load only necessary components

  • Optimize state management with libraries like Redux or Context API

  • Minimize the use of inline styles and prefer CSS stylesheets for better performance

Q37. What are new features of HTMl5,css positions

Ans.

New features of HTML5 include semantic tags, canvas, and video/audio support. CSS positions include sticky and grid layout.

  • HTML5: Semantic tags like

    ,
    ,
  • CSS positions: Sticky position allows elements to stick to the top or bottom of the viewport. Grid layout provides a more flexible way to create complex layouts.

Q38. Git commands: How to commit ,merge code, how to resolve merge conflicts

Ans.

Git commands for committing, merging code, and resolving merge conflicts

  • To commit code: git commit -m 'Commit message'

  • To merge code from a branch: git merge branch_name

  • To resolve merge conflicts: manually edit the conflicting files, add changes, and then commit the merge

Q39. Two arrays passed to one function, then remove the elements passed from source array and present in another array

Ans.

Remove elements from source array present in another array passed to a function

  • Loop through elements in source array and check if they exist in the other array

  • If an element is found in both arrays, remove it from the source array

Q40. tell me mounting and shallow concept in testing library

Ans.

Mounting is the process of rendering a component into the DOM, while shallow rendering allows testing a component without rendering its children.

  • Mounting is the initial phase of the component lifecycle where the component is rendered into the DOM.

  • Shallow rendering in testing library renders only the component itself, not its children.

  • Shallow rendering is useful for isolating the component being tested and avoiding rendering its entire component tree.

  • Example: In React testing ...read more

Q41. what is redux-toolkit and what difference b/w redux and redux-toolkit

Ans.

Redux Toolkit is the official, recommended way to write Redux logic. It simplifies the process of managing state in React applications.

  • Redux Toolkit provides a set of tools and best practices to streamline Redux development.

  • It includes utilities like createSlice, createReducer, and configureStore to simplify the code and reduce boilerplate.

  • Redux Toolkit also includes built-in Immer integration for writing immutable update logic more easily.

  • It encourages writing Redux code in ...read more

Q42. what are fragments in react js

Ans.

Fragments in React.js are used to group multiple elements without adding an extra node to the DOM.

  • Fragments are a way to group multiple elements without using a wrapper element.

  • They help in avoiding unnecessary divs in the DOM.

  • Fragments can improve performance by reducing the number of DOM nodes.

  • They are useful when returning multiple elements from a component's render method.

  • Fragments can be written using the syntax or the shorthand <> syntax.

Q43. What is reducer and it's flow

Ans.

A reducer is a pure function in React that takes the previous state and an action, and returns the new state.

  • Reducers are used in React to manage state changes in an application

  • They take the previous state and an action as input

  • Reducers are pure functions, meaning they do not modify the state directly

  • They return a new state based on the previous state and the action

  • Redux is a popular library that uses reducers to manage state in React applications

Q44. ES6 features and its use where and why?

Ans.

ES6 features are modern JavaScript syntax and features that make code more concise and readable.

  • Arrow functions for concise function syntax

  • Template literals for easier string interpolation

  • Let and const for block-scoped variables

  • Destructuring for easily extracting values from objects and arrays

  • Spread and rest operators for easily manipulating arrays and objects

  • Classes for object-oriented programming

  • Modules for better code organization and reusability

Q45. How the performance optimization can be done in React Js Application

Ans.

Performance optimization in React Js can be achieved through code splitting, memoization, virtualization, and minimizing re-renders.

  • Implement code splitting to load only necessary components when needed

  • Use memoization techniques like useMemo and useCallback to prevent unnecessary re-renders

  • Implement virtualization for long lists or tables to render only visible items

  • Minimize re-renders by using shouldComponentUpdate or React.memo for functional components

Q46. how would you add a Dynamic title on every page in React

Ans.

Use React's state to dynamically update the title on each page

  • Create a state variable to hold the dynamic title

  • Update the state variable with the desired title for each page

  • Use useEffect hook to update the document title with the state variable

Q47. How to communicate child to parent components in react?

Ans.

Using props and callbacks to communicate data from child to parent components in React.

  • Passing data from child to parent components using props

  • Using callbacks to send data from child to parent components

  • Using context API for global state management

Q48. why react hooks are use full?

Ans.

React hooks simplify state management and lifecycle methods in functional components.

  • Hooks allow functional components to have state and lifecycle methods

  • They reduce the need for class components and HOCs

  • Hooks make code more readable and easier to test

  • Examples of hooks include useState, useEffect, and useContext

Q49. What are Hooks in React.js

Ans.

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

  • Hooks are functions that let you use React features in functional components

  • They allow you to use state and other React features without writing a class

  • Hooks provide a way to reuse stateful logic between components

  • Some commonly used hooks are useState, useEffect, and useContext

Q50. Difference between var and let, difference between redux and flux

Ans.

Var is function scoped, let is block scoped. Redux is a predictable state container, Flux is an architecture pattern.

  • Var can be redeclared and updated within its scope, let cannot be redeclared but can be updated within its scope

  • Redux has a single store for the entire application, while Flux has multiple stores

  • Redux uses a unidirectional data flow, while Flux uses a bidirectional data flow

  • Redux has middleware for handling side effects, while Flux does not have built-in suppor...read more

1
2
3
4
5
6
Next
Interview Tips & Stories
Ace your next interview with expert advice and inspiring stories

Interview experiences of popular companies

3.7
 • 10k Interviews
3.9
 • 7.8k Interviews
3.7
 • 7.3k Interviews
3.8
 • 5.4k Interviews
3.8
 • 4.6k Interviews
3.6
 • 2.3k Interviews
4.1
 • 2.3k Interviews
4.0
 • 750 Interviews
4.0
 • 248 Interviews
View all

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

Reactjs Developer Interview Questions
Share an Interview
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+

Reviews

4 L+

Interviews

4 Cr+

Salaries

1 Cr+

Users/Month

Contribute to help millions
Get AmbitionBox app

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

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter