Advantages of React
1. Easy to learn
React is comparatively easy to learn. Compared to other frontend frameworks such as Angular, React is one of those libraries which you can master within a matter of months. Even within weeks, you will be able to create a basic React application that is completely functional. Unless you want to get into the depth of the most advanced features, you will be able to create pretty big React applications even with the basic knowledge. Frameworks such as Next.js that are built on top of React makes the process even easier and productive.
2. Reusable components
Like most of the modern frontend frameworks, React let you use the components as many times as you would like without having to create a duplicate. You can organize your code in small reusable components which can be included in any template. To manage the dynamic parts, React lets you use states and props that you can pass to these components. The target component will be rendered based on the props you provide, making sure that you can implement the same component anywhere you would like with dynamic parts.
3. Automatic re-renders
React makes use of states. As soon as one of the states which is being used by a certain component changes, it will be re-rendered to update the DOM. The developer doesn’t have to do anything apart from the logic to change the state to make the changes visible in the DOM. There are even more advanced features such as memoization, hydration, and contexts, making React one of the most powerful frontend libraries even for the biggest and complex applications.
4. A huge community and libraries
Because React is pretty matured, there are millions of developers and thousands of libraries available, which will be extremely beneficial in the long run. No matter what type of function you want to implement on your website, there will be most probably a library made by the community for the same purpose. This saves a ton of time, which you would have spend on developing everything from scratch. The huge community around React will answer any of your questions regarding the library. It will be very hard to come across a problem that none of the React developers didn’t already.
5. React is pretty fast
Disadvantages of React
1. Big bundle size
Unless you optimize your code before deploying it to the production, React applications can be pretty big. Even if your project just has a couple of pages, React still has to inject its base code in order for the application to work. This won’t be a problem for smaller projects with smaller user base. But for big companies with millions of simultaneous users utilizing the application, speed could be a big factor, which is directly dependent on the amount of code. There are a lot of newer, modern frameworks that focus on smaller bundles and provides almost all the features as React.
2. Doesn’t use the native HTML
React depends on the JSX format, which is slightly different from the native HTML. So if you are to build your entire application in React, and sometimes in future you decide to migrate to the native HTML, things are going to take a little while to migrate. Even though there are compilers which will automatically do this for you, things might break during the transition. Frameworks such as Vue, and Svelte has a much closer structure to the web standards. Apart from that, the learning curve to understand JSX could also be a disadvantage.
3. Breaking changes
Unless you choose an additional Framework that is built on top of React which is SEO friendly, React in itself is not going to be very search engine friendly. Because everything is done after the page has been loaded, the search engine bots will not be able to understand the content of a React web page. Frameworks such as the Next.js tackles this issue by implementing server side rendering. So if you are planning to use React to create a website that focuses on search engine traffic, you should probably go with such a framework. If you are just building a web app where SEO doesn’t matter much, you are good.
5. It is a library, not a framework