About React

What is React?

React is an open-source frontend JavaScript library which is used for building user interfaces especially for single page applications. It is used for handling view layer for web and mobile apps. React was created by Jordan Walke, a software engineer working for Facebook. React was first deployed on Facebook's News Feed in 2011 and on Instagram in 2012.


What are the major features of React?

  • It uses VirtualDOM instead of RealDOM considering that RealDOM manipulations are expensive.
  • Supports server-side rendering.
  • Follows Unidirectional data flow or data binding.
  • Uses reusable/composable UI components to develop the view.

What are the advantages of React?

Below are the list of main advantages of React,

  1. Increases the application's performance with Virtual DOM.
  2. JSX makes code easy to read and write.
  3. It renders both on client and server side (SSR).
  4. Easy to integrate with frameworks (Angular, Backbone) since it is only a view library.
  5. Easy to write unit and integration tests with tools such as Jest.

What are the limitations of React?

Apart from the advantages, there are few limitations of React too,

  1. React is just a view library, not a full framework.
  2. There is a learning curve for beginners who are new to web development.
  3. Integrating React into a traditional MVC framework requires some additional configuration.
  4. The code complexity increases with inline templating and JSX.
  5. Too many smaller components leading to over engineering or boilerplate.

What are the common folder structures for React?

There are two common practices for React project file structure.

  1. Grouping by features or routes:

    One common way to structure projects is locate CSS, JS, and tests together, grouped by feature or route.

    common/
    โ”œโ”€ Avatar.js
    โ”œโ”€ Avatar.css
    โ”œโ”€ APIUtils.js
    โ””โ”€ APIUtils.test.js
    feed/
    โ”œโ”€ index.js
    โ”œโ”€ Feed.js
    โ”œโ”€ Feed.css
    โ”œโ”€ FeedStory.js
    โ”œโ”€ FeedStory.test.js
    โ””โ”€ FeedAPI.js
    profile/
    โ”œโ”€ index.js
    โ”œโ”€ Profile.js
    โ”œโ”€ ProfileHeader.js
    โ”œโ”€ ProfileHeader.css
    โ””โ”€ ProfileAPI.js
  2. Grouping by file type:

    Another popular way to structure projects is to group similar files together.

    api/
    โ”œโ”€ APIUtils.js
    โ”œโ”€ APIUtils.test.js
    โ”œโ”€ ProfileAPI.js
    โ””โ”€ UserAPI.js
    components/
    โ”œโ”€ Avatar.js
    โ”œโ”€ Avatar.css
    โ”œโ”€ Feed.js
    โ”œโ”€ Feed.css
    โ”œโ”€ FeedStory.js
    โ”œโ”€ FeedStory.test.js
    โ”œโ”€ Profile.js
    โ”œโ”€ ProfileHeader.js
    โ””โ”€ ProfileHeader.css

Last updated on by krishnaUIDev