DEV Community

Cover image for What is React JS ?
Lukman Hossain
Lukman Hossain

Posted on • Edited on

What is React JS ?

ReactJS:

ReactJS is a JavaScript library. It’s used for developing complex and interactive web and mobile UI, especially for a Single Page Application(SPA). ReactJS helps to build reusable UI components because it follows the component based approach.

React Higher-Order components and example:

Higher-order component is an advanced way of reusing the component logic.
Examples:

  1. Render high jacking.
  2. Props manipulation.
  3. State abstraction and manipulation.
  4. Code reuse, logic, and bootstrap abstraction.

Difference between Virtual Dom and Real Dom:

Virtual Dom:

  1. Fast update but can’t directly update HTML.
  2. DOM manipulation is very easy.
  3. No memory wastage.
  4. Update JSX, If element update.

Real Dom:

  1. Slow update but directly update HTML.
  2. DOM manipulation is very expensive.
  3. Too much memory wastage.
  4. Create a new Dom if element update.

UseState in React:

UseState is a built-in hook that allows adding state to functional components in react package. We use it inside a function component. We use it to create a piece of state without switching to class components.

Reduce in React:

Reduce is a function that specifies how applications state changes in response to an action. It works by taking previous states and actions then returning new values.

Difference between JSX and JS:

JSX

  1. JSX is JavaScript XML. Which is a combination of HTML and JavaScript.
  2. Use to write react component.
  3. Making the code easier to read and understandable for the user.

JS

  1. JS is a scripting language of ECMAScript.
  2. Use to make the webpage more interactive.
  3. Basically, it adds life and creativity to a website, making it more engaging.

ReactJS Optimization:

By using the below roles we optimize a react application-

  1. Dependency optimization.
  2. Using immutable Data structures.
  3. Avoiding props in initial states.
  4. Memorize React components.
  5. CSS animation Instead of JS animation.

Happy Learning !!

Top comments (0)