React JS Interview Questions and Answers Set 4

31.How to use https instead of http in create-react-app?

You just need to use https=true configuration. You can edit your package.json scripts section:

“scripts”: {

“start”: “set https=true && react-scripts start”


Or just run set https=true && npm start

32. What are pure components?

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.

33.How can we find the version of react at runtime in the browser?

You can use react.version to get the version.

Const react_version = react.version


<div>{`react version: ${react_version}`}</div>,



34. What is the significance of keys in react?

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.

35.What is jest?

Jest is a javascript unit testing framework created by facebook based on jasmine and provides automated mock creation and a jsdom environment. It’s often used for testing components.

36. What were the major problems with mvc framework?

Following are some of the major problems with mvc framework:

  • Dom manipulation was very expensive
  • Applications were slow and inefficient
  • There was huge memory wastage
  • Because of circular dependencies, a complicated model was created around models and views

37.Why you can’t update props in react?

The react philosophy is that props should be immutable and top-down. This means that a parent can send any prop values to a child, but the child can’t modify received props.

38. Explain flux.

Flux is an architectural pattern which enforces the uni-directional data flow. It controls derived data and enables communication between multiple components using a central store which has authority for all data. Any update in data throughout the application must occur here only. Flux provides stability to the application and reduces run-time errors.

39.What do you understand with the term polling?

The server needs to be monitored to for updates with respect to time. The primary aim in most of the cases is to check whether novel comments are there or not. This process is basically considered as pooling. It checks for the updates approximately after every 5 seconds. It is possible to change this time period easily. Pooling help keeping an eye on the users and always make sure that no negative information is present on the servers. Actually, it can create issues related to several things and thus pooling is considered.

40.What is the recommended way for naming components?

It is recommended to name the component by reference instead of using display name.

Using display name for naming component:

Export default react.


Displayname: ‘todoapp’,

// …


The recommended approach:

Export default class todoapp extends react.component {

// …