Virtusa Software Services
Billionaire Bucks Interview Questions and Answers
Q1. 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:
Q2. 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
Q3. 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.
Q4. 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
Q5. 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.
Q6. 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
Q7. How setState works in React?
setState is a method used in React to update the state of a component.
setState is asynchronous and batched for performance optimization.
It merges the new state with the previous state.
It schedules a re-render of the component and its children.
Passing a function to setState ensures the previous state is used correctly.
Example: this.setState({ count: this.state.count + 1 })
Top React Developer Interview Questions from Similar Companies
Reviews
Interviews
Salaries
Users/Month