React JS Interview Questions and Answers Set 1

1.what is react?

React is a front-end Java script library developed by face book in 2011.

It follows the component based approach which helps in building reusable UI components.

It is used for developing complex and interactive web and mobile UI.

Even though it was open-sourced only in 2015, it has one of the largest communities supporting it.

2.How is react different?

Since react is a little small concentrated on building UI components, it is essentially not the same as a considerable measure of other Javascript frameworks.

For instance, Angularjs (1.x) approaches building an application by expanding html markup and infusing different develops (e.g. directives, controllers, services) at runtime. Subsequently, Angularjs is extremely obstinate about the more architecture design of your application — these reflections are absolutely helpful now and again, yet much of the time, they come at the cost of adaptability.

3.Why reactjs is used?

React is used to handle the view part of mobile application and web application.

4.What are the features of react?

Major features of react are listed below:

It uses the virtual dom instead of the real dom.

It uses server-side rendering.

It follows Uni-directional data flow or data binding.

5.How reactjs framework is different as compared to others?

Basically, reactjs is a limited library that builds ui parts, it is essentially not quite the same as a considerable measure of other javascript structures. One common example is angularjs approaches building an app simply by expanding html markup and infusing different develop such as controller at runtime. Therefore, angularjs is exceptionally obstinate about the more noteworthy engineering of your application.

Weekend / Weekday Batch

6. How is react different from angular?

React vs angular

Topic React Angular
1. Architecture Only the view of mvc Complete mvc
2. Rendering Server-side rendering Client-side rendering
3. Dom Uses virtual dom Uses real dom
4. Data binding One-way data binding Two-way data binding
5. Debugging Compile time debugging Runtime debugging
6. Author Facebook Google

7. What is arrow function in react?
Arrow functions are extremely important for react operations. It prevents this bugs. Arrow functions make it easier to predict the behavior of this bugs when passed as callbacks. They don’t redefine the value of this within their function body. Hence, prevents bugs caused by the use of this within callbacks.

8. Differentiate between stateful and stateless components.

Stateful vs stateless

Stateful component Stateless component
1. Stores info about component’s state change in memory 1. Calculates the internal state of the components
2. Have authority to change state 2. Do not have the authority to change state
3. Contains the knowledge of past, current and possible future changes in state 3. Contains no knowledge of past, current and possible future state changes
4. Stateless components notify them about the requirement of the state change, then they send down the props to them. 4. They receive the props from the stateful components and treat them as callback functions.

9.What are the popular packages for animation?

React transition group and react motion are popular animation packages in react ecosystem.

10. What are the different phases of react component’s lifecycle?

There are three different phases of react component’s lifecycle:
Initial rendering phase: this is the phase when the component is about to start its life journey and make its way to the dom.

Updating phase: once the component gets added to the dom, it can potentially update and re-render only when a prop or state change occurs. That happens only in this phase.

Unmounting phase: this is the final phase of a component’s life cycle in which the component is destroyed and removed from the dom,