ReactJS Flashcards

1
Q

What are the features of React?

A

It uses the virtual DOM instead of the real DOM.
It uses server-side rendering.
It follows uni-directional data flow or data binding.

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

List some of the major advantages of React.

A

It increases the application’s performance
It can be conveniently used on the client as well as server side
Because of JSX, code’s readability increases
React is easy to integrate with other frameworks like Meteor, Angular, etc
Using React, writing UI test cases become extremely easy

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

What is JSX?

A

JSX is a shorthand for JavaScript XML. This is a type of file used by React which utilizes the expressiveness of JavaScript along with HTML like template syntax. This makes the HTML file really easy to understand. This file makes applications robust and boosts its performance.

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

What is the Virtual DOM?

A

A virtual DOM is a lightweight JavaScript object which originally is just the copy of the real DOM. It is a node tree that lists the elements, their attributes and content as Objects and their properties. React’s render function creates a node tree out of the React components. It then 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.

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

What do you understand from “In React, everything is a component.”

A

Components are the building blocks of a React application’s UI. These components split up the entire UI into small independent and reusable pieces. Then it renders each of these components independent of each other without affecting the rest of the UI.

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

What is Props?

A

Props is the shorthand for Properties in React. They are read-only components which must be kept pure i.e. immutable. They are always passed down from the parent to the child components throughout the application. A child component can never send a prop back to the parent component. This help in maintaining the unidirectional data flow and are generally used to render the dynamically generated data.

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

What is a state in React and how is it used?

A

States are the heart of React components. States are the source of data and must be kept as simple as possible. Basically, states are the objects which determine components rendering and behavior. They are mutable unlike the props and create dynamic and interactive components. They are accessed via this.state().

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

How can you update the state of a component?

A

tate of a component can be updated using this.setState().

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

What is arrow function in React? How is it used?

A

Arrow functions are more of brief syntax for writing the function expression. They are also called ‘fat arrow‘ (=>) the functions. These functions allow to bind the context of the components properly since in ES6 auto binding is not available by default. Arrow functions are mostly useful while working with the higher order functions.

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

What are the different phases of React component’s lifecycle?

A

nitial 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.

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

What is an event in React?

A

In React, events are the triggered reactions to specific actions like mouse hover, mouse click, key press, etc. Handling these events are similar to handling events in DOM elements.

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

What are Higher Order Components(HOC)?

A

Higher Order Component is an advanced way of reusing the component logic. Basically, it’s a pattern that is derived from React’s compositional nature. HOC are custom components which wrap another component within it. They can accept any dynamically provided child component but they won’t modify or copy any behavior from their input components. You can say that HOC are ‘pure’ components.

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

What are Pure Components?

A

Pure components are the simplest and fastest components which can be written. They can replace any component which only has a render(). These components enhance the simplicity of the code and performance of the application.

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

What is the significance of keys in React?

A

Keys are used for identifying unique Virtual DOM Elements with their corresponding data driving the UI. They help React to optimize the rendering by recycling all the existing elements in the DOM. These keys must be a unique number or string, using which React just reorders the elements instead of re-rendering them. This leads to increase in application’s performance.

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

What are the React Lifecycle methods?

A

Render, componentDidMount, componentDidUpdate, componentWillUnmount, shouldComponentUpdate, getDerivedStateFromProps, getSnapshotBeforeUpdate

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