Ques 1. What is React?
React is upheld by Facebook and a community of developers and establishments. React is used as a base in the development of single-page, web, or mobile applications. Though, React handles state management and renders that state to the DOM, therefore creating React applications involves the usage of additional libraries for routing and client-side functionality.
Ques 2. What are the features of ReactJS?
The important features of ReactJS are as follows:
- Components: Components are the building blocks of any React application. A component is basically a portion of the user interface. React divides UI into independent, reusable parts that can be separately processed.
- One-way Data Binding: ReactJS follows one-way data binding, unlike other frameworks. The key benefit of One-Way data binding is that the data flows in a single direction throughout the application which gives better control. Because of this, application’s state is contained in specific stores and as a result, rest of the components remains loosely coupled. This makes the application flexible therby resulting in increased efficiency.
- Virtual DOM: Virtual DOM is a node tree that lists the elements and its’ attributes, content as objects and their properties. React’s render function develops a node tree out of the React components. It then updates this tree in response to the mutations in data model caused by actions done either by the user or system.
- Performance: React uses Virtual DOM, which makes the running of web applications much faster as compared to those that have been developed with alternate front-end frameworks. React breaks down complex user interface into individual components, thereby allowing several users to work on each component simultaneously, ultimately resulting in speeding up of the development time.
- Extensions: React has numerous extensions that offers broad application architecture support. It delivers server-side rendering, which encompasses rendering a normal client-side web application on the server, and then sends a fully rendered page to the client. It employs Flux and Redux widely in web application development. Finally, there is React Native, a popular framework derived from React, used to create robust mobile applications.
Ques 3. Name some of the advantages of React
Ans 3. This question is one of the most asked question in React.js interview.
You should share React’s major advantages as mentioned under:
High Efficiency: React is flexible and efficient because of it’s virtual DOM. It automatically estimates the changes to be made in DOM therefore avoids expensive DOM options and make regular updates whenever required.
Diversification of Developer Tools: We need to install ReactJS official browser extension to get the most out it. It comes fairly handy, for debugging the app. It gives a direct peek at the virtual DOM.
Ques 4. Why React?
The previous frameworks were using a traditional data flow. Here, the data was received from various sources which was passed to the dispatcher. The dispatcher then forwarded data to the store, from where it ultimately came to the view. The view was then the part where you or a user could interact with the application. So, whatever you could see on the browser as a web page was the view itself.
But, what do you think happens at the back-end of the frameworks using this traditional data flow?
Each time we add new data or otherwise any data is updated at the back end, the browser reloads the web page and the whole process is repeated again.
This old-style data flow has one disadvantage, it uses the DOM (Document Object Model). DOM is an object that is created by the browser each time a web page is loaded which can vigorously add or remove the data at the back end. But every time any modifications are conducted a new DOM is generated. This recurrence of DOM results in redundant memory wastage and results in weakened performance of the application.
Besides these factors the manipulation of DOM was expensive. This is where ReactJS comes to our rescue. With ReactJS, you can divide your entire application into various self-governing components.
But now whenever any new data is added or updated from the back end every time, ReactJS uses a new approach to deal with it. It just destroys the old view instead of reloading the entire page. Afterwards, it reduces the view components with updates or new data and then places the new view in old one’s place. To resolve the memory wastage due to DOM, React introduced Virtual DOM. You might be curious about what is this virtual DOM and how it solves our problem? Don’t worry, refer to the next question to differentiate between DOM and Virtual DOM
Ques 5. Differentiate between Real DOM or HTML DOM and Virtual DOM
Ans 5. Below is the difference of between DOM and Virtual DOM:
|Real DOM or HTML DOM||Virtual DOM|
|It updates slowly||It updates faster.|
|It allows a direct update from HTML.||It cannot be used to update HTML directly.|
|Memory consumption is high||Memory consumption is less|
|DOM manipulation is expensive||DOM manipulation is easy|
Ques 6. What are ReactJS Prerequisites?
Ans 6. Below are some of the concepts that you should be familiar with before learning ReactJS:
- Programming concepts like functions, objects, arrays, and to a lesser extent, classes
Ques 7. What is JSX?