General React Questions Flashcards

1
Q

Differentiate between Real DOM and Virtual DOM.

A

Real Dom

  1. It updates slow.
  2. Can directly update HTML.
  3. Creates a new DOM if element updates.
  4. DOM manipulation is very expensive.
  5. Too much of memory wastage.

Virtual Dom

  1. It updates faster.
  2. Can’t directly update HTML.
  3. Updates the JSX if element updates.
  4. DOM manipulation is very easy.
  5. No memory wastage.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is React?

A
  1. React is a front-end JavaScript library developed by Facebook in 2011.
  2. It follows the component based approach which helps in building reusable UI components.
  3. It is used for developing complex and interactive web and mobile UI.
  4. Even though it was open-sourced only in 2015, it has one of the largest communities supporting it.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are the features of React?

A
  1. It uses the virtual DOM instead of the real DOM.
  2. It uses server-side rendering.
  3. It follows uni-directional data flow or data binding.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

List some of the major advantages of React.

A
  1. It increases the application’s performance
  2. It can be conveniently used on the client as well as server side
  3. Because of JSX, code’s readability increases
  4. React is easy to integrate with other frameworks like Meteor, Angular, etc
  5. Using React, writing UI test cases become extremely easy
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What are the limitations of React?

A
  1. React is just a library, not a full-blown framework
  2. Its library is very large and takes time to understand
  3. It can be little difficult for the novice programmers to understand
  4. Coding gets complex as it uses inline templating and JSX
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is JSX?

A
  1. shorthand for JavaScript XML
  2. type of file used by React which utilizes the expressiveness of JavaScript along with HTML like template syntax
  3. makes applications robust and boosts its performance
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What do you understand by Virtual DOM? Explain its working.

A
  1. Virtual DOM is a lightweight JavaScript object which originally is just the copy of the real DOM
  2. It is a node tree that lists the elements, their attributes and content as Objects and their properties
  3. React’s render function creates a node tree out of the React components
  4. React updates this tree in response to the mutations in the data model which is caused by various actions done by the user or by the system.
  5. Whenever any underlying data changes, the entire UI is re-rendered in Virtual DOM representation.
  6. Then the difference between the previous DOM representation and the new one is calculated.
  7. Once the calculations are done, the real DOM will be updated with only the things that have actually changed.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Why can’t browsers read JSX?

A
  1. Browsers can only read JavaScript objects but JSX in not a regular JavaScript object.
  2. Thus to enable a browser to read JSX, first, we need to transform JSX file into a JavaScript object using JSX transformers like Babel and then pass it to the browser.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Components

A

Reusable pieces of the application UI that has inner dynamic functionality and state.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Classes

A

Interfaces of properties and methods that will be assigned to object instances.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Inheritance

A

The extension of existing properties and methods from a parent class to a subclass. The subclass extends the parent class to inherit the base parent class’s methods and properties.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

State

A

The internal data of a React component. The state can be updated through interactions with the component during the application.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

SetState

A

The official way to update state in a React component. It is a react rule to not modify the state directly. Instead, provide new values for keys in the state, using the setState() method. The setState() method recalls the render method when complete, giving the component the chance to reflect changes in the UI.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

.bind

A

A JavaScript method that passes the this object down from a component to a helper methods. Crucial for components to pass down the this.setState() method to helper methods.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Class Properties and Initializers

A

An alternative syntax for declaring the state and within components that automatically binds the this object.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Props

A

Data passed down to the React component from the parent.

17
Q

Bundling

A

The packaging of multiple JavaScript files and their dependencies into one giant file that the HTML can refer to.

18
Q

DOM

A

The Document Object Model for the web application. The document object, provided to the JavaScript, allows methods to update the UI.

19
Q

React’s Virtual DOM

A

An internal virtual representation of the DOM, that is much lighter weight, which allows React to efficiently compute updates using the document API.

20
Q

Lifecycle Methods

A

Method that fires in different phases in the React component. Most have to do with the component’s relationship with the document.

21
Q

componentDidMount

A

fires when the component appears in (mounts to) the DOM

22
Q

componentWillUnmount

A

fires when the component is about to leave (unmount from) the DOM.

23
Q

Fetch

A

Implemented as a JavaScript promise, this method can make HTTP requests to grab data.

24
Q

Stateless Functional Components

A

An alternative cleaner syntax to create React components based on returning JSX from a function.

25
Q

React Router

A

A technology which can turn a single-page app into one with multiple pages of content based on paths.

26
Q

Higher Order Components

A

Components that take other components as inputs, to return an entirely new component. They are like functions which have component inputs, and output a new customized component, based on that component input.