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,
- Increases the application's performance with Virtual DOM.
- JSX makes code easy to read and write.
- It renders both on client and server side (SSR).
- Easy to integrate with frameworks (Angular, Backbone) since it is only a view library.
- 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,
- React is just a view library, not a full framework.
- There is a learning curve for beginners who are new to web development.
- Integrating React into a traditional MVC framework requires some additional configuration.
- The code complexity increases with inline templating and JSX.
- 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.
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.jsfeed/โโ index.jsโโ Feed.jsโโ Feed.cssโโ FeedStory.jsโโ FeedStory.test.jsโโ FeedAPI.jsprofile/โโ index.jsโโ Profile.jsโโ ProfileHeader.jsโโ ProfileHeader.cssโโ ProfileAPI.jsGrouping by file type:
Another popular way to structure projects is to group similar files together.
api/โโ APIUtils.jsโโ APIUtils.test.jsโโ ProfileAPI.jsโโ UserAPI.jscomponents/โโ Avatar.jsโโ Avatar.cssโโ Feed.jsโโ Feed.cssโโ FeedStory.jsโโ FeedStory.test.jsโโ Profile.jsโโ ProfileHeader.jsโโ ProfileHeader.css