React Interview Q's Flashcards
What is React?
It is an open-source front-end JavaScript library most popular for single-page web applications. It is helpful when interactive and complex UIs are built for websites or mobile apps. React.js was released for use in 2015 and since then it has become one of the most trusted and used technologies of recent time. It has built one of the largest developer communities around itself.
List some of React js’s features.
Important features of React.js include:
Instead of a real DOM, there is Virtual DOM
It completely renders the HTML files on the server into client HTML pages, in other words, server-side rendering
In React.js, the data can be passed to the other parts of an application only in one direction. In other words, there is a unidirectional flow of data.
What are the main advantages of React.js?
The main advantages of React.js are:
It enhances the performance of the application
It can be used from the client-side as well as the server-side
The readability of code is higher in React.js because of JSX
It offers easy integration with frameworks such as Angular, Meteor, etc.
It is easy to write UI test cases with React.js
What is JSX?
JSX is the syntax extension for Javascript in React.js. With the help of JSX, it is easy to define how the user interface should look. Additionally, with JSX, the file containing the Javascript code can be used to write the HTML structures as well.
Describe an event in React.js? How does this differ from an event in JS?
When a user presses a key, clicks the mouse, or performs any action on the machine or when the machine itself triggers an action, these actions are registered as events in React.js.
In React.js, we use camelCase to name events, instead of the lowercase in HTML
In React.js, because of JSX, a function is passed as an event handler, instead of the string in HTML.
In HTML, we specify event in html tags like onclick, onsubmit etc. and pass the string that contain the parenthesis at the end.
In html, we can also add them afterword using external javascript using addEventListener.
In React, we specify event at the time of creating our component.
we use camel case convention in React i. e. onClick, onSubmit.
In React, we bind them using method name only like onClick={greet}.
addEventListener cannot be used in React component
How do lists work in React.js?
Lists in React.js are created similar to how they are created in regular Javascript. With lists, data can be displayed in an orderly manner and is useful in displaying menus on websites. For traversing lists, the map() function is used. For example,
An array of numbers is taken by the map() function and their value is multiplied by 5
var numbers = [2,4,6,8,10]
const multiplyNums = numbers.map((number => {
return (number*5);
});
console.log (multiplyNums);
Output: The output in Javascript will be logged in the console. The output in the above case is [10, 20, 30, 40, 50]
What are keys used in React.js lists?
Keys are used in React.js Lists because:
Key helps in identifying what objects have been altered, moved, or deleted from lists
With the help of keys, it is easier to determine which objects must be re-rendered instead of all components being re-rendered all the time.
React.js interview questions that ask about the use of a certain function or component in React.js programming are common.
Is HTML used in React?
No, it uses an HTML-in JavaScript syntax called JSX (JavaScript and XML) that converts HTML tags to React elements.
Can you tell two downsides of React?
It is difficult to integrate with an MVC framework like Rails. Also, users need to have the knowledge about integrating user interface into MVC framework.
Can you explain the differences between real DOM and virtual DOM?
Real DOM and Virtual DOM differ in following ways:
Real Dom:
-updates slowly
-HTML can directly update
-Memory waste
Virtual Dom:
-Updates faster
-Can’t be updated directly
-Less memory consumption
Explain flux concept in React.
It is a new kind of architecture used for client-side web applications. Supports the concept of Unidirectional Data Flow.
What is Redux in React?
An open-source JavaScript library for front-end development and acts as a container for JavaScript applications that is used for the applications state management.
Explain the ‘Store’ feature.
It is a feature of Redux that allows the application to save the entire State at one place. This allows you to get regular updates from the store directly.
What is a high order component in React?
It is an advanced-level technique in React for reusing component logic.
What is the presentational segment?
It is a component in React that just renders HTML and its only function is presentation markup.
Explain props in reactjs?
Props in React mean properties. They act as a communication channel from parent to child.
What does super keyword mean in React?
It is used to call super or parent class.
What is yield catch phrase in JS?
It is used to delay and resume a generator work.
List the two types of React component.
Two types of React component are as follows:
Function component
Class component
What is a synthetic event in react js?
It is an object that serves as a cross browser wrapper of the browser’s native event.
In Redux, what is an action?
In Redux, an action is an object that contains information about an event that has occurred in an application.
What are stateless components?
They are pure functions with no render method.
What is react router and why would you use it?
It is a library for routing in React. With React router, you can persist certain elements on the page while changing or re-rendering others that you include as sub routes. For example, the navbar can remain while the main content of the page changes. The navbar wouldn’t need to re-render which improves performance.
Explain Jest.
Jest is a JavaScript framework created by Facebook and is based on Jasmine. Its feature-rich API helps to get results quickly.
Value from context: {value}