Libraries vs Frameworks & The React Ecosystem | Lecture 135 | React.JS đŸ”„

The Coding Classroom
6 Dec 202309:53

Summary

TLDRThis video script delves into the fundamental distinction between frameworks and libraries, using a relatable analogy of making sushi at home. It highlights React as a powerful JavaScript library, offering developers the freedom to choose the right tools and libraries to build robust applications. The script explores the vast React ecosystem, comprising numerous third-party libraries for routing, state management, styling, and more. It also introduces opinionated React frameworks like Next.js and Remix, which provide a more streamlined development experience by bundling pre-selected libraries and configurations. The video promises to equip learners with a solid understanding of React and its essential libraries, laying the groundwork for exploring advanced frameworks in the future.

Takeaways

  • đŸ§© React is a JavaScript library, not a framework, which means it provides building blocks for user interfaces, but does not include features like routing, styling, or HTTP request management out of the box.
  • 🍣 Frameworks like Angular are like an all-in-one sushi kit, providing all the necessary ingredients, while React is like buying ingredients separately, offering more flexibility but requiring additional choices and setup.
  • 🔌 React relies on a vast ecosystem of third-party libraries to add functionality like routing, state management, styling, and more, giving developers freedom to choose the libraries that best suit their needs.
  • 🧰 Opinionated React frameworks like Next.js, Remix, and Gatsby build on top of React, providing pre-configured solutions for common requirements like routing, state management, and styling, improving developer experience and project setup speed.
  • đŸ—ïž React frameworks can be considered full-stack frameworks, as they offer features that allow building complete web applications while using React as the base layer.
  • 📚 Learning to use React effectively involves understanding and integrating its most important third-party libraries, which will be covered in detail throughout this course.
  • 🌐 React's immense popularity has led to a vast ecosystem of third-party libraries for various needs, such as routing, HTTP requests, state management, styling, form handling, animations, and UI component libraries.
  • ⚖ Frameworks offer a batteries-included approach, providing a complete structure with tools and conventions, while libraries like React offer more freedom but require more decision-making and integration.
  • 🔄 If a chosen third-party library changes or is no longer maintained, it may require finding a replacement in a React project, whereas frameworks provide a more stable, integrated solution.
  • 🚀 Mastering React and its ecosystem of libraries is a prerequisite for effectively using opinionated React frameworks like Next.js, which will be covered in the later part of this course.

Q & A

  • What is the main difference between a framework and a library in the context of React?

    -A framework like Angular is a complete structure that includes everything needed to build a large-scale application, while React is a library that primarily focuses on rendering components to the user interface (UI). React requires additional third-party libraries for features like routing, styling, and HTTP requests.

  • What are the advantages and disadvantages of using a framework versus a library?

    -The advantage of a framework is that it comes with many features out-of-the-box, but the disadvantage is that you're stuck with the framework's tools and conventions, even if you don't agree with them. On the other hand, a library like React offers more flexibility and freedom to choose the third-party libraries you want, but this also requires more research and decision-making.

  • Can you build a React application without using any external libraries?

    -Yes, it is possible to build React applications without using any external libraries, especially for small apps or while learning React. However, for larger, production-level applications, it is recommended to use third-party libraries for features like routing, state management, and styling.

  • What is the React ecosystem, and why is it important?

    -The React ecosystem refers to the vast collection of third-party libraries available for React developers to use in their projects. This ecosystem is important because it allows developers to choose the best libraries for their specific application needs, such as routing, state management, styling, and more.

  • What are opinionated React frameworks, and why were they developed?

    -Opinionated React frameworks like Next.js, Remix, and Gatsby were developed to address the overwhelming decision-making process involved in choosing and setting up multiple third-party libraries for a React application. These frameworks are built on top of React and include the developers' opinions on how to handle aspects like routing, state management, and styling.

  • What are some advantages of using an opinionated React framework?

    -Using an opinionated React framework can make project development easier and faster, as many important decisions have already been made for you. It can also lead to a better overall developer experience, as the framework offloads much of the setup work and provides additional features like server-side rendering or static site generation.

  • Can you explain the analogy used in the script to differentiate between a framework and a library?

    -The script uses the analogy of making sushi at home. Getting an all-in-one sushi kit is compared to using a framework, where everything is included but you're stuck with the provided ingredients (tools and conventions). Buying individual ingredients separately is compared to using a library like React, where you have the freedom to choose the best ingredients (third-party libraries) but also need to research and assemble them yourself.

  • What is the purpose of the section discussing React frameworks like Next.js in the script?

    -The section discussing React frameworks like Next.js is included to introduce the concept of opinionated frameworks built on top of React, which can provide a more structured and feature-rich development experience compared to using React with individual third-party libraries. It serves as a preview for a later part of the course where one of these frameworks will be used for a larger project.

  • What are some examples of third-party libraries mentioned in the script that are commonly used with React?

    -Some examples of third-party libraries mentioned in the script that are commonly used with React include React Router (for routing in single-page applications), React Query (for managing remote server state), Redux (for managing global application state), styled-components or Tailwind (for styling).

  • What is the main takeaway regarding the choice between using a framework or a library in a React project?

    -The main takeaway is that both approaches have their advantages and disadvantages. Frameworks like Angular provide a more structured and opinionated approach with many features out-of-the-box, while React as a library offers more flexibility and freedom to choose third-party libraries but requires more decision-making and setup. The choice depends on the specific project requirements and the developer's preferences.

Outlines

00:00

đŸ§© React: A Library, Not a Framework

This paragraph explains the key difference between React and frameworks like Angular or Vue. React is a JavaScript library that provides a view layer for building user interfaces, unlike frameworks that offer an all-inclusive structure with built-in features like routing, styling, and HTTP management. Using React requires integrating separate third-party libraries for additional functionality, offering flexibility but also requiring more decision-making from developers.

05:02

🌳 The React Ecosystem and React Frameworks

React's popularity has led to a vast ecosystem of third-party libraries for various needs like routing, state management, styling, and UI components. While overwhelming for some developers, this flexibility allows tailoring applications to specific requirements. To simplify development, opinionated React frameworks like Next.js, Remix, and Gatsby have emerged, offering pre-configured solutions and offloading setup work. These frameworks extend React's functionality, often positioning themselves as full-stack solutions. The course will cover learning React itself and its essential libraries before exploring frameworks like Next.js in depth.

Mindmap

Keywords

💡Library

A library is a reusable collection of code or functionality that can be included in a software application. In the context of the video, React is described as a library rather than a framework. Libraries provide specific functionality without dictating the overall structure of an application. The video explains that React is a 'view library', meaning it handles rendering components to the user interface.

💡Framework

A framework is a more comprehensive structure that provides a complete set of tools and conventions for building an application. Frameworks like Angular are described as 'batteries included', meaning they come bundled with features like routing, styling, and HTTP request management out of the box. The video contrasts frameworks with libraries like React, where developers need to include additional third-party libraries for these functionalities.

💡Ecosystem

An ecosystem refers to the surrounding collection of libraries, tools, and resources that support and extend a particular technology or platform. The video highlights React's 'huge third-party library ecosystem', which provides a vast array of libraries for various purposes like routing, state management, styling, and UI components. This ecosystem allows developers to choose the libraries that best suit their application's requirements.

💡Opinionated

In the context of the video, 'opinionated' refers to frameworks or tools that have pre-defined opinions or conventions about how certain aspects of an application should be structured or implemented. Opinionated React frameworks like Next.js and Remix make decisions about routing, state management, and styling, relieving developers from having to make these choices themselves. This is contrasted with the more flexible approach of using React with separate libraries.

💡Components

Components are the building blocks of React applications. They represent reusable pieces of user interface that can be combined to create more complex interfaces. The video mentions that React's primary purpose is to 'draw components onto a user interface' or 'view'. Components encapsulate markup, styles, and logic, promoting modular and reusable code.

💡Single Page Application (SPA)

A Single Page Application is a type of web application that loads a single HTML page and dynamically updates that page as the user interacts with the application. The video mentions the need for routing libraries when building 'large-scale single page applications' with React, as React itself does not provide routing functionality out of the box.

💡State Management

State management refers to the handling and updating of application data or state in a structured and predictable manner. The video mentions libraries like Redux as part of React's ecosystem for 'managing global application state'. Effective state management is crucial for building complex and scalable React applications.

💡Server-side Rendering (SSR)

Server-side rendering is a technique where the initial rendering of a web application is performed on the server, rather than solely in the client's browser. The video notes that React frameworks like Next.js offer server-side rendering as an advantage, which can improve performance and search engine optimization (SEO) for certain types of applications.

💡Static Site Generation (SSG)

Static site generation is a process where a website's pages are pre-rendered into static HTML files during the build process. The video mentions that React frameworks offer static site generation as a feature, which can provide improved performance and simplified deployment for certain types of websites, such as blogs or documentation sites.

💡Full Stack

The term 'full stack' refers to a comprehensive solution that covers both the front-end and back-end aspects of a web application. The video describes some React frameworks as 'full stack React frameworks' because they include features that allow developers to build complete applications, including server-side functionality, using React as the base.

Highlights

React is a library, not a framework, which means it provides developers with more freedom to choose the tools and libraries they want to use, but also requires more decision-making and setup.

The difference between a framework and a library is analogous to buying an all-in-one sushi kit (framework) versus buying individual ingredients (library).

Frameworks like Angular are 'batteries included' and come with built-in tools for routing, styling, HTTP requests, etc., while React requires developers to choose and integrate third-party libraries for these functionalities.

The freedom to choose libraries in React allows developers to pick the tools that best suit their application's requirements, but also requires more research and learning.

React has a huge ecosystem of third-party libraries for various needs like routing, state management, styling, forms, animations, and UI components.

Some of the most important libraries used with React include React Router, React Query, Redux, styled components, and Tailwind.

The need to choose and integrate many third-party libraries in React has led to the development of opinionated React frameworks like Next.js, Remix, and Gatsby.

React frameworks are built on top of React and extend its functionality by including opinions on how to handle routing, state management, styling, and more.

React frameworks offload setup work from developers by making decisions about which libraries to include, leading to a better developer experience and faster project development.

Many React frameworks offer additional advantages like server-side rendering and static site generation, and can be considered full-stack frameworks for building complete applications.

Mastering React and its most important third-party libraries is a prerequisite for learning and using React frameworks.

The course will cover building a large project using Next.js, a popular React framework, after mastering React and its ecosystem.

React's popularity has led to a vast ecosystem of third-party libraries for various needs like routing, HTTP requests, state management, styling, forms, animations, and UI components.

Choosing the right libraries and staying up-to-date with them is a responsibility for React developers.

React's flexibility and freedom come with the trade-off of decision fatigue and increased setup work for developers.

Transcripts

play00:01

‫All right.

play00:02

‫And now to finish off this section

play00:05

‫let's talk about something entirely different.

play00:08

‫So this lecture is not really

play00:11

‫about how React works behind the scenes,

play00:13

‫but more about what React actually is,

play00:17

‫which is a library.

play00:19

‫So for future React developers like you

play00:22

‫it's important to understand what it means

play00:25

‫that React itself is a library and not a framework.

play00:29

‫And so let's now learn about the differences,

play00:32

‫as well as the React ecosystem.

play00:36

‫And to understand the difference

play00:38

‫between a framework and a library,

play00:40

‫let's start with an analogy.

play00:43

‫So imagine that you want to make your own sushi

play00:46

‫for the first time,

play00:48

‫just like I did recently for the first time as well.

play00:52

‫So, you have two choices about how you want to do it.

play00:56

‫The first option is to just buy one

play00:59

‫of those all in one sushi kits,

play01:01

‫which will come with all the ingredients that you need

play01:04

‫and so then you don't have to buy anything separately.

play01:08

‫All you have to do is to assemble these ingredients

play01:12

‫into your sushi.

play01:14

‫However, there is also a downside to this

play01:17

‫because now you are stuck with the ingredients

play01:19

‫that are included in the kit that you bought.

play01:23

‫So if you find out

play01:24

‫that you don't like one of these ingredients,

play01:27

‫then you still have to use it anyway.

play01:29

‫Now, instead of getting an all in one kit,

play01:32

‫you also have to option to buying

play01:34

‫all the ingredients separately.

play01:37

‫And so this will give you complete freedom

play01:39

‫to choose only the best ingredients

play01:42

‫and the ones that you like the most.

play01:44

‫On the other hand,

play01:45

‫all this freedom can give you decision fatigue

play01:49

‫because now for each ingredient

play01:51

‫you need to research which brand is the best option

play01:55

‫and then you also have to go buy each

play01:57

‫of the products separately.

play01:59

‫And even worse,

play02:00

‫if one of your selected brands changes or is no longer sold

play02:04

‫then you need to start the whole process over.

play02:08

‫Now, okay,

play02:08

‫but probably at this point you're wondering,

play02:11

‫"Why is he going on and on about sushi?"

play02:15

‫Well, the reason is

play02:16

‫that this analogy actually translates beautifully

play02:20

‫into the difference between building a web application

play02:23

‫using a framework or using a library.

play02:27

‫So we could actually just replace the images here

play02:31

‫and call it a day.

play02:33

‫So, we could describe Angular, Vue, or Svelte, for example

play02:37

‫as the all-in one kit

play02:39

‫and React as buying separate ingredients.

play02:43

‫And the pros and cons of building a web up

play02:46

‫with each of these approaches

play02:48

‫are basically exactly the same

play02:50

‫as in making sushi at home.

play02:53

‫Okay, but actually, let's now replace these terms

play02:57

‫with their actual definitions

play02:59

‫and actually learn what's the difference

play03:02

‫between a framework and a library.

play03:06

‫So, in the world of JavaScript

play03:08

‫a framework is basically a complete structure

play03:11

‫that includes everything that you need

play03:14

‫in order to build a complete large scale application.

play03:18

‫We can say that frameworks

play03:20

‫like Angular are batteries included

play03:22

‫because they include stuff like routing, styling,

play03:26

‫HTTP requests for management,

play03:29

‫and more all out of the box.

play03:32

‫Now, the downside of this is that you're stuck

play03:35

‫with the framework's tools and conventions

play03:38

‫even if you don't like or agree with them.

play03:41

‫However, that's actually not always bad.

play03:44

‫And so this is not a real downside for some developers.

play03:48

‫Now, on the other hand,

play03:50

‫we have JavaScript libraries,

play03:52

‫which are basically pieces of code

play03:54

‫that developers share for other developers to use.

play03:58

‫And the prime example here is of course, React,

play04:01

‫which is what we call a view library,

play04:05

‫view because all React does is to draw components

play04:09

‫onto a user interface,

play04:11

‫so onto a so-called view.

play04:14

‫Now, if you want to build

play04:15

‫a large scale single page application,

play04:18

‫you will need to include many external third party libraries

play04:22

‫for things like routing, styling, HTTP requests, and so on.

play04:29

‫So all these functionalities are not part of React itself

play04:33

‫unlike what happens with Angular and other frameworks.

play04:38

‫And so this is how this notion

play04:40

‫that React is a library ties into the analogy

play04:44

‫of buying separate ingredients to make sushi.

play04:47

‫Because to build a React app,

play04:49

‫we have to choose all these separate libraries.

play04:53

‫Now, don't get me wrong here.

play04:55

‫We can actually build React apps with just React itself.

play04:59

‫So, without using any libraries,

play05:02

‫but that only makes sense for small apps

play05:05

‫or while we are still learning React.

play05:08

‫Now, being able to choose multiple libraries

play05:12

‫in order to build your application

play05:14

‫offers you incredible freedom

play05:16

‫because you can choose exactly

play05:18

‫the ones that you like the most.

play05:21

‫And also every app will have different requirements.

play05:24

‫And so each app will require a different combination

play05:28

‫of libraries.

play05:29

‫And so including all of them

play05:30

‫in a framework might not even be necessary.

play05:34

‫However, on the other hand,

play05:36

‫the implication of this is that as a React developer,

play05:40

‫you need to be able to find

play05:42

‫and download all the right libraries

play05:45

‫for your specific application.

play05:47

‫And of course, on top of that

play05:49

‫you then need to learn how to use these libraries

play05:53

‫and even stay up to date with them over time.

play05:57

‫But don't worry, it's actually not as bad as it may sound.

play06:01

‫So, if you follow this course until the end

play06:04

‫you will have a very good understanding

play06:06

‫of the most important libraries that we usually include

play06:10

‫into most React projects,

play06:12

‫which leads me actually to the next point,

play06:15

‫which is React's huge third party library ecosystem.

play06:21

‫So, React's huge popularity has led to a really,

play06:26

‫really large ecosystem of libraries that we can include

play06:30

‫in our React projects for different needs like routing

play06:34

‫for single page applications, making http requests,

play06:39

‫managing remote server state,

play06:41

‫managing global application state,

play06:43

‫styling, managing forms, animations and transitions,

play06:48

‫and even entire UI component libraries.

play06:52

‫Now, I will not go over all of them here one by one

play06:55

‫because that just takes too much time

play06:58

‫and you can also just research them if you need.

play07:01

‫So instead, I will show you which ones I consider

play07:05

‫the most important libraries

play07:07

‫and so these are the ones that we will use later

play07:10

‫in the course.

play07:11

‫So things like React Router, React Query,

play07:14

‫Redux, styled components, or Tailwind.

play07:19

‫Now, many React developers actually do feel overwhelmed

play07:23

‫by having to take so many decisions and choosing

play07:26

‫between so many third party libraries.

play07:29

‫And so this fact, among some other reasons,

play07:33

‫has led to the development

play07:35

‫of multiple opinionated React frameworks

play07:38

‫such as Nextjs, Remix or Gatsby.

play07:44

‫So, Nextjs or Remix are React frameworks

play07:48

‫because they are actually built on top of React.

play07:53

‫So they basically extend React's functionality

play07:57

‫and they are opinionated because other developers basically

play08:01

‫included their own opinions into how to handle stuff

play08:05

‫like routing, state management,

play08:07

‫or styling into these frameworks.

play08:11

‫So, where in a traditional React app,

play08:13

‫we have to make decisions about what libraries to include

play08:17

‫in an app built with a React framework.

play08:20

‫Some of these important decisions

play08:22

‫have already been taken away from you, the developer.

play08:26

‫And so this makes project development much easier

play08:30

‫and much faster,

play08:31

‫and it can also lead

play08:33

‫to a better overall developer experience.

play08:36

‫Now, different frameworks specialize in different aspects,

play08:40

‫but all of them offload much of the setup work from you.

play08:45

‫Also, all of them offer many other advantages

play08:49

‫besides just being opinionated,

play08:51

‫such as server side rendering

play08:54

‫or static site generation.

play08:56

‫In fact, we can even describe many of these frameworks

play09:00

‫as full stack React frameworks

play09:03

‫because they include so many features

play09:06

‫that we can actually build full stack apps with them,

play09:10

‫all while using React as the base layer.

play09:14

‫But anyway,

play09:15

‫this is just a brief overview of React frameworks.

play09:19

‫We will learn a lot more about this

play09:21

‫in the last part of the course

play09:23

‫where we will actually build a very large project

play09:26

‫using Nextjs.

play09:29

‫Now, this will not be included in the course at launch time,

play09:33

‫but I will include it at a later point.

play09:35

‫But at this point, I just wanted to let you know

play09:38

‫that these frameworks exist

play09:40

‫because of course we can only learn about them

play09:43

‫once we really master React itself

play09:46

‫and also its most important third party libraries.

Rate This
★
★
★
★
★

5.0 / 5 (0 votes)

Related Tags
ReactLibraryFrameworkJavaScriptWeb DevelopmentEcosystemThird-Party LibrariesOpinionated FrameworksNextjsRemix