← Previous lessonFree lesson 2 of 3 · lesson 2 of 45Next lesson →

Unlock all 45 lessons of React.jsFull course ₹40,000 · paid

Price & syllabus
Free lesson · 54 min · no payment

Your First React App, Virtual DOM and Component Basics

A free lesson from Skill-Lync's React.js course, on Grow by Skill-Lync · Last updated 16 Nov 2026 · Session: “Week 1 Session 2”

What will you learn in this free React.js lesson?

The instructor explains what React is and how it compares with Angular and Vue, then creates a Hello World app with create-react-app and tours its folders. A swipe-card demo contrasts plain DOM re-rendering with React's virtual DOM diffing, and the lesson closes with functional and class components.

  • What React is and is not
  • Running create-react-app and npm start
  • Browser DOM versus React virtual DOM diffing
  • Functional versus class-based components

What comes after lesson 2?

The next free lesson is lesson 3, “JSX Explained: Expressions, Fragments and Conditional Rendering” (35 min). Later in Skill-Lync's React.js course (paid): lesson 4, Week 2 Session 2; lesson 5, Week 3 Session 1; lesson 6, Week 3 Session 2. The full course has 45 lessons (20 h 46 min of video); see the course overview or its price and syllabus.

Lesson transcript

Machine transcript of the lesson audio (lightly cleaned). Technical terms may contain errors; the video is the reference.

Now, introduction to React.js. Okay. So, what is React? So, as I told, React is a component-based library which is specifically used for a front-end development and it's very lean and focused. Like, it's very, very focusing on how you can develop a component. It doesn't focus much on how you load a data, how you route and how you link your one page to another page and etc. etc. It basically talks about how you can write and manage your component on a browser. That's it. That is it all about. It's not a complete framework. Yeah. It's not a complete framework.

Like I said, it doesn't focus much on how to route, how to link one page to another, how to load a lead data. No. It basically talks about a component development. So, in order to do those other things, you have a third-party packages, npm packages, which you can install and you use with that, those packages with React. That is still fine. But React on its own, it's not a framework. It doesn't care about other things. It just cares about component-based development. That's it. It used to build large page application or large applications with a data that changes over a time. So, React is very good at handling a data which is changing over a time.

And it's often a case with the web applications, right? You get something on the screen and that data changes over a time. Take an example of a website where you can see a score of an IPL match or any football league match. Like, for every second or a minute, you see that scoreboard updated, right? So, there is a data which is changing across a time. Okay? It's changing in a timeline. So, React is the best way for handling a data which is changing over a time.

It has full-fledged ecosystem. It's not bundled within a library. But what my point is, there is an ecosystem available for a React and there is a community support available for React to provide that ecosystem. If you want to load a data in a React, there is something online which is available. You can integrate with your library. If you want to link one page to another page, which you have written in a React, then there is a support in a community available for that. Someone have written a package so that you can do that link.

So, all those things are available. And React is good at integrating to all those ecosystemic libraries. So, that is what React is and React fulfills all those kind of tools. So, now, let's compare React.js with other frameworks and libraries. So, there are other frameworks and libraries available in the market called as Angular is there, Vue.js is there. But React is backed by Facebook. It's created and evolved from a Facebook development team. And they started using it in production Facebook. And they've seen a lot of improvements after they've used it, which is why they presented in the conference and JavaScript conference.

And it became so popular after that. But they haven't stopped there. They're continuously involved in evolution of the React as a library, which then got popular in the open source community. So, it's created and maintained by Facebook. It's a huge advantage. There is a huge demand for such skill set. Like, since it is popular, a lot of companies are using it. Great community support. It focuses on component development code and not all other crafts. So, it's simple. It has effective DOM objects mechanism. Now, what is DOM?

DOM is document object model. It basically, it is how your browser sees your web page. So, if you write a tag, something like HTML tag, any HTML tag, browser saves that tag in some format. That format called as document object model. So, browsers just understand that document object model. And updation to that document object model is very costly. Because browser has to interact with low-level system APIs. So, that is very costly operation. So, in let's say second, in one second, if someone want to patch hundreds and thousands of DOM updates, that will be very inefficient.

But React solves it in its own way. We will talk about that. But it has effective DOM update mechanism. And it can integrate with any other application. You can have a React live side-by-side to any other framework or any legacy web application. So, it can integrate with any of existing applications. That easy. So, let's jump on to the sample Hello World application. So, let's jump on to the sample Hello World application. But before that, I want you to show, like, how I am locating my demos and all the things.

So, now, in order to start with the Hello World application, we need to do a few things. Okay. First, we need to type a command, npx. And we need to write a create React app. What is a create React app? Okay. So, now, let's open React documentation first. So, this is React.js official documentation. Okay. And I want you to also, as a part of your homework, I want you to explore this documentation very well. Because this will be a single point of truth which will be staying with you as a developer.

And you can take glimpses of these documents time to time. So, it has docs, tutorial, blog, and community. What we are interested in is the documentation. So, we are going to docs. And there is an installation section. In installation, there is a getting started for a portion. There are different ways with which you can write a React. You can add React to the current website. Or you can create a new React app from a scratch. And for that, they are indicating do using create React app.

Okay. So, what is a create React app? Create React app is a utility. It's a utility. It's a npm package. React React app. Just search for it. So, recommended toolchain. So, what React is recommending is if you are learning a React or creating a new single page app, use create React app. So, this is what we are going to use in our development course. So, if you open this, you will get something like this. So, create React app is a comfortable environment for learning React. And it is the best way to start building a new single page application in React.

Okay. So, for so good, we already installed node and npm. So, just check it out. You have installed. And then, we need to run these commands. So, let's do that. It will take some time. It's downloading and installing all the packages for this create React app dependencies. If you go to the create React app, it's again an open source project, which helps you to create a React app from a scratch, which internally use a different bundles, which you don't need to understand. So, at this point, lots of things and it's done.

Happy hacking. That's nice. So, this is my app, which got created. Okay. So, now, what they are saying is CD my app. Okay. I'm doing that. Okay. And opening in VS Code. Right away. So, you guys are also installing VS Code. Like, from where to install? I can go to the Google. Type VS Code. You'll get a first link. Go to that. Since I'm using Mac, it's showing me this installer. You can visit the site and install a correct installer as per your OS. Okay. It's straightforward to install.

And you should be able to. Install it very easily. Okay. Coming back to this, we just need to CD inside my app and then use npm start. Once you do npm start, there is some processing which will happen in the background and it will open a web browser automatically. What they are doing is they are internally bundling few things together. And if you see, you can now view my app in a browser. On local, you can hit this URL, which they are automatically hitting and opening a web browser. Note that the development wheel is not optimized. To create a production build, use npm run build, which you don't need to bother at this point. And webpack completed successfully. What is webpack? When I'm saying like they are building few things, for bundling few things internally, they are using a bundler called as a webpack, which is not in scope of this course, but just for your information. And this is what we are seeing. So this is a template that create react app generates by default. Good, right? Now if you just go to the folder, there is node modules. Now all these modules, which are dependencies to create react app, which is a utility.

So this is the utility. So this is the utility we installed right, right? For a create react app for creating new app. So this utility depends on a lot of things. And all those things got installed automatically in node modules. So when you run npx create react app, it installed create react app utility on your local machine, which then installed all kind of dependencies, which are listed in a node module. Okay. And this is the name of your application. You can give any name, any name to your application. Okay. And then you are ready to go.

So now expanding SRC going in app dot CSS. There is some sort of CSS they have written, which is why you can see this fancy spinner of react logo. Then there is something called as app dot JS. Now this is important file. This is where you can see, uh, learn react link. This is coming from here. There is something called as a component dev written over here. There is a return or something, something, then they are exporting something. They are importing logo. So there is a test file. There is index dot CSS. There is index dot JS. And there is something called as a react script, script mode.

We will see what that is in upcoming series lectures. And then there is an app. And then logo. Okay. Then there is something called as a package dot JSON. There is something called as a package log dot JSON. We'll check what those are. Then there is a git ignore. Uh, and then read me will find. So all these, uh, things got installed automatically. And what they're saying over here is edit. SRC app dot JS and save to reload. So just check it out. Go to app dot JS and instead of learn the react, let me change to hello.

So w o r l d. It reload, right? It reloaded and I got word hello world. Okay. It was learn react and got changed to hello world. Simple, right? That was our demo where we just need to update the app dot JS and the immediately we can see the reflections. Simple. So yeah, that's it from a demo of a hello world site. Uh, so regarding the courses demo. So we are going to track all these demos, the demos that we are doing in the class in, uh, a specific repository.

So you just need to go to this specific repository on the GitHub. And once you go there, you should able to see a different branches. So there will be a branch for demo. So for example, if you want to check out the high world demo, which are created in class, you just go to the, that specific branch and check out. In SRC, you should see app dot JS with hello world. Okay. So that's it. For that, if you want to check this repository on your local machine, I believe you already installed the GitHub, uh, like I have indicated in solution step.

And if you want to clone this repository, then go to the code, copy this URL. And run the command, get clone and this copied URL. And that's it. Once you've loaned the repository, you just need to do get checkout and then name of the demo that you wanted to see. It could be get checkout demo slash one underscore hello underscore word or demo slash two underscore VDOM. So you can navigate through demos like this and you can run class demos on your own like this. So all the demos respectively, all the demos that we are going to create, uh, in the classes, I'll push it over here.

Uh, it stands out by using its virtual DOM capabilities. So let's check out what are that. So to understand what is a virtual DOM and, uh, how react operates it, we need to understand the traditional V of ready-to-end. Okay. So let's say we need to understand like how browser re-rend or renders or re-renders, uh, a data to a web page when there is a constantly changing a data. Okay. So now assume that this is my data and this is the template. Now template is what template is a V or this is a markup, which are expecting to re-render once it get merged with a data.

Okay. So data always get merged with the template and then it formulates the final HTML to render. But browser doesn't understand this HTML. So what it does it, it creates a memory structure out of this HTML and store with himself. Okay. So browser stores a structured HTML, which is called as document object model. So its own way of representing a visuals. So it's basically a tree-like structure like seen in this PPT where there's a div, h2 child of div is h2, p and another p tag.

And this p tag has one more child as a NYC. This p tag will be manager and h2 will have one more child, which called as a mohan. I have not shown that specifically because I just wanted to focus on this p tag. So far, so good. So browser is creating this in memory. Now the problem with this is, this is a in-memory browser's in-memory storage. So if someone wants to alter this, that operation is very costly. Why? Because then browser needs to re-render or render the element on the screen.

For that, it needs to go through multiple low-level APIs, which is why it's expensive. Now let's understand if something at this particular level gets changed, what will happen? If something at this level, let's say location got changed, then you need to combine that again with the template and need to formulate a new HTML. Now browser doesn't understand what got changed. So it basically essentially re-renders everything. Browser is not smart enough to figure it out. Okay, just location is changed. But designation of or role of the mohan and the name of the mohan is still the same.

So just update the location. Browser is not that smart. But it does it, it re-renders entire tree and show to the screen. Let's try to understand the same using a demo. So this is a demo. This is a fiddle demo. What I'm doing over here is I have a list of employees. These are the employees which are coming to the swipe gate of one of the company in order manner. Okay, so first Ajit will come, then Mohan will come, then Priya, then Maria, then Mohan again will come.

Okay, so this is what their order is. So this is a div which I've given a name as a gate. Okay, let me refresh name as a gate. And then there is a button. On click of this button, I'm triggering the function called as a swipe. This is the swipe function where I'm creating my own template. Now this swipe takes one argument and that is employee. So I'm picking a employee one by one from this list and passing to this particular function. Then once the employee data reached to this function, I'm combining it with the template and then injecting inside this div.

That's all. That is the program. Now let's try too. Now let's try too. Inspect the HTML of this div. This is my div. Let me swipe for a four step. So my Ajit, employee Ajit, it came to screening gate. This is Ajit, who is a web developer, has a location 301. Now Mohan also stays at same location. The name of this employee got changed, role got changed, because earlier it was a web developer. From web developer, it became a manager. But location, it's still the same. Okay. Now observe this. You will see some flashes over here. What that flash means is, browser is recalculating that particular node. And specifically observe this last node. Ideally, it should not get recalculated, because location is same. Location of Ajit and Mohan is same. But if I click on swipe, you will see flash over this B tag also.

So if I swipe. So if I swipe, you can see that flash, which means browser got recalculated. And that is the problem with a traditional way of rendering, where a browser don't understand what got changed and how to update a DOM optimistically. Which is why React came up with a concept of virtual draw. Now this is the, some writing for the traditional way of rendering, which I already explained. And let's come to the React way of rendering. Now what React does is, React sees as, okay, this is a data, fine. And this is a template. Now React way of writing a template called as a JSX, which we'll cover in this course a bit later.

But for now just consider it called as a JSX. And then, React creates its own structure in his own memory. Okay. So React creates its own data structure, which will eventually render on the browser. But it doesn't directly go to the browser. It has some intermediary step, where it stores a data structure in tree format. So similar to the browser DOM, now there is one more level, which is handled by the React itself on its own memory. Okay. So now, div, which is a top level element, and all the child elements, along with the data inside it.

So React have created this snap for its internal handling purpose. Now let's assume something got changed in between. Let's say location got updated. Yeah. But one point to remember is, even though React has the snapshot in its memory, browser still has its own DOM. Okay. So both currently are pointing with a same data structure. Let's say same data structure. There are some internal differences. But for now, let's consider they are exactly the same. Now what happens is, let's say this location got changed. From NYC, it became, let's say, loss engineer, LA.

So location got changed. Once location got changed, React recreated the structure, which it's holding its memory. It's recreated. So div, h2, p, p, and this LA. But now there is an important step over here. It sees there is an earlier snapshot presented. There is an earlier snapshot. So it compares the earlier snapshot with the latest snapshot. There is no DOM in picture yet. What we are looking at is the structure, which React created for its own internal purpose. So it diffs between the snapshot of a template with different time slot.

Now, for a slot 1, where location is NYC, for a time slot 2, where location got updated to LA. Now, once React diff between these two snapshot, React comes to know, oh, there is only one change, which is at this point. And what is that change? The location got updated from New York to Los Angeles. So React then smartly identifies the diff between two states and it only instructs DOM to update just that node and not entire tree. So you see, what React did over here?

React smartly acted over here as an intermediary. It diffed both the versions, both the states, where location was near and when it got updated to LA. It diffed it properly and figured out what is the minimal change which needs to patch to actual DOM. So earlier, browser used to calculate, recalculate all the nodes, but now with React, browser needs to calculate only the text node of a last p tag alone. Now, there is a benefit of the performance because it's just updating a single node versus updating an entire DOM tree structure.

And that is why React is different and that is what React virtual DOM does in a state of performance. So this is React virtual DOM. So let's look at the demo for a virtual DOM and try to understand. So in order to switch to, let me change location to my demo. Now, if I want to switch to next demo, demo, right? So over here, I'm indicating which branch you need to go for. It's saying demo slash to underscore VDOM. So get checkout demo slash to underscore VDOM and you got switched to that branch and then I'm opening my Visual Studio Code.

Yeah, so I'm on that branch and I have same, I have same, same case. Okay, so I'm writing a same application which was there in a Fiddle in a React way. Now, since we haven't jumped on the React, you will not understand what I've written, but that is fine. I just wanted to show you how it looks in the React. Go to the React app, try to refresh and see whether it is refreshing. No, run this source command. I need to cd to my app and then I need to run lpm start, right?

Yeah, so I'm running the swipe card demo now just on React side. Now, let's check out what is happening. So let's see what is our data, okay? So this is employee list, okay? So let's MAC 301 and let's MAC the same data, okay? So my first employee is Ajit, right? So let's keep it Ajit 301 and the second employee is Mohan. So MAC, let's MAC the, that employee is Mohan. So what we are expecting now is the location should not change. This element should stay as is because it's not changing, right?

React should identify the diff between first state and second state and only apply a minimal changes to dog, right? Let's see whether we can see that, okay? So this is my dog. Focus on this and specifically on the last node that should not get flashed. And see, only these two things got flashed. Why? Because of React. Because of React's ability to create a virtual DOM and then update the actual DOM very smartly. Because of virtual DOM, React updates only minimal changes which needs to update a screen as per the logic, okay?

So as per your logic, what are the minimum changes that React calculates and only apply those changes? It will not re-render the entire tree. That is not, that is, that is very expensive. So React just offers you a minimal steps to update the DOM. So that is the point of virtual DOM and that is how it works. Let's go to the folder structure. Let's go to the folder structure. So now if you check out our Hello World program, let's switch back to Hello World, check out demo, okay, let me try it again, this is for my application folder, now I'm on VDOM demo.

Now let's switch it back to Hello World, okay, okay, for that I just need to abort my changes, you see there is one change which I made when I was explaining, so I need to cancel that change first, okay, so I cancel that change and check out to demo1 underscore Hello World. So once I come to this, okay, now there are a bunch of files which you need to understand, package.json, so package.json is basically tells a dependency and scripts required to run the project and application and your test suits.

So this package.json has a bunch of scripts, okay, which need to run your application, but it also has a bunch of dependencies which are very vital while running your application. Now for example, you are running a React code, right, so for React to work, there are two important libraries that you need to download, so you are depending on these libraries, okay, which is why it automatically downloaded, a create React app or utility automatically downloaded those script stores. So this dependency object shows you what all the dependencies of your project, there is a README file which you can update and see and talked about your project, so that is a standard way which basically to document your project or keep a node section of your project.

Then there is a Node modules, okay.json, then there is a Node modules node modules repository.json I already told you that Node modules basically list out all the third-party packages, so whatever packages you need. For example, we talked about this, right, React.json So now React is a third-party library. it's a npm package which will always get listed under this node module similarly for a react dom similarly for react script everything is a npm package which will get listed under node modules directory then there is a public folder now public folder will always have folder containing root html pages or root pages for example this is the index.html everything starts from this index.html okay so this is our root page we are going to inject or we are injecting our react app inside this development okay so this is our root div of any react application which we are writing from scratch okay then there is a src folder now src folder is one for which we need to write our application okay so src folder is the one where we need to write our application so you can create your own folders your own files your own templates and keep it over here so src is the folder where you will touch mostly that that's the folder where you will touch the mostly and that's the location where you keep all your custom files so that is the folder which we will use for a development and it will contain a component in test file okay so now we understood like what all the things present in the react application folder now let's understand how react application bootstrap so if you look at the src folder we can see there are a couple of files files and two important files are app.js and index.js which actually tells us that when you are writing something in a react essentially it will boil down to javascript if you handed over a normal react code to browser browser will not understand it will only understand the javascript and who will transform that special react code to javascript it's something called as a transformation tools which comes by default when we install create react app tool okay so now check it out what is app.js so it looks like like they are creating a function and they're exporting that function so if you look at the output for this particular demo you can see the hello world right which we already seen and then from this function they are returning the some sort of markup which matches with what we can see on the output right okay so they are returning some markup from here and that's it then let's look at the index.js now this file looks some special right and it looks special because there are some new apis that we are not aware of so let's start from top so they are importing two files one is import react from react and then import react down from react down slash client now what are they so these are the basically part of core react library so when we call a react we are basically referring to these two libraries okay and so if you navigate to package.json you can see we are already added react and react down in our dependencies array so who added we didn't add it oh we added when we installed the create react app tool okay so they added they automatically got added because it's by default in built in that tool okay now if you come down uh there is something called as an importing uh index css okay so they are importing the css now again this is not something valid in the javascript you can't directly go in any javascript file and import file and import the css that is not allowed but it's allowed somehow over here why because there is some processing happen when you actually save your code there is a something called as a webpack which builds your all the dependency uh resides in your application and present to the browser in a browser readable format so this is now valid in a react context or in a webpack context then we are importing our app component and after that uh forget about this for now and after that at line number seven we are firing this react api so what there are two parts of it one we are picking some element from somewhere we are picking root element we are picking an element whose id is root and we are passing that reference to a function called react down dot create root and we are returning the result to root constant okay now now where is this root element uh so in order to understand here comes a important for a file from a public folder which is index.html so if you open index.html html you can see it's a regular html over here but there is a div with a id root so basically index.js is looking for uh that development uh this with this they are picking the reference to that root element and handing over to this particular api and this api returns the react wrapped object of this div div and it stores in a root element now in a react we will always define only single html file that's it this is what all we will define when uh when it comes to html and everything uh fits inside this page itself that is why we are calling it as a single page app right because it will always have a single html page and everything will get loaded under the this development so react will kick in under uh the root umbrella of this particular markup now now this is a special reference and on this special reference which this api provided us we are firing a render method now this is again a method from the react inbuilt api and inside this render we are specifying our app component or app function which we are already defined over here so that is how react app bootstrap so this is what we are called our function we will see how to call a function in this way in this declarative way which looks similar to html but it's not exactly html but then this is how any react application bootstraps now let's jump to the component now what are the components the components describes a part of the the component of the user interface it's very true right you Component describes a part of user interface. So webpages comprises of components. So when we talk about any webpage, for example, okay, so let's open youtube.com. So if you see, this is the YouTube webpage, right? Now it has different things. It has a thousand and one different things.

So now there is a search icon and there is a hamburger menu and there is a left side navigation and there is a profile. All these things can be split into individual components. So let me take a snapshot of it. Now, if you see the search component, okay, this can be a one component, entire component because it's a single, single piece of UI, UI, which you can reuse. Let's say you have, you have composed this as a component. And let's say YouTube wanted to integrate to its future product. You can still pick it from here and put it to that future application, right? So this is a one component. Now, again, this entire toolbar can be constructed as a single component.

This single chip can be constructed as a single component. The tiles, video tiles are or can be seen as a separate component. Then your logo and hamburger menu can be one of separate components. So what we are saying is our entire web page comprises of many components. Okay. It depends on developer, like how he wanted to see a page of, like someone want to visualize entire screen of tiles as a single component. Okay. He can do that, but it's not advisable. So what it, what, what, what, what basically standard is, like try to think of a component as an atomic structure, which you can reuse in multiple places. Now, if you create a single slide as a component, you just need to create, or you just need to reuse the same component again and again, so that you can construct the entire screen.

So in this particular case, a wiser choice as a component as a component is select a single tile as a component rather than constructing an entire pane as a single component. That is what we are saying, right? The components of web pages comprises of different components and components are usable and can be nested inside another component. So one component can be nested inside another component, which we call is as a composition and same component with the different properties can be used to show a different information.

So let's say you have a search, you have, let's say you have a search component. Okay. And the currently placeholder is a search. Okay. But in a future application, you want this placeholder to be rewritten as please search here. Okay. That should be a tag. Okay. But otherwise the functionality is exactly the same. Okay. So by passing a different properties, you can reuse the same component. So your component will be a configurable part. Your that UI portion will be configurable. So that is what indicates that same component with different properties can be used to show a different information.

Component code is written in a JavaScript file. So now this is very important. Like whatever we are going to do, we are writing our component in a JavaScript file and very specifically we are writing in a JSX file. Now what is a JSX file? We'll see. But it is essentially, it's a JavaScript file. Okay. So as I indicated, there are two ways to define a component in the React. One is a function component. Now how you will write a functional component? A functional component is a stateless component. This is not entirely true because after addition of React hooks, even you can add a state inside your functional component.

But previously, they used to call a functional component as a dump component or stateless functional component. Okay. So what are functional components? They are simply JavaScript functions. And you just need to return a markup or a JSX from that particular function and that's it. This becomes your single component. This is the component. This particular sample component is just greeting the user. A hello, some curly braces, some funny looking syntax and then profs.fullname. Okay. We'll see what is that. Okay. But this is a functional component. And what is another way? Another way is writing in class B's component. Okay. So class B's component is a stateful component.

Now already I told you that now this distinction was there before React 16.x version because there were no addition to the hooks. After the hook addition, both class and I mean even functional component can have state. But class component is always a stateful component and regular ES6 JavaScript class. It is a regular JavaScript ES6 class which extends React component. So if you see how we define class B's component, this is the way we are defining it. Okay. The only difference from the functional component is functional component can just return a markup using a return keyword.

But over here you need to implement a must have a return method. Okay. So you need to implement a render method over here. And from that render method you are returning some markup. Okay. So this is the difference with the functional component that in class B's component you need to or you bound to write a render method. Let's check the demo. Okay. So for demo you again need to switch to your third demo. What is the name of demo? Demo 3 underscore components. Okay. So get reset heart to just clear out and then get checkout demo 3 underscore component. I switch to third demo. Okay. I can see that into the action. Inside a component I have two folders functional and class B's.

So this is my functional component. So this is my functional component. What I am doing. I have written a simple function. Okay. I am a text argument something called as a props. That is fine. That is fine. That is fine. It can be anything over here. And then I am returning just a markup. Okay. It is a static markup. And this is the interpolation syntax. I want to interpret this variable. In order to interpret it I have written inside a curly braces. And where I have included this component. That is what very important is.

So now. So now this is my functional component. And remember this is app.js. This is the root component of our application. And where I have injected this functional component. Let's not worry about this for now. So this my functional component. This is the component. I have exported it. I import a react from react. This is the standard way we need to do. If you do if you miss us to if you miss to do this there will be error. You need to import a react from a react from a react library. And then you need to write your functional function. And export that function. Why to export? So that you can include or you can use that component in some another component. So this app.js consists of my main component. And this jsx file. Or you can write it in a javascript file also. That is not a problem.

It can be jsx. It can be jsx or js. There is no as such a big deal to this. You can write a component file as a normal javascript file or a jsx file. That is that is completely fine. Okay. So I generally have a practice to write it as a jsx file. Because that is something very relatable to me. And I'll tell why. But yeah. So that is how you're defining the function component. So let's run that. Okay. So I'm john from a function component. Right. So where that john comes from. Okay. So here I'm passing one attribute called as a name. And I'm passing the value of that attribute as a john.

And what I'm doing. And what I'm doing. Inside the function. I'm writing props dot name. Now this props dot name is doing what? It's basically accessing this attribute inside a component. Okay. So that is how properties work. We'll talk more about it in upcoming lectures. But just consider that this is the way to write a functional component. And what about class. For class you need to go to the ES6 syntax of class. Only one change. Instead of rea imp. Only React. You will now import a component also. So one way is to import with this. There is another way. Like you can do this and then choose react.component. This will work also. But this is something I always follow. So it will be component. So what you are doing is you have created a ES6 class. You are named it as a my class.

You extend it from the react component. Okay. And then as I told you, there should be strictly a render method inside your class-based component. I am returning the same. The only difference is I am not just doing props.name. This time I am doing this.props.name. Why? Because classes have always access to this and everything inside a class component has to come from the class. So over here. So over here. So over here. So over here, they are accessing a props like this.props.name. Okay. Why? We will see in upcoming lectures. But just consider this is the way to write a class-based component.

So if you run this class-based component. So if you run this class component by toggling the function. I am John from class-based component. Okay. Very simple. Okay. So this is how we conclude our week one. And in summary in this section, we see the prerequisite and the software tools required to program in React. We see the advantage of React.js over other libraries and frameworks. We see the folder structures and how to build a single page applications in React. We see that. We see create React App Utility. We basically installed that and created a Hellowed program.

Then we went over the folder structure, what all things, package.json file, src folder, public folder, load modules folder. We checked all that. Then we started discussing about components and what are the components. So those are atomic in nature. And each web application has a number of components to it. And those are the basic building blocks. Okay. So when you say a component, it's not just a markup. It's a combination of markup, logic, styling, everything. So it's an individual autonomous UI portion, which can be portable to any application.

It may or may not be. It depends on your requirement. But ideally, it should be a reusable and a configurable. And then we see how we define a component in React. So two ways. One, functional way. Second, class way. Okay. So that is in summary. And here how we conclude our week one. So basically, we learned a lot. We've seen a lot. There are a few things which I'll cover in upcoming sessions. And I hope that you guys will go over those assignments. I will also be supplying a few reading links for an extra study purpose, which you would like to check out. And I would strongly suggest to check them out.

And happy learning. So thanks a lot.

Want the rest of React.js?

Get the full course syllabus and fees.

The full course is paid (₹40,000). We'll send the syllabus and call you back within one working day.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.

Full course · paid

Unlock the full React.js course

The remaining 42 lessons, mentor-reviewed projects and a certificate come with the paid course (₹40,000). Leave your details: we'll send the syllabus and fees and call you back.

Get the syllabus and fees

A counsellor calls you back within one working day.

By submitting you agree to our Terms and Privacy Policy.

Grow by Skill-Lync · free lesson

Start watching

Free, no payment. Leave your details once and every free lesson on Grow plays straight away. A Skill-Lync counsellor may call you about the full React.js course.

By submitting you agree to our Terms and Privacy Policy.

Talk to a career counsellor

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.