- Podcasts
- ReactJS Developers Podcast
- React Imports Explained – Understanding Components, Modules, Hooks and External Libraries
React Imports Explained – Understanding Components, Modules, Hooks and External Libraries
ReactJS Developers Podcast
- December 3, 2026
- 57 min
- Episode 4
About this episodeIn this episode, we explore Imports in React.js, an essential concept for organising code, managing dependencies, and building scalable…
- Understanding imports and exports in JavaScript.
- Why React applications use imports.
- How to import React and React Hooks.
- Understanding named imports and default imports.
- Working with named exports and default exports.
- Importing reusable React components.
- Importing CSS files and assets.
- Importing functions and variables from other modules.
- Understanding third-party library imports.
- Organising imports in React projects.
- Common import errors and how to fix them.
- Best practices for managing React project dependencies.
- Beginners learning React.js.
- JavaScript developers.
- Frontend development students.
- Developers building modular React applications.
- Anyone interested in modern JavaScript development.
Transcript
From the publisherThis transcript comes from the podcast’s own feed, shown as the publisher wrote it.
React Imports Explained – Understanding Components, Modules, Hooks and External Libraries
Hello, today we are going to learn about React Imports. And this is such an important topic that you can't make a single project without learning it. You are making basic projects too, so you will need it. So there are many things, I am going to tell you everything in a single video. Now there are some things here that you will not understand directly now. Like this third-party package. You will not understand what is Axios, what is Browser Router. You will definitely not understand. The point is to learn import. So we will learn that. If you are not able to understand, let it be. Right now, 5, 6, 7 lectures are going to be like this. In which I will just be teaching you. I will be building the basics. So, don't take too much load, this is not understood. Now there are many things that are going to be repeated in the future and we are going to go into depth in that. What engineering is behind the scenes, we have to learn that. So, don't get so much worried from now. So, react imports. First of all, we are going to learn components. How can we export and import these components? And this is very important. So, here I come to the code quickly, our lecture 7 is our react imports, before this we have done all this and here I have already generated this folder structure from wheat, so if you have not done it, then do it, there are many lectures, I am telling you this, I am not going to repeat it again, then go to the wheat site here, there you will get the command of installation, copy paste that command terminal, this folder structure will come to you, If it is not coming then you can see in the previous lecture or the lecture of the set up and folder structure. So here in SRC we have our app.jsx and I have cleaned it completely from the beginning so that there is no time waste. And I have also run it here. Ok, you see how much time I am saving now. So definitely time is also very important. If I write the heading here. So, here we can see the app. Here we can see the app. Wow! That means our project is running. So, what do we have to learn? We have to learn how to import and export the component. So, we have to learn export and import. But before that, I will give you some guidance. If you want to learn export and import in detail, then there will be a lecture on modules. There will be a lecture on modules. There will be a lecture on JS. You can search Premium JS on YouTube. Premium, JS and there you will get the lecture of modules of 40 minutes. See the whole export import, the different types of export imports, everything will be clear to you. Here the React user is only going to learn. Everything will be clear to you there. Let's see here now. So here we are going to use the modern import. Modern export import. export, import, or you can call it ES6, ES6 export, import, or you can call it ES6 module. So by default, this is used in React. And this is what we have to learn. So keep in mind that any one file from another file, why do you have to import export? Because you will not be writing all the codes in one file. Otherwise, how big will the code be? If you are writing all the code in one file, like app.jsx. If you are making a big project or an intermediate project, then will you write 4000-5000 lines of code in one file? It will be very dirty. Then there will be a problem in debugging. You will not know where what is. and that is why it is called React. It tells you to make multiple files in components. If you make multiple files, then you will definitely make multiple files. Suppose we want to use this component in the first file, how will we do that? So, the first component we have made in this file, we will have to export it. We will export from somewhere, that's why we will import from some other place. Someone must have sent me a parcel from Mumbai, that's why I will receive it here. If it is not sent, then what will I receive? So first of all, you have to send it from here, you have to export it. And what will he do? He will receive it. So I made the arrow wrong. Let's correct the arrow a little bit. Our arrow will be like this. So, we are exporting from here. Where are we importing? In the first file. So, we will import here. So, we know that we are working in multiple files. We will export from one place and import from another place. That's it. Now, the way to export, understand my point carefully. We will import and export. But the way to export can be two ways. Two ways. You are saying two, right? Yes, two ways. The first way can be of default export. Default export. The second way can be of named export. These two ways of export in your react or normally export import also exist. So default export and named export. Now if you are doing default export, then you will also do import default. Obviously, if default spelling is wrong, If you are doing default export, then you will do import default. And if you are doing named export, then you will do import named. If you are doing named export, then you will do named import. If you are doing default export, then you will do default import. You should understand this much first. Now let's learn one by one what is default, how to do it, what is named and how to do it. So let's quickly come to the code. First of all, let's see the default one. So I make another file here. First of all, I make a file here in the bugle. In the sense that app.jsx is in our src folder. I make a new component in the src folder. I give the name header. Remember that the name of the naming convention should be capital starting letter. Now I will tell you why you have to give capital. There is a standard method, where is the need to give capital letter in actual, I will tell you just now, wait. So here I am making a function, I have made a function and definitely there is a function of component where we can write html etc. So I made a function, I give the name header h-e-a-d-e-r, can I give it in small? Let me give small here too, first I will show you by giving small, why should not be given, I will show you that. ok and then we will give what is the problem in doing capital H so header and here it is important that the name of the file given here is also given here. No, there is no need. The name of the file given here, suppose you gave the header here, you gave the navbar here, there is no problem, but what is the standard practice, it has to be given here too, it has to be given here too, ok, we will learn the standard practice, first learn it in a dirty way, if we learn it in a dirty way, then a good way will also come, alright, so now what will we do here, we will return return h1 and write here that this is the header. So wherever we are using this header component, what should be rendered there? This is h1 in which it is written that this is the header. Agree with this? Yes, wherever we will use this, this will be rendered there. So, I have to use this component in my header file in app.jsx. How will I do that? First of all, I have to export this component. I will send it and only then I will receive it. First, I have to export the header and export default. First we are learning the default one. So export default. What I had to do? I had to export. I have to export. I have to export default. This is easy. Then I have to do header. Wait a minute. Let's say the name of the variable is Hadoo. From where to do it, you have to tell this. So this is your syntax. This is not rocket science, this is syntax. You have to write import here. You can give any name of the variable here because you are exporting default. If you do named, you can't give anything. If you are doing default, you can give anything. From where? From here. From where? From here. Now what do we have to give here? We have to give the path of that file from where you want to import. So from which file do we want to import? From this file. This component is inside header.jsx. So where is the header file? Here. So we have to give its path. Now how do we give the path? Many people don't know this. So this is a basic HTML thing. I believe you have read relative path, absolute path. And if you are not coming, I will tell you a little bit. where is app.jsx in src folder? so if you put. slash in src folder then you can see the things in that current folder what did I say? app.jsx is in the src folder. So, as soon as you put the dot slash, the things that are visible in the src folder, like assets, header, main, you will say that there is also css, but css is not visible, so css is not coming in the suggestion. You can find extensions for that, that you get in the suggestion, but you are not getting it. So, it is not a problem. We are getting this, see this header. So, our header is imported here. Now see, it is giving me an error, it is giving an error because Hadoo is declared but its value is never read. So for now it is giving me a useless error. If I reload by pressing CTRL-SHIFT-P, then I believe our error will be removed. See, the error has been removed. I will enlarge it a little in this way. Now how will I use this Hadoo? So normally I can use Hadoo in this way. I had told you in the basic lecture also. How to do it? Open Angular Bracket, Hadoo. This is a self-closing tag, so you have to put a slash here and close it like this. Can I use it like this? I can do it, but now I will get an error here. What kind of error? Look at this. I reload. The tag is unrecognized in this browser. If you mean to render react component, start its name with an uppercase letter. If you mean to render react component, which is a react component. If you mean to render react component, then define it with an uppercase letter. You have done it in small. Your starting letter should be uppercase. This is what he wants to say. Start will be with an uppercase letter. If I do capital letter H here. And here I will give Hadoo in this way. So will it work? Wow, it is working and the error has also disappeared. It is working and the error has also disappeared. So where does the error come? It just comes here. It is not that if you give a small letter here, then the error will come. No, if you give a small letter here, then the error will come. So here you have to give capital. Now if you want to give capital here, then you will definitely import in capital letter. Now if you do it in the import capital header, then it does not look good that you are keeping capital here, you are keeping small here. So do capital here too. Now to do capital here, this is the name of your file, right? This is the name of the header file, this is the name of the file. So to do capital on this, you will have to do capital on this. Header. Okay, now capital on this. So now it has become automatic capital here. Wow! This is the power of VS code. Okay. This has become automatic capital. If not, then you can do it. See, now in the suggestion you are getting the same header with capital H. Okay. Now this is capital, so the header we have written in small is not looking good, although it is working, there is no error, but it is not looking good. Here we have given capital in this way, here capital in this way, here small in this way. Keeping it uniform is a good thing. So here also header. So this is the standard way of doing it. Where the error comes, the error only comes here. Here you have capitalized, that's good, it will work. But keep it a little uniform. If there is a header here, then why are you calling it a header? You don't have a girlfriend, so give it a header name here. So here it is working properly. It was working before, but now it is a little better. We have given a header here, we have written a header here, we are exporting a header here, we are importing a header here, and we are using a header here. It looks good. So this is default export and this is default import. The advantage of default export is that you can give any name here. So you don't get any error. Otherwise if you are using it in small and you have to import it in small then you can't use it here. If you do named export then you have to give name as it is. Here you have to give small h. So you are getting an error. So this is the advantage of default that you can give any name here. Now the disadvantage is that you can import only one default export at a time. What did you say? I said that you can export only one component at a time. And if you are exporting only one component, then you will also receive only one component. So if I make another component here, function card like this. So the standard approach in component is that write in capital letter, if there is a function, then we would be writing here in small, but this is a component, so here we give capital as the starting letter, this is a good approach, I told you where the error was, I also told you how to fix it, so here we return, we return an h1, there is no problem, and here we write that it is a card, so wherever this card will be rendered, this card will come, do you agree, yes, Now I have exported the header in default. Now how will I do the card? If I say export default card again, then it will give me an error. This will not work, it will give me an error. See, there is an error in both. This error says that a module cannot have multiple default exports. You cannot export multiple defaults in a module. You can't do multiple default export in a single file or single module. You have done one default export and you can't do the other one. So what will you do now? You can do default only once. Now if you want to do multiple things, then you have made one default. You can make default by choosing only one. The rest you have to do named export. How to do named export? There is nothing special. Just write export here in front of the function. Is it named export? Yes. And you can also write export default in this way. You can also write in this way. You can also write in this way. You can also write in this way. You can also write in this way. You can also write in this way. You can also write in this way. You can also write in this way. You can also write in this way. You can also write in this way. You can also write in this way. You can also write in this way. You can also write in this way. You can also write in this way. You can also write in this way. You can also write in this way. You can also write in this way. You can also write in this way. You can also write in this way. You can also write in this way. You can also write in this way. You can also write in this way. You can also write in this way. You can also write in this way. You can also write in this way. You can also write in this way. You can also write in this way. You can also write in So, we can do this also. And for named export, we have to write only export. For default, we have put default in the middle. For named, we don't put default in the middle. We have to write only export. Ok, export is done. Now, how to receive it? To receive it, you have to do destructure. I told you that it is very important to read the destructure. So here we will put a comma, we will make an object like this for the destructure. And why will we make an object? Because I know that whenever we do named export, all the components we are exporting, it comes inside an object collectively. Means if we export the card, then it will come inside an object like this. And then again, suppose I export one more. Card 2 will come in this object. And this object is being imported here. So you import it by destructuring it. Is it required to destructure? Definitely. You can't do it without destructuring. Because you are doing default export here. So this is your default syntax. So it is compulsory to destructure here. So to destructure, basically you had an object like this in which there was a card and card2. So what will you do to destructure? Here simply write the card in this way. You are also getting suggestions. If I enter the control space here, you are getting suggestions that you have a card, enter a comma, then enter the control space, you have a card2. Then enter a comma and enter the control space. Now there is nothing here. So these were the two you had. See, you can see that the cube symbol is made in this way, whatever your component is. Okay, so we have done named export. Now the name here is very compulsory, give exact. Here you have given card 2, so here also you have to give card 2. Here you have given card, so here also you have to give card. I am just telling you a little more about this starting component, so that you can understand it well. After that, everything else is simple. You will understand it immediately. Alright, so you understood how to use it. Similarly, this will be your card and this will be your card 2. Alright, so see here, this is your card and this is your card. And actually, it is coming because we have not written card 2 here. So now see here, this is the card and this is the card 2. ok, now you understand, for default export, we put default here, now do it here, or do it like this in the bottom, and how to do it in this, in the bottom, here we were able to do it in this way, in a different line, now if I have to export it separately here, then how to do it, then you can do it, remove the export from here, remove the export from here, and export it in this way. I am so sorry, export it. Now, do I have to do it in this way? No, it will give an error. Here you have to make an object in this way. Okay. If you write export directly here, then it puts it inside the automatic object. But if you want to do it yourself, then inside the object in this way, card and here card queue. That's why I was saying that if you are sending an object here, then it is necessary to destructure it here. Do you understand object destructuring? Let me tell you a little. Let obj is equal to something like 21. If you want to use it, you will have to access obj.name and obj.age. Why don't we just do name and age and access? For that, you will have to do this. You will have to make a variable. Let name is equal to obj.name. Let age is equal to obj.age. Now here, wherever you use name, you can use name. If you simply console age, then you can also console age. Okay. Or wherever you want to use, you can do it. So the way to write it in one line is destructuring. That you passed the object in this way. Now which keys are there in the object? So there is name and age. So remove name and age Remove name and age. And remove it. So this is a small syntax. Okay, do you understand or not? So leave it. If you haven't read the javascript then what can I do? I had to do a little bit of javascript. or you must have understood I believe and if you want to understand in more depth then please please go and see destructuring the lecture of modules is in java script and then you will understand better so I suggested that you should see that in sequence and this also so it will be fun ok so you can do it this way so recap it quickly you can do this for default export you can give any name here and you can change the name here if you are doing default then For named export, you have again two ways, here you write export and here you write export. So it is being exported by being combined in an object collectively. So while importing, you can import and use it by destructuring it in this way. Otherwise, you don't have to do it here. So here you make a function and make it and in the end, export everyone in this way. Okay, what if I don't do default export here? And here I try to access the header. So here I will get an error. What error will I get? Let's reload. So see this site is also broken. The request module does not provide an export name default. So default export is not doing. So how are you doing default import here? So remove default import. And comment it. So now here you will not get error I believe. So if you will do default export then only you can do default import. Otherwise no. Ok. I understand. If we do default export, then we can do default import here. Otherwise, we can't do it. In the same way, if you do named export, then you will get suggestions in named import here. If there is no card 3 here, see there is no card 3 here. So, if I want to see here, there is no card 3. Enter control space. See, is there a suggestion of card 3? No. Even if you write card 3, you are not getting suggestions here. Only card, card 2 is available here. So, if I make card 3 here, Card 3. So here you will also get card 3 in the suggestion. Card 3 is not available. Why not available? Because I did not export it. Now to export it, you can do it like this. Card 3, put it like this. Or if you don't want to do this, then you can do it by mixing. You can export it like this here. So it will automatically put this card 3 in this object. You have not put it, but you have exported it here, so it will automatically put it in it. You can import it here. So look at this card 3. You are getting this suggestion, right? Look at this. It is coming in cubes. Okay, card 3. So you can use card 3, definitely. I made it to use it. Wow, wow, it was fun. It was fun. It was fun. It was really fun, wasn't it? Yes, it was really fun. Okay, let's understand the path a little bit. So let me remove the card three. Two is enough. Let's leave the card three here. It's not a problem. If you have exported here and not imported, then it's not a problem. Okay. So here you can understand the path a little bit. I said that you can come to the current folder with the dot slash src. If you are in app.jsx, then src is in the current folder of app.jsx. So what is the current folder? src. So here you can access the current folder with the dot slash, meaning src. And you can import all the things in it in this way. Alright. If something were to happen outside the src, then inside the src, inside the current folder, then dots less. But if it were outside, then let's say here I have a I made a folder inside this app. I made a folder here. Components. Alright. If the folder structure is a little difficult, then I believe you should see the folder structure. Now I put this header inside the components. I put this header inside the components outside. Okay, as soon as I put it outside, our import is fixed here automatically. This is the power of VS Code. Here the import is fixed automatically. I put it outside and VS Code saw that it has put it outside. So it fixed the import here. What did it fix? It put a dot dot slash. We were doing dots less, but it did dot dots less. This means that we understand that if we want to be in the current folder, then we will put dots less. And if we want to go out of the current folder, then it is not necessary that the src folder should always be the current folder. We decide by looking at the current folder. Like app.jsx is in this folder. So if it is in src, then src is the current folder. So to access the current folder, dots less. To go out of the current folder, dot dots less. Now you can see all the things in the app folder. In the app folder, you can see components, header, dot JSX. This will work. What error did we get? Card 3 is not defined. We are using card 3. Now there will be no error. So we understood how to keep the path and other things in mind. We understood everything. Let's leave the header, card and cartoon for now and understand further. so how to import how to use you understood all this and you can also do it in two lines as we did here in this way you can do the default import separately and you can do this named one separately you can also do it like this separately it will work see it is working there is no problem here So you can do it differently. But this is not a good syntax. We do it the same way here. Why do you have to do it differently? This is the default, this is the name. You just have to put a comma in the middle. Do you understand? Should we go ahead? We will go ahead. What else will we do? Now how can we import the CSS file? There is a bit of a gap in the CSS file, but I will not discuss that gap here now. There will be a different lecture on styling in which I will talk about CSS, Tailwind and many other things. I believe I have told you about this in the JSX lecture as well. It has not been posted yet, it will come in the upcoming lectures. The presentation is according to that. I am not able to understand it. If it doesn't come now, how will I understand it? So, I just want to say that in CSS, I am just telling you how to import. There are many things to keep in mind in CSS, but I am not discussing all of them in this lecture. The topic of this lecture is imports. How will we import CSS? In the same way, we have to import here and give a path here. There is no need to do any variable in between. Because CSS is not a JavaScript that we will export a component or function from there, we are importing it and saving it in the variable. You have imported CSS, that means the whole CSS is being used at once. You don't do this in normal HTML CSS, you import style in it, the whole CSS is being used at once. It's not that you are using one class separately and importing another class separately, no. So here you have to do it in the same way. Once you have imported, whatever you write in app.css, you will be able to use it in app.jsx. Really? Yes, look. For now, I have commented app.css. So, see what will happen. It went to the left side. Earlier it was in the middle. But now it went to the left side. Because we have removed css. But black background is still coming. So, black background is coming because of index.css. If I go to main.jsx and comment index.css. So, see this is also removed. So this is completely normal. Now let's import this. Let's remove main.jsx. And here in app.jsx, let's also import app.csx. Now the way to import css is the same. You have to keep in mind the same relative absolute path. And if you want to know in detail, then you can search the relative absolute path HTML lecture and read it anywhere. In the same way, you have to give the path here. As you have given here in this way, in the same way here. App.css was in your same file, in the same current folder, so we have put dots and slashes here and accessed it. Otherwise, we can't access it. If it was outside, then we would have to put dots and slashes. Okay. So if I give a class name here, and why do we give a class name, why do we do it, we will discuss all this in the JSX lecture. Instead of class, we give a class name. Now understand this much. We used to give a class in HTML, here we give a class name. I will give some class name here like a heading and if I come to app.css and give red in bg color from a heading then will it be red? Yes it is red. So this way we are using something in app.css. If I comment then it will be removed. Alright. If I import it again then it will come. Now lets discuss how we can import and use images. Normally we can use path in src. The concept of image is little different. But I will clear the crystal for you. We can work by adding all that. The concept of image is a little different here. But I will clear you completely crystal. See. So what will I do here? I am taking my image tag here. I take it quickly. OK. And look carefully here. The image is also your self-closing tag here. HTML doesn't do this, but if you do it here, there will be an error. Anyway, this is the part of JSX, our next lecture is going to be about that. So we will understand all this, what, when, how, why, why to do it. Now it is the matter of our import. So here slash, self-closing tag can be used in this way. Anyway, why do you have to use it? I am getting suggestions, write, this has come. Wow! In normal HTML, we use SRC in the current folder. SRC has assets and assets has the REACT logo. If we want to use it, we will use. / / in the current folder. SRC has assets. After that, our react.svg, so our image must have come here, our image must have come here, the image tag has come, we have seen some changes, the UI has shifted a little, but again, if it is not visible, there is no problem, the problem is that our image has not come here, our image has not been rendered here, why, we have given the path correctly, You have given the path correctly, but it is important to understand that there is a little working of react here. How is it being served publicly? Like I told you in the folder structure that whatever you write in the public folder is being served publicly. Like here is vid.svg, so if you come here in the browser, Where is our browser? Here it is. You will write only slash vid.svg. You don't have to write all that. Slash public slash vid.svg. No. You will write only slash vid.svg. Because it is being served publicly. It is in the public folder. So whatever is in the public folder, it is being served publicly. So whatever is in it directly, like vid.svg. So we will write here vid.svg. If there was any other folder inside the public folder, assume assets. So we write assets slash vid.svg. But there is no folder in public. There is only vid.svg. So, we will write vid.svg here. And see, we have the icon of vid.svg here. That means, our vid.svg is in the public folder here. So, it is being served publicly. So, we are here. Because it is being served publicly. So, we can use vid.svg directly.. /. vid. svg Ok. Can you see us here? So, you can definitely see. Come back here on the slash. See, our image is attached. Wow, this was in public, so it was installed. So, do we have to put assets in public? And then we will be able to do dot slash assets slash react dot svg in this way. Yes, there is react dot svg in assets. So, can we see react.svg now? Yes, we can see it. Wow! So, if we do assets slash react.svg here, can we see it here? Yes. So, we can see it here because it is being served in the browser. So, we can see it here. And if we put it in SRC? In SRC? So, it is not being served in the browser in this way. So, we cannot access it in this way. Okay. So, how will we do it? So how will we do it? We will do it by importing. No, we can do it like this. There is one way. Do you know what? That you give the whole path here. The whole path means this app is yours. What is inside the app? SRC. What is inside the SRC? Assets. What is inside the assets? react.svg. So if you give the whole path here. Slash. What was the path? src, inside src, assets, and here react.svg. So now look here, this icon is visible. That means if I use this path here, if I use this path here, then it will do our work that either remove the slash or put the dot slash. Okay? Do this work in both. So what will this work for us? Okay, this is working. Whereas in SRC, we have assets and in assets, we have react.svg. So now this is working. But if I was writing dot slash assets, it was not working. So it depends on how react is serving on the browser. It depends on the whole internal working. But here is one more way that I will tell you. And advanced things, we will discuss many things in the future on internal working. So you don't have to worry now. You have to understand what I am telling you now. In the public folder, it was being served publicly, so we were doing dot slash bit dot SVG. But in SRC, the current folder is our SRC, so if we were doing dot slash assets in SRC, then why wasn't it working? Because react was serving it in this way. So it is important to give us this path. Okay. But do you know the best way of this? The import one. You can import it. Give the name of the variable here. Like I give the name of the React logo, from where to do it, so now you have to give the same path here. Which path? Current folder is our SRC, so inside SRC we have assets, inside assets you have react.svg. Extension is very important here. It was not important here, but it is important here. So now we have to use this React logo here. Now we have to inject variable here. So, what we do to inject the variable? In the basic lecture, I told you that to inject the variable, we open and close the curly braces like this. That means, we are going to use the java script here. So, we can put this variable here, react-logo. And what is inside the react-logo? It is the logo. Where is it coming from? From this path. From this file. Okay. So, will it be working now? Yes, it is working. So, what is the perfect way? To work inside the public or to work inside the SRC but to give the full path or to work inside the SRC by importing like this. What is the best way? This is the best way. The import one. Okay. So, we will use the import way. Definitely. We will use the import way. So we understood the images, although there was a bit of confusion because we are new, so the obvious thing is that there should be confusion. If we do projects, then we will get more clarity. When there will be multiple images in multiple files, folders, we will import and export from there, everything will be clear. So what have we learned so far? You have two ways for these components. One is default and one is named. In default, you can give any name and in one go, you can export and import only one thing. In named, name is compulsory. The name you are exporting from there, you have to import from that name by destructuring. Because when you are exporting, then collectively inside an object, Because it is passing in an object, it becomes compulsory to use the object by restructuring it. Alright. After that, the CSS file is a normal way. There is nothing like variable, variable, named, exported. Once you have imported it, the whole CSS is working. The path has to be given in the same way. It was a little different in the images. In the images, we saw how React is serving the file. The way it is serving the file on the browser, we can access it in the same way. So instead of remembering how it is serving, you put the same file path there. It is a good way, you can import. What to do? Import. Import. So put the same relative file path as you were putting in normal import. You have to put the same relative path. Save it in a variable like this and use it here like JavaScript. That's it. Was it simple? Oh, it was absolutely simple. It was fun. Now modules, what is this module? Export-import module? No. We call modules as functions and utilities. I believe you know this too. These are basic things. We often call a function or a file as a module or a function as a module. So it depends on how you say it and with what intention you are saying it. These are just technical terms. So, you don't have to read all these things. So, if you are making a function or a utility, then how will you export and import it? It is the same way. It is the exact same way. Now, the function you are making, then definitely you are making it in JS file in this way. Like here I am making utility.js. Now I will make a function here of the name of the sum. It will take a comma b and will return a plus b. Now I have to export it. So the same way, two ways. Either export default or export the sum in this way. If I have done named export then I have to use sum in app.jsx. So first of all I will import it. And if I have done named export then I have to import named from dots less utilities.js. Give the same path in it. In import, you have to give the same path in the sum. Now which function was here, then I am getting the sum in the suggestion. And I have to use this sum here. So here I can use this sum also. It was taking two parameters, A, B. So suppose I gave 1, 2. So it will return me the sum. So here I store it in let result and do CLG result. So these are the basic JavaScript things. You must be knowing that this was a sum function. We called it and added 1 and 2. So it will do the sum of 1 and 2. It will return the sum of 1 plus 2, which is 3. So 3 is in the result and we are consoling that result. So is it working? Let's see. If we open the console with Ctrl Shift I, then we are getting 3 in the result. That means it is working. And why is it coming twice? The same restricted mode, which I told you to remove, so it will not come twice. In main.jsx, if you remove this strict mode, then it will come only once. Very good. So you understood this too. Then the JSON file is the same story in the JSON file. You just need to have an idea of what JSON is. Like you had the idea of JavaScript. So we discussed JSON in JavaScript itself. That too will be a lecture of 20-25 minutes or whatever. You will have to see it. You can't run away. So let's assume JSON means data. JSON means data. Okay. So, here I am giving some name, what name should I give? I will give data.json, the extension of the JSON file is. json. Now, in the JSON file, you are not making any variable. You are just keeping the data. Either keep the array or the object. But the method of keeping here is strictly following the naming convention. That means, suppose I am just making an object. So in the object, you write the name in this way. But here you can't do it in this way. Here it follows a strict rule. Write it in double quotes like this. Write the key in double quotes and the value in double quotes. And if you don't want to keep any other key pair, then remove this comma. Don't keep a useless comma. Okay. So, json is a little strict. Then if I want to put age here, I put 21. Don't keep a useless comma. Remove it. So, this is how your json is. For now, understand this much. If you want to know in detail, then you can see that there is no problem in it. So, this json data, do you have to put any variable in the variable? No. json means only data, nothing else. Now how we will import this? Suppose we have to use this data here. So import, import and here name here again you can give anything like in svg file here you have data only for save. Data means image can also be anything. So svg which was in this was image data. Here json which is object data. So here again you have to give any name in the same way. So let's say I give the name data only from where to import then dot slash data dot json path again in a similar way as you were giving in the rest. So here I console the data and show you CLG data. So come here. So are you getting the data? Wow, you are getting the data. It was fun. And if you don't understand json, then it's not a problem of react. Okay, json is not a part of react. Do you understand what I mean? Anyway, you will understand all these things in the future. When I will go to API etc., I will repeat JSON once or twice. But in this lecture, I am not saying that JSON is not our main topic in this lecture. Okay? So, anyway, you are understanding. You have understood so much about my way of teaching. So, you have understood this JSON. In the third-party package, you can import and export in the same way. I will show you, but this one will not enter in BHAJA at all. Now I have to use the package of Axios. Now what is the package? This will not be inserted first. I have to use it, so I have to install it. This will not be inserted either. Don't let it enter now, it's not a problem. I have split the terminal. I have to use Axios, so I will install Axios in NPM I. I have installed Axios. Now it is not installed because our net is not connected. Suppose our net is connected and it is installed. Now I will cut it because our net is not connected. If it had been installed, then how would I have imported it? Import exios from exios. Now you are not getting suggestions because our exios is not installed. Now you are not understanding that it is completely normal. It is completely normal that you are not understanding. If you would have understood, then it would have been a little abnormal. How did you understand without telling me? But if you are not able to understand this, then it is completely normal. When you are installing the package, you will import it in the same way. Suppose the package of xios is installed, then from where to import? Just import xios. Do not put any dot or slash. Just import xios from the package. For example, if we are importing from react-router-dom, then import and in react-router-dom we have named export, so how will we know which package has named export and which package has default export. So we can know from its documentation. You can read its documentation by going to google, although I will tell you, but it is the same way you can find out by looking at the documentation. As this is react-dom-install, so I am getting suggestions here react-dom-react In the same way, if our react-router-dom had been installed, then we would have been getting suggestions like react-router-dom and here in this way browser-router would have been getting suggestions and we would have been importing named in this way. Do you know how it will work with documentation? Now we did not understand anything. It is normal. It is a good thing that we did not understand. You are not taking too much load ahead. You just have to understand that in import and export, almost everyone has the same method. There is not much difference. Just keep in mind where the default is happening. What is default? Where the default is happening and where the name is happening. And if you don't know, search on Google. In this case, your default export will be happening or the name one. Google will tell you. Okay. So, okay, I will comment on it. It is not being used. Alright. Go ahead. Let's go ahead. Hooks. Now I told you one hook. Which hook? Use state one. Let's see use state only. Now whatever is hooks, generally hooks are imported. From where it is imported? If you don't use it, then you will get an error. So you know that either there will be a variable here or it will be named in this way. So either one of the two will be given here for the time being. The default hooks are found only in react. So in this way, as I was telling you here, you can relate these two. What I will do here, it will also be happening here. So you will also understand the package a little bit. So here, what to import from react, useState. So why did I put these curly braces? Because the useState hook is being imported named. If I don't know, then search on Google. So, I will write in use state. So, whatever is being imported, you will be getting it in the suggestion. But sometimes, sometimes it happens that you are not getting it in the suggestion. So, with that experience, you will come to know that use state has to be here. If I am not getting the suggestion, then also I will forcefully bring the use state. Okay? That confidence will come with experience. So, look, I am getting use state. Now, I can use use state. You know use. We have discussed in basic lecture. Rest, if you don't know, it's not a problem. Import is done in this way. Okay. Rest, you have to understand what are these things, what are these hooks, then use state is done, use effect is done, everything is normal, your package of react is getting inside it. Alright, now phones and assets, if you have to use it, then how will you do it? This will be coming to us from Google, then how will you do it? The way to use it is exactly the same as you do in CSS, now our net is not connected here, so that mobile of the net is also not here right now. And if I have to turn on my phone, then I will have to get up a little from here. So what should I do? Should I tell you this one? I will tell you, so wait a little. Wait a little and I will see if everything is going on or not. Has the lecture been one hour long? No, it must not have been one hour long. In the beginning, the laptop was running in the middle. When it was on, I believe it would have gone the same in the beginning 20 minutes. So, our lecture is going on. It should be 40-45 minutes long. Even if it is 1 hour long, what is the problem? You understand it well, right? Give me some time. I will connect the internet and then I will tell you how to import Google Fonts. Congratulations! Our internet is connected. Yes, we also have internet. Congratulations! See, I can show you. See, our internet is connected. Wow! You have to come to google fonts because most of the time google fonts are used. Although there are different libraries in react to load fonts. We will be learning all that through projects. So for now, if you want to use a font from google fonts, then how will you do it? So, just like you are doing in normal HTML and CSS, you have to do it like this. How? So, suppose I have to use this Roboto font. Or I have to use this font. What is the name of the font? Bit Count Prop Single. Oh my God, it's a very big name. Let's take a small name. This name will be a little difficult to write. What should I take? Should I take this Hindi one? No, not the Hindi one. Leto. It should look a little different. How will you know? Let's take this one. No, it also has a little long name. Oh man, something small. Let's take this one. Oswald. Yes, this is fine. So, I have to use this font. After seeing this, you will know that font has been applied. So, I have to use Oswald font. So, what I will do? I will click on get font here. The same normal way. Rest, there may be changes in the interface. So, you can see where the embed option is coming here. So, I clicked on get font. Here the embed option is coming. Now, either you can use this whole thing in the heading tag directly. Like, how will you put it in the heading tag? html is there, how html is not there in react? html is there, behind the scene, html, css, javascript is there. ok, and I told you in the folder structure also, how you forget all this, tell me. here you can see html where is it index.html so here in heading tag put it like this so now can we use oswald font? yes we can and we can also use weight from 200 to 700 font weight is 100, 200, 300, bolder, lighter we can use that too so font family oswald let's apply font family how is it looking now on our browser This looks like this, so let's apply Oswald and see how it looks like. Cross it and do you want to put it aside like this? You will know that you can't put it aside because it is stored. Stored means I have locked it. Now you can see how it looks like. If it changes, you will know. So let's come to app.css. And let me do one thing by selecting globally. I will say that the font family will be Oswald. So look at this. Did you get to know? Don't lie. I got to know. It's stuck. Look at this. Look at this. Earlier it was like this. After applying oswald, it became like this. So this is one method. But I don't like this method that go to html and increase the garbage. I like this import one better than that. This is small, this is small. And the style tag that it has given, we don't have to use the style tag. We are not using internal CSS. So leaving the style tag, copy this much. This much is of use. Style tag, you know. So here, take this from import and copy this whole thing here. Okay. so now where to put it? in css so now i will remove this from index.html how much i have put? i have put till this much so see this is long and big, i will remove it so after removing this, it should not work by the rule so see it is not working by the rule, very good so now come here in app.css so in main global file, we mostly do that we import in global file in the top although if you do it in app.css also it will work in the top I have done import and I am also using font family oswald so here we have wow so these are the two ways to do it now this was not the part of react basically as you do in normal html css you have to do the same here too there is a different way too This is also a good way to load and use the font pack in the library. So that no one will know which font you are using. There are many ways to find out which font is being used here. So there are many other good ways, so I will tell you that. For now, I hope you have understood. Take a quick recap. Where is our pen? Here it is. So what did I say? I haven't said anything yet, I'm telling you. I said that there are two ways. Default name. While doing default, you can give any name and at once you can do only one component. In named, you can export multiple components from one file at once and you can import. While importing, you have to destructure. Why? Because while exporting, it is collectively sending you in the format of the object. So while receiving, you can destructure. After that, we saw that the way to import CSS is very simple. You have to put an import, you have to give a path. Then I saw in the image that it depends on react how it is serving. It is serving the public file publicly. Whatever is happening in the public folder, it is being served publicly, so you can access it directly. But if there is something in the src folder, then you will have to mention the entire src path, then you will be able to work. So there is a better way than that. If you want to keep everything normal, uniform, then you use this method of import. And we often use it. Here we did import in this way, saved it in the variable. in this way, sorry, in this way, save it here in the variable and in this way, by putting curly braces here, in the java script, use it in the java script way, then the function is the same way as the component, we will also do the same function, here we will use the name and default, there is nothing in the json file, like your image, what happens sometimes, the image which was your data, There was no default named in the image. There was data, so we could give any name of the variable there. Similarly, your data is also in the JSON file. The same object and array is there, but in a little strict format. The naming convention is a little strict. So we will save that JSON data in a variable. We can use the data. Third-party packages are the same as the normal inbuilt packages in react. Just keep in mind where it is defaulting and where it is being named. Do you know how it will work? From Google. I will tell you, but how will you know if you are building a project from yourself in the future? Google. If you forget, then what to do? Google. Alright. It comes. Okay. We have already done it. We can use the normal react package by importing named in this way. And the font was not of react. We did the same thing in CSS and HTML. So it is not a problem. So, this is how we can do all these things. Now, I have told you all these things collectively at one place. Because these are the basic things due to which people are not able to build projects. It is obvious. You think and see. You think and see. Wait a minute. What do you call it? Meta was coming. So think about it yourself, these are all the things that are being used at the end. If you are making a project, what will you use? Image, as you have already done, video, if you want to do a gif file, you will use image, video, fonts, etc. You will import and export components, these are all the things that make a project. Now if this comes, then you will be able to try the project a little more than yourself. But if this doesn't come, then you will get stuck in export-import. Forget coding, coding is different. You will get stuck in export-import. You won't be able to import. You won't be able to use font. You won't be able to use image. So how will you make a project? So these are the basic things which I want to make you a little strong. Then after that, we have to go ahead in advanced things. And definitely we will go. And light is also done. So that's it for now. Then we will meet in the next lecture. Till then, bye-bye.
