React Js Interview Questions Flashcards

1
Q

What is Reactjs?

A

React is a JavaScript library that makes building user interfaces easy. It was developed by Facebook.

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

Does React use HTML?

A

No, It uses JSX, which is similar to HTML.

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

Give me two most significant drawbacks of React

A

Integrating React with the MVC framework like Rails requires complex configuration.
React require the users to have knowledge about the integration of user interface into MVC framework.

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

State the difference between Real DOM and Virtual DOM

A

Real DOM Virtual DOM
It is updated slowly. It updates faster.
It allows a direct update from HTML. It cannot be used to update HTML directly.
It wastes too much memory. Memory consumption is less

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

What is Flux Concept In React?

A

Facebook widely uses flux architecture concept for developing client-side web applications. It is not a framework or a library. It is simply a new kind of architecture that complements React and the concept of Unidirectional Data Flow.

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

Define the term Redux in React

A

Redux is a library used for front end development. It is a state container for JavaScript applications which should be used for the applications state management. You can test and run an application developed with Redux in different environments.

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

What is the ‘Store’ feature in Redux?

A

Redux has a feature called ‘Store’ which allows you to save the application’s entire State at one place. Therefore all it’s component’s State are stored in the Store so that you will get regular updates directly from the Store. The single state tree helps you to keep track of changes over time and debug or inspect the application.

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

What is an action in Redux?

A

It is a function which returns an action object. The action-type and the action data are always stored in the action object. Actions can send data between the Store and the software application. All information retrieved by the Store is produced by the actions.

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

Name the important features of React

A

Here, are important features of React.

Allows you to use 3rd party libraries
Time-Saving
Faster Development
Simplicity and Composable
Fully supported by Facebook.
Code Stability with One-directional data binding
React Components
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Explain the term stateless components

A

Stateless components are pure functions that render DOM-based solely on the properties provided to them.

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

Explain React Router

A

React Router is a routing library which allows you to add new screen flows to your application, and it also keeps URL in sync with what’s being shown on the page.

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

What are the popular animation package in React ecosystem?

A

Popular animation package in React ecosystem are

React Motion
React Transition Group

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

What is Jest?

A

Jest is a JavaScript unit testing framework created by Facebook based on Jasmine. It offers automated mock creation and a jsdom environment. It is also used as a testing component.

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

What is dispatcher?

A

A dispatcher is a central hub of app where you will receive actions and broadcast payload to registered callbacks.

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

What is meant by callback function? What is its purpose?

A

A callback function should be called when setState has finished, and the component is re-rendered.

As the setState is asynchronous, which is why it takes in a second callback function.

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

Explain the term high order component

A

A higher-order component also shortly known as HOC is an advanced technique for reusing component logic. It is not a part of the React API, but they are a pattern which emerges from React’s compositional nature.

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

Explain the Presentational segment

A

A presentational part is a segment which allows you to renders HTML. The segment’s capacity is presentational in markup.

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

What are Props in react js?

A

Props mean properties, which is a way of passing data from parent to child. We can say that props are just a communication channel between components. It is always moving from parent to child component.

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

What is the use of a super keyword in React?

A

The super keyword helps you to access and call functions on an object’s parent.

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

Explain yield catchphrase in JavaScript

A

The yield catchphrase is utilized to delay and resume a generator work, which is known as yield catchphrase.

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

Name two types of React component

A

Two types of react Components are:

Function component
Class component

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

Explain synthetic event in React js

A

Synthetic event is a kind of object which acts as a cross-browser wrapper around the browser’s native event. It also helps us to combine the behaviors of various browser into signal API.

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

What is React State?

A

It is an object which decides how a specific component renders and how it behaves. The state stores the information which can be changed over the lifetime of a React component.

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

How can you update state in react js?

A

A state can be updated on the component directly or indirectly.

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

Explain the use of the arrow function in React

A

The arrow function helps you to predict the behavior of bugs when passed as a callback. Therefore, it prevents bug caused by this all together.

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

What are the lifecycle steps of React?

A

Important lifecycle steps of React js are:

Mounting- ComponentDidMount- useEffect - Mounting means putting elements into the DOM
Updating - useState()- updating the state of the component that causes a rerender
UnMounting- removing elements from the DOM

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

State the main difference between Props and State

A

The main difference the two is that the State is mutable and Pros are immutable.

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

Explain pure components in React js

A

Pure components are the fastest components which can replace any component with only a render(). It helps you to 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
29
Q

What kind of information controls a segment in React?

A

There are mainly two sorts of information that control a segment: State and Props

State: State information that will change, we need to utilize State.
Props: Props are set by the parent and which are settled all through the lifetime of a part.

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

What is ‘create-react-app’?

A

‘create-react-app’ is a command-line tool which allows you to create one basic react application.

31
Q

Explain the use of ‘key’ in react list

A

Keys allow you to provide each list element with a stable identity. The keys should be unique.

32
Q

What are children prop?

A

Children props are used to pass component to other components as properties. You can access it by using

{props.children}

33
Q

Explain error boundaries?

A

Error boundaries help you to catch Javascript error anywhere in the child components. They are most used to log the error and show a fallback UI.

34
Q

What is the use of empty tags <> >?

A

Empty tags are used in React for declaring fragments.

35
Q

Explain strict mode

A

StrictMode allows you to run checks and warnings for react components. It runs only on development build. It helps you to highlight the issues without rendering any visible UI.

36
Q

What are reacted portals?

A

Portal allows you to render children into a DOM node. CreatePortalmethod is used for it.

37
Q

What is Context?

A

React context helps you to pass data using the tree of react components. It helps you to share data globally between various react components.

38
Q

What is the use of Webpack?

A

Webpack in basically is a module builder. It is mainly runs during the development process.

39
Q

What is Babel in React js?

A

Babel, is a JavaScript compiler that converts latest JavaScript like ES6, ES7 into plain old ES5 JavaScript that most browsers understand.

40
Q

How can a browser read JSX file?

A

If you want the browser to read JSX, then that JSX file should be replaced using a JSX transformer like Babel and then send back to the browser.

41
Q

What can be done when there is more than one line of expression?

A

At that time a multi-line JSX expression is the only option left for you.

42
Q

What is the reduction?

A

The reduction is an application method of handling State.

43
Q

Explain the term synthetic events

A

It is actually a cross-browser wrapper around the browser’s native event. These events have interface stopPropagation() and preventDefault().

44
Q

When should you use the top-class elements for the function element?

A

If your element does a stage or lifetime cycle, we should use top-class elements.

45
Q

How can you share an element in the parsing?

A

Using the State, we can share the data.

46
Q

Explain the term reconciliation

A

When a component’s state or props change then rest will compare the rendered element with previously rendered DOM and will update the actual DOM if it is needed. This process is known as reconciliation.

47
Q

How can you re-render a component without using setState() function?

A

You can use forceUpdate() function for re-rending any component.

48
Q

Can you update props in react?

A

You can’t update props in react js because props are read-only. Moreover, you can not modify props received from parent to child.

49
Q

Explain the term ‘Restructuring.’

A

Restructuring is extraction process of array objects. Once the process is completed, you can separate each object in a separate variable.

50
Q

Can you update the values of props?

A

It is not possible to update the value of props as it is immutable.

51
Q

Explain the meaning of Mounting and Demounting

A

The process of attaching the element to the DOM is called mounting.
The process of detaching the element from the DOM is called the demounting process.

52
Q

What is the use of ‘prop-types’ library?

A

‘Prop-types’ library allows you to perform runtime type checking for props and similar object in a recent application.

53
Q

Explain react hooks

A

React hooks allows you to use State, and other React features without writing a class.

54
Q

What are Fragments?

A

You can use fragment keyword to group a list of children components without using any extra nodes to the DOM.

55
Q

What is the main difference between createElement and cloneElment?

A

createElement is used by react to create react elements.

cloneElement is used to clone an element and pass it new props.

56
Q

What are Controlled Components?

A

Controlled components are component which controls the input elements.

57
Q

Why do you need to use props.children?

A

This props.children allow you to pass a component as data to other components.

58
Q

List down some of the methods in a react-dom package

A

Important methods for react-dom packages are:

render()
hydrate()
createPortal()
unmountComponentAtNode()
findDOMNode()
59
Q

How can we do server-side rendering in React?

A

We can use reaction serve to do the server-side rendering.

60
Q

State the difference between getIntialState() and constructor()?

A

If you want to create one component by extending ‘React. Component’, the constructor helps you to initialize the State. But, if you want to create by using ‘Reat.createClass.’ then you should use ‘genInitiaState.’

61
Q

What is refs?

A

Ref are an attribute of the DOM elements. The primary purpose of the refs is to find the DOM elements easily.

62
Q

What is ComponentWillMount()

A

is invoked immediately before a component is unmounted and destroyed. Perform any necessary cleanup in this method, such as invalidating timers, canceling network requests, or cleaning up any subscriptions that were created in componentDidMount().

63
Q

How to dispatch the data in-store?

A

We can dispatch the data to another component which should be based on the action which stores the parent component.

64
Q

How will be you able to handle more action using redux?

A

In order to create the same component in more action flow, we are using the same functionality in various modules.

65
Q

How can you spill the reducers?

A

We can spill the rescues based on the event actions. That action should be split in separate modules.

66
Q

Name any five predefined prototypes used in React

A

Most important protoype used in React js are:

number
string
array
object
element
67
Q

What is the purpose of using bindActionsCreators?

A

BindActionCreator helps you to bind the event based on the action dispatcher to the HTML element.

68
Q

What is REFS in React

A

Ref is a reference to the element. It should be avoided in most cases. However, sometimes it is used when you need to access DOM or instance of the component directly.

69
Q

Can JSX element be attached to other JSX components?

A

Yes, you can use attach JSX element with other JSX components which is very much similar to nesting HTML elements.

70
Q

What is the Current Stable Version of React?

A

The current stable version of React is version 17.5

71
Q

State the difference between React JS and React Native

A

React js is a front end open-source JavaScript library used for building UIs.

Rect Native, is an open-source, mobile framework which allows developers to user React on platforms like Android and iOS.

72
Q

Why does react need a root element?

A

We need it to render the app into the Dom tree. This is usually in a index.js file.

ReactDOM.render();

73
Q

Explain what is CORS? How does it work?

A

(CORS) Cross-Origin Resource Sharing is a mechanism that enables many resources (e.g., JavaScript, fonts etc.) on a web page to be requested from another domain outside the domain from which the resource originated. It is a mechanism supported in HTML5 that manages XMLHttpRequest access to a domain different.