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

Reactdom.render(

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

Document.getelementbyid(‘app’)

)

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.

REACT JS & CERTIFICATION
Weekend / Weekday Batch

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

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.Explain the role of Reducer.

Reducers are pure functions which specify how the application’s state changes in response to an ACTION. Reducers work by taking in the previous state and action, and then it returns a new state. It determines what sort of update needs to be done based on the type of the action, and then returns new values. It returns the previous state as it is, if no work needs to be done.