Skip to content

Latest commit

 

History

History
119 lines (80 loc) · 3.98 KB

File metadata and controls

119 lines (80 loc) · 3.98 KB

React Interview Questions & Answers

react Interview Questions & Answers

Note: Keep in mind that many of these questions are open-ended and could lead to interesting discussions that tell you more about the person's capabilities than a straight answer would.

1. What is React? How is it different from other JS frameworks? ⭐

Answer

React is a Component-Based JavaScript library for building user interfaces. Opposed to a full framework like Angular React does not ship with routing, state management and data fetching by default, these functionalities have been left to third parties. This makes react really flexible since you are able to choose the best tool for your project’s needs.

2. What are the lifecycle methods of a React component? ⭐

Answer

Every component has several lifecycle methods that can be overridden to run code at particular times in the process. Here is a helpful diagram to better visualize the order in which each lifecycle method is used.

Click here for more information about each lifecycle method

3. What is React Router? ⭐

Answer

React Router is the standard routing library for React. React Router helps you add new screens and flows to your application incredibly quickly, all while keeping the URL in sync with what's being displayed on the page.

4. Explain the Virtual DOM, and a pragmatic overview of how React renders it to the DOM. ⭐

Answer

In React, for every DOM object, there is a corresponding "virtual DOM object." A virtual DOM object is a representation of a DOM object, like a lightweight copy.

When you render a JSX element, every single virtual DOM object gets updated. This sounds incredibly inefficient, but the cost is insignificant because the virtual DOM can update so quickly.

Once the virtual DOM has updated, then React compares the virtual DOM with a virtual DOM snapshot that was taken right before the update.

By comparing the new virtual DOM with a pre-update version, React figures out exactly which virtual DOM objects have changed. This process is called "diffing."

Once React knows which virtual DOM objects have changed, then React updates those objects, and only those objects, on the real DOM

5. Explain the purpose of render() in React. ⭐

Answer

The purpose is to render a React element into the DOM in the supplied container and return a reference to the component (or returns null for stateless components).

If the React element was previously rendered into container, this will perform an update on it and only mutate the DOM as necessary to reflect the latest React element.

ReactDOM.render(element, container[, callback])

Click here for more info on the render() method

6. What is arrow function in React? ⭐

Answer

7. Why would you use React.Children.map(props.children, () => ) instead of props.children.map(() => )? ⭐

Answer

8. how events are handled in React? ⭐

Answer

9. What is JSX in React? ⭐

Answer

10. List some features of ReactJS? ⭐

Answer