Interview Questions & Answers

react-js

  • Architectural pattern that enforces uni-directional data flow.
  • Controls derived data and enables communication between multiple components.
  • Contains a central Store which has authority for all data.
  • Contains a central Store which has authority for all data
  • Any update in data must occur here only
  • Provides stability to the application.
  • Reduces run-time errors.

  • DOM manipulation was very expensive.
  • Slow and inefficient.
  • Memory wastage.
  • Because of circular dependencies, complicated model was created around models and views.

  • Used to identify unique Virtual DOM Elements with their corresponding data driving data driving the UI.
  • Helps React to optimize rendering by recycling existing DOM elements.
  • Keys must be a unique number or string.
  • Instead of re-rendering, with keys React just re-orders the elements.
  • Application’s performance increases.

  • Pure components are the simplest, fastest components which we can write.
  • Cn replace any component that only has render().
  • Enhances the simplicity and performance of the application.
ReactDOM.render(<h1>Hello<h1>, document.getElementById(‘content’));

  • Code reuse, logic and bootstrap abstraction.
  • Render High jacking.
  • State abstraction and manipulation.
  • Props manipulation.

  • Custom components which wraps another component.
  • They accept dynamically provided child components.
  • Don not modify the input component.
  • Do not copy any behavior from the input component.
  • Are “Pure” functions.

Controlled Components

  • Do not maintain their own state.
  • Data is controlled by parent component.
  • Takes in current values through props and notifies changes via callbacks.

Uncontrolled Components

  • Maintain their own state.
  • Data is controlled by DOM.
  • Refs are used to get their current value.

  • HTML from elements maintain their own state in regular DOMs and update themselves based on user inputs.
  • In React, state is contained in the state property of the component and is only updated via setState().
  • JavaScript function is used for handling the from submission.