28 May 2022

React JS Interview Questions

1. What is React?

Ans: React is a JavaScript library for creating user interfaces. It is open source library specifically for single page applications.

  • It is a efficient, flexible & declarative library.
  • React is component based library.
  • It is maintained by a community of developers & companies. Formerly it was maintained by Facebook.


2. What is the Lifecycle of React Component?

Ans: React Component have mainly 4 stages through which it passes

  • Initialization: It is the first step when component prepares with the available props & states
  • Mounting: It is the stage of rendering JSX which is returned by render method
  • Updating: In this stage, component gets updated due to updates of props or state
  • Unmounting:  In Unmounting state, component gets destroys & known as the final step of the Lifecycle

 

3. What is the Component in React?

Ans: Component is the smallest part of UI which can be created using react. 

  • It is reusable & Independent part of code
  • It makes the UI building easier
  • Two type of Component can be created in React i.e. Functional Component & Class Component

4. What is JSX?

Ans: JSX is an extension of the JavaScript syntax. It stands for JavaScript XML. 

  • JSX is more closer to JavaScript than HTML.
  • It allows use to write HTML in JavaScript.
  • It helps to prevent injection attacks
  • Its as statically typed & object oriented programming language

5. What is Virtual DOM in React?

Ans: Virtual DOM is a JavaScript object & Its light weight in nature. It is a programming concept & implemented in JavaScript library on top of the browser APIs.

  • Virtual DOM keeps a light weight representation of Real DOM in Memory
  • It is a virtual representation of the UI which uses ReactDOM library to be synched with the Real DOM
  • Virtual DOM is more like a pattern than concept


6. What is React Fiber?

Ans: It is new engine for reconciliation in React. Its an ongoing re-implementation of Reacts core Algorithm

  • React Fiber is going to introduce some new concepts

7. What is Reconciliation in React?

Ans:  Reconciliation is a process in React. It uses mechanism like diffing to compare two object to determine which part should be update in DOM
  • React updates the DOM through reconciliation process. Due to Reconciliation process it works faster.
  • Virtual DOM & Diffing algorithm is two important concept behind reconciliation process.

8. What is State in React?

Ans:  State is a built-in object in React. It is stored locally in React component to share it with other child component it should be passed as a props to child components.
  • Scope of State always exist in side of the its component
  • State object is initialize inside the constructor & can be used inside the component using this.state
  • It can contain a lot of properties in it. there is no limit on it 

9. What is the difference between the ES5 and ES6 standards?

Ans: There are multiple differences between ES5 and ES6.