## Agenda Today we are going to start with React. Prerequisites that you should know: * HTML/CSS * Javascript Core (Understanding of how Javascript works). * DOM (Vanilla JS) * Modularity (We will know how to export and import different functions and properties from the code. While working with React we use lot of Modular code in terms of components. Everything is modular in React, that why we need to understand Modularity. ) Softwares you must install in System for react * VS Code * NodeJS (React is dependent on NodeJS) * Git (Not necessary) Before starting with React, we will first understand 1 topic and then we will move forward with React. That topic is Modularity. whatever code you write shoud be written in form of modules so that you can specifically use, Read and Maintain your Codebase. Modularity refers to the practice of breaking down a larger software program into smaller, self-contained, and reusable modules. These modules encapsulate specific functionality, variables, or objects, making it easier to manage, maintain, and scale your JavaScript code. **[Ask the learners]** Suppose you have written all the modules you are using in NodeJS in a single file, is this a Good practice? No, this is not a good practice because what modularity says is whatever feature you want to write, make separate module for it. Suppose you want to code a calculator and you want to make modules for each function it will do. Just make 4 functions addition, subtraction, multiplication and division. We can simply make 4 functions: ```javascript function add(a, b){ console.log(a+b); } function sub(a, b){ console.log(a+b); } function mul(a, b){ console.log(a+b); } function div(a, b){ console.log(a+b); } add(2, 3) sub(10, 5) mul(3, 4) div(10, 2) ``` Now we want to make this code modular, and that module, we should be able to use in different JS files. For that we have to import and export functions and properties of the code. For exporting the function to new file, first lets create 1 file called ModuleTest.js where we will import all these functions that we have just created. for exporting the functions: ```javascript module.exports={ addition: add, substraction : sub, multiplication : mul, division : div } ``` **[Ask the learners]** What would you do if you want to import these files? Using Require, yes we can use require to import a file in other JS file. So in this case: ```javascript const calculator = require("./calc") calculator.addition(2 , 3) calculator.multiplication(2 ,3) calculator.substraction(3 , 1) calculator.division (10 , 5) ``` So we are trying to import a module named "calc" and use the functions addition, multiplication, subtraction, and division from that module. Also we dont need to use console.log here because we are already logging the output in the the function definition. Benefits of this are: * Code Reusability: Modules are self-contained units of code that can be reused across your application or in other projects. This reduces the need to rewrite the same functionality, saving time and effort. * Ease of Maintenance: Smaller, well-defined modules are easier to understand and maintain. Developers can focus on individual modules without needing to comprehend the entire codebase, which simplifies debugging and updates. * Readability: Well-structured modules with clear interfaces and documentation enhance code readability. Other developers (including your future self) can easily understand how to use and interact with a module. Lets understand module.exports object: ModuleExports defines an object in which you can pass your functions in keys and you can use those keys whenever you are Importing your module and they will invoke the function associated with them Respetively. It is used to define what a module should export to be used in other parts of your code. It allows you to encapsulate code in a module and expose specific functions, variables, or objects for use in other files or modules. So this is all about Modularity. Now we will look into React. We will be learning it from scratch. React is the most popular and important library for Frontend Development. React is most in demand and companies want frontend developers who works on React. React is JS library for frontend Development developed By Meta(facebook) and this actually is very fast performing tool and it follows Component Based Architecture. Lets understand what is Component Based Architecture: If you talk about Vanilla JS, DOM is a tree structure  Doing Operations in a DOM is a heavy operations, So remove these Heavy Operations, React introduced Component Based Architecture. It says that anything you create can be hashioned into separate component, allowing you to work on each of them separately. **[Ask the learners]** What do I mean by a Component Based Architecture? If you take a look at LinkedIn's interface, you'll notice several components, and each of these components functions as an independent entity.If you examine the particular section, you'll see that all the sections are distinct components and also operating of one another. This is precisely what React does, it structures the architecture in a component-centric manner.  If you currently have an application. React's library will partition each of the sections into distinct components, allowing you to work on them separately and independently.This is essentially the core functionality of React. This makes the code maintainable and it also enables you to reuse individual components repeatedly. Consider LinkedIn as an example. You'll notice that various sections, such as the boxes, share a similar structure, even though they contain different data. So let's create HTML file, index.html to do one task that is append Hello from HTML in an HTML page. ```javascript=