HomeVideos

50+ HOURS REACT.JS 19 MONSTER CLASS

Now Playing

50+ HOURS REACT.JS 19 MONSTER CLASS

Transcript

83526 segments

0:00

so before we dive into the course first

0:01

of all I want to mention a few things I

0:04

can't make any promises but I can

0:06

confidently say that this course will

0:08

give you a job and what I can promise is

0:11

that this course will take you from zero

0:13

to a react expert a react monster that I

0:18

can definitely give you a promise now

0:20

you might be wondering why I'm so sure

0:22

about this and the answer is simple I

0:24

began learning reactjs in 2018 and

0:27

started teaching it in 2001 I appload my

0:30

first reactjs course on my YouTube

0:32

channel 2 years ago or almost 2 years

0:34

ago and since then I gained extensive

0:37

experience by building numerous projects

0:40

and working with different companies now

0:42

I'm eager to Lear you a job now I know

0:45

that's a lot of things that I just said

0:47

now the real question is what you can

0:49

expect from this course in this course

0:52

you're are going to be learning a lot

0:54

and I mean a lot of things so now let me

0:56

explain all of them one by one in one

0:59

breath first of all we are going to be

1:00

starting from the react fundamental by

1:02

building 10 projects and countless

1:04

exercises then we will jump to react

1:06

with time script by building five

1:07

projects and countless exercises then

1:10

react hook form with one project Des UI

1:12

shads and UI redex UI tman CSS simple

1:15

hooks advanc hooks learn everything

1:18

about Zeus by building 10 projects every

1:20

single thing I know about the framer

1:22

motion and also animation in general by

1:24

building 10 projects 10 stack query 10

1:27

stack router and also if you guys don't

1:30

know the 10 stack framework which was

1:32

just launched 3 days ago and you will

1:34

learn all of that by building 10 more

1:36

projects then we're going to be jumping

1:38

into the advanced Parts like design

1:39

patterns in reactjs design system in

1:42

reactjs react testing Redux toolkit with

1:44

two full stack projects next CH from

1:47

beginning to advanced level react native

1:49

with projects and also we are going to

1:51

be building Advanced projects okay that

1:54

was a lot of thing that I just explained

1:57

I'm going to break them down one by one

1:58

in a few seconds but yeah this is what

2:00

you can expect from this course and this

2:02

course is still in the construction you

2:05

are watching only the first part of this

2:07

course and which is about like almost uh

2:10

11 or 12 hour of content so you are

2:12

watching the first part of this course

2:14

and in the upcoming series we're going

2:16

to be covering the rest of these topics

2:18

which I just mentioned so yeah I'm super

2:20

excited and I hope you are too now

2:22

finally I want to talk about one final

2:25

thing and I promise then we will jump to

2:26

the course I've mentioned this in my

2:28

previous courses in my react native

2:30

course and also in my data structure and

2:31

algorithm course that if you don't want

2:33

to subscribe to my YouTube channel you

2:35

don't have to if you don't want to send

2:37

me a money you don't have to if you

2:39

don't want to follow me on Instagram or

2:41

in X or Twitter whatever you want to

2:43

call that you don't even have to follow

2:44

me anywhere you don't have to do nothing

2:47

for me but now if you are taking some

2:49

Advantage from my course please do not

2:51

download my courses if you don't want to

2:53

follow me here and there I can totally

2:55

understand like why but if you are

2:57

watching my courses and you are making a

2:58

career out of there and still if you are

3:01

downloading my courses that's not fair

3:03

like I can't do anything about that

3:04

because YouTube doesn't have the

3:06

download feature but yeah like if you

3:08

watching my content please do not

3:10

download that so yeah let's get into the

3:12

course and I'm going to make you a react

3:14

monster so now let's talk about what are

3:16

the things that you have to know before

3:18

jumping into this course so you only

3:20

need to know HTML and CSS that's going

3:23

to be the main prerequisites for this

3:24

course you don't have to know SS and

3:27

this one is optional but I will highly

3:29

recommend commend you to learn tailn CSS

3:31

because in this course we're going to be

3:33

building a lot of projects and for The

3:34

Styling we're going to be using tailn

3:36

CSS so this one is optional but yeah

3:39

once again my recommendation will be to

3:42

learn that and also you have to know

3:44

JavaScript but in this course you can

3:46

definitely skip the O op part you don't

3:48

have to know what a oop is to take this

3:50

course which you are currently watching

3:52

right now and if you guys already saw my

3:56

old react J course where in the world is

3:59

the okay let me just search for there we

4:01

go if you guys are wondering like should

4:03

I have to watch this course before

4:04

jumping into this reactjs course the

4:06

video which you are currently watching

4:07

right now you don't have to watch this

4:10

video and even though I'm going to

4:12

private this video and ah God damn it

4:15

you also have to know typescript I

4:17

forgot this one you also have to know

4:20

this typescript now let me just say that

4:21

once again HTML CSS tell CSS JavaScript

4:25

and typescript so that's the only thing

4:27

that you have to know for watching this

4:29

course so now let's get into the cording

4:31

so what is reactjs react is a free and

4:33

open source JavaScript library specially

4:36

designed for building the user

4:37

interfaces now there are a few buzzword

4:39

in this definition let me clarify that

4:42

for you so the first one we have is a

4:44

open source so what is a open source

4:46

open source refer to the type of

4:48

software or basically anything where the

4:51

source code is made available to the

4:52

public this means that anyone can view

4:55

modify and distribute the code of that

4:56

specific thing and in our case in reactj

4:59

yes now what is a library library is a

5:02

collection of pre-written code that

5:04

developer can use to perform a common

5:06

task or add a specific functionality to

5:08

their applications now what is a UI UI

5:11

or the user interface is the means

5:13

through which the user interact with our

5:15

application reactjs was created in 2011

5:18

it uses something called the component

5:20

model which we will discuss more in

5:22

detail in this course but not right now

5:24

it allows us to build modular apps and

5:26

finally there is a saying about reactjs

5:28

that learn it once and write it anywhere

5:31

so now let me break all of them one by

5:32

one B is the most popular powerful

5:34

frontend Library developed and sponsored

5:37

by Facebook a component is just a piece

5:39

of the UI that has its own logic and

5:41

appearance a component can be small as a

5:43

button or large as entire application

5:46

you'll discuss more about components in

5:47

more great detail later in this course

5:49

but not right now if you learn react GS

5:51

once you will not only be able to build

5:53

only the websites but you can also build

5:56

the mobile application desktop and also

5:58

even the virtual reality and there are a

6:01

lot more things that you can do with

6:02

reactjs so you just have to learn it

6:04

once and write it anywhere so that was

6:06

just a quick intro to react GS and now

6:09

let me make a setup forward coding

6:10

journey in this course we'll be using a

6:12

vs code for writing work code and you're

6:14

more than welcome to use any text eror

6:16

that you prefer you can use Sublime Text

6:18

you can use jbr products you can use

6:20

anything that you prefer but in my case

6:22

I'm going to be using a vs code for

6:23

writing my code now to install reactjs

6:25

first we will need to open your terminal

6:27

after that we have to type this command

6:29

npm create weat at latest hit enter next

6:34

we have to provide some sort of a name

6:35

for our project I'll call mine as react

6:38

demos you can call it like anything that

6:40

you want next we have to select the

6:42

framework I'll choose reactjs because we

6:44

are now learning reactjs and yeah I'm

6:46

going to just choose reactjs next we

6:48

have to select the variant for now I'll

6:50

just choose JavaScript because I know

6:53

there are a lot of people who are

6:54

watching this course they don't have the

6:56

knowledge of typescripts so if you are

6:58

someone who already know what typescript

7:00

is you don't have to worry about that

7:01

like we going to be still using a

7:03

typescript in this course but not right

7:05

now so yeah I'm going to just choose

7:07

JavaScript for now but later we are

7:09

going to be using a typescript in this

7:11

course now we have to go inside that

7:13

folder by using a CD command or you can

7:15

say the current directory command now

7:17

I'm going to use the code Dot and hit

7:19

enter so it's going to open that in my

7:21

vs code now want you to open your

7:22

integrated terminal inside your vs code

7:25

and just type this command so you can

7:27

either use npmi or you can use PM

7:29

install if you wanted to so both of them

7:31

will work totally fine so it's going to

7:33

install all of the packages by which or

7:35

reactjs is depends on so it's going to

7:37

take a bit of time I'm going to fast

7:38

forward the video right now let's

7:40

discuss these files and folders so the

7:42

first folder that we have is a node

7:43

modules folder and this folder has all

7:45

of the module and packages by which or

7:48

reactjs is depends on and later in this

7:50

course if you install any third party

7:52

packages that will be also included in

7:54

this folder so the next folder that we

7:56

have is a public folder and public is

7:58

the folder where we put all for assets

8:00

file like HTML Etc next we have a SRC

8:03

folder and SRC or source is the hard of

8:07

for entire project and we're going to be

8:09

spending like almost 90% of our time in

8:11

this folder so now inside this SRC

8:14

folder we have a few more files and

8:16

folder so the first one we have is the

8:18

asset folder and as the name suggest

8:20

that in this folder we are going to be

8:21

putting like all of our assets files and

8:23

folder like images svgs external icons

8:26

and so on and so forth next we have two

8:28

other files like app. CSS and also

8:31

index.css so as the name suggest that

8:33

we're going to be writing our style

8:35

inside these files so we are going to be

8:37

providing our style for our UI inside

8:40

these files next we have two more files

8:42

like app.jsx and also main. jsx these

8:45

are something called the component file

8:47

which we're going to be discussing later

8:48

in this course but you don't have to

8:50

worry about that for now next we have a

8:52

GE ignore file and this is a GitHub

8:54

related file when we are pushing our

8:56

code to GitHub this file allows us to

8:58

ignore a certain file or folder for

9:00

example like this node modules folder is

9:02

a huge folder and if you don't want to

9:04

push that to our gab repository so we're

9:06

going to be just putting the name of our

9:08

node modules folder in inside this dog

9:11

ignore file and it's going to just

9:12

ignore that whenever we are pushing our

9:14

code to our giab repository next we have

9:16

our es. config.js file and this is a

9:19

configuration file for our es next we

9:22

have our index. HTML file and this is

9:24

the most important file because in this

9:27

file we have our HTML content and we

9:29

also have a deal with ID of root or rejs

9:32

will select this element and render all

9:34

of our content to that specific day like

9:38

I'm going to show you from where we are

9:40

selecting that day with a class of Route

9:42

I mean like with the IDE of root next we

9:44

have our package.json file and this file

9:46

is the heart of our project it contains

9:48

metadata about the project such as like

9:50

project name version description and

9:53

scripts and more importantly it list the

9:55

dependencies and their version that

9:57

where project needs to run here is

9:59

something which we're going to be

10:00

discussing later in this course next we

10:02

have a package log.jn file file is

10:05

automatically generated and updated when

10:07

install or modify dependencies it locks

10:09

the version of all of the packages and

10:11

their dependencies to ensure a

10:13

consistent and reproducible build

10:15

envirment something which you don't have

10:17

to worry about okay so next we have a

10:19

simple readme.md file and this file

10:21

provides the summary of what our project

10:23

is about it usually include information

10:25

like project purpose feature and aims to

10:28

accomplish about this spefic specific

10:29

project we can also preview there by

10:31

clicking on this icon and here you can

10:33

see and this is how our preview will

10:34

look like once we push our code to our

10:36

gab repository next we have our V.C

10:39

config.js file and this file is used to

10:41

provide configuration for the V itself

10:44

so yeah that was a lot about the files

10:46

and folders and you don't even have to

10:48

worry about these files and folder to be

10:50

honest and now I'm going to remove all

10:51

of the unnecessary stuff from our

10:53

project time for the cleanup so for now

10:56

we don't need this public folder so I'm

10:57

going to select them and delete them

10:59

next we also don't need this SS folder

11:01

so I'm going to remove that from here we

11:03

also don't need the app. CSS and also

11:06

the index.css as well next we have to go

11:09

inside this men. jsx and just remove

11:12

this line of code so I'm going to just

11:13

remove the SMI file and now finally I'm

11:16

going to go into my f. GSX file I'm

11:18

going to select every single thing from

11:20

this file and I'm going to just remove

11:22

that from here and next I'm going to be

11:24

just creating something called a

11:25

component but you don't have to worry

11:26

about what a component is for now so

11:28

I'll just use like const app and I'll

11:31

just use my arrow function and return

11:34

just H1 or you know what not H1 I'll

11:36

just return like section which will say

11:39

like hello now I'm going to save my file

11:41

and now to run this code I'm going to

11:43

have to open my integrated terminal and

11:45

now just use my npm run Dev so it's

11:47

going to run my code on this port right

11:49

here so I'm going to copy that or you

11:51

can just hold command or control and

11:53

click on there and we are getting this

11:55

error right here this because we now

11:57

successfully created this component but

11:59

we also have to export this so that we

12:01

can use it in other files so I'm going

12:02

to use like export default and then my

12:04

app so if I sve there and I'm going to

12:07

have to refresh there so what are we

12:08

getting we are now getting our hello

12:11

right here which is amazing so yeah this

12:13

is how we going to be removing all of

12:15

that unnecessary stuff from our project

12:17

so what is component components are

12:19

independent and reusable bits of code

12:22

they serve the same purposes jscript

12:24

function but work in isolation and

12:26

return HTML or jsx to be size so

12:29

something which we're going to be

12:30

discussing very soon cregs allows us to

12:33

make our website modular by using

12:35

something called the separation of

12:36

concern so if I ask you to build this UI

12:40

so how can you go about doing that if

12:42

you are coming from HTML cssa and

12:43

JavaScript background you will first

12:45

create index.html file then CSS file

12:48

then Javascript file and in the HTML

12:51

file you will put all of your structure

12:52

for this project then in the CSS file

12:55

you will put all of the styling and in

12:56

the Javascript file you will provide the

12:58

functional to it this process is still a

13:01

separation of concern but in reactjs we

13:03

can do that a bit more better in reactjs

13:06

we can split this entire project into

13:09

multiple components or you can say the

13:11

parts so you can either say like

13:14

components or parts so if you want to

13:16

build this project by using reactjs we

13:18

will start by creating a component for

13:20

the nailbar and in there we will put our

13:22

HTML CSS and JavaScript inside their

13:25

specific file then we will create

13:27

another component for a search bar next

13:29

next for the menu and also for the

13:30

article and also finally we'll create a

13:33

component for the card and we will reuse

13:36

that card again and again in our UI so

13:38

that was about the theory but how are we

13:40

going to make a component a component

13:42

you just have to create a JavaScript

13:44

function but whenever you are creating a

13:46

component you have to keep a few things

13:48

in mind the first thing that you have to

13:50

keep in mind is that the first letter of

13:51

your component name should be uppercase

13:54

you can also create your component by

13:56

either using the function resert keyword

13:58

or you can create your component Arrow

14:00

function syntax as well the final thing

14:02

that you have to keep in mind is that

14:04

anytime you are working with a component

14:06

you have to return some sort of HTML

14:08

from that component Now to create a

14:10

component I'm going to go into my

14:11

app.jsx file and I'm going to remove

14:13

every single thing from there because I

14:15

want to start from scratch so as I said

14:16

that components are just a JavaScript

14:18

function so if I just create a

14:20

JavaScript function by using either the

14:21

function resert keyword or I can also

14:24

create my component by using the arrow

14:26

function so for now I'll just stick with

14:28

this function resert keyword and by the

14:31

way anytime you are creating a component

14:33

there are two things that you have to

14:34

keep in mind number one the first letter

14:37

of the name should be uppercase and the

14:39

rest of them will be lower case so if I

14:41

want to give my component as the name of

14:42

like app the first letter should be

14:45

uppercase and the rest of them can be

14:47

like anything you can create the as

14:49

uppercase or lower case that's only on

14:51

you but the first letter should be upper

14:53

case I'm going to just give it the name

14:54

of like app and the next thing that you

14:56

have to keep in mind is that from the

14:58

component you always like always have to

15:01

return some sort of a GSX we did not

15:03

discuss about GSX not right now but we

15:06

will very soon so I'm going to just

15:08

write my H1 right here and I'll just

15:10

write like hello word so now if I sve my

15:13

file this is how we are going to be

15:14

creating our component but now we have

15:16

to tell our reactjs that now we

15:18

successfully created this component we

15:20

want to render that to our UI so to

15:22

render that to our UI first of all we

15:24

have to export that so that we can use

15:26

the in other places of our project so

15:28

I'm going to just use like export

15:29

default and then F so as soon as I do

15:32

that and save my file now I'm going to

15:34

open my terminal right here I'm going to

15:36

just use my npm run Dev and here you can

15:38

see we are now getting our hello word

15:39

right here from our component so what's

15:41

going on so now we successfully creating

15:43

our component and now we exporting there

15:45

so that we can use this component in

15:47

other part of our project so where we

15:50

are using that component so if I go into

15:52

my main. jsx file right here so here you

15:55

can see we are now rendering this

15:56

component right here so first of all we

15:59

are now importing this component which

16:01

we just created right here inside this

16:03

app.jsx file and now we are exporting

16:05

there and here inside this men. jsx file

16:08

we're now importing this component and

16:10

we are now rendering that to or UI and

16:14

as I said previously that I want you to

16:16

keep in mind this root now we are

16:18

selecting that root right here by using

16:20

document. getet element by ID and we are

16:23

now selecting that root which is inside

16:26

this index.html file as you can see

16:28

right here now we are selecting that

16:29

root so here you can see we have a root

16:31

ID and we are now selecting there by

16:34

using document. element by ID right here

16:37

and now inside that route like this

16:39

route we are now rendering our app

16:42

component right here so that's the only

16:43

reason we're now getting this hello

16:45

world right here so if I change

16:46

something inside that component like if

16:48

I go into there and I'm going to just

16:50

change that to like my own name maybe

16:52

now if I save there and here you can see

16:53

I'm now getting my own name so yeah this

16:55

is how we are going to be creating a

16:57

component and let me just say that once

16:58

again anytime you want to create your

17:00

component the first letter will be upper

17:02

case and the rest of them can be either

17:04

upper case or lower case or that's only

17:06

on you and also we have to return some

17:09

HTML from this function okay so we can

17:12

also refactor this code to use Arrow

17:14

function so I'll just use like const and

17:16

I'm going to just convert this function

17:17

to use the arrow function if you prefer

17:20

this way you can also create your

17:21

component by using this Arrow syntax or

17:24

you are more than welcome to use this

17:26

function Reser keyword right here so

17:28

yeah this is how we are going to be

17:30

working with components welcome to the

17:32

first challenge of this course so here

17:34

is the UI and I want you to split this

17:36

UI into multiple components you don't

17:39

have to write any code for that just get

17:41

a pen and paper if you have that but if

17:43

you don't have a pen and paper you can

17:44

also use some sort of a photo editing

17:46

software which will allow you to just

17:48

Mark a few things inside this UI and

17:50

make them as a separate component and

17:52

yeah we also have another part of this

17:54

challenge which we are going to be

17:55

seeing in a few seconds but I want you

17:57

to go ahead and pause the video and do

17:59

this challenge by yourself so if you can

18:01

do it then come back and watch the

18:02

solution and now I'm going to give you

18:04

my solution so I'm going to use a figma

18:06

for there and if you want to use some

18:07

sort of other Pho editing software you

18:09

are more than welcome to do that so the

18:11

first thing that I want to do is that I

18:12

want to create a component for this

18:15

burger menu so I'm going to just create

18:16

a separate component and I'm going to

18:18

put like all of the structure The

18:19

Styling and also the functionality

18:21

inside that component and then I will

18:24

also create a component for the

18:26

navigation so I'll just create a

18:27

navigation right here and excuse my

18:31

drawing and also my bad uh yeah you get

18:36

the idea so this is how we are going to

18:37

be creating a component for the

18:38

navigation we can also split this entire

18:41

navigation into multiple components but

18:43

we don't have to like this is going to

18:45

be enough for this navigation component

18:47

we will put our logo inside there we

18:50

will also put our search field which

18:52

will allows us to search our uh stuff

18:54

inside this Wikipedia and finally we are

18:56

going to be also providing our create

18:58

account and also the login and we also

19:00

have these three dots and I don't have

19:02

any idea what the hell these three dots

19:04

do okay so that's going to be my second

19:06

component next we're going to be also

19:08

creating a component for the banner in

19:10

some situation we would want to show

19:12

this banner and in a lot of times we are

19:14

not going to be showing this Banner so

19:16

yeah this is going to be basically my

19:18

primary component and there is a big

19:20

difference between like uh huge

19:22

component and a small component which we

19:23

are going to be seeing inside this

19:25

course but not right now so this is

19:27

going to be my third component component

19:29

for the banner okay and also we are

19:31

going to be creating a component for the

19:33

sidebar or you can just give it the name

19:35

of like a side if you want it to but I'm

19:37

going to give it the name of like

19:38

sidebar and I guess that's going to be

19:40

fine okay and also we're going to be

19:43

creating a component for the appearance

19:45

so I'm going to also Mark there as a

19:47

separate component okay so we can also

19:50

split this entire U into like nested

19:53

component as well we can also create a

19:55

separate component for these radio

19:57

button if you wanted to but but we don't

19:59

have to do that okay and also we're

20:01

going to be creating a component for the

20:03

header so now let me just highlight that

20:06

right here just

20:09

like that so this is going to be

20:11

basically our header and finally we are

20:13

going to be creating a component for our

20:15

main content so this is going to be

20:17

basically our huge component which will

20:19

allows us to render all of that content

20:21

right here inside this uh Wikipedia okay

20:25

like once again we don't have to create

20:27

a component for all of there we can put

20:29

all of that entire logic into one

20:32

component if you wanted to but that's

20:34

not going to be the ideal way to create

20:35

our website or our apps so that's why we

20:38

are going to be splitting this entire UI

20:40

into multiple components so yeah that

20:43

was the part one of our challenge one

20:45

next we have to create a new file called

20:47

grid. jsx and inside that file we're

20:50

going to be creating our grid component

20:51

by using the function decoration syntax

20:53

after that we are going to be

20:54

refactoring that code to use the arrow

20:57

function instead and finally we just

20:59

have to render that into our app

21:00

component so once again give it your

21:02

best shot if you can do it that's

21:04

completely okay then come back and watch

21:05

the solution and I'm going to give you

21:07

my solution so what I'm going to do is

21:09

that I'm going to create a component

21:10

folder and I'm going to give the name of

21:12

like G do uh not TSX but genesic and I'm

21:15

going to use my RFC so it's going to

21:17

gives us all of that code but I'm not

21:19

going to do that I'll just create a

21:21

function and now I'm going to give it

21:23

the name of like greed it's not going to

21:24

take any perimeters so I'm going to

21:26

remove them and finally we only have to

21:28

return what H1 and which will just say

21:30

like GRE or hello word would be fine so

21:33

I'm going to sve my file now we have to

21:35

export this component so that we can use

21:36

that in other files so I'm going to be

21:38

using like export default of grid so now

21:40

I'm going to save my file let me go into

21:42

my app.jsx component and let's just

21:45

register that component right here okay

21:48

so if I save my file and here you can

21:50

see we now getting our hello word right

21:51

here which is looking amazing but I'm

21:53

going to go in there and refactor this

21:55

code to use the arrow function so I'm

21:57

going to remove that and change the to

21:58

const and also make there as Arrow

22:01

function so now if I save my file and

22:03

still we getting that same result which

22:05

is saying hello word okay so yeah that

22:07

was our first challenge in this course

22:09

we usually create a separate components

22:12

folder and we put our components inside

22:15

there so I'm going to just create two

22:16

component with the name of like greet or

22:19

greeting. jsx and also add. jsx and by

22:22

the way you can give it any name that

22:24

you prefer and now I'm going to just

22:26

create my greet component right here

22:29

here and I'll just return my H1 which

22:32

will say uh hello or yeah hello would be

22:36

fine I'm going to sve my file and I'm

22:38

going to show you extension which will

22:39

help you a lot so I want you to go into

22:42

your extension area and just search for

22:44

reactjs and once you do here you can see

22:46

I want you to install this extension in

22:48

your vs code just install this extension

22:50

and it's going to give you a lot of

22:51

Snippets okay so throughout the course

22:53

I'm going to show you a lot of uh

22:54

Snippets which you can use but by the

22:57

way if you want to use them so you you

22:58

have to install that in your vs code so

23:00

this component took a lot of time to

23:02

write now in this component I'm going to

23:04

just use r a f c e okay so you just have

23:07

to write there and once you hit enter so

23:10

here you can see it's going to gives us

23:11

the entire boiler plate of our component

23:13

let me just show you there once again

23:16

you just have to write ra fce and hit

23:19

either tab or hit enter it's going to

23:20

give us that entire component right here

23:22

so if I save my file now that we

23:24

successfully created our add component

23:26

and also our GRE component and by the

23:29

way we also have to export that so we

23:30

can use it in other files so we have to

23:32

just use export default and then grid

23:35

okay so if I save my file now the next

23:36

thing that we have to do is that we have

23:37

to register the inside or app components

23:41

so that we can see them on the screen so

23:42

I'll just remove this H1 from here and

23:45

I'll just use my grid first of all and

23:47

as soon as I hit enter here you can see

23:49

it will automatically import this so if

23:51

it didn't you have to import them

23:52

manually so now just close there like

23:55

this and by the way this is how we call

23:57

our component this is how we register

23:59

our component this is how we export them

24:02

and this is how we call them okay so if

24:04

I save my file and here you can see we

24:07

are now getting our hello right here

24:09

which is coming from this create

24:10

component I'll remove that from here and

24:13

I'll also render my ADD component and if

24:15

I hit enter so it's going to

24:16

automatically import there now I'm going

24:17

to save my file and what are we getting

24:19

we are now getting our add right here so

24:21

we can write like anything that you want

24:23

so I'll just write like something cool

24:26

and now if I save my file and we're now

24:27

getting what something cool right here

24:29

so yeah this is how we can create a

24:31

separate component folder and we can put

24:33

our entire components inside there

24:35

welcome to another challenge so in this

24:37

challenge you're going to be creating

24:38

three components and a lot of j6 inside

24:41

there so the first thing that I want you

24:43

to do is that I want you to create a

24:44

header. jsx file and inside that file

24:46

you are going to have to create your

24:47

functional component with the name of

24:49

header and inside that header you're

24:50

going to be returning the header element

24:53

and inside that header element you're

24:54

going to be creating H1 which will say

24:56

like welcome to my website and also so

24:58

you're going to be creating underneath

25:00

this H1 you're going to be creating your

25:01

navigation and that navigation will have

25:03

three anchor tags the first one will say

25:06

home the second one will say about and

25:08

the third one will say contact so that's

25:10

going to be the first part of this

25:12

challenge okay so if you want to give it

25:15

a shot right now so you can totally go

25:17

ahead and give it a shot but now I'm

25:18

going to explain these two and then I'm

25:20

going to give you my solution the next

25:21

thing that you have to do that create a

25:23

photo. jsx file and create your

25:25

functional component inside there it

25:27

will only return the folder element and

25:29

inside that folder element you're going

25:31

to be providing a paragraph which will

25:32

say like copyright uh 2024 or it should

25:36

be 2025 my bad but yeah you can proide

25:39

like basically any basically anything

25:41

that you like but in my case I'm going

25:42

to specify like copyright 2024 or 25 in

25:46

my website and that's the second part

25:48

and now for the third part you're going

25:50

to be creating your main component and

25:52

that main component will just return

25:54

your main element and also inside that

25:57

main element you're to be creating your

25:59

H2 which will say like main content and

26:01

now underneath that H2 you're going to

26:02

be creating a paragraph and you can like

26:04

basically put anything that you prefer

26:07

so give it to your best shot if you can

26:08

do it that's completely okay then come

26:10

back and watch the solution and then I'm

26:12

going to give you my solution and

26:13

basically you're going to be just

26:14

importing there and putting there right

26:15

here inside the app component so now let

26:17

me just show you all of that so the

26:19

first thing that I want to do is that I

26:21

want to create my header. jsx and I'm

26:23

going to be using my RFC for the sem my

26:26

file I'm going to remove this header

26:27

from there and provide my H1 which will

26:29

say like welcome to my website okay so

26:33

that's going to be the first thing next

26:34

we also have to create our navigation

26:36

and inside this navigation we're going

26:38

to be creating a three anchor tag so if

26:40

I just use like this a and times three

26:43

so it's going to give us this anchor tag

26:44

like three times so for the first one

26:46

we're going to be providing a home and

26:48

for the second one we're going to be

26:50

providing about and also for the third

26:53

one we are going to be providing a

26:54

contact okay so if I just write like

26:56

contact and sem my file so it's going to

26:58

form form there for me I'm going to go

26:59

ahead and go to my app and register my

27:01

header component right here okay let's

27:04

just import there and registered that

27:07

here so now if I save my file and here

27:09

you can see we're now getting more

27:10

welcome to my website home about and

27:12

contact so that was the first part now

27:14

in the second part we're going to be

27:16

creating a main component okay so I'll

27:18

just say like main. jsx and inside there

27:21

we're going to be creating our RFC or

27:23

you know what it should be a main you

27:26

know what you can like basically give it

27:27

any name that you prefer but in my case

27:29

I'm going to give it the name of like

27:30

main content and change that to main so

27:33

I'm going to copy there and let me just

27:35

place there right here okay and I'm

27:37

going to also use the H2 which will say

27:39

like main content and now need that

27:41

we're going to be creating our paragraph

27:43

which will say like this is the main

27:45

content and now I'm going to save that

27:47

now let me just go ahead and go to my

27:49

app and register my main component right

27:52

in here and now here you can see we're

27:54

now getting like main context content

27:59

content there we go so now if I save my

28:01

file and now we are getting like main

28:03

content and this is the main content

28:05

which is looking amazing now for the

28:07

final component we're going to be

28:08

creating our footer. jsx and now inside

28:11

there we're going to be using our RFC

28:13

and remove this Dev and change that to

28:16

folder okay let's just provide our

28:18

paragraph which will say copyright

28:21

2025 my website so now if I save my file

28:24

we also have to registered that inside

28:26

our app component l like so okay and I'm

28:31

going to register this semi file and now

28:33

we are getting our copyright 2025 my

28:36

website so that was another challenge

28:39

about the basic component what is jsx

28:42

jsx allows us to write HTML in reactjs

28:45

jsx makes it easier to write and add

28:48

HTML in reactjs so this is how our jsx

28:51

looks like so first of all we have our

28:53

component and inside this component we

28:55

are now returning some HTML now I know a

28:58

lot of you will ask me hose like why

29:00

can't we just call it HTML why are we

29:02

calling it jsx jsx simply means

29:05

JavaScript XML behind the scene we're

29:08

working with JavaScript this is just the

29:10

illusion of HTML this is not HTML code

29:14

behind the scene your reactj compiler

29:16

will compile our code into pure

29:19

JavaScript so don't believe me now let

29:21

me show you now let me write a bit of

29:23

jsx so that you guys can see how we can

29:25

work with jsx so I'll just create a

29:27

section and inside this section I'll

29:29

also provide a bit of ID to it so I'll

29:31

just give the name of like section and

29:33

inside this section I'll create my H1

29:35

which will say my website underneath

29:37

this H1 I'll create my article and

29:40

inside this article I'll create H2 which

29:42

will say like welcome to reactjs now

29:45

underneath this H2 I'll create a

29:47

paragraph and which will say like

29:50

paragraph

29:52

paragraph content or text I'm going to

29:55

also provide a class name to it and by

29:57

the way instead of writing a class you

29:59

have to write a class name and I'm going

30:01

to tell you why but you have to write a

30:03

class name for now and I'll just give

30:04

you the class name of text right here so

30:06

if I save my file and here you can see

30:08

we now getting our result right here so

30:10

if I right click on there and go to my

30:11

inspect element we are first of all

30:13

getting our root and now inside this

30:15

route we have our section with idea of

30:16

section we have our H1 we also have our

30:19

article and inside this article we have

30:21

this H2 and we also have this class we

30:24

are now providing a class name and here

30:26

you can see we are now getting a class

30:28

this is a gs6 rule which I'm going to

30:30

explain in a few seconds but yeah here

30:32

you can see this is how we can write

30:34

HTML inside our JavaScript function so

30:37

to combine all of them this is how we

30:39

can create our component now let me show

30:41

you how our reactjs convert all of these

30:43

HTML to JavaScript and to show you there

30:46

first of all you have to go into this B

30:48

js. and inside there you have to place

30:50

your HTML content so I'll just copy my

30:53

HTML content from here and I'm going to

30:55

just place it right here and what are we

30:57

getting we getting JavaScript so if I

30:59

copy that instead of writing this

31:01

section and article and stuff like that

31:03

I'm going to just remove that from here

31:05

I'll just for my return statement and

31:07

I'm going to place this uh content right

31:09

here I'm going to also remove this stuff

31:11

let's just remove them I'm going to also

31:13

select this comment and hit contrl d

31:16

control D or command D and command D and

31:19

I'm going to just remove that from here

31:20

so if I sell my file now I'm going to

31:22

zoom out a bit and first of all I'm

31:24

going to also copy this line of code and

31:26

I'm going to have to put the at the top

31:28

and you don't have to worry about this

31:30

code we are not going to be writing our

31:31

code like this you don't have to worry

31:33

about this coding so I'm going to save

31:34

my file and now if I go into my website

31:36

and refresh there once again we are

31:39

getting the same result like my website

31:41

welcome to react and paragraph content

31:43

so if I go into the section we have our

31:45

ID we have our H1 article or H2 and also

31:48

our paragraph with a class of text right

31:50

here so if you weren't using jsx so we

31:52

are going to have to create our

31:54

component this way like come on look at

31:57

this this redundancy we are now using

31:59

some djsx and providing a section to it

32:02

then we are providing ID and children

32:05

and there are a lot of things going on

32:07

so instead of writing all of them I'm

32:09

going to totally remove that from here

32:12

and I'll just replace that with this

32:14

return statement and I'm going to also

32:15

remove this first line so this is what a

32:18

jsx is and this is the power of reactjs

32:21

and also jsx in

32:23

reactjs welcome to another challenge so

32:25

in this challenge you're going to be

32:26

practicing ch X so first of all I want

32:29

you to create a file with the name of

32:31

welcome message. jsx and inside that

32:33

file then you have to create a component

32:35

with the name of Welcome message inside

32:37

that component you will have a div and

32:39

inside that div you will have your H1

32:42

first of all and inside that H1 you're

32:44

going to be providing like hello word

32:46

underneath this H1 you're going to be

32:47

also creating a paragraph which will say

32:49

like welcome to learning GSX and finally

32:51

you have to import in the app. j6 and

32:54

render that to the Dom so give it your

32:56

best sh if you can do it that's

32:57

completely okay then come back and watch

32:59

the solution and I'm going to give you

33:01

my solution I'm going to create a file

33:02

with the name of welcome message. jsx

33:06

and inside that we're going to be using

33:07

our rafc to create this component right

33:10

here and first of all we have our div

33:12

and now inside this div we're going to

33:14

be defining our H1 which will just say

33:16

like uh hello word and now underneath

33:19

this H1 we're going to be creating our

33:20

paragraph which will say like welcome to

33:22

learning jsx I'm going to save this file

33:25

now let me go ahead and go to my app.js

33:27

x file and register my welcome component

33:31

right in here okay so I'll just close

33:33

there like so sa my file and here you

33:35

can see we now getting hello word and

33:37

also welcome to learning jsx so yeah

33:40

that was our second challenge whenever

33:42

you're working with jsx there are a few

33:44

rules that you have to keep in mind I'm

33:46

going to show you that rules but first

33:47

of all I'm going to remove this article

33:49

from here I'm going to save my file and

33:51

here you can see we are now getting on

33:52

my website which is looking amazing so

33:54

the first rule that you have to keep in

33:56

mind is that from one component you are

33:59

allowed to return only one parent like

34:02

there can't be multiple parents so what

34:04

am I talking about let's suppose if I

34:06

just move this line of code into new

34:08

line so what are we getting we are now

34:10

getting an error it is saying that you

34:12

are not allowed to create multiple

34:14

parents like this is a parent and this

34:16

is also a parent or I can just write a

34:19

div and here you can see still it's

34:20

going to give us that error right here

34:22

and why is that because as I said that

34:24

our rejs compiler will compile our code

34:27

to JavaScript and that's not allowed in

34:30

JavaScript anytime you are working with

34:32

jsx this is the first rule that you have

34:34

to keep in mind that from one component

34:37

you are only allowed to return one div

34:40

and now inside this div you can do

34:43

anything like you can create any amount

34:45

of nested stuff so you can create your

34:47

H1 you can write anything inside there

34:49

even inside this H1 you can write a div

34:51

and you can write anything inside there

34:53

underneath there but you have to keep in

34:56

mind that from one component you have to

34:58

return only one parent and anything you

35:01

write inside that parent will totally

35:03

work okay so that's the first thing that

35:05

you have to keep in mind the next thing

35:07

that you have to keep in mind is that in

35:09

jsx you have to close all of your tags

35:12

in HTML like that wasn't necessary if

35:14

you want to work with like images so you

35:16

just create your image and you don't

35:18

even have to close that if you don't

35:19

want it to but in jsx you have to close

35:22

there as you can see right here so if I

35:24

just remove there it will give us that

35:25

error right here like j6 element image

35:28

has no corresponding closing tag like

35:30

you have to close there and that doesn't

35:32

matter if you're working with the image

35:34

or if you're working with the divs so

35:36

I'm going to just remove that from here

35:37

and here you can see it's going to also

35:38

give us that error right here and we can

35:40

also make it as a self-closing tag if

35:42

you wanted to but you have to keep in

35:44

mind that anytime you're working with

35:46

jsx you have to close all of your HTML

35:49

tags okay so that's the second thing

35:51

that you have to keep in mind the third

35:53

thing that you have to keep in mind is

35:54

that anytime you are working with the

35:55

classes you are not allowed how to

35:57

provide a class by using the class

36:00

keyword instead of a class you have to

36:02

provide a class name so what am I

36:04

talking about I'm going to just write H1

36:05

and I'll just say like hello and now if

36:08

I just provide class right here I'll

36:10

just write a class and now here I'm

36:12

going to just say like uh my class and

36:15

here you can see it's not going to give

36:16

me any error now if I save my file and

36:18

now if I refresh that and go into my

36:21

console now it's going to gives us this

36:23

error like invalid don't property class

36:25

did you mean class name because what

36:27

JavaScript compiler will now think that

36:29

you're defining some sort of a class as

36:31

we learned in a oop section like object

36:33

oriented programming section in our

36:35

JavaScript course JavaScript will think

36:37

like you are defining some kind of a

36:39

class and like The polymorphism

36:41

Inheritance and all of that concept that

36:43

we learned okay so JavaScript will think

36:46

that you are defining that class but we

36:48

are not defining that class we are just

36:50

providing a class to or element okay so

36:54

to provide a class we have to use our

36:56

class name instead so if I just remove

36:59

there and if I change that to the class

37:01

name and now if I save my file and now

37:03

if I refresh it and here you can see

37:05

that error is now gone so yeah that was

37:08

the third thing that you have to keep in

37:09

mind and now the fourth thing that you

37:11

have to keep in mind anytime you are

37:12

working with the forms in some situation

37:14

we also want to provide a label forward

37:16

input field okay so I'll just use like

37:18

form and I'm going to just remove this

37:20

action because we don't need there and

37:22

now inside this form we will just create

37:24

a label so if I just create my label

37:27

inside some situation we would want to

37:28

provide our four attribute to it so if I

37:30

just write like name and I'll just use

37:33

my name inside there I'm going to create

37:35

my input field which will say like uh

37:37

text would be fine I'll also proide a

37:39

bit of placeholder to it so enter your

37:42

name I'm going to sve my file and now if

37:44

I just refresh there and what are we

37:45

getting we are now getting like invalid

37:47

D property 4 did you mean the HTML 4

37:50

because now once again what JavaScript

37:53

compiler will think that you're creating

37:54

some sort of a full loop okay so we are

37:57

not creating a four Loop we are now

37:58

providing just a four property or the

38:01

four attribute to our label so instead

38:03

of providing a four we have to write our

38:05

HTML 4 okay so I'm going to save my file

38:08

and now if I refresh that and here you

38:10

can see that error is now gone I can

38:12

write anything I want so yeah that was a

38:15

few rules about GSX that you have to

38:17

keep in mind whenever you're working

38:18

with the GSX in this series we learned a

38:21

few rules about GSX and we're going to

38:23

be exploring more throughout this course

38:25

but now I'm going to just make you

38:27

recall those rules okay so the first

38:29

thing that I want you to do is that I

38:30

want you to create a file with the name

38:32

of jsx roles. jsx inside that file

38:35

create a component or a functional

38:36

component with the name of jsx rules and

38:39

then inside that jsx rules component

38:41

you're going to be creating a div and

38:43

inside their day first of all you have

38:44

to write H1 with the title of jsx rules

38:47

and now underneath there you're going to

38:49

be creating a threee paragraph and one

38:51

paragraph will say like jsx must return

38:53

a single parent element another

38:55

paragraph will say like jsx element must

38:57

uh must be properly closed and the third

38:59

one will say like j6 attribute are

39:01

written using a camel case like instead

39:03

of using a class we're going to be using

39:05

a class name this is the most simplest

39:08

challenge okay so give it your best shot

39:10

if you can do it then come back and

39:12

watch the solution and now I'm going to

39:13

give you my solution now let me create

39:15

my component with the name of jsx rules.

39:17

jsx I'll just create my functional

39:20

component Right Here and Now inside this

39:22

functional component the first thing

39:23

that we have is our div and now inside

39:26

this div we have our H1 and I'll write

39:28

like jsx rules and now underneath this

39:30

H1 we're going to be creating a

39:32

paragraph which will say like jsx must

39:34

return a single parent element okay

39:38

that's going to be the first one we're

39:39

going to be also creating another

39:40

paragraph which will select jsx uh

39:43

element must be properly closed and come

39:47

on this should be a close and also we

39:49

have a jsx attribute or written using a

39:52

caml case like so so I'm going to save

39:54

my file we have to remove them and yeah

39:56

that's all simple exercise now we have

39:58

to register this component inside our

40:00

app so I'll just register there right

40:02

here okay so we have our jsx rules so

40:05

I'm going to sa my file and here you can

40:07

see we now getting those rules right

40:08

here so we have our GSX rules so yeah

40:11

that was another challenge in this

40:13

course now let's talk about expression

40:15

in jsx so with jsx you can write your

40:18

expression inside the curly braces and

40:20

the expression can be a react variable

40:22

or property or any other valid

40:24

JavaScript expression jsx will execute

40:27

the expression and give you the result

40:29

okay so here you can see I have my app

40:30

component and now inside this app

40:32

component I have a paragraph and now

40:34

inside this paragraph I'm now writing 2

40:36

+ 2 as it is without providing any curly

40:39

braces nothing to it so it's going to

40:41

gives us the result of 2+ 2 as it is why

40:44

is that because of re will treat it as a

40:46

text but now if you wrap that inside the

40:49

curly braces it's going to give us the

40:50

result of four and why is that now

40:52

reactjs will treat it as a valid

40:54

JavaScript expression so it will execute

40:56

their EX it's going to gives us the

40:58

result of the and we are not just

41:00

limited right 2 + 2 we can also create

41:02

some sort of a variable and we can put

41:03

our values inside there then we can use

41:05

the inside our UI we can even also

41:08

create a function we can also embed that

41:10

function inside our UI and also the

41:13

classes as well so now let me just show

41:15

you all of the in action now let's

41:17

discuss how we are going to be embedding

41:18

Dynamic content in our jsx so first of

41:22

all I'm going to just create my

41:23

paragraph inside this paragraph I'll

41:24

just say like 2 + 2 now here is a

41:26

question for for you what do you think

41:28

will be the result of this code so if I

41:30

save my file I want you to give me the

41:32

answer and the result will be 2 + 2 why

41:35

is that because we are not wrapping this

41:37

code inside the curly brace but now if I

41:40

wrap that inside the curly brace we now

41:43

entered our JavaScript word so if I sell

41:46

my file now and here you can see now

41:48

it's going to gives us for right here

41:50

why is that because now we are running

41:52

this expression inside the JavaScript so

41:55

reactjs compiler will compile this code

41:57

and it will think like this is a

41:58

JavaScript code so it will execute this

42:00

code so if I just write like 2 + 2 is

42:03

equal to outside from this curly braces

42:06

now it's going to giv us like 2 + 2 is

42:08

equal to 4 okay which is amazing so

42:10

that's the first thing that you have to

42:12

keep in mind next I'll just create a

42:13

variable with the name of like my name

42:17

and I'm going to store my name inside

42:18

the like husan webd and now underneath

42:20

this paragraph I'm going to create my H1

42:22

right here and now let's suppose if I

42:24

want to dynamically render my variable

42:27

name inside this H1 how can I go about

42:29

doing there well so if I just write like

42:32

my name if I save my file I'm now

42:34

getting my name right here but I want to

42:36

get this value like hoseen web dev so

42:38

how can I go about doing that to do that

42:41

we have to WRA this variable name inside

42:43

these curly Braes like the curly opening

42:46

brace and the curly closing brace so if

42:48

I save my file and now it's going to

42:50

gives us hosen web dev right here okay

42:52

so this is how we going to be rendering

42:54

our variables dynamically inside our jsx

42:58

we are not limited to just render our

43:00

expression and also our variable name we

43:02

can also provide arrays if you wanted to

43:04

so I'll just create like paragraph I'll

43:06

just say like my friends list and now

43:09

inside this list I'm going to first of

43:11

all open and close my JavaScript word

43:13

and now inside there we're going to be

43:15

creating our array which will say like

43:16

Alex we also have John and also W and

43:21

something like that and Jordan so if I

43:23

sell my file and here you can see we are

43:25

now getting like my friend list we have

43:27

we have Alex John Wah and also Jordan

43:29

right here which is amazing now I'm

43:31

going to create a function and I'm going

43:33

to execute or embed this function

43:35

dynamically inside my GSX so I'll just

43:38

use like multiply it's going to take the

43:40

perimeter of a and also B and it's going

43:43

to return like a * B okay and now

43:46

underneath this paragraph I'm going to

43:47

create yet another paragraph which will

43:49

say like 2 * 2 is equals to and now we

43:52

are going to be entering our JavaScript

43:53

word and now inside this JavaScript word

43:56

we are going to be exit in our function

43:58

which is a multiply and for the

43:59

perimeter I'm going to pass 2 comma 2 so

44:02

if I save my file and what are we

44:04

getting we are now getting like 2 * 2 it

44:06

gives us four so if I change that to

44:08

like 2 * 10 save my file it's going to

44:11

give us like uh 2 * 10 will gives us 20

44:14

but here I'm writing like 2 * 2 and now

44:17

it's going to give us 20 so if I just

44:19

change that to like uh 2 * 10 and now

44:22

the label is totally correct like this

44:23

is going to be the label and this is

44:25

going to be the actual value which we

44:27

are now getting from the JavaScript I'm

44:29

going to undo that and the final thing

44:30

that I want to show you about the

44:31

embedding is that we can also embed a

44:34

special class into our GSX so I'll just

44:36

create a special and I'll just write

44:38

like simple class or something like that

44:41

now I'm going to create a paragraph I'm

44:42

going to proide like uh this is uh

44:45

special class or something like that and

44:47

inside this paragraph what I want to do

44:49

is that I want to create my class name

44:51

and I'm going to just remove this Cordes

44:53

from here and I'm going to provide my

44:54

curly Braes and now inside this curly

44:56

bra Braes I'm going to copy this simple

44:58

class name and I'm going to just place

45:00

it right here so if I sell my file and

45:02

now Watch What Happens so if I select

45:04

this class right here so what are we

45:06

getting we are now getting our simple

45:07

class and now this simple class is

45:10

coming dynamically from our JavaScript

45:13

word right here so I can totally change

45:14

that to like

45:16

um any anything I want so if I save

45:21

there and here you can see it's going to

45:22

give us like anything I want so yeah

45:25

this is how we going to be creating

45:27

stuff by using a JavaScript and this is

45:29

how we going to be embedding there to

45:30

our jsx by using these curly braces in

45:33

this challenge you're going to be

45:34

practicing the dynamic content in

45:36

reactjs so the first thing that I want

45:38

you to do is that I want you to create a

45:39

file with the name of greetings. jsx and

45:42

inside there you have to create your

45:43

functional component with the name of

45:45

greetings so inside that component

45:47

you're going to be returning a div that

45:49

is containing the H1 and that H1 element

45:51

will dynamically display the greting

45:53

message like basically you have to

45:54

create a variable with the name of like

45:56

Hello World or hello or gracias or

45:59

something like that and you have to

46:00

renter that greetings dynamically inside

46:03

this H1 next create a paragraph element

46:05

that dynamically display the current

46:07

dead so if you can't do this

46:10

one okay I'm going to show you the

46:12

solution but yeah at least give it a

46:13

shot if you can do it like doesn't

46:15

really matter okay and yeah here are

46:17

more instruction if you care about that

46:19

and next you have to create a component

46:21

with the name of product info and inside

46:23

that product info component uh you're

46:25

going to be returning a div and inside

46:27

their D use the product object in this

46:30

case not just a product but the product

46:32

object that contains the following

46:34

properties like name will be set to

46:36

laptop price will be set to like 12200

46:38

availability will be set to in stock so

46:41

once you do that then uh render your

46:43

component to the app.jsx and that's

46:46

going to be it so give it your best shot

46:48

if you can do it then come back and

46:50

watch the solution and I'm going to give

46:51

you my solution so I'll just create my

46:53

greed. jsx component I'm going to be

46:55

using my rafc and the first thing that I

46:58

want to do is that I want to greet so

46:59

I'll use like greet which will say hello

47:02

and underneath it or you know what let

47:04

me just show that right here I'm going

47:05

to be using H1 and I will just render my

47:08

GRE uh right here so I'm going to save

47:10

my file let me go ahead and go to my app

47:12

and register my greet right here and now

47:16

I'm going to save my file and here you

47:18

can see we're now getting what hello

47:19

right here which is looking amazing we

47:21

also have to render the DAT so I'll just

47:23

use like that and now let's just use our

47:25

new dat and now rendered there right

47:28

here so I'm going to just provide like

47:30

de as a label and here we're going to be

47:32

rendering our de and now we have to

47:34

access the get date method on there so

47:36

now if I save my file now it's going to

47:38

use like the date is 19 so that was the

47:41

first portion of this exercise now let's

47:44

just create another component with the

47:45

name of uh produ info. jsx jsx there we

47:50

go we're going to be also creating our

47:52

functional component and this functional

47:54

component will have our product so I'll

47:55

just write like product and that's going

47:57

to be object so we're going to be

47:59

providing the name as a property and

48:00

that's going to be set to a laptop we're

48:02

going to be also providing the price and

48:04

price will be set to like 12200 and also

48:07

the availability will be set to in stock

48:09

availability in stock okay so now we

48:12

have to s file now that we have to

48:14

render the name price and availability

48:17

totally dynamically so how can we go

48:19

about doing that I'm going to remove

48:20

this name and now here inside we're

48:23

going to be using our H1 let me just

48:25

provide a label of name and now we are

48:27

going to be using a product. name right

48:29

here now if I sa my file oh first of all

48:32

we have to register this component so

48:34

I'm going to be using like product info

48:36

and hit enter save my file it's going to

48:38

giv us a laptop now I'm going to go in

48:40

there and the next thing that we have to

48:42

do is that we also have to render the

48:43

price and also the availability so I'm

48:46

going to basically duplicate that two

48:47

times and change the levels so I'll just

48:49

change that to price and also provide a

48:52

dollar symbol there and we also have to

48:54

change the name to the price okay and

48:57

also we have to remove this name and

48:59

change their two availabilities so I'll

49:01

just place this availability right here

49:03

because I can't spell that case I'll

49:06

just write like availability here sa my

49:09

file and now we are getting the name of

49:11

the laptop also the price and also the

49:13

availability which is now set to in

49:15

stock so now if I change like any of

49:17

these values so instead of 1 1200 I'm

49:19

going to change that to like 15500 now

49:21

it's going to totally render there

49:23

dynamically and we can also change there

49:25

to like uh computer instead and now it's

49:29

going to giv us a computer okay so yeah

49:31

that was our challenge about the dynamic

49:34

content now let's talk about list in

49:36

reactjs so in reactjs you will render

49:38

your list with some type of loop the

49:41

JavaScript map array method is generally

49:43

the preferred method to use for the list

49:45

so here you can see we have our

49:47

component Right Here and Now inside this

49:48

component we have our numbers array and

49:51

now if you want to it over through each

49:53

number inside this array and render

49:56

there to the

49:57

so we are going to be using first of all

49:59

the curly braces and now inside this

50:01

curly braces we're going to be getting

50:02

our numbers list and then we can use our

50:05

map method on there and now inside this

50:07

map method it's going to take a callback

50:09

function and we're going to be passing a

50:11

number and also the index and now inside

50:13

there we going to be using the UL and Li

50:15

to render our numbers to the Dom so this

50:18

is how we're going to be doing all of

50:19

this so now let me show you the inaction

50:21

now let's talk about how we can work

50:23

with list so first of all we have to

50:25

create a list then we are going to be

50:26

working with the I'll create a numbers

50:28

list and inside these numbers I will put

50:30

like 1 2 3 4 5 and now we have to

50:33

iterate over through each item inside

50:36

that list and do something with that so

50:38

in my case I'm going to just iterate

50:40

over through each item inside this list

50:42

and I'm going to render that to the Dom

50:43

so to do that first of all we are going

50:45

to be using like some sort of a main or

50:47

section or anything like that so that we

50:49

can work with that so then we are going

50:52

to be entering into our JavaScript word

50:54

so that we can use our JavaScript array

50:56

method like like push pop reduce filter

50:59

map and all of that methods in this case

51:01

I'm going to copy the name of this

51:02

numbers array and now if I just use dot

51:05

so here you can see we have all of our

51:07

JavaScript array method like we have ADD

51:09

concare copy within entries every fil

51:12

filter find find index flat flat map and

51:15

we have a lot of them but in this case

51:17

I'm only interested in the map method

51:20

and now here we are going to be passing

51:21

our call back function to it so I'll

51:23

just use like uh number would be fine

51:25

and now for this call back function here

51:27

you can see I want you to notice that

51:30

now in this case we are providing a

51:32

parentheses we are not providing a curly

51:35

braces so I want you to keep that in

51:36

mind so now we are putting these

51:38

parentheses and now if I hit enter right

51:39

here I'm going to just write my ul and

51:41

now inside this UL I'm going to write my

51:43

li right here so now inside this lii a

51:46

lot of people will think that we are

51:47

going to be just copying this number and

51:49

we have to just place it right here and

51:50

S our file and that's going to be a let

51:52

me just say that once again we are now

51:54

iterating over through each element in

51:56

inside this array we now rendering that

51:58

to our browser but now Watch What

52:01

Happens here you can see we now getting

52:02

a number number number and we are not

52:05

getting our numbers right here so to get

52:07

these numbers we have to once again

52:10

enter our JavaScript word so I'm going

52:12

to have to remove them or you know what

52:13

we have to just wrap there with these

52:15

curly braces right here so if I just

52:17

wrap it with this curly braces save my

52:19

file and now we are getting 1 2 3 4 and

52:22

five but there is still a problem now

52:24

you might be asking like what's the

52:26

problem if I go into the console what

52:28

are we getting we are now getting an

52:29

error each child in the list should have

52:31

a unique key prop and why are we getting

52:35

this error we now getting this error

52:37

because later in this course we're going

52:39

to be learning about something called a

52:40

state and state will allows us to mute

52:43

it or change these values like let's

52:45

suppose if I want to remove something

52:47

from this array or if I want to add a

52:49

new element to this array so how can I

52:52

go about doing that so to do that for

52:54

that we are going to be using a state we

52:56

are not there yet so we are not going to

52:57

be discussing a state right now but you

52:59

have to keep in mind that anytime you

53:01

want to change something inside this

53:03

array we have to first of all provide a

53:05

label for that place okay so like let's

53:08

suppose if I want to either remove or

53:10

update or something inside this array

53:12

I'm going to have to first of all

53:13

provide some sort of a unique label to

53:15

it I'll just write like uh 10 for this

53:19

first one and then 20 for the second one

53:22

and 30 for the next one and so on and so

53:24

forth so this is how we going to be Pro

53:26

providing a unique label so anytime we

53:29

remove something from this list or

53:31

reents will know from where we remove

53:34

their specific thing so to do that we

53:36

are not going to be providing our unique

53:38

things right here for each element

53:39

inside our array but instead we are

53:41

going to be providing there for the

53:43

parent so we are going to be using a

53:44

keyword here and that key will always be

53:47

unique like you have to provide a unique

53:49

thing for each element inside this array

53:52

okay so if you provide like one for this

53:54

one and also one for this one it's going

53:56

to give you an error like it's going to

53:58

still say each child should be unique

54:00

okay so now I'm going to copy it and I'm

54:01

going to place it right here and now if

54:03

I save my file if I just refresh there

54:06

and here you can see we now getting 1 2

54:07

3 4 5 and we are not getting that error

54:10

so this is how we going to be itating

54:11

over through each element inside our

54:13

list and this is how we are going to be

54:15

providing a unique key or a unique

54:17

identifier for each element inside this

54:20

list and this is how we going to be

54:22

rendering there to the Dom now I'm going

54:24

to just remove all of that stuff from

54:25

here and I'm going to also remove this

54:27

number from here and I'm going to

54:29

replace that with this huge array and

54:31

here you can see we have our users info

54:33

array and now inside this array we have

54:35

a few objects so we have object one two

54:37

and a lot of them and inside this object

54:40

we have a username we have the email and

54:42

also the location so we have username of

54:44

H then we have some sort of a test email

54:46

and we also have a location and then we

54:48

have the same thing for each object

54:51

inside this array so now I want to itate

54:53

over through each element inside this

54:55

array and I want to render the username

54:58

email and location for each user inside

55:01

this user info so how can I go about

55:02

doing that well to do that we're going

55:05

to be once again using our map method so

55:08

first of all we have to go inside to the

55:10

JavaScript word and then we have to use

55:12

our user info and what is the users info

55:15

users info is that array and now we're

55:17

going to be iterating over through that

55:19

array okay so I'll just use like do map

55:21

method and here I'll just provide a user

55:24

as a perimeter and now inside there

55:26

we're going to be using our ul and as I

55:28

said that we have to provide a unique

55:30

value trade so in this case I'll just

55:32

provide like meth. random and now it's

55:33

going to give us like a random number

55:35

each time we render our content to the

55:37

browser okay so now inside there I'll

55:39

just use my lii we have to go inside to

55:41

the JavaScript word once again and we

55:43

can use our user and then Dot and here

55:46

you can see we have our username

55:48

location and also the email so if I just

55:50

select my username save my file and if

55:52

this is the first time you are working

55:54

with

55:54

reactjs this may look a bit uh crazy to

55:57

you but trust me if you did a bit of

55:59

practice you will get there so I'm going

56:01

to save my file and here you can see we

56:03

now getting our uh usernames right here

56:05

for each person now I'm going to

56:07

duplicate this lineup code and instead

56:08

of providing this username I'm going to

56:10

hit control and space and now we can

56:12

select the location I'm going to

56:14

duplicate there once again and now I'm

56:16

going to hit control NW once again and

56:18

now I'm going to select my email okay so

56:20

I'm going to save my file now let me go

56:22

back and this is how our entire code

56:24

looks like and first of all we have our

56:26

array inside this array we have our

56:28

objects and inside these objects we have

56:31

our username email and also the location

56:33

and now we are iterating over through

56:34

each item inside this array and we are

56:37

now only rendering the username location

56:40

and also the email and here you can see

56:42

we now getting the username location and

56:44

also the email so we can also change

56:47

that to the username email and then

56:49

location and now it's going to gives us

56:51

the same result right here which is

56:53

amazing but there is a optional thing

56:55

that I want to do if you don't care

56:57

about that you don't have to worry about

56:59

that if you don't know what a JavaScript

57:01

destructuring is you can go ahead and

57:02

watch my JavaScript video about there I

57:05

have a complete course on JavaScript so

57:06

if you take that course you would be

57:08

fine so now I'm going to destructure

57:11

this value if you can destructure there

57:13

you don't have to worry about that now

57:14

I'm going to remove this users from here

57:16

and I'm going to provide my cly bra

57:18

right here and I'm going to destructure

57:20

the username also the email and I'm

57:23

going to also destructure the location

57:24

as well and now I no longer have to use

57:27

this users again and again I'm going to

57:29

select that hit contrl d contrl d and

57:32

I'm going to remove that from here okay

57:34

so now if I save my file and now if I

57:36

refresh there still we are getting that

57:38

same result right here but now we no

57:40

longer have to provide that user dot

57:42

again and again for all of these

57:44

properties so yeah this is how we are

57:45

going to be destructuring the properties

57:48

from this array welcome to another

57:51

challenge so in this one you will

57:52

practice how you can render a list of

57:54

data so the first thing that I want to

57:56

do is that create a user list. jsx file

57:59

and inside there create a user list

58:01

component create a users array with the

58:03

following object like this object right

58:05

here each user will have the ID name and

58:07

also the edge then use a map method to

58:10

render each user to the Dom okay so

58:12

that's going to be the first portion of

58:13

this challenge in the next portion

58:15

you're going to be creating a product

58:16

list file and inside that file you're

58:18

going to be creating a product list

58:20

component and inside that component

58:22

you're going to be creating a products

58:23

array and inside this array you will

58:26

have have like these objects which will

58:28

represent different objects so we have

58:29

ID for the object the name price and

58:32

yeah I guess that's going to be fine and

58:34

now finally you have registered that

58:35

inside the app component so give it your

58:38

best shot if you can do it that's

58:39

completely okay then come back and watch

58:41

the solution and I'm going to give you

58:42

my solution so what I'm going to do is

58:44

that I'm going to create my user list.

58:47

jsx component inside that I'm going to

58:49

be using my RFC so the first thing that

58:51

we want to do is they want to create our

58:53

users array so I'll just use like cons

58:55

users and that's going to be set to this

58:57

array and now inside this array we're

58:59

going to be creating different object

59:00

for each object or for each user we're

59:02

going to be providing the ID and also

59:04

we're going to be providing the name in

59:06

this one that's going to be set to lless

59:07

and I'm going to also provide the age of

59:09

25 to there okay so now I'm going to

59:11

duplicate there a few times and I'm

59:13

going to change the ID to one to two and

59:15

also to three I'm going to also change

59:17

the name to Bob and this one to

59:22

Charlie change the edge to 30 and also

59:27

the edge 222 so that's going to be my

59:28

users array and now inside this array we

59:30

have a few users right here now I want

59:32

to itate over through their users and I

59:35

want to render them to the Dom so how

59:37

can I go about doing this so I'll just

59:38

remove this users list and inside there

59:40

we're going to be using our curly Braes

59:42

so we are now entering the JavaScript

59:45

word so now we're going to be using the

59:46

users which is our array so now inside

59:49

there we can use our map method so I'll

59:51

just provide a user and now here for

59:54

each user we're going to be rendering

59:55

the div first of all let's just write a

59:57

div and I'm going to also close this div

60:00

right here semi file and for this div

60:02

we're going to be also providing the key

60:04

and the key which we are going to be

60:05

setting will be user. ID and this ID is

60:09

coming from each of the users right here

60:11

so we have a ID one two and also the

60:14

three so that's done now inside this D

60:16

we're going to be also creating our H1

60:18

which will say name okay so for the name

60:20

we are going to be using like user.name

60:22

I'm going to also duplicate and change

60:24

that to Edge okay and also change this

60:27

label to Edge as well so now I'm going

60:28

to save my file let's just go ahead and

60:30

go to our app and register our user list

60:33

right here so I'll use like users list

60:35

save my file and here you can see we now

60:38

getting each of the user right here so

60:39

we have a Lis Bob and also Charlie so

60:42

that was the first thing now the next

60:44

thing that we have to do is that we have

60:45

to create our product list. jsx

60:47

component inside that we are going to be

60:49

using our rafc and inside there let's

60:52

just Define our products here and that's

60:54

going to be set to array in this array

60:56

will have a few object and each object

60:58

will have the ID the name so I'll just

61:01

write like iPhone or maybe phone would

61:03

be fine and I'm going to also put the

61:05

price of I don't know just a random

61:06

arbitrary price like I don't know 600

61:10

699 or something like there I'm going to

61:12

duplicate there a few times and change

61:15

there to two and also change this one to

61:17

three and I'm going to also change the

61:19

name of that to like laptop instead of

61:20

providing a phone I'm going to change

61:22

that to headphones and let's just also

61:24

change the price to to like 12200 and

61:27

also change the price to1 199 I'm going

61:30

to save my file and this is how we're

61:32

going to be defining our list of object

61:34

okay so now we have to iterate over

61:36

through there so if you want to iterate

61:37

over through there we're going to be

61:39

using a products. map method and it's

61:42

going allows us to itate over through

61:43

each element okay so now inside there

61:46

we're going to be using our div let's

61:48

just close there like

61:50

so sa my file we going to be also

61:53

passing our key today and key will be

61:55

coming from e each of the products we're

61:56

going to be providing like product. ID

61:59

which is coming from this product and

62:01

each will have different ID so that's

62:02

why we are now providing there because

62:04

that's going to be a unique one so

62:05

that's why we are now providing there so

62:07

I'm going to just use like uh H1 for the

62:09

name and I'm going to provide like

62:11

paragraph. name and I'm going to also

62:13

change that two price and change the

62:16

label two price as well so let's just

62:18

provide a dollar symbol I'm going to

62:19

sell my file and now let me go ahead and

62:21

go to my app component and register my

62:25

product product uh list right here s my

62:28

file and I'm going to comment this line

62:30

out and here you can see we're now

62:32

getting different product like we have a

62:33

phone laptop and also the headphones oh

62:36

we are providing a dollar symbol twice

62:38

I'm going to have to remove that in one

62:40

area so I'll just remove that from here

62:42

because we are already providing there

62:44

as a string so I'm going to save my file

62:46

now now that's looking better so yeah

62:48

that was our map method practice or

62:51

challenge now let's talk about the props

62:53

so Props or properties are argument pass

62:56

into react components and props allows

62:58

us to pass data from the parent

63:00

component to a child component props are

63:03

passed to a component via the HTML

63:05

attribute so here you can see I have my

63:07

app component and now inside this app

63:09

component I'm going to be calling my

63:11

user component and now let's suppose if

63:13

I want to pass some sort of a image path

63:15

from the app component which is a parent

63:17

component to the user component which is

63:19

a child component so I'll just write an

63:21

image or you can also write IMG you can

63:24

give it any name that you like and then

63:25

you have to write a equal to sign and

63:27

then you have to specify the path okay

63:29

so we can also specify the name we can

63:31

also provide the image as a number we

63:33

can also provide the is mered flag as a

63:36

Boolean and we can also provide Hobbies

63:38

as an array so this is how we are going

63:40

to be passing our data from the parent

63:42

component to the child component and now

63:44

to receive that data from the parent

63:47

component inside the child component so

63:49

this is how we going to be doing there

63:51

first of all we going to be taking a

63:53

props as a perimeter inside our

63:55

component and then we can use that prop

63:57

and then we can use the do notation to

63:59

access all of that data so I can use

64:00

like prop. image so it's going to give

64:03

us the image and now I can use prop.

64:05

name prop. age and also prop. ismed and

64:08

also prop. Hobbies okay so it's going to

64:11

gives us all of their data from the

64:12

parent component to the child component

64:15

so now let me show you all of the in

64:16

action now let's talk about the props

64:18

like how we are going to be passing our

64:20

data from the parent component to the

64:22

child component first of all we're going

64:24

to have to create our child component

64:25

component and then inside that child

64:27

component we're going to be getting our

64:29

prop okay so I'll just create my user

64:31

component and inside this user component

64:33

I'll just return my section right here

64:35

so if I save there now we have to call

64:37

or register this component inside this

64:39

parent component so I'll just use my

64:41

user component right here and now we are

64:43

going to be passing our data from this

64:45

parent component to this child component

64:49

so how can you go about doing there to

64:51

do that we're going to be using a props

64:53

and if you are coming from the HTML

64:55

background you already used props but

64:57

you didn't even know you are using it

64:59

you've already used this image tag and

65:01

now here you can see these are the props

65:04

for this image tag like we are now

65:06

providing a source and we are also

65:07

providing the alternative text for this

65:09

image props so you already use these

65:12

props but you didn't know that you were

65:13

using a prop okay so now if you want to

65:15

past some sort of a data from this

65:17

parent component to this child component

65:20

so we're going to be using a prop now we

65:22

can provide any kind of data that we

65:23

like so I'll just provide like name and

65:26

now I'll just write like hosan webd and

65:29

by the way this prop can be anything and

65:32

this value can be also anything like you

65:34

can provide banana right here and you

65:36

can provide like orange if you wanted to

65:39

that will work exactly the same so I'm

65:41

going to just undo that to name and now

65:43

I'm just spacing name from the parent

65:45

component to this child component so now

65:48

if you want to access that name inside

65:50

this child component so I'm going to

65:52

have to use my props right here so I'll

65:54

just use like props and now I'm going to

65:56

log these props to the console so I'll

65:57

just use my props right here save my

66:00

file and now Watch What Happens so if I

66:02

just refresh there what am I getting I'm

66:04

getting a name with the value of hosan

66:07

web and where is that coming from that

66:09

is coming from this user prop right here

66:13

so once again if I change that to like

66:14

banana and now if I save there I'm now

66:17

getting that banana right here so if I

66:18

just refresh there I'm now getting that

66:20

banana so yeah this is how you're going

66:22

to be passing your data from your parent

66:24

component to the child compon component

66:26

and this is how you're going to be

66:27

accessing there so now we have to use

66:29

that I'm going to just remove that from

66:31

here and now inside this section I'll

66:33

just use my H1 I'm going to provide the

66:35

label of name and here we have to render

66:38

that inside our JavaScript so we're

66:40

going to be using like props do name

66:42

right here because this is the name of

66:44

for prop if I save them and I'm now

66:46

getting the result right here now I'm

66:48

not only limited to provide the strings

66:50

I can also provide like anything I want

66:52

so I'll just use like Edge and Edge will

66:54

be set to 18 not 18

66:57

22 and I'm going to also provide the

67:00

Boolean value like is married and that's

67:02

going to be set to false we cannot see

67:04

that not right now because we are now

67:06

rendering there to the UI so we will not

67:08

see the result of there but later very

67:10

soon we're going to be also discussing

67:12

about the Boolean values for the props

67:14

as well you will see there very soon

67:16

don't worry about it we can also provide

67:18

the list if you wanted to so I'll just

67:19

use like um coding I'm going to also

67:22

provide like uh reading and also this

67:25

sleeping so if I say that so it's going

67:28

to format that it this way so I'll just

67:30

remove that from here and now we have to

67:32

access that right here so I'm going to

67:34

just put like this is my name and Edge

67:37

and I'm going to render my prop. Edge

67:39

right here I'm going to also render my

67:41

is mared uh Boolean plag so I'll just

67:44

use like is uh married and here I'm

67:47

going to pass my props do is mared and

67:50

now underneath them we are going to be

67:52

providing our H4 of hobbies and here we

67:55

have to just render or Hobbies right

67:56

here come on if I can type it today like

67:59

props do Hobbies so if I sell my file

68:02

and here you can see we now getting our

68:04

name age and also is merried but we

68:06

cannot see the value of there as I said

68:09

that we will very soon but this is just

68:11

a Boolean value and we cannot see that

68:13

not right now and we also have our

68:16

hobbies and hobbies are coding reading

68:17

and sleeping in some situation we would

68:19

also want to provide our images so I'll

68:21

just provide yet another prop for the

68:23

image and here I'm going to just pass my

68:25

own image which is coming from my guub

68:27

repository if you have your own image

68:28

you can totally proide there and now we

68:31

also have to render there right here so

68:32

I'm going to be using my image tag

68:34

instead of providing these quotes I'm

68:35

going to remove that from here and I'm

68:37

going to just render them dynamically so

68:39

I'll just use like props do image or IMG

68:42

and I'm going to also provide some text

68:44

for this alternative text so I'll just

68:46

use like props do I guess name would be

68:49

fine so if I save there and I now

68:51

getting this amazing guy but this is

68:54

super uh this is super huge so I'll just

68:56

have to provide a width of 200 would be

68:59

fine s my file and here you can see I'm

69:01

now getting this card right here so I'm

69:03

now getting my image the name Edge and

69:06

everything right here so this is how we

69:08

going to be passing our data from this

69:09

parent component to this child component

69:12

and this is how we are going to be

69:14

accessing their data by using the props

69:16

and this is how we are going to be

69:17

rendering their data by using the props

69:20

now there is one thing that I want to do

69:22

which is called the prop destructuring

69:24

but if you don't know what to D

69:25

structuring is you can either go to my

69:27

uh JavaScript course and watch what a

69:29

destructuring is or you can just read

69:31

about the you can ask from chgb if you

69:33

wanted to but you have to learn about

69:35

the prop destructuring so because I'm

69:37

going to be using a prop destructuring

69:38

right now so I'll just remove these

69:40

props right here and I'm going to just

69:42

destructure my name Edge and also is

69:45

mered flag and also the Hobbies so now I

69:48

no longer have to use this props again

69:50

and again so I'm going to select one

69:51

hitr dtrl dtrl d contr d control D and

69:56

remove there and now if I save my file

69:58

and here you can see everything is still

70:00

working the way we expect him to work

70:02

okay so now we are destructuring all of

70:03

that properties and now we are using

70:05

that inside our component so yeah that

70:07

was it about the props and that was it

70:10

about the props destructuring time for

70:12

the prompts exercise so in this exercise

70:14

you're going to be creating a products.

70:16

GSX file and inside that you're going to

70:18

be defining the functional component

70:19

with the name of person and it will take

70:21

two props so it's going to take the

70:23

person name and it's going to also take

70:25

the the person Edge okay so now inside

70:27

that person component you're going to be

70:29

using the edge2 which will display the

70:31

person name and then you're going to be

70:33

using a paragraph which will display the

70:34

person Edge so that's going to be the

70:36

first portion of this exercise now in

70:38

the second portion you're going to be

70:40

creating a product. GSX file and inside

70:42

there once again you're going to be

70:43

defining the functional component with

70:45

the name of product and now inside this

70:47

it's going to also take Pro two props so

70:50

you're going to be providing the the

70:51

product name and also the product price

70:54

so you're going to using H2 to display

70:56

the product name you're going to be

70:57

using a paragraph to display the product

70:59

price and finally you have to just

71:01

import it to your app component and

71:03

that's going to be it so give it your

71:05

best shot if you can do it that's

71:07

completely okay then come back and watch

71:08

the solution and now I'm going to give

71:09

you my solution so I'll just create like

71:11

person. jsx component and I'm going to

71:14

be using my RFC inside there and let me

71:16

just go ahead and go to my app register

71:19

my component here so I'll just use like

71:20

person import there and close there now

71:23

I want to provide a prompt to this

71:24

person

71:25

so how can I go about doing there I'm

71:27

going to provide the name and name you

71:30

can provide like basically any name that

71:31

you prefer but in my case I'm going to

71:32

specify my own name and also I'm going

71:35

to provide my Edge which will be set to

71:36

22 so now that we successfully provided

71:39

these uh prop right here so the next

71:41

thing that we have to do is that we have

71:42

to go ahead and go to this person and we

71:45

have to use those props so to use them

71:47

we're going to be using a props and here

71:50

first of all we have to use our H2 not

71:52

H1 but H2 and we're going to be using a

71:55

pro prop. name cuz we are now only

71:57

interested in this name right here so

72:00

that's how we are going to be rendering

72:01

that name next we also have to create a

72:04

paragraph which will render The prop.

72:07

Edge so now if I save my file and here

72:09

you can see we now getting the name and

72:11

also the edge right here so that was the

72:13

first portion of this challenge so the

72:15

next thing that we have to do is that we

72:17

have to create our product. jsx

72:19

component I'm going to be using the rafc

72:22

and once again we have to go to our app

72:24

and register or product component right

72:26

here it's going to also take two props

72:28

so we're going to be providing the name

72:30

and name will be set to iPhone and I'm

72:32

going to provide the price of like a lot

72:34

of price uh I don't know maybe I guess

72:37

that's going to be fine so now let's

72:38

just save this file and go into our

72:40

product and we going to be getting that

72:42

props by using this props object and we

72:45

have to use our H2 to render the PRS do

72:48

what I forgot the name and also the

72:51

price so I'll just render the name and

72:53

also we have to use our paragraph

72:55

and which will say props do price okay

72:58

so now if I save my file and here you

73:00

can see we are now getting hosan and

73:02

also 22 as an ede and we're also getting

73:04

the name of iPhone and the amount of

73:08

price so that's cool and everything but

73:10

the next thing that we have to do is

73:11

that we have to destructure the name and

73:13

the edge and we have to use the inside

73:15

this component so to do that I'm going

73:17

to remove this props like uh yeah I'm

73:20

going to just remove that and I'm going

73:21

to put the name and also the edge we no

73:24

longer have have to use this props dot

73:26

again and again so I'm going to select

73:27

that and hit control D so it's going to

73:29

select that twice and remove there now

73:32

if I save my file and once again here

73:34

you can see the result is exactly the

73:36

same and next we have to go into the

73:38

product and remove this props from there

73:41

and we're going to be providing or

73:42

destructuring the name and also the

73:44

price okay so now I'm going to select

73:46

this props once again and hit contrl D

73:49

and remove the save my file and now we

73:51

are getting exactly the same thing so

73:53

yeah this is how we are going to be

73:55

providing a props this is how we going

73:56

to be destructuring the and this is how

73:59

we are going to be using the inside our

74:00

components now in some situation we

74:02

would want to pass our data from our

74:04

parent component to our child component

74:06

by closing this so what do I mean by

74:08

that let me just zoom in a bit and the

74:10

first thing that I want to use that I

74:11

want to create a components folder and

74:14

I'll provide my card. TSX not TSX but

74:16

GSX inside there now let me use my RFC s

74:20

my file and what I'm going to do is that

74:22

I'm going to call my card component

74:24

right here but I'm not going to call my

74:27

component like so I'm going to close

74:29

them manually like that and now inside

74:32

there what I want to do I want write my

74:33

H1 which will say like my card and I

74:35

will also provide a paragraph which will

74:37

say like this is some content for card

74:41

one okay so now let me just save my file

74:43

and now let me go back so here you can

74:45

see we are now passing this data to our

74:48

card component by closing there but now

74:50

the question is how in the we're going

74:52

to be accessing that data so to access

74:54

that data data there is something called

74:56

the children which allows us to access

74:58

their data from the parent component to

75:00

the child component so I'll use like

75:02

props and here I'll just use like promps

75:05

do children so if I use that now let me

75:08

use my npm run Dev just going to start

75:11

my server let me just write a local host

75:13

right here and what are we getting we

75:15

are now getting like my card and also

75:17

that same paragraph text right here okay

75:20

so we can also destructure them by just

75:22

removing these prompts and destructure

75:23

our children so now we no longer have to

75:26

specify this props do and now we have to

75:28

save our file and here you can see we

75:30

are still getting there and yeah I'm

75:32

going to just duplicate there like a few

75:33

times so that was for the one and I'm

75:36

going to just duplicate there like two

75:37

times so this is going to be my carard

75:40

two and then card three and yeah we are

75:43

now getting all of the data from our

75:45

parent component which is this app

75:47

component and we are now passing that to

75:48

the card component and this is how we

75:50

are going to be accessing there by using

75:52

the children now let's talk about the

75:54

conditional renderings so conditional

75:55

rendering allows us to dynamically

75:57

display different UI component or

75:59

content based on a specific condition

76:01

this enables us to create more

76:03

interactive and responsive user

76:05

experiences so there are a few ways to

76:07

conditionally render or UI the first way

76:09

is to just use the ifnl statement and

76:11

also we have another ways like using the

76:13

trary and also the end operator so now

76:16

let's talk about the first one which is

76:18

the ifnl statement so here you can see

76:20

we have two component like we have the

76:21

valid password component and we also

76:23

have the invalid password component now

76:25

we are going to be creating yet another

76:27

password component and then we are going

76:29

to be calling there inside our app

76:31

component and now inside this app

76:33

component we are going to be passing the

76:34

isid prop to it and that's going to be

76:36

said to true now we will receive that

76:38

prop inside the password component and

76:41

then we're going to be providing our

76:42

check so if our is valet prop is true

76:45

we're going to be rendering the wet

76:47

password component so if that's not the

76:49

case we're going to be returning the

76:50

invalid password component so we can use

76:53

that by using the ifnl stat and we can

76:55

also refactor this code to use the

76:57

JavaScript Turner so to use that here

77:00

you can see I'm going to comment all of

77:01

that code out and now I'm going to be

77:02

using my trary operator so if is valid

77:05

prop is equal to true we're going to be

77:07

rendering our valid password component

77:10

but if that's not the case we're going

77:12

to be returning the invalid prop

77:13

component here is another example I have

77:15

a card component and now inside this

77:17

card component I have my groceries and

77:20

now here I'm going to be checking if

77:22

groceries. length is greater than zero

77:25

and then we are going to be displaying

77:26

this UI but if that is not the case like

77:29

if you don't have any content inside the

77:31

groceries list then it's not going to

77:33

show us anything so without wasting any

77:35

time now let's get into the coding now

77:37

let's talk about how we are going to be

77:38

rendering our UI based on some sort of

77:40

condition so to do that I'm going to

77:42

create three components so the first

77:44

component I'm going to create will be AA

77:46

password component which will only

77:48

return like H1 valid

77:50

password I'm going to duplicate that and

77:53

I'm going to change that to invalid pass

77:54

password and also the component name to

77:57

invalid password as well okay so that's

78:00

going to be my first two component I'm

78:02

going to also create a component for the

78:04

password itself and here inside there

78:06

we're not going to be returning anything

78:08

I'm going to call this component my

78:09

password component right here inside my

78:11

app component and I'm going to also give

78:13

it the prop off is valid and that's

78:15

going to be set to true now inside my

78:17

password component I'm going to also

78:19

destructure that prop which is the is

78:21

wellet prop now inside this password

78:23

component I'm going to be checking if is

78:26

valid so in that situation we are going

78:28

to be returning the valid password

78:30

component and if that's not the case

78:32

we're going to be returning the invalid

78:34

password component right here so now let

78:36

me just say that once again first of all

78:38

we are creating two component like the

78:39

valid password and also the invalid

78:41

password and we are also creating a

78:43

password component which is taking the

78:45

prop of is valid now that is set to True

78:48

based on that prop we now checking if

78:50

that is said to True render this

78:53

component if there is not set to true

78:55

then render this component so now in

78:57

this case the is valid is set to true so

79:00

it's going to giv us the result of valid

79:02

password component which is the valid

79:04

password and here you can see we now

79:06

getting the valid password component why

79:08

is that because is valid is now set to

79:11

true so it's going to gives us the valid

79:13

password component right here but now if

79:15

I make that is false so now let me just

79:17

change that to false and now we are

79:18

getting an invalid password component

79:20

right here because what is valid prop is

79:23

set to false so it's not going to render

79:25

this UI instead it's going to render

79:27

this UI right here so that was the first

79:30

way we can render our components based

79:32

on some sort of a condition now we can

79:33

totally refactor this code to use a

79:35

trinary operator so I'm going to comment

79:37

this line out and you know what I'm

79:38

going to also comment that line out and

79:40

I'll just return like is valid and if

79:43

that's the case we're going to be

79:44

returning the valid come on valid

79:46

password component and if that's not the

79:48

case we're going to be returning the

79:50

invalid uh password component right here

79:52

so if I save that that's going to work

79:54

exactly the same so if I change that to

79:57

true and it's going to give us that

79:59

valid password component now I can also

80:01

refactor there a bit more if I wanted to

80:03

so I can totally remove this coding I

80:05

can also remove this return statement

80:06

and I'm going to also remove this cly

80:08

braces from here semi file and this is

80:11

how we are going to be conditionally

80:12

rendering our UI now let me give you one

80:14

more example by using the end operator

80:16

so I'm going to just remove all of that

80:17

coding from here and now I'm going to

80:19

create a separate component with the

80:20

name of card so I'll just give it the

80:22

name of card and I'm going to remove

80:24

that from here here and this is how we

80:25

going to be creating our component and

80:27

I'm going to also call this component

80:29

right here inside my app so I'll just

80:31

remove that and render my card component

80:33

right here so if I save there and we are

80:35

now getting our card right here which is

80:37

looking amazing now inside this card

80:39

component I'm going to provide my items

80:41

right here so cons items and we will

80:44

have a few items right here inside this

80:45

component and now let me just place this

80:47

item right here so we have a few items

80:50

inside this list so what I'm going to do

80:52

is that I'm going to just remove this

80:54

card from here and I'm going to just

80:55

write my H1 card and I'm going to also

80:57

pass my card Emoji right in here now

81:00

underneath that I'm going to

81:02

conditionally render my UI so I'll just

81:04

check like items do length so if the

81:06

items. length is greater than zero and

81:09

we are going to be rendering our H2 so

81:11

I'll just use my H2 right here and I'm

81:13

going to say like you have um items.

81:16

length we're going to be checking the

81:18

length of four items and then items in

81:20

your card so if I save my file and here

81:23

you can see it's going to giv us like

81:25

you have four items inside your card so

81:28

if I just remove like one of them I'm

81:29

going to just remove that sa my file I

81:31

it's going to give us like you have

81:32

three items inside your card and now if

81:35

I completely remove every single thing

81:37

from this card so now this condition is

81:39

false like items. length is no longer

81:42

greater than zero it is equal to zero so

81:45

we not going to be getting this result

81:47

right here so if I sa there and it's

81:48

going to only gives us the card which is

81:50

coming from this H1 but it's not going

81:52

to gives us this result as you can see

81:54

right here here so if I just undo that

81:56

and let me just get there back s my file

81:58

and now we are getting like you have

82:00

four items inside your card now

82:02

underneath there I'm going to just

82:04

render my items right here so I'll just

82:06

use like ul and now inside this UL I'm

82:08

going to provide my H4 and let's just

82:11

provide like um products or something

82:13

like that now underneath this H4 I'm

82:15

going to go into my JavaScript once

82:16

again and I'm going to be using items.

82:19

map method and here we're going to be

82:21

passing our specific item and now inside

82:23

there we're going to be passing Li and

82:25

which will just say like uh item right

82:28

here and we're going to be also passing

82:29

a key to this so for the key I'll just

82:31

use like key uh m. random and now if I

82:34

save my file and here you can see we are

82:36

now getting our item right here like we

82:37

have a wireless airbuds power bank new

82:40

SSD Hur and stuff like that but if I

82:43

remove every single thing from here semi

82:46

file we are only getting this products

82:48

we are not getting our uh item Des

82:50

because we are not rendering anything

82:52

right here because our card is totally

82:54

empty and we are also not getting

82:56

anything that's because this condition

82:58

is false so if this condition is false

83:00

we not going to be getting this UI time

83:02

to tackle the conditional rendering

83:04

challenge so the first thing that I want

83:05

you to do is that I want you to create a

83:07

weather. jsx file and inside that file

83:09

you're going to be creating a functional

83:11

component with the name of weather and

83:12

it will take the prob of temperature and

83:15

then I want you to use the if else if

83:17

and else statement to conditionally

83:18

render different messages based on the

83:20

temperature value which we're going to

83:22

be specifying in a few seconds so if the

83:24

temperature is below 15 display its cold

83:27

outside and if the temperature is

83:29

between 15 and 25 then display it nice

83:32

outside and if the temperature is above

83:34

25 then display like it's hot outside so

83:37

that's going to be the first portion of

83:39

this challenge now in the second

83:41

challenge that we have to do is that we

83:42

have to create a user status component

83:45

and inside that component it will also

83:47

take two Boolean prop the first one will

83:49

be uh logged in and the second one will

83:51

be is admin so use the end operator to

83:54

display the message for admin and also

83:57

for the normal user as well so if the

83:59

log in and also there is admin both of

84:02

these props are true which means like

84:04

the person is admin so then I want you

84:06

to display like welcome admin so if

84:09

that's not the case and if only the log

84:11

in is true then display like welcome

84:13

users so that's going to be the second

84:15

portion now for the final one you have

84:17

to create a greetings. jsx file inside

84:19

that file you're going to be creating a

84:21

functional component with the name of

84:22

greetings and it will also take uh what

84:25

do we call it the prop of time of the

84:26

day you you can provide like morning or

84:29

afternoon or evening or something like

84:30

that then I want you to use the trary

84:33

operator so if the time of the day is

84:34

equal to morning then display good

84:37

morning so if the time of the day is

84:39

equal to afternoon then display good

84:41

afternoon and finally you have to just

84:43

import all of that component inside the

84:45

app.jsx and check out the result off

84:48

there so give it to your best sh if you

84:50

can do it that's completely okay then

84:52

come back and watch the solution and now

84:53

I'm going to give you my solution so

84:55

what I'm going to do is that I'm going

84:57

to Define my weather. jsx component and

84:59

we're going to be using our rafc inside

85:02

there we can Define like let temp and

85:04

temp will be equals to 26 for the first

85:06

one okay and now here the first thing

85:09

that we have to do or you know what we

85:10

don't even have to provide all of that

85:12

let's just remove that from here we're

85:13

going to be using our if else if an else

85:15

statement so let's just provide for the

85:18

condition like temp so if the

85:19

temperature is less than 15 so in this

85:22

situation we going to be rendering uh

85:24

what do we call it it's cold outside

85:28

okay and if that's not the case so what

85:30

we have to do we have to check for the

85:32

temperature if temperature is greater

85:34

than or equal to 15 and temperature come

85:38

on temperature is less than or equal to

85:40

25 so in this situation we're going to

85:42

be rendering this H1 one more time and

85:45

it will say like uh it's nice outside

85:49

okay and finally if that is not equal to

85:52

anything so we are going to be just

85:53

returning but you know what we also have

85:55

to specify the lsf one more time and for

85:59

this condition we're going to be

86:00

providing like if temperature is greater

86:02

than 25 so in this situation we going to

86:04

be returning our H1 one more time and we

86:07

will say like it's hot outside okay so

86:10

now I'm going to sve my file and then we

86:13

have to register this component inside

86:14

our f. TSX file so I'll just use like

86:17

weather TSX or jsx to be precise so I'm

86:20

going to save my file and check this out

86:22

so it's going to give us like it's hot

86:24

outside but now if I change there to

86:27

like I don't know maybe 15 and now if I

86:29

save my file so here you can see it's

86:31

going to use like it's nice outside and

86:34

now if I change that to like I don't

86:35

know maybe uh three would be fine so if

86:38

I change that to three so it's going to

86:40

giv this like it's cold outside so that

86:42

was the first portion of this Challenge

86:45

and now the next thing that we have to

86:46

do is that we have to create our user uh

86:49

user status. jsx component so I'm going

86:52

to be using my RFC inside there and also

86:55

I'm going to go into my app and let's

86:57

just comment this line out and I'm going

86:59

to render my user status component and

87:01

it's going to take two props so it's

87:03

going to take like uh logged in and I'm

87:06

going to set there to true and then is

87:08

admin and I'm going to also set that to

87:10

false I'm going to save my file and now

87:12

let me go ahead and use those props

87:14

inside this component so we are going to

87:16

be just taking the props and let's just

87:18

provide our check so I'm going to remove

87:20

that from here and we're going to be

87:21

checking there if prop. uh logged in l o

87:26

GED logged in and props do is admin so

87:30

in that situation we're going to be

87:31

returning like H1 which will say like

87:34

welcome admin because uh if the user

87:37

already logged in and if the user is

87:39

also in admin so we're going to be

87:40

showing like welcome admin so if that's

87:43

not the case so we are going to be only

87:45

showing like uh H1 which will say like

87:48

welcome

87:49

normal or welcome user okay so I'm going

87:53

to save this file right right now and we

87:55

already registered there right here so

87:57

here you can see it's going to give us

87:58

like welcome user and why is that

88:00

because logged in is set to true but is

88:03

admin is set to false so that's why we

88:05

are now getting like L welcome user but

88:07

if I change that instead of a false I'm

88:09

going to change that to true and save my

88:11

file now it's going to use this welcome

88:13

admin right here so that was the second

88:15

portion of our Challenge and now for the

88:17

third and final one we are going to be

88:19

creating our greeting. jsx component

88:22

this is use our RFC e sa my file and

88:25

registered there right here inside my

88:27

app so I'll just use like greetings and

88:29

close there it's going to also take the

88:32

prop of time of day and I'm going to set

88:35

there to morning okay and let's just go

88:38

ahead and go to our component inside

88:40

this component we're going to be

88:41

receiving our props once again and

88:43

instead of providing this return

88:44

statement we're going to be using aary

88:46

operator so I'm going to be using like

88:47

if prop. time of day is triple equals to

88:52

morning so in this situation we are

88:54

going to be rendering over H1 this is

88:56

right our H1 God damn what the hell am I

88:59

doing and which will say like good

89:01

morning and if that's not the come on if

89:06

that's not the case so we are going to

89:08

be rendering H1 one more time and which

89:10

will say like uh good afternoon

89:13

afternoon and I'm going to save my file

89:15

and we also have to return there so

89:18

let's just check this out here you can

89:20

see it's going to gives us good morning

89:21

then because we are now providing the

89:23

time of the day is morning but if I

89:26

change that to like uh afternoon come on

89:30

afternoon and sell my file so it's going

89:32

to give us like good afternoon so let me

89:34

go there and we can also destructure our

89:37

prps so we can just uh destructure like

89:39

time of day copy there and we no longer

89:42

have to provide our prop dot so let's

89:45

just save there and it's going to still

89:46

gives us that same result right here so

89:49

yeah that was our challenge

89:52

about uh God damn it that was our

89:54

challenge about the conditional

89:55

rendering in reactjs there are a lot of

89:58

ways to style our component but in this

90:00

specific section we are going to be only

90:02

learning about the basics but later in

90:04

this course we are going to be also

90:05

learning about the popular libraries

90:07

like redex and dii tell CSS shars and UI

90:11

and stuff like that but for now we are

90:13

going to be only learning about the

90:14

basics of styling so what I'm going to

90:16

do is I'm going to just create my

90:17

section and inside this section I'm

90:19

going to just write my H1 inline style

90:22

and now if I save my file and here you

90:23

can see we are now getting our inline

90:25

style right here which is looking

90:26

amazing so if I want to change the color

90:28

of that or if I want to provide some

90:30

sort of a styling for that so I can just

90:32

use a style attribute and equal to and

90:35

then double curly brace not a single but

90:38

double curly braces you have to keep

90:40

that in mind first of all you're going

90:42

to be opening your curly braces you're

90:43

going to be opening double curly braces

90:45

and then you're going to be closing

90:47

double curly braces and now inside there

90:49

you can write like all of your CSS

90:51

styling right here which youve already

90:53

learned in my HML and CSS courses so

90:55

I'll just write like color and I'm going

90:57

to just write like um black uh not black

91:01

but uh red so if I save there and here

91:04

you can see we are now getting a red

91:05

color right here which is looking

91:06

amazing and now I'm going to also

91:08

provide a background color to it but

91:10

there are a few things that you have to

91:11

keep in mind in CSS we write our

91:14

background color like this first of all

91:15

we write a background and then Dash and

91:17

then color but this is not a CSS you not

91:21

currently working with the CSS you are

91:22

working with the reactjs so you have to

91:25

keep in mind that you're going to be

91:26

writing your CSS in one line like a

91:29

background color but this is not

91:31

accurate here you can see we are also

91:33

getting this suggestion like background

91:35

color as a camel case so if I click on

91:38

that anytime we have some sort of a

91:40

property which have two name like

91:42

background and also the color so we are

91:44

not going to be providing spaces we are

91:45

not going to be providing a dashes and

91:47

we are also not allowed to write that in

91:49

lower case or in totally upper case we

91:52

have to write that as a one word and

91:54

also we have write as a camel case just

91:57

like this and I'm going to just a value

91:59

for this I'll just use like teal and I'm

92:01

going to also provide a bit of padding

92:02

to it so padding will be two r or

92:04

something like that and yeah I'm going

92:07

to save my file and here you can see we

92:08

now getting more styling right here I'm

92:10

going to just change the color of there

92:12

to like white and now there looking

92:13

better so this is how we are going to be

92:15

providing our styling in line so first

92:18

of all you have for a style attribute

92:19

and then double curly braces is opening

92:22

and double curly braces is closing and

92:24

you also have to keep this rule in mind

92:27

so that was the first way now we can

92:29

also extract all of that uh styling from

92:31

here and we can put there some sort of

92:33

object and then we can reference that

92:35

object inside the style so I'm going to

92:38

go to the top and here I'll just create

92:40

my variable with the name of like Styles

92:42

and I'm going to just place my styling

92:44

right here but first of all we have to

92:46

wrap the inside this curly braces like

92:48

as a object and then we have to place

92:50

our styling there I'm going to save my

92:52

file and I'm going to copy the variable

92:54

name from there and we have to just

92:55

place it right here but in this case we

92:58

are not going to be writing double curly

93:00

braces we are going to be only working

93:02

with the single curly braces so that's

93:04

our JavaScript word right here now

93:06

inside this JavaScript word we are now

93:08

rendering or styling totally dynamically

93:11

so if I save my file and here you can

93:13

see if I just refresh there that's going

93:15

to still work exactly the same so I can

93:17

just change the color of that to like uh

93:19

Crimson or something like that and here

93:21

you can see it's going to still work

93:22

right here so that the second way to

93:24

style our component now let me show you

93:26

one more way so I'm going to just remove

93:27

all of that content from here and also

93:29

this H1 so if I save my file and I'm

93:32

going to go in there I'm going to remove

93:34

this component folder from here and I'm

93:35

going to create my file which will be

93:37

index. CSS file okay and now inside this

93:40

index. CSS file we're going to be

93:42

placing all of our CSS like body will be

93:44

set to this color and also we are

93:46

providing a display flex and all of that

93:48

kind of stuff which you've already

93:49

learned in my CSS course so here you can

93:51

see we're now providing all of our

93:53

styling now I'm going to go into my

93:54

app.jsx component and inside that now if

93:57

I want to use all of that styling the

93:59

first thing that we have to do is that

94:01

we have to import that in this component

94:03

so I'm going to be just using like

94:04

import and then we have to write a

94:06

string and then we have to go one level

94:07

up above we have to just write index.

94:10

CSS so if I save my file and now if I

94:12

hold control and click on there it's

94:14

going to brings us to this index.css

94:16

file right here so now inside this

94:19

section I'll just use my H1 and I'll

94:21

just write like separate file for

94:24

styling or something like this so if I

94:26

save there and now we are getting this

94:28

result right here so now all of our

94:29

styling are now successfully applied to

94:32

this component so I can totally comment

94:33

this line out and now it's not going to

94:35

gives us any styling and I can totally

94:37

uncomment there and here you can see we

94:39

now getting all for styling so yeah this

94:41

is how we are going to be styling our

94:43

component by using a inline and separate

94:45

object and also index. CSS file and now

94:48

let's talk about the icons like how we

94:50

are going to be iring icons in our

94:53

project to do that there are a lot of

94:55

icons libraries for reactjs but this one

94:58

is a bit popular one and this is a

95:00

reactjs icon Library so first of all we

95:03

have to install this library inside our

95:05

project then we will be able to use that

95:07

so now I'm going to go into my react

95:09

icons and here you can see we have like

95:11

a lot a lot of icons right here so to

95:14

install that we going to be using this

95:16

command so I'm going to just copy there

95:18

and now I'm going to open my terminal

95:19

right here and just close every single

95:23

thing I'm going to just place my command

95:24

right here which is npm install react

95:26

icons D- s so if you don't want to

95:29

provide this D- sell you don't even have

95:31

to do that okay so I'm going to just hit

95:32

enter right here so it's going to

95:33

install that inside this project and

95:36

here you can see that's now successfully

95:37

installed and as I mentioned in the

95:39

beginning of this video that if we

95:41

install any third party libraries or

95:43

packages that's going to be available

95:45

inside this node module so I can totally

95:47

search for the react uh icons so you

95:50

know if I just search for the icons and

95:52

here you can see we have have our react

95:54

icons right here so if I open that here

95:56

you can see we have like a lot of icons

95:59

so this is how we are going to be adding

96:00

that to our project and now let's talk

96:02

about how we are going to be using the

96:04

inside word project so to use that the

96:06

first thing that we have to do is that

96:07

we have to import that specific icon

96:09

which you want to use so I'll just go

96:12

ahead and search for a specific icon so

96:14

I'm going to go to the home there are a

96:16

lot of icons I'm going to search for the

96:18

cart and here you can see it's going to

96:20

give us a lot of cards right here let's

96:22

suppose if I want to use this card I'm

96:23

going to click on there now I can

96:25

totally copy there and here you can see

96:28

this is how we are going to be importing

96:30

there and now we can totally use that by

96:32

using this icon so I'm going to copy

96:33

that from here now let me just place it

96:36

right in here save my file and now if I

96:38

go there refresh

96:41

there we have to run our terminal so npm

96:44

run Dev now if I refresh there so here

96:47

you can see we're now getting our icon

96:49

now I can search for something else like

96:51

I don't know computer or something

96:54

it's going to give us this computer I

96:55

can totally copy

96:58

there I'm going to go to the top and I'm

97:00

going to just place a right here I'm

97:02

going to copy that from there now let me

97:05

just place the here and close the my

97:09

file check it out and we are now getting

97:11

our computer right here so yeah that was

97:13

it about the styling and also about the

97:15

icons Welcome to The Styling challenge

97:17

so in this challenge I want you to

97:18

create a style card. jsx file and inside

97:22

there you're going to be defining the

97:23

function functional component with the

97:24

name of style card and use the inline

97:27

style here the keyword is use the inline

97:29

style to style your component so by

97:32

using the inline style you have to

97:33

change the background color to light

97:35

blue also provide a pairing of 20 pixel

97:37

provide a border radius of 10 pixel and

97:40

also change the color of the text to

97:41

like dark blue or something like that

97:43

okay so that's going to be the first

97:45

portion of this Challenge and now for

97:46

the second portion we going to be

97:48

creating our profile card and now inside

97:50

this profile card component we're going

97:52

to be defining our Style by using the

97:55

object and here the keyword is the

97:57

object okay so inside that object we're

97:59

going to be defining our style like the

98:01

background color will be set to light

98:03

gray the pairing will be set to 15 pixel

98:05

board radius will be set to 8 pixel and

98:07

text color will be set to totally black

98:10

okay so apply those styling by using um

98:13

come on inline CSS and also by using the

98:16

object okay and then finally for the

98:18

final portion you're going to be

98:19

installing the Rea icons by using this

98:21

command and then you have to render this

98:24

fa beer icon that's going to be it you

98:27

can also provide the size today like 30

98:29

pixel and you can also change the color

98:32

and yeah finally you have to render the

98:34

inside your app component or register

98:36

the inside your app component so you can

98:38

see the result so now let me just go

98:40

ahead and create my component right here

98:42

so I'll start by defining the style

98:44

card. jsx component this is use our RFC

98:48

go back and go to my app component and

98:51

inside there we going to be registering

98:53

string word style card like so and

98:56

inside the style card the first thing

98:58

that I want to do is that I want to show

99:00

all of these styling so set the

99:02

background color to uh light blue and

99:04

also provide a padding radius and change

99:07

the color of there so I'm going to

99:08

remove this stuff from here and provide

99:11

a style and use my double curly braces

99:14

inside there once we have to change the

99:16

background color so I'll use like

99:18

background color and for the background

99:21

color we're going to be providing like

99:22

light blue and also we have to provide

99:24

the padding and padding will be set to

99:26

20 pixel we're going to be all come on

99:29

we are going to be also providing the

99:31

Border radius not border right but r a d

99:34

i u s border radius will be set to 10

99:37

pixel and we're going to be also

99:38

providing the color and the color will

99:40

be set to dark blue okay so I'm going to

99:42

save my file I'm going to also provide

99:44

my H1 which will say like um style or

99:49

yeah style card they're going to be also

99:51

providing a paragraph which will say Lam

99:52

20 or maybe LM 30 would be fine so if I

99:55

save my file and and now let me check

99:58

this out so we are now getting this

99:59

style component by using the inline

100:01

style so that's looking amazing I'm

100:03

going to also go ahead and go to my

100:05

components folder one more time and

100:07

we're going to be defining our profile

100:10

card. jsx inside there I'm going to use

100:13

my RFC go to my app component and

100:17

comment this line or you know I'm not

100:18

going to comment this line out I'm going

100:20

to be using a profile card and render

100:22

there right right here inside this

100:24

component now for this one we are going

100:26

to be defining these styles to it first

100:28

we have to change the background color

100:29

to light gray we also have to provide a

100:31

pairing border radius and and also text

100:34

color will be set to totally black okay

100:36

so what I'm going to do is that I'm

100:38

going to Define all of that styling by

100:39

using my style object so I'll use like

100:42

Styles and inside there we're going to

100:43

be providing our background color let's

100:46

just provide our light gray inside there

100:48

we're going to be also providing a

100:50

pairing which will be set to 15 pixel

100:52

and the B order radius r a d i u s order

100:57

radius will be set to add pixel and

100:59

let's just provide a color and that's

101:01

the default color which will set which

101:03

will be set to Black and now we have to

101:05

use the styling inside work card so how

101:08

can I go about doing that well we just

101:10

have to write a style and one curly

101:12

braces not twice but only one curly

101:15

braces and we have to render our sty

101:17

inside there I'm going to remove this

101:19

profile card and provide my H1 which

101:21

will say hello word and now underneath

101:24

there let's just put our paragraph which

101:25

will say like LM of 30 so I'm going to

101:28

save my file and now we are getting a

101:30

gray card and also this card so both of

101:33

these stuff are now totally done the

101:35

next thing that we have to do is that we

101:37

have to install the react icons so I'm

101:39

going to stop my server and and I'm

101:41

going to be using npmi or you can also

101:44

use npm install if you wanted to but I'm

101:46

going to use like npmi and then react

101:49

icons now they successfully installed so

101:51

I'm going to run my server once again

101:53

and go into my components folder and

101:56

Define another component which will say

101:57

like icon uh component. jsx so I'll use

102:01

like rafc inside there and here the

102:05

first thing that we have to do is that

102:06

we have to import the fa component or fa

102:09

beer component so we are going to be

102:11

grabbing them from the react icons and

102:14

we are going to be grabbing them from

102:15

the fa so I'll just use like fa a beer

102:19

and I'm going to render there right here

102:21

inside this component so I'll use like

102:23

fa beer and just render that here save

102:27

my file and now we are getting oh we are

102:29

not getting there let me just refresh

102:32

there we should be getting there oh we

102:35

are not oh that's because we did not

102:37

render our component here so I'm going

102:39

to use like icon component icon

102:42

component there we go and save my file

102:45

and now we are getting this beer icon

102:46

right here as you can see now let me

102:49

just duplicate this line of code and I'm

102:51

going to also change the size of that

102:53

like 30 sa my file so it's going to

102:55

gives us like a bit bigger beer now in

102:57

this case I can also change the color of

102:59

there to provide a color attributed so

103:01

I'll just use like gold and save my file

103:04

and here you can see we now getting a

103:05

gold beer so yeah that was it about for

103:08

The Styling challenge now let's talk

103:10

about how we are going to be adding

103:11

events to our elements so to do that

103:14

first of all we are going to be creating

103:16

our button component and now inside this

103:19

button component we going to be only

103:20

returning just a simple button which

103:22

will just say click

103:23

and now I'm going to render them inside

103:25

my app so I'll just use my button and

103:28

save my file and here you can see we are

103:30

now getting work click button right here

103:32

which is not doing anything for now so

103:34

now if you want to attach a event

103:36

handler for this button the first thing

103:38

that we have to do is that we have to

103:39

write the on and here you can see we

103:41

have a lot of events like on aboard on a

103:43

board capture on animation in and there

103:47

are a lot of uh events right here on

103:49

blood and stuff like that so what I'm

103:51

going to do is that I'm going to just

103:52

write my own click event handler and I'm

103:54

going to just pass some sort of a

103:56

function right here so now inside this

103:58

function I can just log to the console

103:59

like uh you clicked me and now I'm going

104:02

to save my file and now if I open my

104:05

console right here now I'm going to

104:07

click on this button and it's going to

104:08

give us like you clicked me right here

104:10

why is that because now we are attaching

104:12

this event handler and we are just

104:13

logging to the console like you clicked

104:15

me we can also extract this logic to a

104:18

separate function so I'm going to

104:19

extract that from here and now we can

104:21

just to create a separate function like

104:23

cons handle click and now we can just

104:26

loog to the console something like

104:28

math.round and then math. random and

104:32

let's just divide them by 10 or multiply

104:35

there by by 10 so if I save them I'm

104:38

going to copy there and we are going to

104:40

be passing the reference of that

104:41

function to this on click event handler

104:44

so if I save there now if I refresh

104:46

there and anytime I click on this button

104:48

it's going to give us a random number

104:49

between 1 through 10 okay so yeah this

104:52

is now working that was the first

104:54

example now let me give you one more

104:56

example so to do that we're going to be

104:58

creating yet another component or you

105:00

know what let me just remove that

105:01

component from here and I'm going to

105:03

create my copy component and now inside

105:05

there we going to be just returning only

105:07

the paragraph and which will just say

105:09

come on let's just return a paragraph

105:11

which will just have like LM of 20 and

105:14

I'm going to save this file word here

105:15

I'm going to attach my own copy event

105:17

handler right here and we are going to

105:19

be also creating this function like copy

105:21

Handler in a second so I'm going to copy

105:24

there and now let me just create this

105:25

function inside this copy component so

105:28

I'll just use like const copy Handler

105:30

and now inside they I'll just loog to

105:32

the console like stop stealing my

105:35

content so if I save there and now if I

105:37

just refresh there we are getting some

105:39

sort of error that's because instead of

105:41

that button I'm going to have to provide

105:43

the copy right here I'll just remove

105:45

that and change that to that copy

105:47

function copy component save my file and

105:50

now if I just refresh there and here you

105:52

can see we now getting our text but if I

105:54

just select some portion of this text

105:56

right click on there and copy there it's

105:58

going to give us that warning like stop

106:00

stealing my content which is looking

106:02

amazing so this is how we going to be

106:03

working with the on copy event handler

106:06

now let me give you one more final

106:07

example and I guess that's going to be

106:09

here so I'll just remove that component

106:11

from here I'm going to also remove this

106:13

copy from here and now let me give you

106:15

the move so not movie but just move

106:18

component and now inside them we are

106:21

going to be returning once again or

106:23

paragraph and that paragraph will have

106:25

the content of like LM 20 and now I'm

106:28

going to be attaching my own Mouse move

106:31

okay so when somebody Mouse over or how

106:34

over this text so we are going to be

106:36

firing some sort of event so to do that

106:38

I'm going to just provide my move uh

106:41

Handler function which we're going to be

106:42

creating in a second now let me just

106:44

create that function right here so we

106:46

can either create it by using this

106:47

function Reser keyword or we can create

106:50

there by using the arrow function so

106:52

it's not going to take any parameter and

106:54

we are going to be alerting and I'll

106:56

just say like uh Mouse move event fired

107:00

and now underneath that we can just loog

107:02

to the console like Mouse move event

107:04

fire there same thing so if I save my

107:06

file and now if I just refresh there but

107:09

first of all you're going to also have

107:10

to register there inside our app so

107:13

let's just register there right here so

107:15

if I save my file and Watch What Happens

107:18

so whenever I H my mouse over to there

107:21

first of all I'm getting like Mouse move

107:23

event fired if I click on okay we are

107:25

also getting in the console like Mouse

107:27

move event fired so this is how we going

107:29

to be attaching different kind of events

107:31

to or specific elements in this section

107:34

I'm going to be introducing two topics

107:35

at once first we're going to be learning

107:37

about the stand and then we're going to

107:39

be jumping into the hook so now let's

107:41

talk about what is a state and why you

107:43

should even care about that so state is

107:45

a way to store and manage the data that

107:47

can change over time and affect how the

107:49

component renders we defin state by

107:52

using something called the use St hog

107:54

which allow you to set the initial value

107:56

and provide a way to update that state

107:58

so that was just a quick definition of

107:59

what a state is but now here is a

108:01

keyword the use stand hook so now what

108:04

is a hook and why you should even care

108:06

about them so hooks are a new edition in

108:09

react 16.8 they let you use state in

108:12

other reactjs features without writing a

108:14

class based components so back in the

108:16

day not that long ago we were using a

108:19

class-based component like everywhere

108:21

nowadays we only use functional based

108:24

component and nobody use a class based

108:26

component so hooks were introduced in

108:28

the react gs16 version and they allow

108:31

you to manage your state inside the

108:33

functional component so that's the only

108:35

theory that you have to keep in mind

108:36

about the hooks and there are a lot of

108:39

hugs which we are going to be covering

108:40

throughout this series but now in this

108:42

section we are going to be learning

108:43

about what a use St is and how it works

108:46

so now let's talk about what is a UST so

108:48

UST hook allows us to track the state in

108:50

the functional component and that

108:53

generally refer to the data or the

108:55

properties that need to be tracking in

108:57

our application so that's the only thing

108:59

that you have to keep in mind about the

109:00

use St so how the syntax will look like

109:03

so here you can see first of all we are

109:05

going to be using our use St hog and

109:07

then we're going to be using the array

109:08

is structuring and first of all we have

109:11

a data which we are going to be

109:12

providing inside our Us St and then we

109:15

have a function which allows us to

109:17

change that data inside our Us St okay

109:20

so you know what that's a lot of theory

109:22

now let me just write some code and then

109:23

you'll get to know what I'm talking

109:24

about now let's talk about the stat and

109:26

the use St hook so to do that first of

109:28

all we have to import the use St in our

109:31

project so this is how we're going to be

109:33

importing there and now let's use the

109:34

user hook inside our project so I'm

109:36

going to be using like cons counter and

109:38

that's going to be equals to the US St

109:40

and the initial value will be set to

109:41

zero okay and now I'm going to just log

109:43

this counter to the console so if I sve

109:45

my file and here you can see we are now

109:47

getting two things the first thing that

109:49

we are getting is the initial value

109:52

which we specified inside this Us St

109:55

word here and the second thing that we

109:57

are getting is a function which will

109:58

allows us to change this initial value

110:01

okay so if I specify like my own name

110:03

like hus webd and I'm going to save

110:05

there and now if I just refresh there

110:07

what am I getting I'm getting hose webd

110:09

as my name which is the initial value

110:11

for my state and I'm also getting this

110:13

function which will allow me to change

110:16

this value okay so you have to keep that

110:18

in mind so the best and the convention

110:20

way to use this us is to destructured

110:23

there by using the array destructuring

110:25

why is there because this is not an

110:27

object this is array so in this

110:29

situation we're going to be using the

110:30

array destructuring to destructure our

110:33

initial value and also this function so

110:35

we are going to be destructuring this

110:37

initial value to use this somewhere and

110:40

we are going to be also destructuring

110:41

this function to change the value of

110:43

this St so what I'm going to do is that

110:45

I'm going to just remove this counter

110:46

and I'm going to be using the AR

110:48

structuring syntax right here so now

110:50

here you can pass anything that you want

110:52

but my case I'm going to just give it

110:53

the name of like count and then we have

110:55

to provide the comma and we're going to

110:57

be also destructuring that function as

110:59

well so to destructure there the

111:01

convention is to use the set and then

111:04

provide the name for your initial value

111:06

so now in this case we specify this

111:08

count so we are going to be passing our

111:10

count right here so if you were like

111:13

passing some sort of a apple maybe so we

111:15

going to be passing like set Apple so

111:18

this is just a convention if you want to

111:20

follow that you totally can but you

111:21

don't have to this should be an apple

111:25

there we go okay so now I'm working with

111:27

my account so I'm going to just space my

111:29

account right here and then the

111:30

convention I'm going to follow will be

111:32

the set count there we go in the initial

111:35

value I'm going to specify only zero

111:37

right here inside there and now if I say

111:39

there next thing that I want to do is

111:41

that I want to render what I currently

111:43

have inside this T so I'm going to just

111:45

write my H1 and here I'll just pass my

111:48

count variable which we are now

111:50

destructuring from our used so if if I

111:52

sell there and as you can see right here

111:54

we are now getting the zero which is

111:56

looking amazing so if I change that to

111:57

like I don't know maybe 100 and sell

112:00

there and now we are getting this 100

112:01

right here so that's amazing now the

112:03

next thing that we have to do is that we

112:05

have to somehow change the value of this

112:08

initial state so initially we specify

112:10

the value of zero today but now you want

112:12

to change that to like I don't know

112:14

maybe 1 or 100 or something like that so

112:17

to do that we're going to be creating

112:19

our button so I'll just create my button

112:21

right here and I'm going to just space

112:22

like plus right here or I can just say

112:24

plus but you know what that plus symbol

112:26

would be fine and I'm going to be

112:28

attaching the event handler on there

112:29

which will be the on click so when

112:31

somebody clicks on that button so we're

112:33

going to be firing this function which

112:35

is the increment function so I'm going

112:36

to copy the name of this function and

112:38

now let me just create this function

112:39

right here so I'll just use like cons

112:41

increment and this function will only

112:43

take this set count and remember this

112:46

set count is a function which allows us

112:48

to change the value of our counter or

112:51

our initials stad okay so I'm going to

112:53

just execute this function Right Here

112:56

and Now how we are going to be changing

112:57

the value of our function so if I just

112:59

write like count plus one and now if I

113:01

sve my file and here you can see we now

113:03

getting our button and now if I click on

113:05

there anytime I click on there it's

113:07

going to increment my counter by one so

113:09

let me just refresh there 1 2 3 and so

113:12

on and so forth okay so now I can also

113:16

duplicate this line of code and I'm

113:17

going to just change that to minus and

113:19

I'm going to also create a function for

113:20

the decrement so DEC me and I'm going to

113:24

copy their function name I'm going to

113:26

duplicate this line of code I'm going to

113:27

place the name of my function and

113:29

instead of a plus I'm going to change

113:31

there to minus so if I save there now we

113:33

have our decrement Button as well so if

113:35

I click on there anytime I click on

113:37

there it's going to decrement my counter

113:38

by one now I know a lot of people will

113:40

ask me like husan can we change the

113:42

value of this count without using this

113:45

set count so you know what let me just

113:46

do that I'm going to remove that from

113:48

here and now let me just use my count

113:50

plus one instead of providing that uh

113:52

set count and stuff so I'll just use

113:54

like count minus one and now I'm going

113:56

to save my file so if I save my file and

113:58

refresh there now if I click on there

114:00

here you can see behind the scene this

114:02

counter is updating the UI is not

114:05

updating why is there because the set

114:07

count method allows us to change the

114:09

value of our St and anytime we change

114:12

the value of our state our component

114:15

will rerender I want you to keep that in

114:17

mind anytime we change the value of our

114:19

function or not a function but a state

114:22

by using the set count method or any set

114:25

method it's going to render our

114:27

application but now in this case it will

114:29

not render our application it will still

114:32

change the value of our state but it

114:34

will not rerender our application okay

114:36

so this is not allowed this is a big no

114:38

no in reactjs you cannot change the

114:41

state of your application without using

114:43

the set method like you have to use

114:45

there so I'm going to copy there and now

114:47

let me just wrap there like so okay so

114:50

I'm going to also use my set counter

114:52

right here here and let's just close

114:54

there like this way so I'm going to save

114:55

my file and once again if I click on

114:57

this button so it's going to increment

114:59

there and this one will decrement or

115:01

decrement there now let me give you one

115:03

more example of how we are going to be

115:05

updating our array of content so once

115:08

again we are going to be importing our

115:09

use St and then we are going to be

115:12

creating our St so I'll just use like

115:13

use St in the initial value I'm going to

115:15

specify array right here so for the

115:18

first one we're going to be providing

115:19

Alex and I'm going to also provide a

115:21

John as my friends and I'm going to

115:23

store that inside my variabl and I'm

115:25

going to be also using my ARR

115:26

restructuring so I'll just use like

115:27

friends and also set friends right here

115:30

this is just a convention if you want to

115:32

follow there you are more than welcome

115:33

to follow there but if you don't want to

115:35

follow there you don't have to now

115:37

inside this section I'm going to be

115:38

using my friends now let's just iterate

115:40

over through each friend and we're going

115:42

to be providing our friend right here or

115:44

just F would be fine and now inside

115:47

there we're going to be using our lii

115:49

let me just use my li right here and we

115:51

are going to be rendering or friend okay

115:53

so for the key I'm going to past like

115:55

math. random and that's going to be fine

115:58

so if I save my file and here you can

115:59

see we are now getting Alex and also

116:01

John which is looking amazing so now the

116:04

next thing that I want to do is that I

116:05

want to add a new element or add a new

116:07

friend to this list so how can I go

116:09

about doing that to do them I'm going to

116:12

just create a button right here and now

116:14

I'll just give it the name of like add

116:16

new friend or something friend would be

116:19

fine come on f r e n d there we go and

116:21

I'm going to attaching the event handler

116:23

which will be on click add one friend

116:27

would be fine so I'm going to copy there

116:29

and now let me just add that friend by

116:31

using this function so I'll just use my

116:33

add one friend and here we are going to

116:35

be creating our Arrow function and now

116:38

in this case to mutate this array or to

116:40

change something inside this array we're

116:42

going to be using our set friend so I'm

116:44

going to just call this function Right

116:45

Here and Now inside there first of all

116:47

we are going to be getting like all of

116:49

the friends which we currently have we

116:51

don't want to change the existing data

116:52

inside this array but we want to add yet

116:55

another new friend so this is how we are

116:57

going to be cloning the existing data

116:59

inside our state or or array and then

117:01

we're going to be adding a new one so

117:03

I'll just P like my own self like huzen

117:06

uh webd and now if I save my file and

117:08

here you can see we now getting like add

117:10

new friend button and now if I click on

117:12

that so it's going to also add there

117:13

right here so this is how we going to be

117:15

updating or mutating or array now let me

117:17

show you how we are going to be removing

117:19

a specific person from this list so to

117:22

do there I'm going to just create here

117:23

another button which will say like uh

117:26

remove one friend or something and I'm

117:28

going to also paste the own click event

117:30

handler on there which will say like

117:32

remove friend okay so I'm going to copy

117:34

there and let me create that function

117:35

right here so I'm going to be creating

117:37

my remove function and let's just use

117:39

our set friend one more time then now

117:41

here we're going to be using our friends

117:43

and now we going to be using a filter

117:45

method because we want to filter out

117:47

that specific person and then we want to

117:49

just remove that so I'll just P like my

117:51

callback function right here so if that

117:54

specific friend is not equals to John we

117:57

only want to remove that John so we

117:59

don't want to remove anything else we

118:01

only want to remove this John so if I

118:03

sell my file and now here you can see we

118:05

have like Alex and also John so if I add

118:08

there now it's going to remove this John

118:10

from this list so if I click on there

118:12

and here you can see it's going to

118:13

remove that John so this is the second

118:16

way now let me show you the final way

118:17

which is how we going to be updating a

118:19

specific print so yeah let me me just

118:22

show you there I'm going to create a

118:23

button and which will say like um come

118:26

on update one friend and I'm going to

118:29

also attach my event handler on there

118:31

which will say like update one or update

118:34

one friend would be fine I'm going to

118:36

copy there and let's just create that

118:38

function right here we're going to be

118:40

still using our set friends and now here

118:42

we have to specify our friends. map

118:45

because we want to iterate over through

118:46

all of the friends that we currently

118:47

have and now we just have to use like if

118:49

friend is equals to Alex so in that case

118:53

we just want to change his name to like

118:54

Alex Smith or something like that but if

118:57

that's not the case we only want to

118:59

provide that specific name okay so here

119:01

we are using a trary operator like if

119:04

our friend is equal to Alex we just want

119:06

to change his name to Alex Smith but if

119:09

that's not the case we just want to

119:10

return all of the overall friends okay

119:12

so now I'm going to sve my file and here

119:15

you can see we have like Alex and we

119:16

also have like husb so if I just refresh

119:18

there add my own self and now I want you

119:21

to notice this so if I click on update

119:23

one friend so it's going to change the

119:25

name of this Alex to Alex Smith so this

119:27

is how we going to be using a UST state

119:29

with array of content now that was about

119:31

the number we also learned about how we

119:33

going to be updating the array but now

119:35

let's talk about how we are going to be

119:36

updating the object so I'll just use

119:38

like import and then use that I'm going

119:40

to import it right here and now let me

119:42

just use like cons movie or just movie

119:45

would be fine and then set movie okay so

119:48

we're going to be using our used not

119:49

transition God damn it used St and here

119:52

we're going to be specifying our object

119:54

and for the object we're going to be

119:56

specifying like the title of the movie

119:57

which will be one of my favorite movie

120:01

Equalizer three and then we're going to

120:03

be also providing a ratings for there so

120:05

ratings will be set to seven I'm going

120:07

to sve my file so this is how we are

120:09

going to be initially providing our

120:10

content forward State and now let me

120:13

render that right here to the UI so I'll

120:16

just use like H1 and here we're going to

120:18

be using like movie. tile and then we

120:22

going to be also using paragraph of

120:24

movie. rating so if I save there so here

120:28

you can see we now getting the movie

120:29

title and we are also getting the

120:31

ratings so I'll just change there to

120:33

ratings there we go and change this one

120:36

to the title now that's looking better

120:39

so now the next thing that I want to do

120:41

is I want to create a button which will

120:43

update the rating of this movie so I'll

120:45

just write like change rating or my own

120:47

click EV Handler which will say handle

120:50

click I'm going to copy there and here

120:52

we are going to be creating that

120:53

function right here cons handle click

120:56

and now inside this function we are

120:58

going to be updating only the ratings

121:00

nothing else but only the ratings so to

121:02

do that first of all we're going to be

121:03

making a copy of our St so to make a

121:06

copy of our St so we can use like copy

121:09

movie and now here inside there we can

121:11

use dot dot dot and movie like we want

121:14

to take the title and also the ratings

121:16

so this is how we are going to be making

121:18

a copy of our movie then we can specify

121:20

the comma in what thing you want to

121:22

change so I'll just write like readings

121:25

and then we want to change there to five

121:27

so this is how we going to be making a

121:28

copy of our movie and this is how we can

121:31

change a specific thing inside that

121:33

movie or inside that object okay and now

121:36

we are going to be using our set movie

121:39

which is the function which allows us to

121:41

change this St and I'm going to specify

121:43

my copy movie right here if i s my file

121:46

and here you can see if I click on this

121:48

button so it's going to change the

121:49

ratings to five right here which is

121:52

amazing but this is the longer way of

121:54

doing things but we can totally refactor

121:57

this code to use a short hand so I'm

121:58

going to just comment this line out and

122:01

I'm going to just cut that from here and

122:03

instead we're going to be using the

122:04

object I'm going to use dot dot dot

122:06

movie and then comma ratings and I'm

122:09

going to just specify five right here so

122:11

this is just a shorter way of writing

122:12

all of that stuff so I'm going to just

122:14

refresh there and click on the change

122:16

ratings so it's going to also change the

122:18

ratings to five and let's just remove

122:20

that from here and now that's looking

122:21

better we can also remove these C braces

122:24

we don't need that that's looking cool

122:26

and yeah that's looking better so that

122:29

was how we are going to be using the US

122:30

St with object but in some situation we

122:33

would have like array of objects so how

122:35

can you go about doing that we're going

122:37

to be using our used St first of all and

122:39

inside there we're going to be passing

122:41

the array of objects so inside each

122:44

object we're going to be placing the ID

122:46

which will be set to one and title will

122:48

be like I don't know some sort of a

122:50

movie name like Spider-Man and I'm going

122:52

to also specify the ratings to there and

122:54

rating will be set to three I'm going to

122:56

duplicate there and change the rating to

122:58

six and change the movie title to

123:01

Superman and also the ID will be set to

123:04

two so now in this case we have array of

123:08

objects right here and now if you want

123:10

to modify that how can you go about

123:12

doing that so to do that first of all we

123:14

have to store that in some sort of a

123:16

state so I'll just use like movies and

123:18

then set movies and that's going to be

123:20

equals to this use function right here

123:22

so if I save that the next thing that we

123:24

have to do is that we have to it R over

123:26

through each element inside this array

123:28

and we have to render that and I'm going

123:30

to just go into my section and inside

123:33

this section I'll use my movies. map and

123:36

I'm going to only pass my M for the

123:38

movie like for each of the movie and now

123:40

inside there we're going to be using our

123:42

Li let me just use that manually and I'm

123:45

going to pass my movie. tile or not

123:49

movie but just m. tile would be fine and

123:53

I'm going to also provide the key and

123:54

that will be like math. random and

123:57

provide my random key to it now

123:59

underneath that we're going to be

124:00

creating a button which will say like

124:02

change name and we're going to be also

124:05

attaching the event handler on there

124:06

which will say like handle click I'm

124:08

going to copy that from here and let's

124:10

just create that function right here so

124:12

I'll just use like cons handle click and

124:14

in this case once again we're going to

124:16

be using the set movies and it's going

124:17

to allows us to change our state and

124:20

here we're going to be passing our

124:21

movies and I'm going to be using the map

124:23

method to to itate over through each

124:24

movie and let's just use our M for each

124:27

of the movie so if m. ID is equals to

124:30

one so in this situation we just want to

124:33

change the movie first of all we're

124:34

going to be making a copy of all of the

124:36

movies and then we only want to change

124:38

the title uh to John Wick four or maybe

124:44

five would be fine and now outside from

124:47

there what am I doing okay so now

124:50

outside from there we are going be

124:52

closing over tary operator and just

124:54

provide ID here so now let me just

124:55

explain this code first of all we are

124:58

now iterating over through each movie

125:00

and we are now storing there in m and

125:02

now we are checking if the movie ID is

125:04

equals to one we are only checking the

125:06

first movie so if that's the case so

125:08

what do we have to do we have to make a

125:10

copy of our entire State movies and we

125:13

only want to change the name of the

125:14

first movie to John week chapter 5 okay

125:17

so if that's not the case we just want

125:18

to return all of the movies that's

125:20

exactly what we are doing right now if I

125:22

save my file and let me just refresh

125:24

there and if I click on the change name

125:27

it's going to change there to John Wick

125:29

chapter 5 so yeah this is how we are

125:31

going to be iterating over through the

125:33

entire list array of St and now this is

125:36

how we are going to be mutating that St

125:38

or changing that St or updating that St

125:41

so that's cool and everything but now in

125:43

some situation we would want to share

125:45

word St into other component so how can

125:48

you go about doing that first of all

125:50

we're going to be importing what used

125:51

State and then I'm going to just create

125:53

some sort of a state like count and also

125:56

the set count and that's going to be

125:58

equals to the U State and the initial

125:59

value will be set to zero now I'm going

126:01

to go ahead and create a few components

126:03

so I'll just create my uh components

126:05

folder and we have our component 1. jsx

126:10

and we also have our component 2. jsx

126:14

now inside this component one I'm going

126:16

to be using my rafc save this file and

126:19

inside the component two we're going to

126:20

be using our r fc2 and now I'm going to

126:24

go into my app component and we have to

126:26

import our component come on component

126:30

one and we also have to import our

126:32

component two as well right here I'm

126:35

going to save this file and now inside

126:37

this section I'm going to call my

126:39

component one first of all and let's

126:42

just execute there and I'm going to also

126:44

call my component come on

126:47

component component two and I'm going to

126:50

also execute the now I want to share

126:52

this state into this component so how

126:55

can I go about doing that well to do

126:57

that we are going to be using our prop

126:59

system so we can just say like count and

127:01

count will be that count or that initial

127:04

value of the St so we are now passing or

127:07

St from the app component from the

127:09

parent component to the component one

127:12

and also to the component two as a

127:14

children component okay so I'm going to

127:16

also pass my on click on click Handler

127:20

as a function name and here we're going

127:23

to be also passing our function inside

127:25

this so I can just say like set count

127:27

and here I'm going to be just passing

127:28

like count + one I'm going to save this

127:30

file and now I can totally copy all of

127:33

that stuff from here and now I can

127:35

totally paste it right here so I'm going

127:37

to save my file let me just say that

127:39

once again we are defining our state

127:42

inside the app component and we are now

127:44

sharing there with the component one and

127:46

also the component two by using this

127:49

prop system okay so now inside component

127:52

one we can now totally destructure that

127:54

and we can totally use our state from

127:56

the app component inside the component

127:59

one and to do that I'm going to first of

128:01

all destructure my component so I'll

128:03

just use like count and also the own uh

128:05

click Handler right here which is a

128:08

function name and now inside this

128:09

component one div I'm going to just

128:11

remove there and just write my paragraph

128:14

and say like count I'm going to render

128:16

my count inside there I'm going to also

128:18

provide my button and which will just

128:20

say like increment

128:22

and I'm going to pass my own click event

128:25

handler on there and then I'm going to

128:27

pass my handle click right here I'm

128:29

going to copy there go to the top and

128:32

here we have to just use our handle

128:34

click when somebody use it we're going

128:36

to be firing this function okay so let's

128:38

just execute this sem my file and let me

128:40

just show you so here you can see we are

128:42

now getting this from our paragraph and

128:44

now if I click on this so it's going to

128:45

just update my account right here from

128:47

the component B from the child component

128:51

we now now updating the parent component

128:54

so that was the first way now I'm going

128:55

to go into my second component or a

128:57

component two or you know what I'm going

128:59

to just copy this stuff from here I'm

129:01

going to place it here and inside this

129:04

component one I'll proide my paragraph

129:06

and render my count inside there let's

129:09

just proide our button and increment

129:12

here as well and let's just use our own

129:15

click event hander handle click event

129:18

copy there go to the top and use my

129:20

const hand handle click and we're going

129:23

to be passing our on handle or on

129:26

Handler okay so I'm going to save my

129:28

file and now here you can see we have

129:30

two components and they are updating

129:33

each other so if I click on there and

129:35

it's going to update there right here so

129:37

why is there now our state is available

129:39

inside the parent component and we are

129:42

now updating there from the child

129:44

component so this is the result that we

129:45

are getting so if I click on the

129:47

increment it's going to increment there

129:49

right here so this is how we are going

129:50

to be sharing St by using the prop I

129:53

know we learn a lot about the use St but

129:56

still there is one final thing I want to

129:58

talk about which is SC how we going to

130:00

be passing a arrow function or just a

130:02

function as the initial value forward us

130:04

here so what I'm going to do is that I'm

130:06

going to Define my component spoolder

130:09

and I'm going to create a component with

130:10

the name of example 1. TSX not a TSX but

130:13

just a GSX and I'm going to be using RFC

130:16

and yeah I'm going to render this

130:18

component right here like example examp

130:21

example one and I'm going to just render

130:23

there sa my file check this out and here

130:26

you can see we are now getting our

130:27

example one right here let's just remove

130:29

the St in CSS and now let's start

130:31

working on this so the first thing that

130:32

I want to do is that I want to create my

130:34

state so I'll just create a state with

130:36

the name of count and also set count

130:38

it's going to be equals to this use

130:39

stand and for the initial value now we

130:42

are going to be passing a callback

130:44

function okay just like there so this

130:46

callback function will only runs when

130:49

our component first render so like any

130:51

logic I put inside this callback

130:53

function will only run on the first

130:55

render so what I'm going to do is that

130:57

I'm going to specify my initial account

130:59

all use like initial count and it's

131:01

going to be equals to some sort of a 10

131:03

value and I'm going to also return this

131:05

initial count from this aror function so

131:07

now let me just save that next we have

131:09

to render there so I'm going to just

131:10

remove that from this UI and I'm going

131:12

to write my H1 which will say count and

131:14

here we have to render our count next we

131:17

also have to create a button which

131:18

allows us to increment our counter Okay

131:21

so I'll use like uh on click and here

131:23

we're going to be passing this increment

131:25

function so I'll just use like cons

131:27

increment and inside this function we're

131:30

going to be only using the set count and

131:32

proide my previous count value today and

131:35

next come on what the hell am I doing

131:37

next we have to just use our previous

131:39

count and plus only one to there now I'm

131:41

going to save my file and as soon as I

131:43

save my file and refresh there and here

131:45

you can see it's going to gives us 10

131:46

value as a initial value for this count

131:49

right here so now I can totally

131:50

increment there and I can do whatever I

131:52

want to do with that so yeah that was

131:55

the example number one now let me give

131:56

you one more example which will be

131:58

example 2. TSX jsx what the hell am I

132:02

saying let's use word RFC inside there

132:05

also I want to render there inside my

132:07

app component so I'm going to comment

132:09

this line out and I'm going to render my

132:11

component to okay

132:14

component okay component two or example

132:18

two not a component so I'll use like

132:20

example two close sem my file check this

132:23

out so here you can see we are now

132:24

getting our example two so now the first

132:26

thing that I want to do is that I want

132:27

to create my random number I'll use like

132:29

random number and also set random number

132:33

is going to be equals to this use St

132:36

once again and for the initial value

132:38

we're going to be passing this callback

132:40

function right here okay so now inside

132:42

this callback function I'll just use

132:43

like meth. Flor and here I'm going to

132:45

also proide like meth random and then

132:48

times 100 would be fine so now if i s my

132:51

file oh it should be just equal to sign

132:54

okay so it's going to gives us a random

132:55

function whenever this component first

132:57

render so I'll just remove that from

132:59

here and I'm going to write my H1 which

133:01

will say like random number and then I'm

133:04

going to render my random number okay

133:07

like so so now if I save my file and

133:09

here you can see it's going to gives a

133:10

zero let me just refresh this it's going

133:12

to give a 7 to2 refresh there once again

133:14

so anytime I refresh this going to gives

133:16

us a random number now underneath this

133:17

H1 I'll create a button which will say

133:20

like generate um new number or generate

133:23

a new random number or something like

133:25

that and when somebody clicks on this

133:27

button we're going to be firing this

133:29

function which is a generate new random

133:31

number now let me copy that and I'll

133:34

create this function right here it's

133:36

going to be an arrow function and I'll

133:37

just P like new number and that new

133:40

number will be equals to met. BL and

133:43

also we have to specify met. random

133:45

times 100 one more time like 100 like so

133:49

and finally we're going to be set there

133:51

two or random stat so here we have to

133:54

specify our new number and now if i s my

133:57

file and whenever I refresh my page it's

133:59

going to gives us a different random

134:01

number so I can also click on there so

134:03

now it's going to also gives us a

134:04

different random number so that's also

134:06

done now let me give you the final

134:08

example like example 3. jsx I'll use my

134:12

RFC inside there like rafc save my file

134:16

go into my app and render this component

134:19

right now like example

134:21

and close there so the first thing that

134:23

I want to do is I want to Define my

134:24

state so I'll just proide like name and

134:26

set name and it's going to be equals to

134:28

the use state so let's just use our use

134:30

St and for the initial value we're going

134:33

to be placing an arrow function so first

134:35

of all we have to save some sort of a

134:36

name to our local storage so I'll just

134:38

use like variable with the name of like

134:40

saved number or saved name to be precise

134:44

and that's going to be equals to the

134:45

local storage and here we want to use

134:47

like get item and we're going to be

134:49

getting our item from our local storage

134:51

if we have there but if we don't have

134:53

there let's just use like save name if

134:55

we have the save name so we just want to

134:57

pass there and we want to get that from

134:59

our local uh storage and if that's not

135:02

the case we just want to set the initial

135:04

value to empty string now let me go to

135:07

the UI and change that to my H1 or yeah

135:10

H1 would be fine and here I'll just say

135:13

like your name and here we have to

135:15

render our name like this name right

135:18

here so now need this H1 I'll create

135:20

input field with the type of text and

135:21

I'm going to also provide the value and

135:23

the value will be coming from the state

135:25

which is a name and when somebody tried

135:26

to change something inside this we're

135:28

going to be fting this handle change

135:30

function and now I'm going to also

135:32

provide the placeholder which will say

135:33

like enter your name okay and finally

135:36

let me create a button which will say

135:38

like clear name and whenever somebody

135:40

clicks on this button we're going to be

135:42

fing this handle clear function which

135:44

we're going to be creating in a original

135:45

imag just create first of all we are

135:47

going to be creating this handle change

135:49

function then we're going to creating

135:51

that clear function so what I'm going to

135:53

do is that I'm going to F this handle

135:55

change function is going to take an

135:56

event and here inside this event we're

135:59

going to be setting the name to event.

136:01

target. value now I'm going to also use

136:04

the use effect so whenever our component

136:06

first renders so in this situation we

136:09

just want to set our item which will be

136:11

a name and we want to provide our json.

136:14

string if inside there and provide a new

136:16

name to there okay so I'll also provide

136:18

the dependency array and for the

136:19

dependency array we're going to be

136:21

providing a name and now finally let me

136:23

also create this handle clear function

136:25

and then inside this clear function

136:28

we're not going to be doing anything

136:29

crazy but I'll just write like set name

136:31

and the initial value will be empty

136:33

string okay so here you can see we have

136:34

our name and stuff so now let me open my

136:37

console go into my application oh my God

136:42

this is super white I don't know why but

136:44

yeah let me just right click on that and

136:46

force that to a dark God damn it this is

136:49

super white so let me just go into local

136:51

storage and here whatever I type inside

136:54

there it's going to be putting it right

136:56

here but that value will be also stored

136:58

inside my local storage so whenever I

137:00

refresh there and here you can see that

137:03

value will still be here so now whenever

137:05

I click on this clear name so it's going

137:07

to clear this out so the whole point of

137:09

this section was that we can also

137:11

specify a arrow function or just a

137:13

function to our user welcome to the user

137:16

challenge so the first thing that I want

137:18

you to do is that I want you to create

137:19

the counter. jsx file and inside that

137:22

file you're going to have to create the

137:23

counter uh component and use the UST to

137:26

manage a simple counter state so first

137:28

you'll have to initialize the state by

137:29

providing a zero value to that then

137:31

create a button to increment your

137:33

counter by one display the value of that

137:35

counter so that we can see the result so

137:37

this is going to be the first portion of

137:39

this challenge so in the next portion

137:41

you're going to have to create the to-do

137:42

list. jsx file and then you have to

137:44

create a component with the name of

137:45

to-do list then use the UST St once

137:48

again to manage a simple state or array

137:50

of of to-dos inside the state initialize

137:52

the state with empty array then create a

137:54

form to add a new to-do item in that

137:56

list then display the value of that

137:58

to-do list and that's going to be the

138:00

second portion so now for the third one

138:02

you're going to have to create your uh

138:03

profile. jsx file and inside that you're

138:06

going to be defining the profile

138:07

component once again you're going to be

138:09

using the use stad to manage the object

138:11

with the user profile information so

138:13

initialize the St with object containing

138:15

the name and Edge and provide the input

138:17

field to update the name and also the

138:19

edge then finally display the updated

138:21

information inside that component so now

138:24

for the fourth step you're going to have

138:26

to use the US once again and create a

138:28

shopping list. jsx file also the

138:30

shopping list component and use the US

138:33

St to manage the array of object where

138:35

each object represent a shopping item

138:37

for example like the name and also the

138:39

quantity so initialize the state with

138:41

the empty array and also create a form

138:43

to add a new item to that array and then

138:45

finally display the list of shopping

138:47

items okay so yeah this is how you're

138:49

going to be importing the for your app

138:51

component so you guys can see everything

138:53

so give it your best shot if you can do

138:55

it that's completely okay then come back

138:57

and watch the solution now I'm going to

138:58

give you my solution let me create my

139:01

counter. jsx file and I'm going to be

139:03

using the rafc so my file go to my app

139:06

and registered there right here this is

139:09

right where counter hit enter and just

139:12

close this so I'm going to save my file

139:14

I'm going to also run my server which

139:16

I'm already doing so let me just do that

139:18

once again and now we are getting our

139:20

counter which which is looking amazing

139:22

so the first thing that I want to do is

139:23

that I want to make a St so I'll just

139:25

use like UST St and as soon as I do this

139:28

so it's going to import that from the

139:29

reactjs for the initial value I'm going

139:31

to specify zero today and I'm going to

139:33

be using the ARR D structuring to

139:35

destructure the count and also the set

139:37

count out of there now we are going to

139:39

be using the count to show the initial

139:42

value so I'll just use like uh paragraph

139:45

and I will say like you clicked and let

139:47

me just render my count right here count

139:50

times there we go and also I'm going to

139:52

provide a button which will allows us to

139:54

change our state so I'll just provide

139:56

the name of like increment as a label

139:58

and whenever somebody clicks on that

140:00

button we're going to be firing this

140:02

function which will allows us to change

140:04

our data so we're going to be using the

140:05

set count and now we are going to be

140:07

providing the updated value so I'll just

140:09

write like count plus one now let me

140:11

just save my file and if I click on this

140:13

increments it's going to just increment

140:15

my counter by one okay so that's cool

140:18

but we can also decrement our counter so

140:19

let me just change the to decrement and

140:22

instead of providing a plus I'm going to

140:24

change there to minus so now I'm going

140:25

to save my file and now if I click on

140:27

this decrement so it's going to

140:28

decrement my counter by one so yeah that

140:31

was the first portion of this uh

140:33

exercise now we're going to be creating

140:34

a to-do list so I'll just create a

140:36

component or a file with the name of

140:38

to-do list

140:40

too list. jsx I'll use my rafc inside

140:44

there say my file go to my app and

140:46

register there right here so I'll use

140:48

like to-do list come on like so and cl

140:51

close my file and here you can see we're

140:53

now getting our to-do list which is

140:55

looking amazing so the first thing that

140:56

we want to do is that you want to

140:57

initialize our St so I'll use like use

141:00

St one more time uh use St there we go

141:03

and for the initial value we're going to

141:05

be specifying empty array inside there

141:08

now let me just destructure my to-dos

141:10

and also set to-dos out of them and now

141:13

underneath we're going to be also

141:14

handling over form so for form input

141:16

we're going to be creating a state for

141:18

the like input value and then set input

141:21

come on input value as well and that's

141:25

going to be equals to the US and the

141:27

initial value will be set to empty

141:28

string now let's get into the UI so I'm

141:30

going to remove that from here and I'm

141:32

going to create my H1 which will just

141:34

select to do list and now underneath

141:36

this H1 we're going to be creating a

141:38

form and we're not going to be providing

141:39

any action to there so I'll just use

141:41

like on submit when somebody submit

141:43

there we're going to be firing a

141:44

function which is called the handle

141:46

submit which we going to be creating in

141:47

a few seconds and now inside this form

141:50

you going to be defining our input field

141:52

for the value I'll specify the input

141:55

value that state which we've already

141:57

defined right here so I'm going to copy

141:59

there and now let me just place there

142:01

here like so and I'm going to also

142:03

provide the placeholder which will say

142:05

like add a new too I'm going to save my

142:08

file right now and we are not getting

142:10

anything this because we did not

142:11

register this component anywhere so I'm

142:13

going to go ahead and registered there

142:15

oh we already did there but why aren't

142:18

we getting anything oh you know what uh

142:21

We've provided this function but we did

142:23

not create this function so that's why

142:24

we are now getting that error underneath

142:26

this input field we're going to be

142:28

defining our button which will say like

142:29

add to do and the type will be set to

142:32

submit so it's going to allows us to

142:33

submit our form so now underneath this

142:35

form we we would also need to render our

142:38

to-dos so for that I'm going to be using

142:40

a ul and for this UL we're going to be

142:42

defining our to-dos and now let me just

142:44

iterate over through all of that to-do

142:46

so I'll just write like too and also the

142:48

index right here okay and and inside

142:51

then we're going to be defining our lii

142:53

and here we are going to be just

142:54

providing our to-do so that we can see

142:56

what to-do we will also provide the key

142:58

and that's going to be set to that index

143:00

which we are grabbing we cannot see

143:01

anything this because like we have to

143:03

create this function so I'm going to

143:05

copy there and let me just create this

143:06

function right here so I'll just use

143:08

like cons handle submit it's going to

143:10

take the event object I'm going to also

143:12

provide my curly braces and let me just

143:14

use like e do prevent come on p r v n

143:18

prevent default to prevent the default

143:21

behavior of there and we are going to be

143:23

also first of all checking the input

143:24

value and let's just provide our trim

143:26

method on there like if you have empty

143:28

spaces so just totally remove them now

143:31

we are going to be getting our set to do

143:33

like this one and we're going to be

143:35

changing the value of this so how are we

143:37

going to be doing that to do that the

143:39

first thing that we have to do is that

143:40

we have to make the copy of the existing

143:42

item which are available inside this

143:44

toio so how are we going to be doing

143:46

there you guess that we're going to be

143:48

using dot dot dot and toos next we have

143:51

to provide our updated value so for that

143:53

updated value we're going to be using

143:54

like input value and now underneath that

143:57

we're going to be also emptying out or

143:59

input field so I'll just use like set

144:01

input value and set that to empty string

144:04

now that's done so if I save my file the

144:06

next thing that we have to do is that we

144:08

also have to bind another function right

144:10

here to this input field so when

144:11

somebody change this I'll use like on

144:14

change we're going to be firing this

144:16

function which will be a handle chain so

144:17

I'm going to copy that and now let me

144:20

find my function right here so let's

144:21

just create our handle change it's going

144:23

to take the event object one more time

144:25

let's just provide our equal to sign

144:27

there and now we are going to be using

144:29

like set input field not them we're

144:32

going to be defining our set input value

144:34

and it's going to take that event.

144:36

target. value like anything we specify

144:39

inside this input fi so it's going to

144:41

take that it's going to show up right

144:42

here to the input value so now I'm going

144:44

to save my file and now let me write

144:46

like I don't know like walk the come on

144:49

oh my God walk the dog let me click on

144:52

the addir Todo so it's going to add

144:53

there right here can also write like uh

144:56

I don't know and click on this so it's

144:58

going to add that right here to this

145:00

to-do list so yeah that was another

145:02

example of this to-do list next we have

145:04

to create our profile so I'll just

145:05

create a component with the name of

145:07

profile. jsx I'll be using the rafc

145:10

inside there and the first thing that I

145:12

want to do is that I want to initialize

145:14

my profile or my state with a value of

145:16

profile so I'll use Like Us St and the

145:19

initial value will be set to this object

145:20

and I'm going to specify the name name

145:22

will be set to totally empty string

145:24

we're going to be also providing a edge

145:25

and Edge will be also set to totally

145:27

empty string so what I'm going to do is

145:30

that I'm going to destructure a few

145:31

things out of there so we're going to be

145:33

destructuring the profile and also the

145:35

set profile from this use St so that's

145:38

done next we have to go ahead and remove

145:40

this profile from there and I'm going to

145:42

be using H2 and I'll select user profile

145:45

and now underneath this H2 we're going

145:46

to be creating our div and inside the

145:48

div let's just Prov a label and we're

145:51

not going to be providing any HTML for

145:52

values to this I'll just remove that

145:54

from here and I'm going to only say name

145:57

and now inside this label even we are

145:59

going to be defining our input field

146:01

okay so the type will be set to text

146:03

we're going to be also providing the

146:04

name and name will be set to name and

146:06

let's just put the value and value will

146:08

be coming from the profile. name okay so

146:12

which is this profile do name which will

146:16

be coming from there and when somebody

146:18

types something inside there going to be

146:20

firing this function which will say like

146:22

handle change CH there we go so we're

146:25

going to be creating this function in a

146:26

few seconds but you know what I'm going

146:29

to first of all take care of the rest of

146:30

these labels and stuff okay so

146:32

underneath this div let me Define

146:34

another div we're going to be once again

146:36

providing a label we're not going to be

146:37

providing an HTML 4 value today and

146:40

inside this label the first thing that I

146:41

want to do is that I want to provide my

146:43

Edge and let's just provide our input

146:44

field right here so the type will be set

146:46

to number I'm going to provide the name

146:48

of Edge and I'm going to also provide

146:50

the value and value will be set to

146:53

profile. Edge which will be coming from

146:55

my state and when somebody change there

146:57

once again we are going to be firing

146:58

this handle change function in a few

147:00

second which we're going to be creating

147:02

okay so now underneath this Dev we're

147:04

going to be using our H3 and I'll use

147:06

like profile information and now

147:09

underneath this profile information so

147:10

I'll just uh like render all of that

147:12

values which I'm going to providing in

147:14

my input field so I'll just write like

147:16

name and I'm going to use like profile.

147:18

name and also I'm going to creating a

147:20

edge and here we're going to be

147:22

rendering The profile. Edge so now let

147:25

me just save there and finally let me

147:26

just create this handle change function

147:28

and that's going to be it so what I'm

147:30

going to do is that I'm going to write

147:31

like handle change it's going to take

147:33

the event object and inside this

147:35

function we're going to be destructuring

147:37

like uh the name and also the value out

147:41

of this event. target value t r g there

147:44

we go and we're going to be also using

147:46

the set profile and here we have to

147:49

specify the previous one so we are going

147:50

to be using like previous profile and

147:53

it's going to take that event it's going

147:55

to take this call back function so first

147:57

of all we have to spread out the pre

147:58

previous profile and now we have to

148:00

specify the new one so we're going to be

148:02

taking the name and we have to provide

148:04

the new value to there okay so I'm going

148:06

to save my file and that's going to be

148:08

it for this entire profile let me just

148:10

show you this so I'm going to refresh

148:12

then oh first of all we have to register

148:14

that into app component so I'm going to

148:16

comment this to-do list and I'm going to

148:18

register my profile component there we

148:21

go save my file and now we are getting

148:24

our profile component so first if I

148:26

specify some sort of a name like husan

148:28

and it's going to add there right here

148:29

for this name right here uh I don't know

148:32

like 20 or 22 or something like that so

148:35

it's going to automatically add there

148:37

right here uh for this profile

148:39

information so that was another one and

148:42

now let's talk about the final one which

148:44

will be the shopping list so I'm going

148:46

to comment this line out and let me just

148:48

go ahead and create my shopping list so

148:50

come on shopping list. jsx I'm going to

148:53

be using my rafc so my file go to the

148:57

fjs and use our shoing list and render

149:01

there save my file once again and the

149:03

first thing that I want to do is that I

149:04

want to initialize all of my St so I'll

149:06

just uh create like items and also set

149:09

items and that's going to be equals to

149:12

UST St and the initial value will be set

149:14

to empty now we're going to be also

149:15

creating one for the name so set name

149:18

it's going to be equals to the US St and

149:19

the initial value will be set to empty

149:21

string we're going to be also creating

149:23

one for the quantity and also set

149:26

quantity there we go it's going to be

149:28

equals to the US St and we're going to

149:30

be providing the empty string inside

149:32

there now let me just go ahead and go to

149:34

the UI and remove this shopping list

149:35

from there I'm going to write my H1

149:37

which will say like shopping list and

149:39

underneath this H1 let is create our

149:41

form we're not going to be providing any

149:43

action today but we are going to be

149:45

providing the on submit Handler and when

149:47

somebody submit that then we are going

149:49

to be fing in this function okay so

149:51

let's just create our input field inside

149:53

there the type will be text and we're

149:55

going to be also providing a placeholder

149:57

which will say like item name or

150:00

something like that and we're going to

150:01

be also specifying the value and value

150:03

will be coming from the name so I'm

150:06

going to copy them and let's just

150:08

provide there right here and when

150:09

somebody try to change there we're going

150:11

to be firing this function so I'll just

150:13

use like set name and I'm going to write

150:15

like event.

150:16

target. value so I'm going to save my

150:19

file and that's going to be for this

150:20

first input field and now we can totally

150:22

duplicate this so I'm going to select

150:24

there and duplicate them here we have to

150:26

change the type to number we also have

150:29

to change that to quantity so quantity

150:31

there we go we also have to specify the

150:34

value like quantity and also the set

150:38

quantity there we go okay so that's

150:41

going to be it now underneath that we

150:42

are going to be also creating a button

150:44

which will say like uh add item and here

150:47

we have to specify the type which will

150:49

be set to submit in lowercase submit

150:52

there we go now that's cool and

150:54

everything but the final thing that we

150:55

have to do is that we have to show our

150:57

shopping list this is how we are going

150:59

to be creating our shopping list we're

151:00

going to be providing a name of our item

151:03

we're going to be also providing a

151:04

quantity and when somebody clicks on

151:06

this BN so it's going to add there but

151:08

we also have to show that quantity and

151:10

also the name so to show them we're

151:12

going to be using our Ur and inside this

151:15

UL we're going to be using like items.

151:17

map and we have that items which we have

151:19

declared up above we have all of that

151:21

items right here it's going to take the

151:23

item and it's going to also take the

151:24

index as well and inside there we're

151:26

going to be providing our Ali and it's

151:28

going to take the key and key will be

151:30

coming from the index and for the value

151:32

we're going to be using like item. name

151:35

and then we are going to be also

151:36

providing the quantity q n t y and

151:40

quantity will be item. quantity there we

151:43

go or you know what let me just change

151:46

there to semicolon so I'm going to send

151:48

my file next we have to create our

151:50

handle submit function which we've

151:52

specified right here so let me just go

151:54

ahead and create there I'm going to be

151:56

using like handle submit it's going to

151:57

take the event object and inside there

152:00

we're going to be preventing the default

152:01

Behavior first of all and now inside

152:04

there let's just check if we don't have

152:06

the name or if we don't have the

152:08

quantity so in that situation we are

152:10

going to be only returning like nothing

152:13

basically so we just want to stop our

152:15

execution there if that's not the case

152:17

and if you only have like either the

152:19

name or the quantity so in that

152:21

situation we're going to be creating our

152:23

new object which will select new item

152:25

itm there we go and we're going to be

152:28

creating a new item object it's going to

152:30

take the name we're going to be also

152:32

providing the quantity but in this case

152:34

we can also just write like quantity

152:36

just like so we can even remove one of

152:38

them if you wanted to but now in this

152:40

situation we are going to be converting

152:42

our quantity to a number so to convert

152:44

that to number we're going to be using

152:46

the parse integer and here we have to

152:48

specify our quantity so now let me just

152:50

save there and this is how we are going

152:52

to be creating our new item and we have

152:54

to Now set there to this set item so

152:56

I'll just go ahead and use my set items

152:59

this is provide our previous items and

153:02

here we're going to be using first of

153:04

all let's just clone our previous items

153:06

and come on what the hell am I doing let

153:09

me just clone this previous item and

153:11

also provide a comma there and use my

153:13

new item right here okay and also we are

153:16

going to be clearing the input field so

153:17

we're going to be using like uh set name

153:20

and also the set quantity LSS provide

153:23

empty string for all of them now that's

153:24

only done I'm going to save my file

153:26

check this out so we have our shopping

153:28

list so I can just write like

153:31

um computer and that's going to be like

153:34

3,000 or something like that I can't

153:37

even speak no more God damn it let me

153:39

click on this add item now it's going to

153:41

give us the name of the item and it's

153:42

going to also giv us the quantity and

153:44

quantity is that much so I can just

153:46

write like basically anything I want and

153:49

I can add that and here you can see I'm

153:50

now getting that same result so yeah

153:52

that was a huge challenge but I hope

153:55

that was worth it because Us St is the

153:58

most important thing in reactjs and you

154:01

have to make sure that you master the US

154:03

St so that was a huge challenge about

154:06

the US and you even build like three or

154:08

four challenges or maybe a projects to

154:10

be precise so I can totally uncommon all

154:13

of them and and now let me show you all

154:15

of them here you can see we can now

154:17

increment and also decrement we can also

154:19

add a new to do we can also just provide

154:22

a name and also the edge if you wanted

154:24

to and shopping list un name it okay so

154:27

we would be totally getting our value

154:29

which is now added so now let's talk

154:31

about the react portal so what do I mean

154:33

by react portal react portal is a

154:35

feature that allow you to render a child

154:37

component into a Dom node that exist

154:40

outside the hierarchy of the parent

154:42

component so this can be useful for

154:44

scenarios like whenever we are creating

154:46

a model or tool tips or drop down menus

154:49

where you want to break out of the usual

154:51

parent child structure and render in a

154:54

different part of the Dom okay so you

154:56

can think about the portal is just like

154:59

the Rick and Morty portal okaye so which

155:01

will allow you to go to anywhere inside

155:04

your Dome so that was just a basic

155:06

Theory and now let's get into the coding

155:08

and then you'll get to know what I'm

155:09

talking about so to learn about the

155:11

react portal first of all we're going to

155:13

be creating a components folder and

155:15

inside this folder we are going to be

155:17

defining our copy input. jsx file and

155:20

inside this file we're going to be

155:21

creating where RFC s my file go to my

155:24

app and render this component right here

155:27

is I'll use like copy input and close

155:30

there so the first thing that I want to

155:31

do is then want to just make a simple

155:33

component so I'll just create a state

155:35

with the name of like input value come

155:37

on input value it's going to also take a

155:40

set input value so we're going to be

155:42

setting that to the used St and for the

155:45

initial value we're going to be

155:46

providing only empty string and we're

155:48

going to be also creating yet another

155:49

set for the copied and then set copied

155:53

like so it's going to be equals to the

155:54

use once again and for the initial value

155:57

we're going to be specifying fals to

155:58

there okay that's also done now let's

156:01

get into the UI and I'm going to remove

156:03

this copy input text from here and I'm

156:05

going to create my input field inside

156:07

there God this keyboard is super fast

156:11

I'll provide the value and the value

156:12

will be coming from the input value

156:14

which we are creating up above and

156:16

whenever somebody try to change

156:18

something inside this we going to be

156:20

firing this function and providing or

156:23

set input field right here and the

156:25

initial value will be set to event.

156:27

target. value and yeah I guess that's

156:29

going to be fine but we're going to be

156:31

also creating a button which will say

156:33

like copy it or copy would be fine okay

156:36

so whenever somebody clicks on this

156:38

button we're going to be finding this

156:39

copy or handle copy function so now let

156:41

me copy there and create this function

156:43

right here so I'll use like cons handle

156:45

copy create this eror function right

156:47

here so we're going to be using like nav

156:49

Gator n AIG g t o r this is a JavaScript

156:53

function so we have to use like

156:55

clipboard property on there and you want

156:58

to write text to there okay so I'll use

157:00

like uh write text and here we have to

157:03

specify our input value and also we want

157:06

to use the then method because we're

157:08

going to be delaying there okay so let's

157:10

just use our then method and inside

157:12

there we're going to be providing a set

157:14

C and provide true to them you also have

157:17

to use our set timeout and here here we

157:19

have to specify our callback function

157:21

and for this callback function we're

157:23

going to be providing our set copied

157:25

which will be set to false you want to

157:27

just set that to false and also you want

157:29

to provide 2 seconds of delay today so

157:32

now let me just save my file and check

157:34

this out so here you can see we have our

157:36

input field I can type whatever I want

157:38

to type inside there I write like hosan

157:41

web dev and now if I click on this copy

157:43

and if I go into the new tab and place

157:46

it right here so here you can see we're

157:47

now getting our hosen web dev right here

157:49

which is cool now the next thing that we

157:51

want to do is that we want to create our

157:52

popup content. jsx component and I'm

157:55

going to be using my RFC inside there so

157:58

let me just past this copied as a prop

158:01

to this function so here I'm going to be

158:03

rendering my popup component let just

158:06

close there and we're going to be

158:08

passing this copied as this copied prop

158:11

right here now let me go ahead and grab

158:13

there by using the destructuring so now

158:15

let me just save my file and now I'm

158:17

going to change that to a second so I'll

158:20

just write a section right here what the

158:22

hell was that this keyboard is super

158:24

fast so now let me just change that to a

158:26

section God s ctio and there we go okay

158:31

and I'm going to also change this level

158:32

and here we have to check if he copied

158:35

the content so which means you want to

158:37

show this UI so I'll use like uh div

158:40

inside this div I'll write like copied

158:42

to clipboard like so okay so now let me

158:46

just save my file but I also want to

158:47

provide a bit of styling to this I'll

158:49

use use like style and here for the

158:51

style we going to be providing a

158:52

position and Position will be set to

158:54

Absolute and we also want to provide a

158:56

bottom and bottom will be set to only

158:59

three Rs now let me go ahead and check

159:01

this out so now let me just refresh

159:03

there and if I type anything inside

159:05

there and I click on this copy button

159:07

it's going to show us this copy to the

159:09

clipboard and then it will disappear let

159:11

me try that once again if I click on

159:13

this copied so it's going to show us

159:14

this copied content and then it will

159:16

make it disappear so yeah that's cool

159:18

and everything but now let me show you

159:19

the Dom tree if I open my console I mean

159:22

like the element let me go to the body

159:25

let me also go to the root so here you

159:26

can see all of our content let me just

159:28

zoom in a bit all of our content is now

159:31

available inside this route and this

159:33

root is coming from this index.html file

159:37

so here you can see we have a div and

159:39

inside this div we have the ID of root

159:41

we now selecting there and we are now

159:43

rendering all of our content to that

159:45

root right here but let's suppose if we

159:48

don't want to render our content to this

159:50

div so let's suppose if you want to

159:51

render our cont to the body or somewhere

159:53

else so how what we are going to be

159:55

doing there so to do that you guessed it

159:58

we going to be using the react portal so

160:01

first of all we going to be importing

160:02

the react portal so I'll use like import

160:05

and then create portal and we are going

160:08

to be getting that from the react Dom

160:11

not from the react J but from the react

160:13

D okay so first of all you have to

160:15

import this create portal and now to use

160:18

them this is how we going be using there

160:20

so now let me just call this create

160:21

portal right here and here the first

160:24

thing that we have to do is that we have

160:25

to specify what content you want to

160:28

render trying to render the H1 or any

160:31

kind of content that you want to render

160:33

that's going to be the first parameter

160:35

next you also have to specify where you

160:37

want to render there so I'll just use

160:39

like something else but first of all I'm

160:41

going to go ahead and go into my index.

160:43

HTML file and here I'm going to just

160:45

render like some sort of a DA which will

160:47

have like pop up

160:50

uh content or something like this so

160:52

here you can see I defined my own D with

160:53

the idea of popup content I'm going to

160:55

copy that from here and now let me go

160:57

ahead and provide a comma there once

160:59

again so I'll just provide a comma here

161:02

and now we have to select that D so I'll

161:04

use like document do query selector not

161:07

selector all but just a query selector

161:10

and inside this query selector we want

161:12

to access that div which we just created

161:14

right here so first of all we have to

161:16

provide this pound symbol and then we

161:18

have to specify this popup content so

161:20

now if I save my file and refresh there

161:22

and what are we getting we are now

161:24

getting this popup content now if I

161:26

expand that in inside there we have our

161:28

section so inside there here you can see

161:30

we have our section and this section is

161:32

currently empty because we did not copy

161:35

your content so here you can see if I

161:37

just type something and as soon as I

161:39

click on there it's going to render my

161:41

content right here and then it will make

161:43

it disappear so you know what a bit more

161:45

delay to this so let's just and change

161:46

that to 5 Second would be fine so now if

161:49

I i s my file and now let me just P like

161:52

hen web dev and now if I click on this

161:55

copy and here you can see if I expand

161:57

there and yeah we are now getting this D

161:59

let me try there once again expand there

162:03

yep we are now getting this copied to

162:04

the clipboard so yeah this how we're

162:06

going to be rendering our content to

162:08

another part of our Dom by using the

162:10

react portal so we've already seen keys

162:13

in the list section but I want to

162:14

explain there a bit more so what I'm

162:16

going to do is that I'm going to create

162:17

my components folder and inside this

162:19

folder I'm going to create a switcher

162:22

jsx and I'll just write my RFC inside

162:25

there and register there right here

162:26

inside my app component uh switcher

162:29

there we go now let me go ahead and go

162:31

to my component and first I'm going to

162:33

create a start with the name of s sw4

162:35

switcher and then set s SW it's going to

162:37

be equals to this uh us start once again

162:40

and we're going to be providing the

162:41

initial value of false today okay so

162:44

what I'm going to do I'm going to render

162:46

my dark and light mode so I'll just put

162:48

there like so I'll use like s SW if you

162:50

have there in that situation we want to

162:52

provide one UI but if you don't have

162:54

there want to provide another UI so I'll

162:57

just write like a spin and this Spen

162:59

will say dark okay but if that's not the

163:02

case we want to provide yet another with

163:03

the text of light to it okay so now let

163:06

me just save there so that's also done

163:08

we also have to provide a br for a

163:10

breaking and now underneath that we're

163:13

going to be creating an input field with

163:14

a type of text and now underneath this

163:16

input you want to create a button and

163:18

which will say like switch S W T C and

163:21

when somebody clicks on this button we

163:23

want to change that so I'll use like set

163:25

switch or a set s SW to be precise let's

163:28

just put our s and not s you guys

163:31

already know all of this stuff so let me

163:33

just explain the once again here you can

163:34

see we're now rendering this content ear

163:36

dynamically then we have a br then we

163:39

also have a input field and also a

163:40

button which allows us to switch between

163:42

the dark and light mode okay so this is

163:45

how it will look like so if I click on

163:47

this it's going to make it dark if I

163:48

click on the once again so it's going to

163:49

make it light let's suppose if I type

163:52

something inside this input field and if

163:54

I click on this switch and here you can

163:56

see that input field will stay the same

163:59

even though we changed it to dark but

164:02

this input field still have this value

164:04

so to make the totally unique so for

164:06

that we can proide a key so what I'm

164:08

going to do is that here I'm going to

164:10

pass a key and this key will take our ST

164:12

which is s SW so if that is the case we

164:15

are going to be providing a dark but if

164:16

that's not the case we are going to be

164:18

providing a l now we are providing a

164:20

unique value to this specific input

164:23

field so if you have some sort of a

164:24

value so if our input field is set to

164:27

true it's going to make it dark but if

164:29

that's not the case we're going to be

164:31

getting a light this is now set to dark

164:33

let me change that to light and if I

164:35

type something inside this input field

164:37

and click on the switch here you can see

164:39

that value is now successfully gone we

164:41

are not storing there in some sort of a

164:42

local storage or in some sort of a

164:44

database so that's why qu is now

164:46

successfully gone case so now if I type

164:48

something inside this input field once

164:50

again so it's going to remove all of

164:52

their value from this input field okay

164:54

so this is how we are going to be making

164:57

or specific element or a component

164:59

totally unique by providing a key to

165:01

there if I change that to something else

165:03

like uh I don't know like placeholder or

165:06

something like that let me just write a

165:07

placeholder okay and now if I save my

165:10

file and here you can see it's now set

165:11

to light if I type something inside

165:13

there and switch there that value will

165:15

still be there why because we're using a

165:18

placeholder and not a key so if I

165:20

convert there to key and if I type

165:22

something inside this input field so it

165:24

will remove there from here because this

165:26

input field is no longer that old one

165:28

okay so this is how we are going to be

165:29

making it unique now let's talk about

165:31

the use effect hook so use effect hook

165:33

allow you to perform a side effects in

165:35

your component so some example of what

165:37

side effects are like fishing the data

165:39

directly updating the Dum and also

165:41

logging something to the consoer also

165:43

considered to be a side effect inside

165:45

your component so anytime you want to do

165:47

some sort of a side effect inside your

165:49

component like for instance if you want

165:50

to fit some sort of data inside your

165:52

component so in that situation we're

165:54

going to be using the use effect hook so

165:56

how this syntax will look like here you

165:58

can see we are now first of all using

166:00

our use effect hook and now inside this

166:02

use hook we are now providing our

166:04

callback function to it and then inside

166:06

that callback function you can do

166:08

anything you want to do but there are a

166:10

few things that I want you to keep in

166:11

mind when working with the use effect

166:13

the first thing is here you can see we

166:15

are not providing any array that array

166:17

is something called the dependency array

166:18

array which I'm going to be explaining

166:20

in a few seconds so anytime we don't

166:22

specify the dependency array so in that

166:24

situation that call back function will

166:26

call on every single render I want you

166:29

to keep that in mind whenever we don't

166:31

specify the dependency array which means

166:33

like that call back function which we

166:35

now providing inside our use effect will

166:37

be fired on every single render next

166:41

let's talk about the use effect with

166:42

conditional so you cannot prep your hook

166:45

inside the conditional statement if you

166:47

want to use the conditional statement

166:48

you are going to have to use the inside

166:50

the use effect hook okay so also keep

166:53

that in mind now the final thing that I

166:54

want you to keep in mind is that any

166:56

time we specify the empty dependency

166:59

array forward use effect it will only

167:01

fire that function which is available

167:03

inside our use effect hook on the

167:05

initial render like when our component

167:07

first renders it will call their

167:08

function not when our component changes

167:11

but if we create some sort of a state

167:13

and we provided the value of that state

167:15

so anytime that state changes that

167:18

component will reender and that callback

167:21

function will fire okay so I know that

167:23

was a lot of theories now let's get into

167:25

the coding and then you'll get to know

167:26

what I'm talking about now let's talk

167:28

about yet another hook which is called

167:30

the use effect hook so we set up the use

167:32

effect hook to run some code when our

167:34

component render for the first time and

167:36

whenever it reenders and also when some

167:39

sort of a data changes inside our

167:42

component so how are we going to be

167:43

making a setup for that the first thing

167:45

that we have to do is that we have to

167:46

grab our use St and also they use use

167:49

effect okay so we're going to be

167:50

importing our use effect from the react

167:52

JS and now we have to use that but

167:54

before we use that I'm going to also

167:56

make a set of for my value so I'll just

167:58

use like value and also set value that's

168:01

going to be equals to the use St and

168:03

we're going to be providing the initial

168:04

value of zero inside there now I'm going

168:07

to be using my user F hook and now

168:09

inside this user F hook it takes two

168:12

arguments the first argument it takes is

168:14

a callback function and the second

168:16

argument it takes is a dependency array

168:18

which is something I'm going to be

168:19

showing you in a few seconds but now

168:21

let's talk about this callback function

168:23

now inside this callback function you

168:25

can write any kind of logic that you

168:27

like you can even use your document.

168:29

title you can log something to a console

168:31

you can fish some sort of a data you can

168:33

do anything you want to do inside this

168:35

uh callback function okay so what I'm

168:37

going to do is that I'm going to just

168:39

use my console.log and I'm going to just

168:41

write like call use effect right here

168:43

and I'm going to also use my

168:45

document.title and that's going to be

168:47

equals to increment

168:50

and I'll just provide the value which

168:52

I've already set up inside my state

168:54

right here okay so I'll just call there

168:56

now the next thing that I want to do is

168:57

that I'm going to just remove this F

168:58

From Here and Now inside there I'll just

169:01

use my H2 and I'm going to also render

169:03

my value inside there and also I'm going

169:06

to just create a button to increment my

169:08

counter so I'll just use like click me

169:10

and I'm going to also provide the on

169:12

click man hander to it and let's just

169:14

pass our call back function inside this

169:15

I'll just use like set value and here

169:18

we're going to be passing like value +

169:19

one which is just incrementing there so

169:22

here you can see I want you to only

169:23

focus on this use effect right here now

169:26

inside this use effect we are not

169:28

providing our dependency array we are

169:30

just creating our use effect or we are

169:32

just calling our use effect and we are

169:34

just passing our call back function to

169:36

there okay so now if I save the changes

169:38

and if I refresh there here you can see

169:40

we now getting this result which is like

169:41

called use effect twice and why are we

169:44

getting there twice this because here

169:46

you can see we are using uh this stck

169:48

mode so if I just remove the strict mode

169:50

from here save my file and now if I

169:52

refresh there I'm only getting this

169:54

message once not twice so that's also

169:57

something if you want to keep in mind

169:59

you can totally keep that in mind so

170:01

yeah so here you can see now anytime I

170:04

change something inside my component

170:07

that call back function will fire every

170:09

single time okay so here you can see if

170:12

I click on this button and it's going to

170:14

giv us that message once again if I

170:16

click on there once again and here you

170:17

can see my title is changing

170:19

and also I'm getting this result right

170:21

here inside my console so why is that

170:23

that's because we are not providing any

170:25

dependency array right here so when we

170:27

are not providing any dependency array

170:29

to our use effect it will run this code

170:32

every single time whenever our component

170:35

rerender so I want you to keep that in

170:37

mind but now I'm going to also provide

170:39

my empty dependency array right here so

170:41

if I just use like comma and I'm going

170:43

to also provide my empty dependency

170:44

array and now if I save my file and now

170:47

let me just refresh there here you can

170:48

see we are getting our call use effect

170:51

on the first render but now if I click

170:53

on this button we are not getting our

170:56

result right here and here you can see

170:58

the title it is also not incrementing

171:00

and we are also not getting any more

171:02

results why is that as I said that once

171:05

we specify this empty dependency array

171:08

we didn't specify nothing inside there

171:10

like this dependency array is totally

171:12

empty so in that situation this callback

171:15

function will only fire once once our

171:18

compound renders this call back function

171:20

will fire but not again and again but

171:23

now in this situation I'm going to also

171:25

copy this value and I'm going to also

171:27

place it right here so if I save my file

171:30

and now let me just refresh there and

171:31

here you can see we have our callback

171:33

function called once again and now if I

171:35

click on this click me button we are

171:37

getting there now I know a lot of people

171:39

will ask me like Huzan what's the point

171:40

of providing this value and we can also

171:43

just remove the ins can also gives us

171:44

that same result right here like we are

171:46

getting this uh result right here inside

171:48

the console and also our title is also

171:51

incrementing so like if I click on there

171:53

here you can see both of them are

171:54

working exactly the same thing like

171:56

don't they now now if we specify this

172:00

value right here and anytime where

172:03

component changes because of this state

172:06

this call back function will fire but if

172:08

we have some sort of other state and

172:10

that state is also rendering or

172:13

component this code will not fire so now

172:15

let me just give you the example of that

172:17

I feel like I'm confusing you so you

172:19

know what let me just say that once

172:20

again now that we specify the value of

172:22

this state and anytime that state

172:25

changes and our component rerenders

172:28

because of this state this callback

172:31

function will fire but if we have some

172:33

sort of other state and our component

172:35

rendered or reender because of that

172:38

other state this callback function will

172:40

not fire so now let me give you example

172:42

of there so I'll just use like const and

172:44

then something and then set something

172:47

and that's going to be equals do this

172:48

use Effect one more time and we're going

172:50

to be providing the initial value of

172:52

zero today so I'm going to duplicate

172:53

this line of code and I'm going to also

172:55

write like uh increment by something

172:59

okay and now instead of providing the

173:01

set value I'm going to change that to

173:02

like set something and now if I say my

173:04

file and here you can see if I just

173:06

refreshed it and I want you to keep in

173:08

mind here you can see it's going to

173:10

gives us that value for the first render

173:12

and now if I click on the click me it

173:14

will render my component because of this

173:18

St right here we are now providing this

173:19

value right here but now if I click on

173:21

this increment by something nothing is

173:24

happening right here and why is there

173:26

because here you can see we are only

173:28

providing this value which is a state

173:30

value and whenever our component changes

173:32

because of this value so then this

173:35

callback function will fire okay and

173:38

whenever our component changes because

173:39

of something else this callback function

173:41

will not fire so if I also copy it and

173:44

if I just write a comma here and I'm

173:46

going to also provide this something

173:47

right here my file and now let me just

173:49

refresh there if I click on this button

173:52

it's going to fire if I click on this

173:53

button it's going to also fire okay so

173:56

yeah keep that in mind and now the final

173:58

thing that I want to show you is that

174:00

the conditional statement so I'm going

174:01

to just remove that from here and now if

174:04

I just use like um if value is greater

174:08

than zero I want to wrap this entire

174:10

hook inside that conditional statement

174:12

so if I save my file and Watch What

174:15

Happens so here you can see we are

174:16

getting warui but now if I click on the

174:18

click me button we are getting our error

174:21

right here and that's a huge error you

174:23

know I'm going to go to the top react

174:25

has detected a change in the order of

174:27

the hook called by app this will Le to a

174:29

bug and errors if not fixed for more

174:31

information go to this link okay so we

174:34

are not allowed to wrap or hook inside

174:37

the conditional rendering if you want to

174:39

use some sort of a condition we have to

174:41

use that inside the use effect so if I

174:44

just put that inside this use effect I'm

174:46

going to also put that inside this us

174:48

effect and now if I save my file and now

174:50

if I just refreshed it and now I can

174:52

click on there and everything will work

174:54

totally the same so yeah that was just

174:57

the basics of use effect I'm going to

174:59

remove all of that stuff and now let me

175:01

show you how we going to be fetching a

175:03

data by using our use effect so I'll

175:05

just save my file now let's get into the

175:07

data fetching so to fetch your data the

175:09

first thing that we have to do is that

175:10

we have to create some sort of a state

175:12

where we're going to be ping our data so

175:14

I'll just use like uh data and then set

175:17

data and we're going going to be using

175:18

our use come on use St once again in the

175:21

initial value I'm going to specify empty

175:23

array right here okay now underneath

175:26

that I'm going to be using my use Effect

175:27

one more time and now inside this use

175:29

effect I'm going to just pass my

175:30

callback function and now here I'm going

175:33

to P my empty dependency array right

175:35

here this empty dependency array just

175:37

simply means that this callback function

175:39

will run only once okay and now inside

175:42

there we're going to be using our

175:44

asynchronous function so I'll just

175:45

create my asynchronous function and I'm

175:47

going to give it the name of like get

175:49

data you can give any name that you like

175:50

I'm not going to be providing any

175:51

perimeter today and I'll just use like a

175:54

word and we are going to be fetching our

175:55

data from this resource if I go to this

175:57

Json placeholder typei code and here you

176:00

can see this is a website of there you

176:03

can learn more about there if you wanted

176:04

to but the one we are interested in but

176:06

is by getting this data so I'll just

176:08

copy there or you know what I'm going to

176:10

just go into the to-dos so I'll just use

176:13

that right here and I'm going to provide

176:15

my to-dos and hit enter and here you can

176:17

see it's going to give us a lot of to

176:19

word here so we have like ID you know

176:21

let me just zoom in a bit so we have our

176:23

ID we have the title and also the

176:25

completed flag for all of these data and

176:28

by the way this is array so that's why

176:30

we set up what used as our array right

176:33

here I'm going to copy this link and I'm

176:35

going to go into my file right here and

176:38

we're going to be placing that inside

176:39

our fetch okay so I'll just place it

176:41

right here and I'm going to also store

176:43

there some sort of variable like cons

176:45

res or response would be fine and now

176:47

underneath there I'll just convert there

176:49

to the Json so it's going to give us

176:51

like response I'm going to change that

176:52

to the Json and store that in the data

176:55

variable okay so now I can log the data

176:58

and I can do a lot of things with that

176:59

data but you know I'm going to just put

177:01

a conditional statement like if we have

177:02

the data and the data. length like if

177:05

you have some sort of a data so in this

177:07

situation we are going to be taking our

177:09

state which is set data and we are going

177:11

to be using that right here and now let

177:14

me just run them we're going to be

177:16

taking that data as a return value and

177:18

we are going to be putting the inside

177:20

our set data okay now that we

177:22

successfully created our function but

177:24

now we have to call it right here inside

177:26

there so if I just use like get data and

177:28

I'm going to just execute there and this

177:30

is how we are going to be fetching our

177:31

data by using the use effect our data

177:34

fetching logic is now successfully done

177:36

so I'm going to collapse that right here

177:37

now that we successfully get the data

177:39

but the next thing that we have to do is

177:40

that we have to render that data to the

177:42

Dom so I'm going to be using like ul and

177:45

inside this UL I'm going to use my data

177:47

because this is the state where all of

177:50

our data is located so we're going to be

177:51

using there and we already know that

177:54

there is come on let me just go into the

177:56

to-do that is array and inside this

177:59

array we have a lot of like objects

178:02

right here so we're going to be

178:03

iterating over through there and to

178:04

iterate over through there we are going

178:06

to be using the map method and I'm going

178:08

to just P like item or to do would be

178:10

fine okay so now inside each of these to

178:13

do we're going to be using our Li and

178:16

now I'll just render like um come on all

178:19

render like too too. tile and I guess

178:23

that's going to be fine I can also

178:25

provide the idea of like math. random or

178:28

I can use like uh too. ID which is this

178:33

ID hopefully it will gives us so we have

178:35

our ID right here so we can also use

178:37

that if I sve my file and here you can

178:39

see we are now getting all of the too's

178:41

ID so now let me just refresh there and

178:43

everything is working the way we expect

178:45

him to work so we are now getting the ID

178:47

but we can also get the body okay we

178:51

don't have the body so if I go into let

178:54

me just go back yeah I'm going to go to

178:56

the post and now inside this post we

178:58

have our body so I'm going to copy there

179:00

I'm going to go in there and here I'll

179:03

just change there two posts or yeah post

179:06

would be fine so if I save there now I

179:08

can successfully get the body as well so

179:11

if I just duplicate that and change that

179:13

to the body and we are getting an error

179:16

so we have to wrap in some sort of a

179:17

section I'm going to cut that from here

179:19

and also place it here sem my file and

179:22

now if I go there refresh there God damn

179:25

it I'm not getting any body each charge

179:27

should be a unique got cut that from

179:30

here put there for the section you don't

179:33

need there right here so I'll just

179:35

remove the okay sem my file and refresh

179:38

there we're only getting the title but I

179:41

guess we're not getting the B so if I

179:42

just write like B and dash dash yeah we

179:46

are getting this B right here so yeah

179:48

this is how we going to be getting the

179:50

title and this is how we going to be

179:51

getting the body so this is how we are

179:53

going to be using the use effect to

179:55

fetch the data and also we learn a lot

179:57

about the use effect welcome to the use

179:59

effect channel so in this one I want you

180:01

to create the use effect component then

180:03

use the use effect to log message to the

180:05

console whenever the component first

180:06

mounts for example when it runs for the

180:09

first time then in the second portion

180:11

you're going to be using the use Effect

180:12

one more time create first of all the

180:13

counter effect component then use the

180:16

use effect to update the document time

180:18

whenever the component value changes

180:20

like first you have to initialize the

180:21

count to zero value by using the US St

180:24

then render B that increments the

180:26

account and use the use effect to update

180:27

the document title title whenever the

180:29

component changes and finally you're

180:31

going to be using the use effect to

180:33

fetch the data so first of all you have

180:35

to create a component with the name of

180:36

like fish data effect and then inside

180:39

that you're going to be using the use

180:40

effect to fish your data from this

180:41

endpoint like from this API which is a

180:44

Json placeholder typei code.com and

180:46

forpost

180:48

yeah give it your best shot if you can

180:50

do it then come back and watch the

180:51

solution and I'm going to give you my

180:53

solution so first of all create a

180:54

component with the name of like basic

180:57

effect. jsx I'm going to be using my RFC

181:00

inside there let's just go ahead and go

181:02

to my app and register my component

181:04

right in here so I'll use like basic

181:07

effect and close this so if I save my

181:09

file and here you can see we now getting

181:11

our basic component or basic effect

181:13

rather now the first thing that I want

181:14

to do is that I want to grab my use

181:16

effect from the reactjs and I'm I'm

181:17

going to be passing a call back function

181:19

today and inside there let's just use

181:21

our conso log which will say like basic

181:24

component mounted right here we're going

181:26

to be also providing an empty dependency

181:28

array and watch what happens whenever

181:30

the component first renders so I'll just

181:32

write like H1 and check the console

181:36

console to see the

181:39

message so we're going to be checking

181:41

the console right now so let me just go

181:43

ahead and go to the console let's just

181:46

refresh there and we are getting a basic

181:48

component mounted for the first time and

181:50

why is that that's because of this empty

181:52

dependency array so that was the

181:54

challenge number one and let's just

181:55

remove there I'm going to create another

181:57

component which will be a counter

181:59

effect. jsx and let's just use our rafc

182:02

inside there and register my component

182:04

right here which will say counter effect

182:07

and I'm going to place that right here

182:09

and inside this component the first

182:11

thing that I want to do is that I want

182:12

to create my count and also set count is

182:15

going to be equals to the use come on

182:17

use stand and the initial value will be

182:19

set to zero now I'm going to be using

182:22

the use Effect one more time for the

182:24

side effect so now inside them we're

182:26

going to be also passing a count right

182:27

here like whenever our component changes

182:30

because of this St so watch what will

182:32

happen so I'll just use like document.

182:35

title and that's going to be equals to

182:37

this template literal and let's just

182:40

provide our count and the count value

182:42

from or state so I'll just use like

182:44

dollar sign and then and then discount

182:47

and now for this I I'm going to remove

182:48

that from here and I'll just write like

182:51

count here and render my count to

182:54

dynamically now we going to be also

182:55

creating a button which will say like

182:57

increment and here whenever somebody

183:00

clicks on this button we're going to be

183:01

firing this function which will be the

183:03

set count and here we have to specify

183:06

count + one I'm going to save my file

183:08

right now and Watch What Happens so here

183:10

you can see I want you to notice this

183:13

area right here this title so whenever I

183:15

click on this increment it's going to

183:17

change the counter to it and it's going

183:18

to also change this count title right

183:21

here to add so if I just click on there

183:23

and here you can see it's going to

183:24

increment my counter by one so that was

183:27

the Second Challenge now for the third

183:29

challenge uh we have to create our fetch

183:31

data component so I'll use like fetch

183:33

data effect. jsx do jsx and let me just

183:38

use my RFC inside there let's just

183:40

create our St so that we can store our

183:42

data inside there so I'll just use like

183:43

post and then set post and that's going

183:46

to be equals to the used stand we're

183:48

going to be providing the empty

183:49

dependency array or not dependency but

183:51

empty array just for holding our data

183:54

now we are going to be performing the

183:55

side effects so for that we have to use

183:57

our use effect and here we are going to

184:00

be providing our empty dependency array

184:02

right here and now we're going to be

184:04

defining our function which will allows

184:05

us to fetch our data so what am I even

184:09

doing what the hell let's just provide

184:10

our asynchronous function and we are

184:12

going to be providing first of all the

184:14

response and let's just use our a and

184:16

we're going to be fetching our data data

184:18

from this URL and also we have to

184:20

convert our data or response to Json so

184:23

we're going to be storing there in the

184:25

data and finally we have to store the

184:27

inside our stat we're going to be using

184:28

like set set post and put our data

184:31

inside there now underneath this

184:32

function we are going to be calling it

184:34

okay so now if I save my file and call

184:36

it and it's going to give us the perfect

184:38

response so we have to also render their

184:40

data to the Dom so that we can see them

184:42

so I'm not going to do anything crazy so

184:44

I'll just write like first post title

184:47

and here underneath this H1 we're going

184:49

to be iterating over through all of the

184:50

post so I'll just use like post. length

184:53

is greater than zero so in this

184:55

situation we're going to be using our H2

184:57

and I'll just write like um post and we

185:00

just only want to get the first post

185:02

we're not interested in all of them and

185:04

we only want to get the title out of

185:05

that but if that's not the case we're

185:08

going to be rendering or lowering dot

185:09

dot dot so now if I save my file first

185:12

of all we want have to register there so

185:14

I'll just go to my app and comment this

185:16

line out and register my patch data

185:19

effect component there sa my file now we

185:22

are getting this title and yeah this B

185:24

as well so now if I refresh there it's

185:26

going to give us the loading for a brief

185:27

second as you can see and then it's

185:29

going to give us the data this is how we

185:31

are going to be fetching a data by using

185:33

the use effect and this is how we going

185:35

to be performing more side effect by

185:36

using the use effect so now let me just

185:39

uncommon all of them and now we can

185:41

increment something and we can also

185:42

check out the logs and stuff like that

185:45

so now let's talk about the famous

185:46

problem with reactjs which is is called

185:48

the prop drilling so what is a prop

185:49

Drilling and why you should anyone care

185:51

about that so here you can see I have a

185:53

component High here right here so I have

185:55

a different component like app card

185:57

header navigation user date time and so

185:59

on and so forth and here inside the app

186:02

component I have a data suppose if I

186:04

want to pass that data from the app

186:06

component to the date component so how

186:08

can I go about doing that so to do that

186:10

there are a lot of ways to do the in

186:12

reactjs which we're going to be learning

186:14

throughout the course like by using Zeus

186:16

and also using the cont API and also

186:19

Redux toolkit and there are a lot of

186:20

ways but now let's talk about the prop

186:23

drilling we are going to be drilling

186:24

this data into multiple component so we

186:27

are going to be taking that data and we

186:29

are going to be passing that data into

186:31

all of these component by using the

186:33

props so how are we going to be doing

186:35

that so I'm going to pass my data from

186:36

the app component to the card component

186:38

by using the prop then I'm going to pass

186:40

that to the users component and now

186:42

finally I'm going to pass that to the de

186:43

component and then there we can use that

186:46

but imagine if you're working with like

186:48

Google or maybe Facebook or some big

186:50

companies they would have like a lot of

186:52

components and I mean like a lot they

186:55

would have like thousand component if

186:57

not million component so what you will

186:59

do is that you will just P your data by

187:01

using the props and you will just drill

187:03

your data no there is a solution for

187:06

that I'm going to show you that solution

187:07

in a few seconds but first of all I want

187:09

to show you the prop Drilling in action

187:11

then we will jump into the solution so

187:13

now let's talk about the prop Drilling

187:14

in action so what I'm going to do is

187:16

that I'm going to just create create my

187:17

components folder and inside this folder

187:20

I'm going to create my component a. jsx

187:23

and also component b. jsx and finally

187:27

component c. jsx and now I'll just go

187:30

into my component a and I'm going to use

187:33

my RFC and I'm going to go to the

187:35

component B let's just use our RFC and

187:39

also to the component C so now inside my

187:42

app component I'm going to just create

187:44

some sort of a variable with the name of

187:45

like name and I'm going to give my name

187:48

inside there so I'm going to save this

187:49

file now we have to paste this name data

187:52

into this component C so how can you go

187:55

about doing that so to do that the first

187:57

thing that we have to do is that we have

187:58

to call our component a and now let's

188:02

just render them we have to P that name

188:03

is the prop for our component a so I'll

188:06

just provide my name right here I'm

188:08

going to save there now inside my

188:09

component a I'm going to destructure

188:11

there right here and also we're going to

188:14

be just passing there into the component

188:16

B so I'll just use like component B and

188:19

I'm going to hit enter so it's going to

188:20

Auto Import there now we're going to be

188:22

taking that prop of name and we're going

188:24

to be passing that two or component B so

188:27

I'll just write like name right here so

188:28

I'm going to save there now I'm going to

188:30

go into the component B I'm going to

188:32

also destructure there right here I'll

188:34

just use my name and finally we have to

188:37

use that inside the component C okay so

188:39

I'll just close that right here and I'm

188:41

going to also past that as a prop so

188:43

that I can use that inside my component

188:45

C so I'll just go to my component and c

188:48

and I'm going to just destructure there

188:49

right here I'll just destructure my name

188:52

and now let's just use there right here

188:53

so I'll just use my H1 and I'm going to

188:55

just render the name right here so if I

188:57

save my file now so now we are drilling

189:00

this name is a prop to all of these

189:02

component like first of all we are

189:03

passing there to component a then to the

189:05

component B then to the component C and

189:08

finally we now rendering there inside

189:10

the component C so that's going to be a

189:12

lot of process and let's suppose if you

189:14

working with some sort of a bigger

189:15

company and you're going to have to pass

189:17

your data as a prop to all of these

189:19

component and that's going to be a

189:21

nightmare so to solve this problem we

189:22

are going to be learning about the

189:24

Contex API so now let's talk about the

189:25

context API context API is a feature

189:28

that allow you to manage and share State

189:31

across your component Tre without having

189:33

to pass prop down manually at every

189:35

level of your component tree it is

189:37

useful for scenarios where you need to

189:39

share data or function across many

189:42

component especially when these

189:43

components are deeply nested something

189:46

which we just saw few seconds ago so for

189:48

there we use a props but in this

189:50

situation we are not going to be using

189:51

any props we are going to be using

189:53

something called the context API and now

189:55

let's get into it so that was the basic

189:57

theory about the context API and now

189:59

let's refactor our prop drilling to use

190:02

the context API so what I'm going to do

190:05

is that first of all I'm going to have

190:06

to import my context so I'll just use

190:08

like create context and we're going to

190:10

be importing that from the reactjs so

190:12

now that we successfully import that so

190:14

the next thing that we have to do is

190:15

that we have to create the instance of

190:17

the so I'll just use like create context

190:19

and now we're going to have to store

190:20

them some sort of a variable so I'll

190:22

just give it the name of like data you

190:23

can like basically give it any name that

190:25

you like and I'm going to also export

190:27

that so that I can use this context

190:29

anywhere inside my project so that's

190:31

good now the next thing that I want to

190:32

do is that I want to wrap my entire

190:34

application to use this context so how

190:36

can I go about doing that I'll just uh

190:39

wrap there by using my data which is now

190:42

holding the value of my context so I'm

190:44

now calling this data right here and I'm

190:46

going to just close there and once I

190:48

close there and I'm going to also wrap

190:50

my component a inside there then we have

190:52

two properties so if I just write like

190:54

dot it's going to gives us consumer and

190:57

it's going to also gives us the provider

190:58

so provider just simply means this going

191:01

to allows us to provide our value or our

191:03

data into multiple components so I'm

191:06

going to just choose this provider and

191:07

here we just have to use our value and

191:10

inside this value we have to pass the

191:12

data which want to pass inside our

191:14

component so we no longer have to use

191:16

all of these props I'm going to just

191:18

remove them from here I'm going to copy

191:20

my name from there and I'm going to just

191:21

put there right here so if I save my

191:23

file and we also have to just uh copy

191:26

this one and we have to place it right

191:28

here so this is how we are going to be

191:30

using our prop first of all we have to

191:32

import it then we have to create an

191:33

instance of there then we have to use

191:35

the provider property on there and this

191:37

provider property allows us to provide

191:39

our data into multiple component so we

191:42

no longer have to drill our data into

191:44

multiple components by using the props

191:46

so I'm I'm going to go into my component

191:48

a and we no longer need this name right

191:50

here so I'm going to just remove there

191:52

just just remove there I'm going to go

191:54

into the component B I'm going to also

191:55

remove that from here let's just remove

191:58

that from here and now inside the

192:00

component C I'm going to also remove

192:02

that from here but now the question is

192:04

how are we going to be receiving that

192:06

data now that we pass that data right

192:09

here into this component but how in the

192:11

what we are going to be receiving there

192:13

or consuming there to receive there the

192:15

first thing that we have to do is that

192:16

we have to import our context as I said

192:19

like we're going to be using this export

192:21

so that we can use this context inside

192:23

multiple components so now we are going

192:24

to be importing there so I'll just use

192:26

like import my data and if I just H

192:28

enter right here so it's going to import

192:30

that from my app component and now we

192:32

have to use the inside our component so

192:34

what I'm going to do is that I'm going

192:35

to just remove that from here and I'm

192:37

going to also remove this divs from here

192:39

and instead I'm going to replace there

192:41

with this data and if I just write the

192:43

dot so what are we getting we are now

192:45

getting the provider and we are also

192:46

getting the consumer so this consumer

192:49

will allows us to consume their data or

192:52

receive their data this is how we are

192:54

passing the data and this is how we are

192:57

going to be receiving that data now this

193:00

consumer take a callback function so we

193:02

going to be passing our function inside

193:03

then to get our data so I'm going to

193:05

just write these curly braces right here

193:07

and I'm going to just provide my

193:08

function it's going to take the

193:10

perimeters so I'm going to just specify

193:11

the perimeter of name and now let's just

193:13

create our callback function now inside

193:16

there I can just return like H1 and now

193:18

inside this H1 I can use my name right

193:20

here so if I just write a name save my

193:22

file and if I just refresh there and

193:24

here you can see I'm now getting my name

193:26

so if I go ahead and change that to like

193:28

I don't know John or something so here

193:30

you can see we're now getting word John

193:31

so that's looking cool like we are

193:33

totally receiving this data but now the

193:35

question is let's suppose if I want to

193:38

provide like multiple data so how can I

193:40

go about doing there I'm going to go

193:42

into my context once again and I'm going

193:44

to just duplicate there like we are

193:45

creating one more instance so for

193:47

context and I'm going to just rename

193:48

that to a data one you can like

193:50

basically give it any name that you

193:52

prefer but in my case I'm going to just

193:53

rename that to data one I'm going to

193:55

save this file and now the next thing

193:57

that we have to do is that we have to

193:58

just create some sort of other data so

194:00

that we can pass that data into our

194:02

component so I'll just use like Edge in

194:04

this case and I am 22 so I'll just put

194:06

my 22 Edge right here okay and now if

194:08

you want to pass that into our component

194:11

so in that situation we're going to be

194:12

using our data one and then Dot and we

194:15

have our provider and this squ will

194:17

allows us to pass our data so I'm going

194:19

to just wrap that right here and once

194:21

again we're going to be using our value

194:23

and in this case we're going to be

194:24

passing the H as a value right here we

194:27

already provided the name but now in

194:29

this case we're going to be passing the

194:30

value so now that we successfully pass

194:32

this data we have to go into our

194:34

component C and we have to consume that

194:36

data or grab that data so I'm going to

194:39

just comment this line out and now if

194:41

you want to consume that data or receive

194:43

that data so now inside this data one

194:46

what do we have to do we have to just

194:48

use our return statement and now inside

194:50

this return statement once again we are

194:52

going to be using our data one inside

194:54

this if I just hit enter so it's going

194:55

to Auto Import that right here okay so

194:57

now we have to use that and once again

194:59

we're going to be using our consumer

195:00

property inside there and now inside

195:03

this data one consumer we are going to

195:05

be once again using a callback function

195:07

so I'll just use like Edge and now

195:09

inside there I'm going to just use my H1

195:11

right here first of all we have to

195:12

return that because we are using curly

195:14

braces and I'm going to write like my

195:16

name is and then I'll just put my name

195:18

inside there like name and I'm going to

195:20

also use like and I am uh age years old

195:26

there we go so if I sell my file and

195:28

here you can see I'm now getting like my

195:29

name is John and I'm 22 years old so

195:32

this is once again not a good way to

195:34

pass our data but at least it is better

195:36

than the prop drilling okay so we are

195:39

passing our data we are receiving our

195:41

data but now if you want to receive that

195:43

data we're going to have to use this

195:45

call back function and all so to solve

195:47

the problem so to solve even this

195:49

problem we are going to be using the use

195:51

context hook so now let's discuss about

195:53

the use context hook now let's talk

195:54

about the use context hook in reactjs so

195:57

use context hook allows us to access the

195:59

context value provided by the context

196:01

object directly within the functional

196:03

component so context provides a way to

196:05

pass the data through the component tree

196:07

without having to pass prop down

196:09

manually at every level something which

196:11

we just saw a few seconds ago so now we

196:13

only care about the use context H and

196:15

now let's get into it so now let's

196:17

refactor this code to use our context

196:19

hook so what I'm going to do is that

196:21

first of all we have to import or use

196:24

context hook right here so once we

196:26

successfully import them the next thing

196:28

that we have to do is that we have to

196:29

call that right here so I'm going to use

196:31

like use context and now inside this

196:33

context you have to keep in mind from

196:36

where your data is coming from is that

196:39

coming from the data or the data one

196:41

which we are already creating right here

196:43

like we're creating our create context

196:45

instance and now we passing our data by

196:48

using either the data or the data one so

196:51

now in this situation we have to tell

196:52

our hog like from which context or data

196:55

is coming from so in this situation I'm

196:56

going to copy this data and I'm going to

196:58

just put that right here and I'm going

196:59

to store there in some sort of a

197:00

variable like username or something like

197:02

that so this is how we are going to be

197:04

getting our data by using this use

197:06

context we no longer have to provide all

197:08

of these call back function return

197:10

statment and all of that so I can also

197:12

use there for the data on so I'll just

197:14

use like Edge and I'm going to use my

197:16

use not but use context once again and

197:19

I'm going to just P my data one inside

197:21

there so now I can totally remove all of

197:24

these codes I'll I'll just remove there

197:26

and here you can see we can just use

197:27

like our H1 and now inside this H1 I can

197:30

use like my name is and then I'm going

197:33

to just past my username right here and

197:35

I am age years old and I'm going to save

197:39

my file we have to write upper Cas a and

197:42

save my file and here you can see I'm

197:44

now getting like my name is John and I'm

197:46

I'm 22 years old so this use context is

197:49

very helpful so this is how we are going

197:51

to be passing our data and this is how

197:54

we are going to be receiving your data

197:56

by using the use context so yeah that

197:58

was it about the use context hook time

198:00

for the context challenge so the first

198:01

thing that I want you to do is that I

198:03

want you to create the user context. GSX

198:05

file and inside that file create a user

198:08

context and also the user provider which

198:10

will allow you to hold the shared data

198:12

next we have to use the use context to

198:14

access that data so once again you're

198:16

going to have to create the user

198:17

profile. jsx component and inside that

198:20

component you're going to have to use

198:21

the use context to access that data okay

198:25

and then finally you're going to be

198:26

updating that data so once again you're

198:28

going to have to create the update user.

198:30

jsx file and inside that file you have

198:32

to define the component then use the use

198:34

context which will allow you to access

198:36

their data and somehow update their data

198:39

so give it your B shot if you can do it

198:41

that's completely okay then come back

198:43

and watch the solution and now I'm going

198:44

to give you my solution so inside this

198:46

SRC I'm going to create a file with the

198:49

name of user context. jsx and inside

198:53

there the first thing that I want to do

198:54

is that I want to import my create

198:56

context and also the used St as well

199:00

next we have to Define our context I'm

199:01

going to be using Create context and

199:04

execute there and I'm going to also

199:05

store there in some sort of a variable

199:07

so I'll just give it the name of like

199:09

user context and now inne that we have

199:11

to create our provider so I'll just use

199:13

like cons user provider and that's going

199:16

to be equals to this children and it's

199:18

going to take the children and also

199:20

inside this component we are going to be

199:22

defining our used and the initial value

199:24

will be name so I'll just write like

199:26

John D and we're going to be

199:28

restructuring the user and also the set

199:31

user out of this used T okay so now

199:33

underneath that we're going to be

199:35

returning our user context which we've

199:38

already created right here we are going

199:40

to be calling there and now inside this

199:42

context we already know that we have a

199:44

property called dot provider so I'm

199:46

going to just write provider copy there

199:49

and also place it right here and now

199:51

inside there we're going to have to

199:52

paste some sort of a data so now in this

199:54

situation we're going to be passing our

199:56

user and we will also P the function

199:59

which will allows us to change that user

200:01

so I'll just write like user come on

200:03

value first of all and here we have to

200:05

Define our user and now I'm going to be

200:07

creating a function which will allows us

200:08

to change that state so I'll just use

200:10

like conceptd User it's going to be a

200:12

function which will take like a new uh

200:15

yeah new name would be f now I'll just

200:17

write like set user and here I'm going

200:19

to put the name then we will just

200:21

provide the updated name okay so now we

200:23

successfully created this function so

200:25

I'm going to copy the name of there and

200:26

place it right here and here we also

200:29

have to provide their children which we

200:31

are now taking as a prop so I'll just

200:33

write that children and that's

200:34

everything that we have to do and

200:36

finally we also have to export this so

200:38

that we can use the in other file so

200:40

I'll use like export export the user

200:42

context and also the user provider so

200:46

that I can use it in other component so

200:48

now that's done next we have to create

200:50

our component so I'm going to go into my

200:52

component folder and I'm going to create

200:53

my user profile. jsx okay so inside

200:57

there we're going to be using the use

200:59

context to access the data from our

201:01

context and we going to be also

201:03

importing the user context like from

201:05

which context we want to get that data

201:07

now let me create my component right

201:09

here and I'm going to just give it the

201:11

name of like user profile and now inside

201:13

this component we have to access the

201:15

data from our context so we're going to

201:17

be using the use context to access that

201:19

data from which context from this user

201:22

context which we've already specified or

201:24

defined right here okay so that's done

201:27

now I'm going to destructure only the

201:29

user we don't need this update user

201:31

right here we are only interested in

201:33

this user which we are now providing

201:35

right here okay if you want to get that

201:37

user so I'm going to remove this user

201:38

profile from here and I'm going to write

201:40

like H1 user profile and now underneath

201:43

this H1 we're going to be creating our

201:44

paragraph and here we have to rer or

201:47

user.name okay so so yeah that's going

201:50

to be fine so now if I save my file uh

201:52

let me just run there npm run Dev it's

201:55

not going to giv us anything because we

201:56

have to define the inside our app so

201:59

I'll just write like user profile BR f i

202:03

l e there we go now let me just save my

202:05

file and refresh there still we're not

202:08

getting anything I don't know why let's

202:10

just open my inspect element go to the

202:12

console and we are getting some sort of

202:15

error cannot destructure a property of

202:16

of user of user context as it is

202:18

undefined oh and my bad here we also

202:22

have to write our user provider so that

202:25

we can provide the in our entire

202:27

application so I'll just s it like user

202:28

provider and now we will be successfully

202:30

able to get their data so here you can

202:32

see we're now getting the user profile

202:34

and we're now getting the data from the

202:36

context inside this user profile

202:39

component so that's the second thing now

202:41

for the final thing we have to create

202:43

our update user. jsx component

202:47

and let me just remove that from there

202:49

and here once again we're going to be

202:50

importing the use context which will

202:52

allows us to get the data and also the

202:55

use State and which will allows us to

202:57

create our state and we're going to be

202:58

also importing the user context from our

203:01

context which we've already defined a

203:03

few seconds ago and I'm going to be

203:04

using my RFC to Define my component and

203:07

now inside there we're going to be

203:09

destructuring the update user from where

203:11

from the use context if you want to

203:14

destructure there from this specific

203:16

user context and now underneath that we

203:18

going to be getting the new name and

203:20

let's just write like set new name and

203:23

that's going to be equals to the US

203:25

state and the initial value will be set

203:26

to empty string now for this UI I'm

203:29

going to remove them and write my H2

203:31

which will say like update username and

203:34

now need there let's just create our

203:36

form remove the action because we don't

203:38

need that and provide the own submit and

203:40

on this submit we going to be firing

203:42

this function which we are going to be

203:43

creating in a few seconds and we will

203:45

also have to to create our input field

203:48

the type will be set to text the value

203:50

will be set to new uh name which we are

203:53

already defining right here and when

203:55

somebody types something in this input

203:56

field so we are going to be firing this

203:58

function which will say like set name or

204:00

set new name rather and we are going to

204:02

be getting our data by using the event.

204:04

target. value okay and now outside from

204:07

that we're going to be also providing a

204:09

placeholder to there which will say like

204:10

enter new name now let me just save my

204:13

file and now underneath that we're going

204:15

to be also creating a button which will

204:17

say like update and the type will be set

204:20

to submit okay so now let me just create

204:22

this handle submit function right here

204:25

so we are not going to be doing anything

204:26

crazy but we are going to be providing

204:28

our event object and now inside there we

204:31

are going to be preventing the default

204:33

Behavior okay and also we're going to be

204:36

checking if new name. RM let's just

204:40

write our triam so if that's the case

204:41

we're going to be using update user and

204:44

provide a new name to there and we're

204:46

going to be also empty out our input

204:49

field by providing a set new name and

204:51

set that to empty string okay so now let

204:54

me just save my file and now if I type

204:56

something inside that component but

204:57

first of all we have to register there

204:59

right here like update user and now let

205:01

me just save my so here you can see we

205:03

now getting our data from another

205:04

component and now if I write like uh or

205:07

no my name if I click on the update so

205:10

it's going update data but we are

205:11

getting some sort of error new update is

205:14

not defined okay God damn it instead of

205:17

a new name I specified the new update so

205:20

now let me just change there to a new

205:22

name sa my file and refresh there if I

205:25

write my own name once again click on

205:26

the update and here you can see it's

205:28

going update their name if I write like

205:30

something else and click on the update

205:32

so it's going to change there to

205:34

something else so yeah that was our

205:36

challenge about the use context and also

205:39

the yeah and also just about the context

205:42

now let's talk about the use reducer hug

205:44

so use reducer is a hug there is similar

205:46

to the US St hook but it is designed for

205:49

more complex State object or state

205:51

transitions that involves multiple sub

205:53

values so it allow you to manister in

205:56

the functional and immutable way I know

205:58

the definition sounds a bit scary and

206:01

trust me the syntax is more scarier than

206:04

the but throughout the course I promise

206:07

I'm going to give you a lot of practice

206:08

about the use reducer hook so now this

206:10

is how the syntax will look like first

206:12

of all we have our used reducer and

206:14

we're now passing the reducer function

206:16

and also the initial value for there and

206:18

we are now destructuring the state and

206:20

also the dispatch so what is all of that

206:23

even mean so now let's talk about the

206:24

used reducer initial state so this is

206:27

the starting value for the state when

206:28

the component first renders we going to

206:31

be passing some sort of initial value to

206:33

that so if you are building some sort of

206:34

a counter app you're going to be passing

206:36

a zero value or 10 value or anything

206:39

like that next we have a reducer

206:41

function this is a function that

206:43

describe how the function should Chase

206:44

based on some action or some conditions

206:48

so it takes the current state and the

206:50

action as an input and return new state

206:53

value to us okay so this is how our use

206:55

reducer will look like but now let's

206:57

talk about the things which we are going

206:58

to be destructuring from the use reducer

207:00

so the first thing that we have is the

207:02

state and this is going to be the

207:04

current state value which you can use

207:06

inside your component and then we have a

207:08

dispatch function and it is a function

207:10

you can call to send action to the

207:12

reducer function which then updates that

207:14

state so I know May sounds a bit scary

207:17

and difficult but trust me it's not so

207:20

you know what now let's get into the

207:21

coding then you'll get to know what I'm

207:22

talking about let's use the used reducer

207:24

in action so what I'm going to do is

207:26

that I'm going to grab my used reducer

207:29

from the reactjs next we have to use

207:32

that so to use that we're going to be

207:33

using the use reducer and it takes two

207:35

perimeter like the reducer function and

207:38

also the initial State i n i t i a l i

207:43

can't spell the initial so this is how

207:46

we are going to be using the use reducer

207:48

function and now we are going to be

207:49

destructuring two things we are going to

207:51

be destructuring the state and also the

207:53

dispatch function so now let me explain

207:55

all of that right now first of all we

207:58

are providing the initial state which we

208:00

are going to be creating right here like

208:02

what will be the initial value of our

208:04

entire state so if you are building some

208:06

sort of a counter app so we are going to

208:08

be providing the initial value of zero

208:10

to there so I'm going to just write like

208:12

cons initial State and now inside there

208:14

we are going to just provide like count

208:16

and that count will be set to zero

208:18

because we're just creating a simple

208:19

example of a counter next we have a

208:22

reducer function and we are going to be

208:24

creating the reducer function right here

208:26

so I'll just write like cons reducer and

208:28

this reducer will take two things it

208:30

will take the state and it will also

208:32

take the action so why do we have to

208:34

provide the state and also the action it

208:36

will take the state like what thing we

208:39

are updating and then how we have to

208:41

update that thing okay like what are we

208:44

updating and how are we updating so

208:47

that's the only thing that you have to

208:48

keep in mind so now let's use what we

208:51

will update and how we will update there

208:53

so to use them we can either use the FNL

208:56

statement we can use the trary but in

208:58

this situation we are going to be using

208:59

the switch and cases case I'll just use

209:01

like switch and if I just hit enter so

209:03

it's going to give the St cases for free

209:05

now I'm going to be using action and

209:07

then I'm going to provide a type we are

209:09

going to be using this action by using

209:11

this dispatch function but you don't

209:13

have to worry about what a dispatch is

209:14

for now so if this action type is equal

209:18

to increment so we're going to just

209:19

provide like increment so in this

209:22

situation we only want to return every

209:24

single thing which is already available

209:26

inside word State like we are creating a

209:28

copy of Word State and then we only want

209:31

to update the count and we want to

209:33

update there by first of all accessing

209:35

state. count and then plus one I'm going

209:38

to sve my file and now let me just say

209:40

there once again this reducer function

209:42

will take the state an action and if

209:44

that action type isal equal to increment

209:47

so in this situation we are going to be

209:49

creating the copy of our entire State

209:51

like let's suppose if you have some sort

209:52

of other stuff like uh notification is

209:56

that on or off or something like that so

209:58

we are going to be making a copy of that

210:00

and now in this situation if the action

210:02

type is equal to increment we're going

210:05

to be only updating this count and where

210:07

is this count coming from this count is

210:09

coming from this state which we are

210:10

going to be providing for our dispatch

210:12

function and this state already has the

210:14

count of Z zero value right here and we

210:17

only want increment there by one okay so

210:20

that's going to be for the increment now

210:21

let's talk about the decrement so I'm

210:23

going to just remove that from here I'm

210:24

going to also provide yet another case

210:26

for the decrement and if you want to

210:28

provide some more State you are more

210:29

than welcome to use that if you wanted

210:31

to but in my case I'm going to only

210:33

return first of all dot dot dot my state

210:35

once again and then we are going to be

210:37

changing our count and our count is

210:39

coming from the state. count and we are

210:42

going to be just decrementing there okay

210:44

so you just have to keep there in mind

210:46

so I can just totly remove these spaces

210:48

I guess I'm going to save my file and

210:49

this is how it looks like right here so

210:52

that's cool but now I'm going to also

210:54

take care of the reset and I guess we

210:56

don't need yeah we do need that I'll for

210:59

yet another case for the reset like we

211:02

are going to be also providing some sort

211:03

of a reset button to there so in that

211:05

situation we are going to be once again

211:07

returning all of our entire State and

211:09

we're going to be just changing the

211:11

count to zero okay so that's cool and

211:15

for the final thing we are going to be

211:17

just returning uh the state overall so

211:20

I'm going to just cut all of that and

211:21

here you can see this is how we are

211:23

going to be creating or defining or

211:24

reducer function so now these steps are

211:27

now successfully done the next thing

211:28

that we have to do is that we have to

211:30

take care of the state and the dispatch

211:32

we use this state to show the data into

211:35

our UI okay so how that's going to look

211:37

like here you can see I have my D and

211:39

now inside this D I'll just create my H1

211:41

right here and in this situation I'm

211:42

going to be using like state which is

211:44

coming from this user reducer You're Now

211:47

using this state and now inside this

211:49

state we have the property of count like

211:51

if you have some sort of other property

211:52

like notification or uh is dark or

211:55

something like that we're going to be

211:57

accessing there but now in this

211:58

situation we only have the count so I'm

212:01

going to access there right here so now

212:02

initial value for my account is set to

212:04

zero so we are going to be getting a

212:07

zero value right here okay so I can just

212:09

provide some sort of a label like uh

212:11

count right here semi file and now we

212:13

are getting this count and this is how

212:15

it's allows us to access our data inside

212:19

our jsx now let's talk about this

212:21

dispatch function this dispatch function

212:23

will allows us to change your state like

212:27

actually change your state this will

212:29

allows us to provide some sort of a rule

212:31

if that rule is equal to increment so

212:34

we're going to be incrementing if that

212:35

rule is equal to decrementing so we're

212:37

going to be decrementing and so on and

212:39

so forth so these are just a rule now we

212:41

are going to be using that rules inside

212:44

our dispatch function and this dispatch

212:46

function will allows us to actually

212:49

change your state okay so I'm going to

212:51

just create a few buttons right here so

212:52

I'll just use like button and now inside

212:54

this button I'm going to just provide my

212:56

plus symbol right here you can also

212:57

write like plus if you wanted to but in

212:59

my case I'm going to just write like

213:01

plus and I'm going to also specify the

213:03

on click event handler and when somebody

213:05

clicks on there we're going to be firing

213:07

our dispatch function and now inside

213:09

this dispatch function we are going to

213:11

be providing the type and if that type

213:13

is equal to increment so you already

213:15

know what do we have to do in that

213:17

situation we are now providing a type

213:19

and that type is if that type is equal

213:22

to increment like if this action type is

213:24

equal to increment we're going to be

213:26

incrementing there okay so I'm going to

213:28

also create here another button which

213:31

will just say minus and when somebody

213:33

click on that button we are going to be

213:34

just using like dispatch function once

213:36

again let's just provide our type and we

213:38

are going to be providing the decrement

213:41

right here DC r e m n there we go I'm

213:44

going to save this file and finally

213:45

we're going to be creating yet another

213:46

button for the reset so I'll just write

213:48

a reset right here and when somebody

213:50

click on this button we're going to be

213:52

firing this dispatch function once again

213:55

and we are going to be providing the

213:56

type and type will be set to reset okay

213:58

so I'm going to save my file and that's

214:00

all the thing that you have to do for

214:02

the use reducer okay so if I click on

214:05

this increment button so it's going to

214:06

just increment my counter if I click on

214:08

this decrement button so it's going to

214:10

decrement my counter and finally if I

214:13

click on the reset button it's not going

214:15

to do anything I don't know why here you

214:17

can see we're now providing a re and

214:19

without the e resert so now if I click

214:23

on this button it's going to make it as

214:24

a zero so if I decrement there like a

214:26

lot of time and if I click on the reset

214:29

it's working and also the increment is

214:31

totally working so yeah this is how we

214:33

are going to be taking care of the use

214:35

reducer function or hook to be precise

214:38

all righty so time for the use reducer

214:40

challenge so first of all I want you to

214:41

create the counter reducer DJs file and

214:44

inside that file find the reducer

214:46

function that will manage a simple

214:48

counter start next you have to create a

214:50

file with the name of counter. jsx and

214:52

inside that file create a functional

214:54

component with the name of counter then

214:56

use the used reducer hook to manage the

214:57

state of that counter and then for the

215:00

third step modify the counter reducer

215:02

DJs file to add more action which will

215:04

allow you to increase and decrease by a

215:06

specific amount then update that

215:09

counter. jsx file to increase and

215:10

decrease the count by a specific value

215:13

using the input field so finally you

215:15

have to register the inside the app. GSX

215:17

file and that's going to be it so once

215:19

again give it your best shot if you can

215:21

do it that's completely okay then come

215:23

back and watch the solution and I'm

215:25

going to be creating my uh what do we

215:27

call it counter reducer DJs file okay so

215:31

inside this file we're going to be first

215:33

of all defining our initial state so

215:35

I'll use like initial State and that's

215:37

going to be equals to the count and

215:39

count will be set to zero now underneath

215:41

that we're going to be creating a

215:42

function and I'm going to give it the

215:44

name of like counter reducer it's going

215:46

to take the state and also the action

215:48

and here we are going to be using like

215:50

once again the switch and cases so for

215:52

the switch we going to be providing a

215:54

action. type so if that is the case

215:57

we're going to be providing the first

215:58

case like increment so if the case is

216:01

increment we going to be returning the

216:03

count and let's just write State count

216:05

to access our data from our count and we

216:08

are going to be incrementing them by one

216:10

but if that's not the case and if the

216:12

case is set to decrement we are going to

216:14

be using the return statement one more

216:16

time let's just use your return and

216:18

we're going to be getting the count by

216:20

using the state. count once again and

216:22

let's just remove one from there like

216:24

decrement one from there so I'm not

216:26

going to go ahead and create a UI for

216:28

that I'm going to also create that other

216:29

state as well so I'll just use like case

216:32

and increment by amount come on

216:35

increment by amount there we go and I'm

216:39

going to use like return and let's just

216:41

write count. count plus action. payload

216:46

I'm going to write payload like so I'm

216:48

going to also duplicate that and change

216:50

that to instead of an increment I'm

216:52

going to write like decrement d e c r e

216:54

m n t decrement by amount once again

216:57

instead of writing a plus I'm going to

216:59

change that to minus and for the default

217:01

value I'm going to only return my

217:03

overall state so that's going to be our

217:06

entire function which will allows us to

217:08

change our data so that's how we are

217:09

going to be creating our counter reducer

217:11

and now underneath them we going to be

217:13

exporting the initial State and also the

217:17

counter reducer function from this file

217:20

okay so I'm going to go ahead and go to

217:21

my component and create my counter. js.

217:25

jsx file and I'm going to Define my RFC

217:28

inside there go to my app and register

217:31

there right here so I'll use like

217:33

counter and hit enter so it's going to

217:35

registered there and let me just see how

217:37

it looks so this is how it looks like

217:40

and yeah we are getting somewhere go to

217:42

my counter one more time and the first

217:44

thing that I want to use that want to

217:45

get my used reducer and also the used St

217:48

function from our react J we're going to

217:50

be also getting a few things from our uh

217:53

reducer file so we're going to be

217:55

getting first of all the counter reducer

217:57

and also the initial St come on initial

218:01

state from this counter reducer now let

218:04

me use my use reducer to Define my

218:06

dispatch function and also my state so

218:08

I'm going to be using like use reducer

218:10

and for the initial value I'm going to

218:11

write like counter reducer and also the

218:13

initial value which we've already

218:15

defined F okay so here we're going to be

218:17

druing the state and also the dispatch

218:19

this going to be equals to this us

218:21

reducer now underneath we're going to be

218:23

also creating a state for the form okay

218:25

so I'll use like input value and also

218:28

set input value okay so that's going to

218:30

be equals to the US state and here we

218:32

are going to be providing only zero

218:34

right here okay so now let me save them

218:36

next let me take care of this UI so I'm

218:38

going to go there and write H2 and

218:41

provide my counter Valu so I'll use like

218:43

state. count to access that value let me

218:46

just save my file and check this out so

218:47

here you can see we are now getting

218:49

count which is now set to zero so that's

218:51

cool but now we have to increment and

218:53

also decrement there so I'm going to be

218:55

using like button and which will allows

218:57

us to increment my counter and another

218:59

button which will allows us to decrement

219:01

my counter okay so I'm going to just

219:04

write like on click event handler when

219:06

somebody click on there we are going to

219:07

be firing like handle increment and also

219:11

handle decrement okay and now let me

219:13

create this function right here so we're

219:15

not going to be doing anything crazy but

219:16

we are going to be creating like handle

219:19

uh increment and that's going to be

219:21

equals to this aror function come on

219:24

that's going to be equals to this error

219:25

function and we're going to be calling

219:27

the dispatch function and provide the

219:29

type of increment to there now let me

219:31

just duplicate this line of code and

219:33

change that to decrement and also change

219:35

the function name to handle decrement so

219:38

I'll just write like handle decrement

219:40

like so so now this function will allows

219:42

us to change our data so now if I click

219:44

on this one so it's increment my counter

219:46

is and now if I click on the decrement

219:48

button it's going to decrement my

219:49

counter now we also have to provide our

219:51

input field which will allows us to

219:53

change the data by providing our value

219:55

so I'll just write a div and inside this

219:57

div we're going to be providing an input

219:58

with a type of number and also the value

220:01

will be set to input value okay and I'm

220:05

going to also provide the on change

220:06

Handler and here we're going to be

220:08

passing our Arrow function which will

220:09

take like set input value and I'm going

220:12

to write like event. target. value

220:14

that's also Al cool but now underneath

220:16

that I'm going to be creating a button

220:18

which will say like add and I'm going to

220:20

also create here another button which

220:21

will say subtract okay and here we have

220:25

to just write like on click event

220:26

handler when somebody clicks on that

220:28

we're going to be fing like handle

220:30

increment by one let me just write like

220:33

increment by one or by amount would be

220:37

fine and we're going to be also

220:38

providing Handle decrement by amount and

220:42

now let me just create these two

220:43

functions so I'm going to copy the name

220:44

of them and Define the right here const

220:48

handle increment by uh by amount and

220:51

here we going to be providing our

220:53

dispatch and for this dispatch for the

220:55

type we're going to be providing

220:57

increment by amount and we also have to

221:00

provide our payload come on payload and

221:03

for the payload we have to provide our

221:04

input value but first of all we have to

221:07

convert that to number so if you want to

221:09

convert that to numbers so you can use

221:10

the number Constructor or you can also

221:13

just use a plus and it's going to also

221:14

convert their two number okay and now

221:17

underneath I'm going to use like set

221:18

input value and change that to zero so

221:21

it's going to clear the input after the

221:23

dispatch and now if I save my file and

221:26

it's going to only work for the first

221:27

one it's going to gives us an error

221:30

because we also have to create this

221:31

function which is Handle decrement by

221:34

amount so I'm going to copy the name of

221:35

there and basically I'm going to just

221:37

duplicate this entire function and

221:40

change the name of that to Handle

221:41

decrement by amount and I'm going to

221:44

also change the name of this one to to

221:45

decrement by amount and the rest of them

221:48

will be the same so now let me just save

221:50

my file and here you can see I can just

221:52

write like I don't know maybe um 100 and

221:56

if I write that and click on the add so

221:57

it's going to add that 100 right here

221:59

and if I just write like uhuh 200 and

222:03

click on a subtract so it's going to

222:04

remove 100 from there now it's going to

222:07

gives us minus 100 I can also increment

222:10

my counter I can also decrement my

222:12

counter so yeah that was our complex

222:15

counter and also what challenge about

222:17

the use reducer if you hearing a

222:19

construction voices in the background

222:21

I'm sorry about that because here in my

222:23

house a construction work is going on

222:25

and I don't want to delete this video no

222:27

more so now let's talk about the use ref

222:29

so what is a US ref and why should one

222:31

care about that use rep hook provides a

222:33

way to access and interact with the Dom

222:36

element or to prist Value across render

222:38

without causing a render so this is

222:41

going to be the most simplest hook in

222:43

our hook list so now let's get into the

222:45

coding then you will get to know what

222:46

I'm talking about all right guys now

222:48

it's time to use the US ref inside our

222:50

component so I'll just use the US ref

222:52

right here now reducer use ref there we

222:54

go we're going to be importing that from

222:56

the reactjs and now we have to use that

222:58

so I'll use like use ref and for the

223:00

initial value you can specify any kind

223:02

of value so I'll just write like no

223:04

because I don't want to specify any

223:06

value to that and next we have to use

223:08

this so to use the first of all we are

223:09

going to be storing there in some sort

223:11

of variable so I'll just use like cons

223:12

element and we have to just uh equal to

223:15

there to this us ref so now I can

223:17

totally log that to the console so I can

223:19

use like element right here if I save my

223:21

file and go to my console let me just

223:23

refresh there so what are we getting we

223:24

are now getting this object with the

223:26

property of current and which is

223:27

initially set to null so this current

223:30

property will allows us to manipulate

223:31

word Dom or to do anything with our Dom

223:34

so I'll just change that to like um

223:36

input element because we're going to be

223:37

creating our input element right here so

223:39

I'm going to change that to input

223:40

element you can like change that to

223:42

basically anything that you want so in

223:44

my case input element would be fine I'll

223:46

just create my input element right here

223:48

and the type will be set to text and I'm

223:50

going to be using the Riff property and

223:52

this riff property will allows us to use

223:54

this ref inside or specific element so

223:57

I'll just use like my input element

223:59

right here and now if I sa my file and

224:01

let me just log that to the console once

224:03

again so I'll just use like input

224:05

element and now if I save my file and

224:07

refresh there okay so here you can see

224:08

we are now getting our input and we are

224:10

also getting our current property and if

224:12

I expand this so that current property

224:14

is now pointing into this input element

224:16

right here as you can see there so if I

224:18

expand this so we have like the value

224:20

property we have a lot of things that we

224:22

can do with this HTML element so what

224:26

I'm going to do is that I'm going to

224:27

just remove that from here and I'm going

224:28

to create a button right here which will

224:30

just say like

224:32

focus and uh right hen maybe you can

224:35

basically manipulate your Dum however

224:37

you want but in my case I'm going to

224:39

just focus and write Huzan inside that

224:41

input field okay so I'll just use my

224:43

arrow function and inside this Arrow

224:44

function I'm going to be creating a

224:45

function which will be a focus input and

224:48

I'm going to execute this so now let me

224:49

just create this function right here

224:51

I'll WR like cons Focus input and now

224:54

inside there we're going to be using our

224:56

input element do current property and

224:58

then we're going to be using this Focus

225:00

method which is coming from the Dom okay

225:02

so we have to just use come on F cus we

225:05

have to just use this Focus method and

225:07

as soon as I save my file and refresh

225:09

there and now if I click on this button

225:11

it's going to focus my input element

225:13

right here now I can basically do

225:15

anything I want to do with this element

225:17

I can change the color I can like

225:18

provide something inside there so now

225:20

let me show you like how we are going to

225:22

be writing something inside this so I'm

225:23

going to xess my input element then I'm

225:25

going to write my current property which

225:27

is already coming from the USF and I'm

225:29

going to get the value and that value

225:31

will be set to like my own name so I'm

225:33

going to save my file and now let me

225:35

just refresh there and now once I click

225:36

on this focus and right so it's going to

225:38

first of all focus our input element and

225:41

it's going to also write this name right

225:43

here so if I change that to like

225:44

something else like I don't know John

225:47

Smith or something like this sa my file

225:49

and now if I click on this it's going to

225:50

write this John Smith right here so this

225:52

is how we are going to be using the user

225:54

ref and we are going to be very rarely

225:56

using this user ref but I don't know

225:58

that was a US ref time for the user ref

226:00

hug so I want you to create a component

226:02

with the name of focus input. GSX and

226:04

that component will focus on the input

226:06

field when the button is clicked in the

226:08

second part I want you to create a

226:10

timer. GSX component and just Implement

226:12

a simple timer where the timer interval

226:14

is store using the ref so give it your

226:17

best sh if you can do it that's

226:18

completely okay then come back and watch

226:20

the solution and now I'm going to give

226:21

you my solution so what I'm going to do

226:23

that I'm going to just create my focus

226:25

uh input. GSX and let's just create

226:27

where

226:28

rafc SA my file and let's just go ahead

226:31

and go to my app and store there right

226:34

here so we have a focus input and I'm

226:36

going to execute them let's just check

226:38

this out yep it's working now the first

226:40

thing that I want to do is that I want

226:41

to grab my us rep from the rejs and the

226:44

initial value will be set to null and

226:46

I'm going to store that in the input ref

226:48

as a value and now we have to use that

226:50

inside our UI so what I'm going to do is

226:52

that I'm going to create my input field

226:54

with the type of text and I'm going to

226:55

also provide the ref and here the ref

226:58

will be that input ref which we've

227:00

already stored right here gu we're going

227:02

to be copying there and now let me just

227:03

place there right here and I'm going to

227:05

also provide the placeholder which will

227:07

say like uh click the button to to focus

227:12

or yeah I guess that's going to be fine

227:13

and now underneath that we're going to

227:15

be creating a button which will say like

227:17

Focus input and I'm going to also attach

227:19

the on click when Handler and we are

227:21

going to be creating this function in a

227:22

few seconds so now let me just create

227:24

this function cons Focus input and

227:26

inside this function first of all we are

227:28

going to be checking if we have the

227:30

input rep. current value so in this

227:33

situation we're going to be taking that

227:35

input rep and we're going to be grabbing

227:37

the current property of there and then

227:39

we're going to be calling the focus

227:41

method on that so anytime we click on

227:43

that button it's going to FOC focus our

227:45

input field so now let me just show you

227:46

there so now if I click on there it's

227:49

going to focus this input field right

227:50

here so that was the first portion of

227:52

this challenge I'm going to close there

227:54

and now let me create my timer so timer.

227:57

jsx

227:59

RFC and now we have to also store the or

228:02

register the inside our app so I'll just

228:05

write like timer and hit enter just

228:07

going to grab the from my timer uh timer

228:10

file so what I'm going to do is that I'm

228:11

going to grabb a few things the first

228:13

thing I will grab is the use rep from

228:15

the reactjs we would also need the use

228:17

effect and also the use St okay so now

228:19

let's just use all of that hooks inside

228:21

our component so I'll just first of all

228:23

create my count and also set count and

228:26

that's going to be coming from the used

228:28

St and the initial value will be set to

228:30

zero we're going to be also creating our

228:32

interval ref so I'll just write like

228:34

interval ref and that's going to be

228:36

equals to the use ref and the initial

228:38

value will be set to now and now let's

228:40

just use the inside our component but

228:42

first of all we also have to create our

228:44

timer so that we can work with this we

228:46

are going to be using our use effect

228:47

because in this case we are going to be

228:49

working with a side effect and for the

228:51

dependency array we are going to be

228:52

setting there to empty dependency array

228:55

now I'm going to get my interval value

228:57

or interval ref and here we are only

229:00

interested in the current property so

229:01

I'm going to grab my current c r n like

229:05

so and that's going to be equals to the

229:07

JavaScript buil-in method which is

229:08

called the set interval and here we're

229:10

going to be passing a callback function

229:12

and I'm going to also give it like 1

229:14

second would be fine for a timer and I'm

229:16

going to write like set count and here

229:19

we have to specify our previous count

229:21

and also we have to add one to the two

229:23

our previous count like so and that's

229:25

going to be it and finally I'm going to

229:27

also write like the clean up function so

229:30

I'm going to just return that clean up

229:32

function right here so we're going to be

229:33

using like clear interval and here we

229:35

have to specify our interval RI one more

229:38

time and we have to provide that current

229:40

property in there okay so now we are

229:41

totally done with all of that value next

229:43

we have to use the inside our component

229:45

so I'm going to remove them and I'll

229:47

write my H1 timer and here we have

229:50

render or count and then seconds and now

229:53

underneath that we're going to be also

229:54

creating a button which will just say

229:56

like stop timer okay so it's going to

229:58

allows us to stop our timer like a pause

230:01

button and whenever we click on this

230:04

what do we want to do we just want to

230:05

fire this function which will be a clear

230:07

interval and here we have to specify our

230:09

interval rep and then do current value

230:12

in there now let me just sve my file and

230:14

here you can see we now getting like the

230:16

timer let me just refresh there 1 two

230:19

and so on and so forth we now getting

230:21

our counter or timer not counter which

230:24

is working totally fine and now if I

230:26

want to stop there or pause there I can

230:28

click on the stop timer so so it's going

230:30

to pause my timer right here okay so

230:32

yeah that was the second portion of our

230:34

Challenge and that was it about the US

230:37

ref challenge now let's talk about the

230:39

custom hooks so custom hooks are a

230:41

JavaScript functions that starts with

230:43

the prefix use for example example use

230:45

fetch use foam and so on and so forth

230:47

and can call other hooks within them

230:49

they allow you to extract and reuse

230:51

logic that inal state or side effect

230:54

making your components more readable and

230:56

maintainable so here you can see I have

230:57

a home component and now inside this

230:59

home component I now fetching the data

231:01

from the todos and then I'm sending that

231:04

data to my St okay so this is okay like

231:07

nothing is wrong in this component but

231:09

now we can extract all of that logic

231:11

into our own hook so that we can reuse

231:13

that hook again and again and we no

231:15

longer have to write all of that code

231:16

again and again so to do that first of

231:18

all we are going to be creating a

231:19

function I'll give it the name of like

231:21

us and it's going to take the URL and

231:23

then we're going to be defining our

231:24

state for there and then we will use our

231:26

use effect and now inside this use

231:29

effect we're going to be using our fetch

231:31

then we are going to be taking that URL

231:32

from the perimeter and we're going to be

231:34

passing that to the fetch then we can

231:36

convert that data to the Json and

231:38

finally we can push that data to the set

231:40

data okay so this is how the syntax will

231:42

look like like this is just a basic

231:44

example Le but through the course we

231:45

going to be seeing a lot more than that

231:47

so now to use that hook inside our

231:49

component this is how we are going to be

231:51

doing there first of all we are going to

231:52

be importing our hook and then we're

231:54

going to be pasing the URL from which we

231:56

want to fet our data and then we can

231:58

just destructure the data and we can use

231:59

the inside our component so this is how

232:02

the use fetch will look like and now let

232:03

me show you all of the in action first

232:05

of all I want to show you the problem

232:07

and then I'm going to show you how we

232:08

can refactor our code to use the custom

232:11

hook okay so I'm going to just create

232:13

like first of all my State I'll just

232:15

write like cons data and then set data

232:18

and that's going to be coming from the

232:20

use State and the initial value will be

232:22

set to now you can write like array if

232:24

you want it to but in my case I'm going

232:25

to write like now next we have to fetch

232:27

our data and to fetch our data we are

232:29

going to be using this use effect for

232:31

the side effects and it's going to take

232:33

the dependency array of totally empty

232:35

array because we only want to render

232:37

this content once and then I'll just use

232:39

like fetch method right here and I'm

232:41

going to provide this URL we're going to

232:42

be fetching our data from this URL now

232:44

let me just use my then and it's going

232:46

to take the response and we're going to

232:48

be converting that response to Json and

232:50

also let's just use our then one more

232:52

time to get the data and I'm going to

232:54

just use like uh set data and we're

232:57

going to be passing our data to there

232:59

okay so this is how we going to be

233:00

fetching our data and this how we're

233:02

going to be pushing our data to our

233:04

state now inside this da we're going to

233:06

be just rendering our content so I'll

233:07

just use like if we have the data then

233:10

we are going to be iterating over

233:11

through the data so I'll just use like

233:13

item or too would be fine I'll use my

233:15

to-do or you know what item would be

233:17

fine what the hell and I'm going to use

233:19

my curly braces and now we have to

233:21

return this paragraph and I just use

233:24

like item. tile and I'm going to also

233:27

provide the key right here and the key

233:28

will be item. ID right here so if I save

233:31

my file as you can see right here we are

233:33

getting all of their title which is

233:35

working totally fine but now let's

233:37

suppose if you want to use this same

233:39

logic in a lot of components so first of

233:41

all we're going to have to create this

233:43

this St in all of that comp component

233:44

then we have to use this use effect in

233:46

all of that component then we have to

233:48

fetch our data change that to Json and

233:50

finally we have to push this data to

233:52

over STS and that's a lot of work and

233:54

now to extract all of that functionality

233:56

to a single function this is how we

233:58

going to be doing there so I'll just

233:59

create a file I'm going to give it the

234:01

name of like use because we are creating

234:02

a hook so I'll just give it the name of

234:04

like use fetch. jsx okay and now inside

234:07

this use fetch. jsx and now inside this

234:10

use fetch method I'm going to just first

234:12

of all import my uh use State because we

234:15

already know that we are going to be

234:17

using some sort of a state and we will

234:19

also import the use effect as well

234:21

because we already know that we are

234:22

going to be using this use effect as

234:24

well okay so now that we successfully

234:26

imported there the next thing that we

234:27

have to do is that we have to just

234:28

create our function so I'll create like

234:30

cons and you can basically give it any

234:32

name that you like but the convention is

234:34

to use the use okay and then you can

234:37

give it like basically any name that you

234:39

like so I'll just give the name of like

234:41

use Fetch and it's going to take the UNL

234:43

because as you can see right here we are

234:45

going to be providing some sort of a URL

234:47

so just going to take that URL right

234:48

here and now let's just create our

234:50

function so the first thing that I want

234:52

to do is that I want to create my data

234:53

and then set data and now we're going to

234:56

be storing there inside the used St and

234:59

the initial value will be set to know

235:00

okay so that's the first thing next we

235:03

have to create exactly the same use

235:05

effect like this so I'm going to copy

235:07

there and now let me just place it right

235:09

here and instead of providing all of

235:10

this URL I'm going to cut that from here

235:13

I'm going to copy this UR URL as a

235:15

perimeter and we're going to be passing

235:16

that to the fetch finally we just have

235:18

to return our data so that we can use

235:20

that in other component so I'll use like

235:22

data right here and this is how we are

235:24

going to be creating our custom hook so

235:27

finally I'm going to have to export that

235:28

so that I can use that in other

235:29

component so I'll use my use Fetch and

235:31

I'm going to save my file and now we

235:33

have to use this use fetch inside or app

235:37

component right here so I'm going to

235:38

remove all of that from here I'm going

235:40

to also remove this one I'm going to

235:41

also remove that sa my file and here you

235:44

can see this is how our component will

235:45

look like but first of all we have to

235:47

use this us fetch inside this component

235:50

and this is how we are going to be using

235:51

the first of all we have to import the

235:53

the use Fetch and now we have to use the

235:56

I'll use like use Fetch and it takes

235:59

that perimeter of URL right here so we

236:01

have to provide that URL right here it

236:03

is now providing this data as array so

236:06

we can totally destructure that as or

236:08

array so I'll just use like data and

236:10

this is how we are going to be

236:11

destructuring our data right here so now

236:14

if we have the data then we are going to

236:15

be iterating over through all of that

236:17

data and we are going to be taking the

236:19

ID we are going to be providing the as a

236:21

key and we're going to be also taking

236:22

the title and we are going to be

236:24

providing the as our jsx value so if I

236:26

save my file and here you can see we're

236:28

now getting exactly the same result

236:30

right here which is amazing and now you

236:32

can fetch your data by using this hook

236:34

in all of your component if you have

236:36

some sort of other component you can

236:38

totally change this URL if you wanted to

236:40

and you can create a custom hook for the

236:42

form and for the validation and for

236:44

everything like basically for everything

236:46

you can create a custom hook now let's

236:48

talk about the use ID hook so the use ID

236:50

hook in reactjs is used to generate a

236:52

unique IDs for a component so yeah it is

236:56

as simple as that so now let's get into

236:58

the coding and then you will get to know

236:59

what I'm talking about so the first

237:01

thing that I want to do is that I want

237:02

to create a component folder and inside

237:04

that we have to create unique id. jsx

237:07

I'll use my RFC inside there and

237:09

register my component inside the app

237:12

like unique ID and Cloud there test this

237:15

out and here you can see we have our

237:16

unique ID which is looking cool so the

237:18

first thing that we want to do is that

237:20

we want to import that unique ID so I'll

237:22

use like uh use ID and hit enter so it's

237:25

going to import there from the react CH

237:27

and now we have to use this so I'll use

237:29

like use ID and call that and it doesn't

237:32

take any perimeter nothing now that we

237:34

have to store there in some sort of a

237:36

variable so I'll store the insert like

237:37

ID it's going to be equals to this user

237:39

ID so what I'm going to do is that I'm

237:41

going to Define my label first of all

237:44

like label and now for this label we

237:46

want to provide our ID so we're going to

237:49

be using that ID totally dynamically and

237:51

now I'm going to just write like email

237:53

and also I'm going to create my input

237:54

field in this input field we have the

237:56

type of email we're going to be also

237:58

providing an ID and the ID will be set

238:00

to once again you get state that ID as

238:04

now if I save my file and test this out

238:05

so now let me go ahead and go to my

238:07

inspect element and go to let me just

238:10

click on this one and here you can see

238:12

it's going to gives a that unique IDE

238:14

right here for the HTML 4 and it's going

238:16

to also give us that unique ID for this

238:19

specific ID attribute okay so that's

238:22

also done but now let's suppose if I

238:24

want to create another input field so

238:25

I'll just write like first of all the

238:27

label or you know let me just copy this

238:29

entire thing from there and place it

238:31

right here and change that to some sort

238:33

of I don't know password or something

238:36

like that I'm going to also change that

238:37

to password and then Watch What Happens

238:40

so if I sell my file and refresh there

238:42

and here you can see this one have the

238:44

ID of R1 but now if I select this

238:47

password is going to also have that ID

238:49

of R1 why is that they are not totally

238:52

unique so now I know a lot of people

238:54

will think that if you want to make the

238:55

unique so we have to just duplicate that

238:57

and change there to like id2 and then

239:00

specify that ID to there so I'm going to

239:02

copy there and place it here and also

239:05

place that here sa my file and now if I

239:07

select the password here you can see

239:09

this one have the ID of R1 and this one

239:11

have the ID of R5 but now the question

239:13

is should I duplicate my code for every

239:16

single input no of course not this is

239:19

not the better way so I'm going to

239:20

remove that from here instead we can

239:23

provide a prefix this so I'll just write

239:24

a dash and then I can write like

239:26

whatever I want to write I can write

239:27

like email so I'll just write an email

239:29

here I'll also provide the email Here

239:32

and Now for this one we're going to be

239:34

providing a password and also for this

239:37

one we're going to be providing a

239:38

password once again now let me just save

239:40

my file you're not getting anything

239:42

that's because we're using the id2 so we

239:44

have to change that to just ID and ID so

239:47

now if I save my file and here you can

239:49

see if I click on the password so here

239:51

you can see we're now prefixing there

239:53

for the email and also for the password

239:55

so now let me go ahead and go to my app

239:57

I'll just create a paragraph which will

239:58

have a lurum and now to need this

240:00

paragraph you're going to be calling

240:01

your component once again now let's just

240:04

close this so if I close the and sa my

240:05

file and now if I click on this

240:08

component so now here you can see this

240:10

component have the RF let me just show

240:12

you there this component have the unique

240:14

ID of RF and this component have the

240:17

unique ID of Rh right here that was just

240:20

a quick hook which I want to cover okay

240:22

so time for the 10 beginners level

240:24

projects so in these projects we're not

240:26

going to be using any types script so we

240:28

going to be only using react JS with

240:30

JavaScript so basically that's going to

240:32

be it so what I'm going to do is that

240:34

I'm going to just make a setup right

240:35

here I'm going to open my terminal and

240:37

let me just zoom in a bit so you guys

240:38

can see everything a bit better I'm

240:40

going to use npm create weed at latest

240:43

I'll give it the name like project demos

240:45

or yeah I guess that's going to be fine

240:47

I'm going to choose reactjs and also

240:49

JavaScript not typescript but JavaScript

240:52

I'm going to go into my projects demo

240:54

and I'll use like npmi to install all of

240:57

the dependencies that's done so I'm

240:58

going to open my us code right here I'm

241:01

going to also open my terminal and use

241:03

npm run Dev to start my server right

241:06

here and let's just remove this boiler

241:07

plate so I'm going to remove this public

241:09

folder I'm going to remove the assets

241:11

also this app. CSS and and index. CSS as

241:15

well let's just remove every single

241:16

thing from there I'm going to use my

241:18

rafc inside there and also remove this

241:21

index.css and you know what I'm going to

241:23

also remove the stri mode right here sa

241:25

my file and now this is how everything

241:27

looks like first of all let me just show

241:29

you there and here you can see we are

241:30

now getting our app which is looking

241:32

amazing okay so time to build our first

241:34

project so I'm going to create my folder

241:36

with the name of components and inside

241:38

there we're going to be creating our

241:39

counter. jsx and let's just use our RFC

241:43

sa my file

241:44

and use that counter right here okay so

241:46

I'm going to be using my counter hit

241:48

enter save my file and this is how our

241:50

counter looks like right here and now

241:52

let's begin with importing a lot of

241:54

stuff so I'm going to be importing first

241:56

of all the user like obviously we would

241:58

need some sort of a St and also we are

242:00

going to be importing the style. CSS

242:03

which I guess I did not create so now

242:05

let me create the right here inside this

242:06

SRC folder so I'm going to create like

242:08

style. CSS and I'm going to place all of

242:10

the CSS that I have already written for

242:13

this project here so basically we're not

242:15

going to do anything crazy but we are

242:17

going to be just centering every single

242:18

thing and yeah you get the idea so if

242:21

you want to get all of these styling you

242:22

can totally go ahead and go to my gab

242:24

repository and you can get all of that

242:26

styling from there so now the first

242:27

thing that I want to do is that I want

242:28

to make a St setup so I'm going to use

242:30

like count and then set count and now

242:32

let's just use what used it and the

242:34

initial value will be set to zero okay

242:36

so now I'm going to save my file and the

242:38

next thing that I want to do is that I

242:39

want to make uh this UI a bit better so

242:42

I'll provide a class name to this Dev a

242:44

container class okay so inside that

242:46

we're going to be creating our H1 which

242:48

will be just I'm going to also provide a

242:51

class name of there to like a number and

242:53

also here we are going to be rendering

242:55

our count so if I just use this save my

242:57

file here you can see we now getting our

242:58

zero right here which is looking amazing

243:01

and you know what first of all let me

243:02

just even wrap in something like so and

243:05

the next thing that I want to do is that

243:07

I want to create my buttons uh container

243:09

like the increment button and also the

243:11

decrement button so I'll use like

243:12

buttons container this is going to be my

243:15

class name and now inside this buttons

243:17

container I'm going to be creating two

243:19

button one will be for the increment and

243:21

another one will be for the decrement so

243:23

this one will be for the plus and this

243:25

one will be for the minus so I'll use

243:27

like decrement there we go and now if I

243:30

save my file and I'm going to have to

243:32

copy the increment styling and place

243:34

this save my file and now they are

243:35

looking better so the next thing that I

243:37

want to do is that I want to duplicate

243:39

them and I'm going to be using the own

243:41

click event handler on both of them so

243:43

for the the first one when somebody

243:44

clicks on there we're going to be firing

243:46

the increment function and when somebody

243:48

clicks on the second button like the

243:50

decrement button so we're going to be

243:51

firing the decrement function okay so

243:53

now let's just register this function

243:55

right here inside our component so the

243:57

first thing that I want to do is that I

243:59

want to create this function like cons

244:01

increment and now here we're going to be

244:03

using like set count and the count value

244:05

will be just plus one like this is going

244:07

to be the increment function and the

244:09

next thing that we have to do is that we

244:10

have to change that to decrement and

244:12

also change that to minus all use like

244:14

decrement and now if I save my file and

244:16

now if I click on this plus button it's

244:18

going to increment my counter and now if

244:20

I click on this decrement button is

244:22

going to decrement my counter so yeah

244:24

that was our first simplest project ever

244:28

the next project that we are going to be

244:29

building will be a to-do list

244:31

application so I'll just use like too.

244:33

jsx and I'm going to use my RFC inside

244:36

there and I'm going to also go ahead and

244:37

go to my stylesheet and remove every

244:39

single thing from there and replace the

244:41

styling right here and if you care about

244:44

these styling you can totally go ahead

244:45

and go to my gab repository and grab all

244:47

of that styling from there okay so now

244:49

I'm going to save my file and now we

244:51

have to register this component right

244:53

here inside our app component so I'll

244:55

use like to do and now if I hit enter

244:57

and this is how we going to be

244:58

registering this component right here

245:01

okay so if I just refresh there and here

245:03

you can see we are now getting our to-do

245:04

which is looking amazing so now inside

245:06

this to-do the first thing that I want

245:07

to do is that I want to grab my Us St

245:10

come on import used St and we will also

245:13

need to provide our style sheets all use

245:15

like dot dot and provide our style. CSS

245:18

right here inside there next we have to

245:20

create two State one will be for the

245:22

to-dos and another one will be for the

245:24

input so I'll use like uh cons todos

245:27

come on to-dos and then set toos and

245:31

that's going to be equals to the used St

245:33

and we're going to be providing the

245:34

initial value of empty array inside

245:36

there because here we're going to be

245:38

storing all of our todos next we have to

245:40

create our input field so I'll use like

245:42

input and also set input here we're

245:45

going to be grabbing like all of the

245:46

data from our input field and we're

245:48

going to be storing that inside our us

245:50

it and the initial value will be set to

245:52

empty string now I'll remove this to-do

245:54

from here and I'm going to also provide

245:56

the class name of container today and

245:58

now inside this container first of all

246:00

we are going to be creating our input

246:01

field and the type will be set to text

246:03

I'm going to also provide a placeholder

246:05

which will say like new too or type new

246:08

to do whatever you want to call it I'll

246:10

also provide the value and the value

246:11

will be coming from this input field

246:14

right here so we're going to be copying

246:15

that and I'm going to place it right

246:17

here and when somebody change or when

246:19

somebody type something inside this

246:21

input field so we're going to be firing

246:23

this function and we're going to be

246:24

changing the value of there we're going

246:26

to be getting all of the value from the

246:27

target. value and we're going to be

246:30

setting that to our input field okay so

246:32

now let me show you how that looks like

246:34

so here you can see we have our input

246:35

field right here and I can type like

246:37

basically anything I want so this is our

246:39

basic input field the next thing that I

246:41

want to do is that I want to create a

246:42

button which allows us to submit or to

246:45

do so I'll use like button which will

246:47

say submit and when somebody clicks on

246:49

this button we're going to be firing

246:51

this function which is a handle submit

246:52

function I'm going to copy that and now

246:55

let's just create there right here I'm

246:56

going to use cons handle submit and here

246:59

inside the we are going to be using the

247:01

set todos and for the set todos we're

247:03

going to be providing our to-dos and now

247:06

as a call back function we're going to

247:07

be using the to-do that perimeter which

247:09

we are now taking for this function and

247:11

we're going to be using the concat

247:12

method on that and here we have to

247:15

specify this value like text and text

247:17

will be equals to this input field like

247:19

anything we want to type anything the

247:20

user type inside this input field that's

247:22

going to be set to the text property and

247:25

also we have the ID and basically we're

247:27

not going to be doing anything crazy but

247:29

I'll just register a random ID right

247:30

here by using meth. floor you can also

247:33

use The UU ID if you wanted to but in my

247:35

case I'm going to just use like meth.

247:36

floor and also met. random times 10

247:39

let's just use our times 10 and this is

247:41

how we can set up our handle submit I'm

247:43

going to also clear out the input field

247:45

okaye I'll use like set input and here

247:48

we have to provide empty string right

247:50

here okay so now I can type something if

247:52

I wanted to but I cannot see that right

247:55

here and why is that that's because we

247:57

did not render all of our content to our

247:59

UI so if I click on that here you can

248:00

see that input field is now successfully

248:03

removed but yeah we cannot see the data

248:06

and now if you want to see that data so

248:08

underneath this button we are going to

248:09

be creating our ul and this UL will have

248:12

the class of like to list and now inside

248:15

this todos list we're going to be

248:16

iterating all through all of the todos

248:18

okay so I'll use the map method on there

248:19

and here we're going to be passing our

248:21

text and also ID which we are going to

248:23

be destructuring from all of that toos

248:26

like as you can see right here we have a

248:27

text and also that ID which we going to

248:30

be destructuring from this function and

248:32

we're going to be using the inside case

248:34

I'll use like uh the and inside there

248:36

we're going to be using what Ali and

248:38

here inside this specific Ali I'm going

248:41

to provide a class name of Tod do today

248:43

and all also the key will be set to that

248:45

ID which is already randomly generated

248:48

by using this m. Flo and also this m.

248:51

random okay so we're going to be

248:52

specifying there for this key and also

248:55

inside this Ali we're going to be

248:57

creating with span and this span will

248:59

take our text so we are going to be

249:01

rendering our text inside this pen and

249:03

we will also have a button which will

249:05

only say X or remove whatever you want

249:08

to call there now let me style this

249:09

button by providing a class name of

249:11

close to there and I'm going to also

249:12

provide the on click event handler when

249:14

somebody clicks on this button so we're

249:17

going to be just firing this function

249:18

which is a remove to-do and we're going

249:20

to be specifying ID to that okay so now

249:22

let me just create this remove to-do

249:24

right here up above underneath this

249:26

handle submit we're going to be also

249:28

creating what remove too so what I'm

249:30

going to do is that I'm going to use

249:31

like remove to-do and it's going to take

249:33

the ID and now here we're going to be

249:35

placing the set to-dos right here and

249:37

that set to-dos will take that to-dos as

249:39

a perimeter and we're going to be

249:41

iterating over through that to-dos by

249:43

using using the filter and then we will

249:45

just provide a t for a specific to do

249:47

and then we can grab the t. ID and if

249:50

that t. ID does not equal to that ID so

249:53

we are going to be removing only that

249:55

specific to-do okay let me just say that

249:58

once again we are now iterating over

249:59

through all of the toos by using this

250:01

filter method we are now filtering out

250:02

all of the todos and if that t like that

250:05

specific T ID is not equals to that ID

250:09

which we are taking as a perimeter from

250:10

this function so in that situation we

250:12

are going to be removing that specific

250:14

to-do okay so now the functionality is

250:16

totally done I'm going to go ahead and

250:18

just add a few to-do like uh walk the

250:21

dog and if I click on the submit okay

250:24

everything is now gone I guess I did

250:26

something wrong and I realized that I

250:28

forgot to include the return statement

250:30

right here so we only have to write a

250:32

return and now if I save my file and

250:34

let's just refresh that and I'm going to

250:36

just write like walk the dog and click

250:38

on the submit button so it's going to

250:39

add there right here then I can write

250:41

like I don't know uh

250:43

record react.js

250:47

course submit and now I can totally

250:49

remove that by clicking on these icons

250:51

here and I can totally remove that if I

250:53

wanted to okay so yeah that was our

250:56

to-do list by using reactjs welcome to

250:58

the project number three and in this

251:00

project we're going to be using the use

251:02

effect to fetch our data from the meals

251:04

DB API okay so I'm going to go ahead and

251:06

create my meals. um jsx and I'm going to

251:10

use my RFC s my file and registered

251:13

there right here okay so I'll use my

251:15

meals and sa my file plus I'm going to

251:17

also go ahead and go to my style sheet

251:19

and remove every single thing from there

251:21

and place this new styling right here

251:23

once again for the final time if you

251:25

care about this styling you can totally

251:27

go ahead and go to my gab repository and

251:29

grab all of the styling from there I'm

251:31

not going to say that anymore okay so

251:33

what I'm going to do is that I'm going

251:35

to first of all import a lot of things

251:37

but I also forgot to tell you that in

251:39

this project we are not going to be

251:40

using the fetch API we're going to be

251:42

using the X library to fetch your data

251:44

so if you guys don't know what xos is

251:47

you don't even have to worry about that

251:48

but if you already know what xos is so

251:51

yeah congratulation we are going to be

251:53

using like npmi and then ex use to

251:55

install the in our machine can install

251:58

them the next thing that I want to use

251:59

that I want to grab there so I'm going

252:00

to use like import xos from xos and we

252:04

would also need the use State and also

252:06

the use effect to provide your side

252:08

effect and fetch your data I'm going to

252:10

also provide my uh what do we call it my

252:12

stylesheet right here so we have a

252:13

style. CSS and now if I save my file and

252:16

here you can see we are now getting our

252:17

meals which is looking amazing the first

252:19

thing that I want to do is that I want

252:20

to make a stad in which we are going to

252:22

be storing all of our items or our meals

252:25

so I'll use like items you can give it

252:26

the name of like meals if you wanted to

252:28

but in my case I'm going to only give it

252:29

the name of like items and then set

252:32

items that's going to be equals to the

252:34

US St and that's going to be equals to

252:36

the empty array because here we're going

252:38

to be storing all of our meals and now

252:40

underneath we're going to be using the

252:42

use effect and here let's just provide

252:44

our callback function today and also our

252:47

empty dependency array right here now

252:49

I'm going to be using ause and for this

252:51

exuse we have a get method and this get

252:53

method allows us to get our data or to

252:56

fetch our data from some sort of a URL

252:58

so URL which is the

253:00

mb.com API then Json version1 one

253:04

filter. PHP question mark C is equal to

253:06

cood we're going to be grabing our data

253:08

from this API and I'm going to also use

253:11

the then case all just provide a then

253:14

right here and for this then we are

253:15

going to be providing our res and now

253:17

inside this res first of all I'm going

253:18

to just log this res to the console so

253:20

I'll use like r. data and then meal so

253:23

now if I save my file and let me show

253:25

you all of that if I open my console

253:28

right here and inside this console we

253:30

have like all of that data which we are

253:31

now fetching from that M DB okay so we

253:34

have a ID we also have the St me and we

253:36

also have this thumbnail I can copy it

253:38

and place it here and hit enter and now

253:41

here you can see we're now getting the

253:42

mail image and so on and so forth so

253:44

yeah this is how we are going to be

253:46

fetching our data but now uh let me just

253:49

send this data to this items right here

253:52

so I'm going to comment this line out

253:53

and I'm going to be using like set items

253:55

and I'm going to use like rest. data. Ms

253:58

so this is how we going to be sending

253:59

our data to our state and now I'm going

254:01

to also provide a catch statement like

254:03

in some situation we will get some sort

254:05

of error so then we don't want to do

254:07

anything crazy with that error so I'll

254:08

just use like console. log of that error

254:10

okay so that's going to be for our catch

254:12

statement so this is how we are going to

254:14

be fetching our data okay so now

254:16

fetching our data is done the next thing

254:18

that we have to do is that we have to

254:19

render that data and to do that I'm

254:21

going to remove this males from here and

254:23

I'm going to provide a class name of

254:24

items container which I already set up

254:27

inside my stylesheet and here we're

254:29

going to be providing a function which

254:30

will be items list and it's going to

254:32

allows us to render all of that items to

254:34

our Dom so I'll use like cons items list

254:37

and that's going to be equals to items.

254:39

map because you want to it over through

254:41

all of that items which we already

254:43

pushed to our St okay so first of all we

254:45

want to iterate over through all of that

254:47

items and here we have to destructure

254:49

all of that properties which we are

254:50

going to be using in this project so

254:52

I'll use like stir meal and also stir me

254:56

thumb and also the ID of that specific

254:59

meal now outside from there what I want

255:01

to do I want to just use my return

255:03

statement and inside there I'm going to

255:05

be using a section with the name not a

255:07

name with a class of card and now inside

255:10

this section we're going to be using our

255:12

image and for the this Source we're

255:13

going to be providing our St meal thumb

255:17

okay which will be the image of our meal

255:19

okay and now for this alternative text I

255:22

can just write like Mr me it doesn't

255:24

really matter and now underneath this

255:26

image we can create our section and I'm

255:28

going to provide a class of content

255:29

today and now inside this section we're

255:31

going to be creating our paragraph which

255:33

will be a stir meal and we will also

255:35

provide another paragraph with the pound

255:38

symbol you don't even have to do that

255:39

that's just for a label and we will just

255:41

render our ID me right here come on id M

255:45

there we go and now if I save my file

255:47

and here you can see we are now getting

255:49

our image also our title and also that

255:52

specific ID so if I just remove that

255:54

pound symbol right here let me just

255:56

remove the sem file and here you can see

255:58

we no longer getting that pound symbol

256:00

and this pound symbol is just for the

256:02

label or whatever you want to call it

256:05

okay so this is how we going to be

256:06

fetching our data and this is how we are

256:08

going to be rendering that data by using

256:10

the use effect and also the xos library

256:13

next we're going to be building a

256:14

calculator so I'll just create a

256:16

calculator. jsx file and I'm going to be

256:19

using my rafc semi file and register

256:21

that calculator right here okay so first

256:24

of all we have to import that I'm going

256:26

to also go ahead and go to my stylesheet

256:28

and R every single thing from there and

256:30

place my new Styles right here okay so

256:32

now I'm going to go into my

256:34

calculator and the first thing that I

256:36

want to do is that I want to grab my use

256:38

St because obviously we would need some

256:39

sort of a St we will also import our St

256:42

file. CSS sem my file and now inside

256:46

this calculator we're going to be using

256:48

our cost and input value and then set

256:51

input value and that's going to be

256:53

equals to or us and the initial value

256:55

will be just empty string now I'm going

256:57

to go ahead and go to my GSX and provide

257:00

a form right here I'm going to also

257:02

remove this div and provide our form

257:04

there and now inside this calculator

257:06

first of all I'm going to also provide a

257:07

class of calculator to it so c l c l a t

257:11

o r and I'm going to also provide the

257:12

name of call could be fine and now

257:15

inside there we're going to be creating

257:17

our input field with a class of value

257:20

and for the value we're going to be

257:22

providing our input value right here now

257:24

underneath that we're going to be

257:26

creating a lot of span so I'm going to

257:27

go back and let's just create our span

257:29

with a class of or you know what yeah we

257:32

will provide a num and also the clear

257:34

class and here we just have to specify

257:36

our C right here for the clear and when

257:39

somebody clicks on that we're going to

257:40

be firing this clear function okay so

257:43

let's just create this clear function

257:44

right away now underneath this St we're

257:47

going to be creating our clear function

257:49

which will just allows us to clear out

257:51

our input field okay so we're going to

257:53

be only providing our empty State inside

257:55

there and now underneath this spin we're

257:57

going to be creating a lot more spins so

257:59

what I'm going to do is that I'm going

258:00

to just create a spin and yeah here we

258:04

just have toire a for Slash and I'm

258:06

going to just duplicate there like a lot

258:07

of time okay let's just remove the and

258:09

change there to the star and S then 8 9

258:14

- 4 5 6 and then plus I'm going to also

258:19

provide the own click EV Handler on them

258:22

so when somebody clicks on each of them

258:24

we're going to be firing the something

258:26

called the display function which we

258:27

going to be creating in a few seconds

258:29

it's going to take some sort of a

258:30

perimeter of symbol so I'm going to copy

258:32

all of their symbols and I'm going to

258:34

provide the as a string value right here

258:36

plus plus will be a special one so we're

258:38

going to be using like uh class name and

258:41

I'm going to provide a class name of

258:42

Plus to it now underneath there we're

258:44

going to be once again creating a lot of

258:45

spins so I'll just use like uh span time

258:49

okay so if I just hit T and I'm going to

258:51

have to save there and I'm going to use

258:53

like one two then three then 0 0 0 then

258:57

Dot and also come on just a DOT and we

259:00

also have to provide our equal to sign

259:02

I'm going to provide my multic cursor

259:04

selection right here and I'm going to

259:06

use my own click event handler like when

259:07

somebody clicks on there we're going to

259:09

be firing this display function which

259:11

we're going to be creating in a few few

259:12

second and here we have to provide all

259:15

of that values right here I'm going to

259:16

copy that and provide the as a string

259:19

value okay and for this final one which

259:21

is equal so I'm going to provide a class

259:23

name of there which will be set to numb

259:25

and also equal right here okay so now

259:28

here for this one we're not going to be

259:30

using a display I'm going to provide a

259:32

calculate function right here so which

259:33

will say like c c a and remove all of

259:37

that execution from here but you know

259:38

what we have to execute the now I have

259:41

to create two function one will be for

259:42

display and one will be for the

259:44

calculate so for this display function

259:46

we are not going to be doing anything

259:48

crazy so let me just create the right

259:50

here we are going to be using like

259:51

display it's going to just allows us to

259:53

display our value so it's going to take

259:55

some sort of a value which we are

259:56

already specifying right here like all

259:58

of these values okay so it's going to

260:00

take some sort of a value and then what

260:02

we want to do with that Valu is that we

260:04

want to use our set input value and here

260:07

we have to provide our input value from

260:09

our state and also we have to just

260:11

combine or add the perimeter value of

260:14

value to it okay so it's going to allows

260:16

us to like render all of that data and

260:18

here you can see this is how it looks

260:19

like I can type any kind of data right

260:21

here and now the final thing that I want

260:23

to do is that I want to just provide a

260:25

calculate function okay so it's going of

260:27

just allows us to calculate our value

260:29

now underneath we're going to be

260:31

creating yet another function for

260:32

calculate it's not going to take any

260:34

perimeter but we are going to be using

260:35

the set input value and here we have to

260:38

specify the EV method or function which

260:41

I'm going to show you in a few seconds

260:42

and inside this a we're going to be

260:44

providing our input value right here so

260:46

now if I save my file and now let me

260:48

just test this out so if I just provide

260:50

like 2 + 2 and if I use this equal to

260:53

sign right here it's going to give us

260:54

four and now if I just provide like 5 +

260:57

I don't know maybe 10 so it's going to

260:59

gives us 15 and I can also use like uh 2

261:03

minus 1 so it's going to gives us one

261:06

and I can also use like 2 * 2 it's going

261:09

to give us four 2 * time 2 there we go

261:13

it's going to give us four and now I can

261:15

use like 5 / by or you know not five but

261:19

6/ by two is going to give us three okay

261:22

so which means like everything is

261:24

working inside our calculator but how is

261:26

it working it is working because of this

261:29

e function or E method whatever you want

261:32

to call that and I'm going to go ahead

261:33

and go to my JavaScript e method and

261:36

this is a bit scary method okay so here

261:40

you can see we have two variable like X

261:41

and Y X is holding the value of 10 and Y

261:44

is holding the value of 20 and we also

261:46

have another variable which will take a

261:48

text and here you can see we're now

261:49

providing that X and Y as a string value

261:53

and now it's going to give us the result

261:54

of there okay so if I go ahead and try

261:56

this out and as you can see right here

261:58

we're now getting 200 and you know what

262:01

let me just show you there if I just

262:02

copy all of there come on I'm going to

262:06

God damn it God oh my God it is not it

262:10

is not allowing me to copy there let me

262:12

just copy there and open my console

262:14

right here and run that code right here

262:17

so let's just refresh there clear this

262:19

out and we have God damn it we have to

262:21

first of all write like allow pasting

262:25

and now I can just provide like all of

262:26

their text right here clear this out

262:29

here you can see we have our X variable

262:31

and Y variable and then we are providing

262:33

a x * Y and now we are using the aail

262:36

method and then we're providing our text

262:38

value which is like X time Y and now I

262:41

can just use like result right here so

262:42

if I just use like result and go back

262:45

and hit enter so now it's going to give

262:46

us the result of that string value keep

262:49

in mind whenever you are using there

262:52

keep this statement in mind executing

262:54

JavaScript from a string is a big

262:56

security risk like you are not allowed

262:59

to use this a method in the production

263:01

ready apps we are using them because we

263:03

are only working with just a simple

263:06

simple calculator app but you are not

263:08

allowed to use this a method on a bigger

263:10

project especially if you are working

263:12

with some sort of a company or with

263:14

someone else okay so keep that in mind

263:16

so this is how our calculator work right

263:18

here time for the fifth project so now

263:21

in this project we're going to be

263:22

building a toggle background color so

263:24

let's just create this so I'll use like

263:26

t o GLE e toggle background color. jsx

263:31

and inside I'm going to be using my RFC

263:33

and let me just go ahead and go to my

263:35

stylesheet every single thing from there

263:37

and provide my style right here okay so

263:40

we are just selecting the ban section we

263:42

also styling the button and also the H1

263:44

okay so that's going to be a lot of fun

263:46

and now inside this toggle function

263:48

first of all you want have to register

263:50

there right here so I'll use like toggle

263:52

background color sa my file and we have

263:55

to grab our St first of all so I'll use

263:57

like Imports use St we have to import

264:00

that from the reactjs and we also have

264:02

to import our style. CSS inside there

264:05

first of all I'm going to be creating

264:07

three stat I'll use like background

264:09

color and then set background color and

264:12

that's going to be equals to the US St

264:14

and we're going to be providing the

264:15

initial value of y today now I'm going

264:18

to also create another one for the text

264:20

color and set text color right here

264:24

that's going to be equals to the UST St

264:25

and for the initial value we're going to

264:27

be providing like one B1 b1b okay kind

264:30

of a grayish color and we're going to be

264:32

also providing a color for the BN style

264:34

as well so we can use like set button

264:37

style and now we have to provide the

264:39

initial value of totally white today

264:41

okay so now that we successfully created

264:43

our state the next thing that we have to

264:44

do is that we have to use the inside our

264:47

UI so I'll just remove that from here

264:49

and provide my style right here so I'll

264:51

use like style and for this style we're

264:53

going to be using the background color

264:56

come on let's just proide our background

264:58

color and that background color will be

265:00

equals to that color which we've already

265:02

set up inside our St next we're going to

265:04

be providing a color and that color will

265:06

be now equal to this text color so we're

265:09

going to be copying there and now let me

265:10

just place it right here and and now

265:12

inside then we're going to be creating

265:14

our button which will allows us to

265:15

toggle our classes or colors to be

265:18

precise so when somebody clicks on this

265:20

button we're going to be firing the

265:22

handle click function which we are going

265:24

to be creating in a few seconds but now

265:26

let me provide a styling today so for

265:28

the style we are going to be providing a

265:29

button style which is now coming from

265:31

this stat right here and we going to be

265:33

also providing a color which will be

265:35

also set to the text color and also

265:38

we're going to be providing a border and

265:39

here we're going to be using the Turner

265:41

it's all used two pixel solid and then

265:44

that text color which we've already

265:46

defined up above okay so if I save my

265:48

file and here you can see we are now

265:50

grabbing that text color from this t

265:52

Okay so that's going to be just for the

265:54

functionality the next thing that I want

265:56

to do is that I want to provide a label

265:57

and here we're going to be rendering our

265:59

label totally dynamically so if our

266:01

background color is equal to this color

266:04

which is like 1B come on 1B 1B 1B so in

266:08

this situation we're going to be using

266:10

the black uh theme as a label we are

266:12

going to be providing a black theme as a

266:14

label for this button but if that's not

266:16

the case so in that situation we are

266:18

going to be providing like White theme

266:20

okay just like so let me just show you

266:23

there and refresh there you cannot see

266:24

there because everything is not only set

266:26

to White and now underneath this button

266:29

we're going to be creating a section for

266:30

our content so I'll create a section

266:32

with a class of content and inside this

266:34

content we're going to be using our H1

266:36

which will just say like welcome to come

266:38

on to a and then we're going to be

266:40

providing our br and real word dot dot

266:44

dot so now if I save my file and refresh

266:46

that we cannot see anything I don't know

266:47

why let's just go ahead and go to our

266:49

console we getting this error because we

266:52

have to create our handle click event

266:53

handler okay so I'm going to go ahead

266:55

and copy the name of there and let's

266:57

just create there right here we are

266:58

going to be taking care of all of the

267:00

state I forgot to do that so I'll just

267:02

create my function with the name of

267:03

handle click and when somebody call this

267:06

function in this situation we're going

267:08

to be taking our set background color

267:10

and we're going to be providing the

267:11

Turner value right here so if we have

267:13

the background color and if that is

267:16

equal to White so in that situation

267:17

we're going to be using this color which

267:19

is uh 1B 1B 1B and if that's not the

267:22

case we're going to be toggling that

267:24

value to totally white color okay and

267:26

now let's just take care of this text

267:28

color which we have right here okay so

267:31

the initial value will be set to this 1

267:32

b1b and we have to just revert that back

267:35

so I'm going to provide like text color

267:37

and if that is and if that is equal to

267:39

this 1B 1B 1B

267:42

in that situation we're going to be

267:44

changing the color of that to like FF a

267:46

31 a and if that's not the case we're

267:49

going to be changing the color to 1 B 1B

267:52

1B once again okay so that's going to be

267:54

it for the text color but we also have

267:56

to take care of this uh button style so

267:58

we're going to be just using that or you

268:00

know what set button style would be fine

268:02

and we have to check if background is

268:05

equal to totally white in that situation

268:07

we going to be changing our color to 1 b

268:10

1 B 1B and if that's not the case we're

268:13

going to be using a totally white color

268:15

so here you can see we have our text

268:17

like Welcome to the Real World if I

268:18

click on this White theme it's going to

268:20

first of all change the background color

268:22

also the text color and it's going to

268:24

also change this text value so let me

268:27

just zoom in a bit like that and now if

268:29

I click on this now it is saying like

268:31

white color and now if I click on this

268:33

it's going to give us like black theme

268:35

right here so yeah that was our color or

268:38

toggle background color okay so time for

268:41

another project we going to be building

268:42

a hien search bar so I'll use like hien

268:46

search bar. jsx inside then I'm going to

268:49

be using a RFC comment this line out and

268:52

grab our hidden search bar s my file go

268:55

to my Styles sheet remove every single

268:57

thing from there and paste the new ones

269:00

check this out in the browser and there

269:02

we go ladies and gentlemen so the next

269:05

thing that I want to do is that I want

269:07

to grab first of all my stat so I'll use

269:10

like you st and we will Al need to grab

269:12

our CSS so I'll go to my style. CSS we

269:16

would also need to install third party

269:18

Library which is called the react icons

269:20

I'm going to be using npmi react icons

269:23

and now if I H enter so can install that

269:25

in my machine right away okay now then

269:28

successfully installed so we're going to

269:30

be only grabbing the fa search icon from

269:33

the reactjs or from the react icons to

269:36

be precise now inside this hidden search

269:38

bar we're going to be creating two

269:40

inputs so I'll just use like uh show

269:42

input and also the set show input that's

269:45

going to be coming from the UST St and

269:47

the initial value will be set to false

269:49

I'm going to also create a BG color and

269:52

also the set

269:53

BG uh color and that's going to be

269:56

equals to the US St and the initial

269:58

value will be set to toally White I'm

270:00

going to change there to a section

270:02

instead of a Dev let's just change there

270:04

to section and I'm going to provide a

270:06

class name of container today and also

270:10

the style of this style which we are

270:12

already specifying for our input guess

270:14

I'll use like background color and also

270:17

that's going to be equals to our BG

270:19

color right here so now if I save there

270:21

we going to be also providing the on

270:22

click event handler and when somebody

270:24

clicks on there we're going to be firing

270:26

this function and we will create this

270:28

function in a few seconds and now inside

270:30

there we're going to be first of all

270:31

checking okay so if we have the show

270:34

input in then situation we're going to

270:36

be providing some UI and if that's not

270:39

the case we're going to be providing

270:41

another UI okay so I'll just uh hit

270:43

enter right here and if that show input

270:45

is equal to true we're going to be

270:47

providing an input field which will have

270:49

the type of text and also it will say

270:51

like a placeholder of search dot dot dot

270:54

but if that's not the case we're going

270:56

to be using our fa icon if a search icon

270:59

we're going to be grabbing there and

271:01

we're going to be attaching the own

271:02

click event handler on there and when

271:04

somebody clicks on there we're going to

271:05

be using like uh set show input and the

271:08

initial value will be set to true I'm

271:10

going to save my file and now nice time

271:12

to create this handle click okay so I'm

271:15

going to go ahead and create the right

271:17

in here okay we're going to be first of

271:19

all changing the background color to

271:22

totally uh 1 a 1 a 1 a and also

271:25

underneath that you're going to be

271:27

checking if e or event. target. class

271:31

name is triple equals to The Container

271:34

which in this case is equal to The

271:36

Container so in that situation we're

271:38

going to be using like set show input

271:40

and we're going to be providing the the

271:42

value of false to it like here you can

271:43

see we're now providing the value of

271:45

false here we also have to provide the

271:47

value of false today and we're going to

271:49

be also changing the background color to

271:52

totally white color so now I'm going to

271:54

save my file and check this out here you

271:56

can see we have our icon so now if I

271:58

click on that it's going to also change

271:59

the background color and it's going to

272:01

gives us this input field right here so

272:03

now if I click on somewhere else so it's

272:05

going to remove that it's going to giv

272:06

us this icon so yeah this is also a

272:09

simple project which I want to share

272:11

with you guys it's time to create a

272:13

simple testimonials project so I'm going

272:15

to create my component first of all. GSX

272:18

and use my RFC and create my testimonial

272:22

right in here baby change the style

272:26

remove every single thing from there and

272:28

place a new styling and here we have to

272:31

go ahead and go to our testimonial first

272:33

of all we have to check how it looks

272:35

like and yeah it is looking great it is

272:38

looking great that was a great start so

272:40

the first thing that I wanted uce that I

272:42

want to grab my used St and also I want

272:45

to grab my style from the style. CSS and

272:49

what I'm going to do is that I'm going

272:50

to create my current index and also Set

272:54

current index first of all and that's

272:56

going to be equals to the US and the

272:58

initial value will be set to zero

272:59

because obviously you want to start from

273:01

a zero and then we're going to be

273:03

creating a lot of testimonials so we

273:05

have a few testimonials we have a

273:07

variable and now inside this variable we

273:09

have our array and now inside this array

273:11

we have a few objects like uh object one

273:14

2 and three and inside these object we

273:16

have a code and also the author who said

273:19

that code so we have like this is the

273:21

best product I have ever used and also I

273:24

highly recommend this product to

273:25

everyone and this product has completely

273:27

change my life so yeah these are my

273:30

testimonials so I'm going to hide there

273:31

from here the next thing that we have to

273:33

do is that we have to use the inside our

273:34

UI so what I'm going to do is that I'm

273:36

going to provide my testimonial as a

273:38

class to this Dev and also I'm going to

273:41

create there with a class of

273:42

testimonials and then Dash Cod and

273:45

inside there first of all we are going

273:46

to be grabbing all the testimonials

273:48

which we already have right here and we

273:51

have our array so which means like we

273:52

can grab the index from there so I'm

273:54

going to use like brackets and here

273:56

we're going to be passing our current

273:57

index which is coming from this state

274:00

right here so basically it's going to

274:02

start from the zero because we are

274:03

providing the initial value of zero

274:05

today so it's going to give us like

274:06

testimonial of zero which means like

274:08

we're going to be getting only the first

274:10

testimonial right here like this

274:13

testimonial so that's done I'm going to

274:16

go ahead and copy my testimonial and

274:18

place there I mean like current index

274:20

and place that there and we are only

274:22

interested in getting the code not the

274:24

author but only the code okay so we're

274:26

going to be getting there and now if I

274:27

save my file and here you can see we now

274:30

getting this code right here and now the

274:32

next thing that I want to do is that I

274:34

also want to show the author so to show

274:36

the author we're going to be using like

274:38

that day once again and I'm going to

274:40

just change the class name to author and

274:42

now inside there we're going to be just

274:44

providing a dash and here we have to use

274:46

once again our testimonials and we're

274:48

going to be once again providing our

274:50

current index and now in this situation

274:52

we're going to be grabbing the author

274:53

from the so here you can see we're now

274:55

getting our jie do and yeah that's

274:58

looking amazing now the next thing that

274:59

I want to do is that I wanted to create

275:00

two buttons the first button will just

275:03

gives us the previous St and the next

275:05

will gives us the next St so I'll just

275:07

create a with the class of testimonials

275:09

now and now inside there we are going to

275:11

be creating two buttons like pre and

275:13

also the next button right here okay so

275:15

let's just use our on click event

275:17

handler on there and when somebody

275:19

clicks on that we're going to be firing

275:20

like uh handle preve and also we're

275:23

going to be firing the handle next uh

275:26

click right here okay so I'm going to

275:28

copy that and now let's just create

275:30

there right here come on const handle

275:32

pre click and now inside there we're

275:35

going to be using the Set current index

275:37

and let's just provide our current index

275:40

plus our testimonial come on or

275:43

testimonial and we're going to be only

275:45

decrementing one from there then we have

275:47

to divide all of them by using our

275:50

testimonials. length Okay so now if I

275:52

save my file and let's just refresh

275:54

there oh it's going to gives us an error

275:56

because we also have to create this

275:57

handle next uh function right here so

276:00

we're going to be also creating there

276:02

right here so what I'm going to do is

276:04

that I'm going to just duplicate this in

276:05

or you know I'm not going to duplicate

276:07

there let me just create my cons handle

276:09

next click uh function right here Here

276:12

and Now inside then we're going to be

276:14

using our Set current index one more

276:15

time and we're going to be providing our

276:17

current index plus one once again then

276:20

we will divide there by

276:22

testimonials. length Okay so now if I

276:24

save my file and here you can see we

276:26

have our previous button and we also

276:28

have our next button right here so if I

276:29

click on this previous I mean like next

276:31

button so it's going to give us a next

276:33

product then I can also click on this

276:35

previous one so it's going to gives us

276:36

that previous product right here so I

276:38

can go on and on so it's going to gives

276:39

us all of that next product then can go

276:42

on and on on the previous St so it's

276:43

going to give us that previous items

276:45

right here okay so this is how we are

276:47

going to be getting the next I mean like

276:49

the previous uh State and this is how

276:51

we're going to be getting the next St

276:53

and we can also remove these curly

276:54

braces from here and I guess I'm going

276:57

to have to leave there for this one so

276:58

let's just save my file and here you can

277:00

see I can click on the next it's going

277:02

to give us the next item and I can also

277:04

click on the previous it's going to use

277:05

as the previous item so if you have like

277:07

a lot of codes you can totally get like

277:10

a lot of different result right here so

277:12

yeah that was our basic testimonial

277:14

project in reactjs okay so time for the

277:17

accordian project so I already changed

277:19

the styling and I also have this UTS

277:21

folder and now inside this UTS folder I

277:24

have this content.js file and now inside

277:26

this content.js file we have our

277:28

accordian data we're now exporting this

277:31

so which means like we are going to be

277:32

using that in other files here you can

277:34

see we have our array and then inside

277:36

this array we have our object it's going

277:38

to have the title which will say like

277:39

what is HTML and then the content which

277:41

will just like uh clarify like what is a

277:44

HTML then we have like what is a reactjs

277:47

what is a nodejs what is a goang and so

277:49

on and so forth and you are more than

277:51

welcome to provide more data to there if

277:53

you wanted to so yeah this is how we are

277:55

going to be exporting there so that we

277:57

can use it in other files so the first

277:59

thing that I want to do is that I want

278:00

to create my accordian component right

278:02

here so I'm going to use like accordion.

278:04

jsx and let's just use our RFC save my

278:07

file and go to my app and registered

278:09

there but we are not going to be

278:10

registering our comp onon it like that

278:13

the first thing that we have to do is

278:14

that we have to get our content which is

278:17

uh accordian data come on if you can get

278:21

the we have our accordian data God damn

278:24

it we have to use our import and we're

278:26

going to be grabbing something from

278:28

let's just go ahead and go to the UTS

278:31

and we're going to be grabbing our data

278:32

from that content okay so the data will

278:34

be that accordion data now we have to

278:37

copy it we have to create our dat with

278:39

the class of accordion and inside this D

278:42

we're going to be iterating over through

278:44

all of that data because we already know

278:46

that this is array so which means like

278:48

we can use the map method on there so

278:50

I'm going to use the map method right

278:52

here and we're going to be restructuring

278:54

the title and also here you can see for

278:56

each object we have the title and also

278:58

the content right here so we're going to

279:00

be destructuring them and the next thing

279:02

that I want to do is that I want to call

279:03

my accordian component right here and we

279:06

are going to be passing two prop St

279:07

we're going to be passing the title as

279:10

the prop to this title I mean like to

279:12

this accordian component we're going to

279:14

be also passing a content today and we

279:17

are going to be passing this content as

279:18

a prop so we are now getting all of the

279:20

title and all of the content from this

279:23

accordian data and we are now passing

279:25

that to our accordian component so I'm

279:27

going to go into my accordian component

279:29

right here and now let me just

279:30

restructure the so I'm going to use like

279:32

title and also the content so this is

279:35

how we are going to be destructuring

279:36

them but the first thing that we have to

279:37

do is that we have to grab our Us St and

279:40

we also have to grab or Styles sheet so

279:42

I'm going to go ahead and go to my

279:43

style. CSS and that's going to be it

279:46

okay so yeah now the next thing that I

279:48

want to use that I want to just make a

279:49

state so which will give us like is

279:51

active and then set is active that's

279:55

going to be equals to the UST State and

279:56

for the initial value we're going to be

279:58

providing a false state today and now

280:00

for this return statement I'm going to

280:02

remove this accordion and change this

280:04

div to or section and now here for this

280:07

section we're going to be first of all

280:08

providing a class name and that's going

280:10

to be the cion card we will also provide

280:14

the key and key will be math. random you

280:16

can like basically provide anything

280:18

there like you can use The UU ID if you

280:20

wanted to now inside there we're going

280:22

to be creating with the class of header

280:24

and when somebody clicks on there we're

280:27

going to be firing our function which

280:29

will say like set is active changing

280:32

that to like is active like once again

280:34

that is now set to false so now here if

280:37

that is set to false it's going to

280:38

change there to true and if that is set

280:40

to true it's to change that to false

280:42

okay and now inside this div we going to

280:45

be creating yet another div which will

280:46

just say like uh my title and now

280:48

underneath this title we're going to be

280:50

providing our paragraph with the class

280:51

of Icon and here if it is active so in

280:55

come on if it is tail in that situation

280:58

we're going to be using this Dash but if

281:00

that's not the case we're going to be

281:02

using this plus symbol right here let me

281:04

just save that and here you can see we

281:06

have our accordion right here so if I

281:08

click on that it's going to change the

281:10

icon to minus and if I click on there

281:12

once again so it's going to change there

281:13

to plus okay so this step is now done

281:16

the next thing that I want to do is that

281:17

I want to take care of this content as

281:19

well so I want to show the content and I

281:21

also want to hide the content okay so

281:24

I'll just create a div the class of

281:25

content and inside this content we're

281:27

going to be checking if it is active and

281:31

then we're going to be creating our

281:32

paragraph let me just create my

281:34

paragraph right here I'm going to

281:35

provide a class name of card info and

281:38

for this card info we are going to be

281:40

rendering our cont content but if that's

281:42

not the case you're not going to see

281:44

anything okay so now let me just show

281:46

you there we have to click over here you

281:48

can see this how my UI looks like but if

281:50

I want to see the content of like what

281:52

is reactj so I can totally click on

281:54

there and I can read the content I can

281:56

totally uncollapse then and so on and so

281:59

forth so yeah this is our basic or the

282:03

most basic accordian component in

282:05

reactjs time for the ninth project so

282:07

now in this one we're going to be

282:09

building the form validation so I'll

282:10

just create a form. jsx and let's just

282:13

use our RFC sa my file and render my

282:17

form right in here semi file let's just

282:20

go ahead and go to our stylesheet and

282:22

remove every single thing from there and

282:23

provide our new style right here and

282:26

check this out our form is looking cool

282:30

but our code will not look cool because

282:32

we're going to have to create a lot of

282:34

state and then we have to keep track of

282:36

all of the stad and this because we are

282:38

not using a form validation Library

282:40

which we will learn in this course but

282:42

not right now called the re hook form we

282:44

will learn there very soon but not right

282:46

now so the first thing that I want to do

282:48

is that I want to import my used St save

282:50

my file but I don't know uh here you can

282:54

see we are getting this data God damn it

282:58

what the hell am I

283:00

doing God go to my amp comment this line

283:04

out sem my file so the first thing that

283:06

I want to do is that I want to create a

283:07

lot of State like the first state will

283:09

be for the username and then Set uh

283:12

username that's going to be equals to

283:13

the use St and the initial value will be

283:16

just empty string let's create for the

283:18

email and then set email set email

283:22

that's going to be equals to the usad

283:24

and once again empty string let's create

283:27

for the password and then set password

283:31

is going to be equals to the US St and

283:32

the initial value will be empty string

283:34

create for the confirm password so

283:37

confirm password and then set confirm

283:41

password is going to be equals to the US

283:44

St and let's just put our empty string

283:46

right here next we have to create a lot

283:48

of State for the errors so I'll create

283:50

like uh State for the username error

283:54

username and then also create one more

283:56

for the set error username it's going to

284:00

be equals to the used St and the initial

284:02

value will be empty string okay let's

284:04

just create for the email one so error

284:07

email and also set error email in equals

284:11

to the used St and the initial value

284:13

will be empty string create for the

284:15

error password and then set error

284:19

password it's going to be equals to the

284:20

US St and the initial value will be

284:22

empty string let's just sare one more

284:24

for the error confirm password c n f i

284:30

RM yep that's correct we also have to

284:32

use what set error confirm password

284:36

right here it's going to be equals to

284:37

the US St and the initial value will be

284:39

empty string okay now underneath all of

284:41

there we're going to be also creating

284:42

for the color so I'll just provide like

284:44

con um user color and then set user

284:49

color it's going to be equals to the US

284:52

St and the initial value will be empty

284:54

string okay let's create for the email

284:57

color and also set email color it's

285:01

going to be equals to the US St and that

285:04

um initial value will be empty string

285:06

let's create for the password color and

285:09

also set password color it's going to be

285:12

equals to the US St and empty string

285:14

let's just create for the final one

285:16

which will be a confirm

285:18

password color it's going to be equals

285:21

to set confirm password color it's going

285:25

to be equals to the used St and the

285:27

initial value will be empty string okay

285:29

that was a lot of strats okay so now

285:32

let's just keep track of all of their

285:34

stats but first of all we have to build

285:36

our UI then we're going to be jumping

285:37

into all of that stuff so I'm going to

285:39

just change that to like a react

285:41

fragments and inside these react

285:42

fragments we're going to be creating our

285:44

div with the class name of card okay so

285:47

now inside this card we're going to be

285:48

creating our card image and uh yeah I

285:51

guess that's going to be fine now

285:53

underneath this card image we're going

285:55

to be creating our form and we're not

285:57

going to be providing any action today

285:58

because we don't want to send our data

286:00

to any server and we're going to be

286:02

using our input field this input field

286:03

will have the text and also the

286:05

placeholder of name okay so the style

286:08

I'll just put like the style will be set

286:11

to border color and the Border color

286:13

will be equals to the user color which

286:15

we've already specified right in here

286:18

okay and for the value I'm going to

286:20

provide the username as the value and

286:22

I'm going to also provide the own change

286:24

event handler when somebody change or

286:26

type something inside there so we're

286:27

going to be using our set usernames come

286:30

on set username and here we have to

286:33

specify our event.

286:35

target. value so if I sve my file and

286:39

check this out so here you can see we

286:41

getting our image and also we are

286:42

getting this input field right here

286:44

which is looking amazing so the next

286:46

thing that I want to do is that I want

286:47

to show my error if we have one error

286:49

okay so I'll just use my paragraph with

286:51

a class of error and here we're going to

286:53

be using like error username okay and

286:57

now underneath there we're going to be

286:58

creating our input field so I'll just

287:00

create input field with the type of text

287:02

and also the placeholder will say email

287:06

and we are going to be providing some

287:07

sort of a style and that style we say

287:09

like a border color and the Border come

287:12

on Border color and the Border color

287:15

will be equals to the email color okay

287:18

which we've already specified up above

287:20

and for the value we going to be passing

287:22

an email as a value and when somebody

287:24

types something inside this we are going

287:26

to be carrying this event and also we

287:28

going to be using our set email event.

287:31

target. value inside the sem my file so

287:33

now here you can see we have our email

287:35

field right here and underneath them

287:37

once again we're going to be using our

287:38

paragraph the class of error and LS

287:41

render or error email right here we're

287:44

going to be creating yet another input

287:46

field and that's going to be exactly the

287:48

same thing but in this case we're going

287:50

to be providing a password and we also

287:52

have to change there to password and

287:54

this one to email right here so for the

287:58

style I'm going to provide the style of

288:01

the Border color of come on Border Co o

288:05

r there we go and the Border color will

288:07

be equals to the password color and now

288:10

we going to providing a value and the

288:11

value will be set to password okay so

288:14

when somebody types something inside

288:16

there we're going to be using our set

288:17

password and here we have to specify our

288:20

event. target. value save my file and

288:23

here you can see we have our password

288:24

field as well and underneath that we're

288:27

going to be once again rendering our

288:29

error so I'll create a paragraph with

288:30

the class of error and which will say

288:32

like error password and now to need this

288:35

paragraph finally we are going to be

288:37

creating an input field for the confirm

288:39

password so I'll just for a password

288:41

once again and we are going to be

288:44

providing a placeholder which will say

288:45

like confirm password and also uh the

288:50

style will be equals to that border

288:51

color once again so I'll use like border

288:53

color so l o r and the value will be a

288:57

confirm password uh color would be fine

289:00

there we go and also I'm going to

289:02

provide the value of confirm password

289:05

and here we're going to be providing the

289:07

own change event handler when somebody

289:09

tried to change something so we we're

289:10

going to be calling this function which

289:12

is like set confirm password and provide

289:14

our event. target. value inside there

289:18

now underneath there we going to be

289:19

creating our paragraph with the class of

289:21

Errors once again or just error and here

289:24

we are going to be rendering for error

289:27

confirm password like so now underneath

289:30

there we going to be creating our BN

289:31

with the class of submit BTN and also

289:34

we're going to be providing the on click

289:36

event handler when somebody try to click

289:38

on this we're going to be using our

289:39

valid dat function which we going to be

289:41

creating in a few second so let's just

289:43

create this validate function and that's

289:45

going to be here I'm going to go to the

289:46

top and create my validate function

289:49

right here const validate is going to

289:51

take the event and inside that we're

289:53

going to be using like event. prevent

289:56

default come on p r v n t prevent

290:00

default like so and provide our check so

290:02

if we have like a

290:04

username link is greater than a so in

290:07

this situation we're going to be using

290:09

like set error username

290:11

and we're going to be setting there to

290:12

empty string and also for the set user

290:15

color we're going to be providing a

290:17

green color to there and if that's not

290:19

the case so in this situation we're

290:20

going to be using like set error

290:22

username and for the error we are going

290:24

to be specifying like username must be

290:27

at letters long or letters and also for

290:32

the set user color we're going to be

290:34

changing there to Red so if I save my

290:36

file and check this out so if I just

290:38

like provide like two s's and click on

290:41

there it's going to give us like user

290:42

must be or username must be at letters

290:45

long okay so if I just put like random

290:47

stuff and click on there it's not going

290:48

to give us that error and now the line

290:50

is set to Green okay that's cool now we

290:53

also have to provide a validation for

290:54

the email so underneath that we are

290:56

going to be checking like if email.

290:59

includes this at gmail.com so if that's

291:03

the case we're going to be using like

291:04

set error email ins set that to empty

291:07

string and also set email color will be

291:09

set to totally green but if that's not

291:12

the case in that situation we're going

291:13

to be using like set email color and we

291:16

have to set the to toally Red once again

291:18

and we have to use our

291:20

set set error email and change that to

291:24

like email should be or should have at

291:28

gmail.com or yeah at gmail would be fine

291:31

so if I save my file and if I just

291:33

specify something and here you can see

291:35

we now getting this error right here so

291:37

if I just use like at gmail.com or

291:39

something C on there and now it's going

291:41

to give us that green uh green line

291:44

right here now underneath that the next

291:46

thing that we have to do is that we have

291:47

to also take care of the password so

291:49

I'll use like if uh password. length is

291:53

greater than add characters add

291:55

characters not a ASX so I'll use like

291:58

set error password and change that to

292:00

empty string and also set password color

292:04

and change the to totally green color

292:07

and if that's not the case we're going

292:09

to be using like said error password and

292:11

provide like password should be add

292:15

letters long and underneath that we're

292:18

going to be using like set password and

292:20

change that to Red so if I save my file

292:22

and if I only provide like 1 two three

292:25

and now if I submit this this error like

292:27

password should be 8 letters long so if

292:29

I just specify something else click on

292:32

that now it's going to gives us the

292:33

green and now for the final validation

292:35

we're going to be checking the confirm

292:37

password so if our password is not equal

292:41

to this empty string so and password is

292:46

equal to the confirm password okay so we

292:48

are going to be using like set error uh

292:51

confirm password and we have to change

292:53

that to empty string and also we have to

292:55

use our set confirm password uh color

292:59

and we have to change that to totally

293:00

green okay so now underneath that we are

293:02

going to be also providing the else

293:03

class if that's not the case we're going

293:05

to be using like set error confirm

293:08

password God damn it set error confirm

293:12

password we have to provide this error

293:14

like passwords didn't

293:17

match ah God damn it we have to WRA in

293:20

double Cotes like so otherwise we're

293:23

going to be getting an error change them

293:25

and we're going to be also using like

293:27

set confirm password password and

293:30

provide a red color right here so if I

293:31

save my file let me just uh refresh

293:34

there and if I just write like 1 2 3 and

293:36

also if I just write like 222 click on

293:39

that it's going to give us the an error

293:41

and now if I write like uh 1 2 3 and

293:43

also one 2 3 inside there it's not going

293:45

to give us any error for the last one

293:47

but it will give us error for this one

293:49

because the password should be add

293:51

characters okay so yeah this is how our

293:54

validation will look like so if I click

293:55

on that it's going to gives us an error

293:57

and now if I specify like some sort of a

293:59

name like my own name husan or husan web

294:03

rather test at gmail.com and then test1

294:08

23 test one 2 2 3 4 5 and test 1 2 3 4 5

294:15

it's going to giv us a green lines right

294:16

here so yeah that was our basic form

294:19

validation in reactjs hey guys and walk

294:22

to YouTube channel so in this video

294:24

we're going to be creating this project

294:26

by just using react jss which means like

294:28

we're not going to be using any backend

294:30

services like mongod DB Mongoose and

294:33

express JS and all of that kind of good

294:35

stuff but instead we're going to be just

294:37

building this project by just using

294:39

reist so this is not a huge project to

294:42

be honest but we are going to be

294:43

rendering a few components and we are

294:45

going to be learning about how we can do

294:48

a filtering in reactjs so like we can

294:50

filter items through search and we can

294:52

also filter through this buttons right

294:54

here and also these uh what do we call

294:57

it custom uh radio buttons and all of

295:00

that kind of stuff so let me just show

295:01

you what this project is all about so

295:03

let's suppose if I want to search for a

295:05

specific U product like I don't know I'm

295:07

going to search for this one so if I

295:09

just type Nike so I'm going to just

295:11

write like n i ke so here you can see

295:13

long uses all of the products right here

295:15

which Nike has so I'm going to just

295:17

write space and then I'm going to just

295:19

write for zoom and here you can see it

295:22

will now gives us this specific product

295:23

which I'm searching for okay so I'm

295:25

going to just clear that and here you

295:27

can see it will now giv us that products

295:28

once again and now if I just click on

295:31

this Nike and here you can see it will

295:33

now giv us all of the products which

295:34

Nike has and now if I click on and by

295:37

the way all of this data is totally

295:39

random and and they aren't specific Nike

295:42

and edits and you can provide a specific

295:44

products for them but for me I just put

295:46

random images of shoes and sandals and

295:49

stuff okay so you will find a link in

295:51

the description below if you click on it

295:54

it will bring you to my gab repository

295:55

and you can download all of the code or

295:58

you can download that um db. JS file and

296:01

then you can grab like all of that

296:03

arrays of data okay so if I just click

296:05

on this EDS it will now gives us all of

296:07

the products of EDS and once again all

296:10

of these products are totally random

296:12

like I don't even know the names of

296:13

these and here you can see we just

296:14

specify the amount of stars they get and

296:17

also the reviews they get and the

296:20

previous price and the new price and you

296:22

can change that however you want and I'm

296:24

going to also show you how you can

296:25

provide that functionality in this app

296:27

as well if you click on the V so it will

296:29

not uses all of the product which this

296:31

Vans have okay so this is the second

296:33

filtering this is the first one this is

296:35

the second filtering let me just click

296:37

on this all products right here and here

296:39

you can see it will not goes all of the

296:40

products if you click on this all one

296:42

more time so here you can see it will

296:44

now gives us all of these products if

296:45

you click on the sneakers and here you

296:47

can see it will just gives us their

296:49

sneakers if you click on a Flats it will

296:51

gives us Flats if you click on a

296:54

sandals and it will gives us these shoes

296:57

they earn sandals as I said like all of

296:59

the data is totally random but you can

297:01

specify like different kind of images

297:03

for the sandals and I'm going to also

297:05

show you how you can do that if you

297:07

click on Heels so here you can see it

297:09

when long uses heels and you can also

297:11

filter through different kind of prices

297:13

like if I click on this all it will now

297:15

gives us all of these products which um

297:18

these Pro prices like random prices we

297:21

have if you click on from 0er to 50 it

297:24

will gives us all of their products

297:26

which has this 50 uh what do we call it

297:28

50 price right here let me click on 50

297:31

through 100 it will now gives us all of

297:32

the products which are 50300 and we have

297:36

150 and we also have over 150 so here

297:40

can see the prices and you can also

297:41

change there however you want all right

297:44

so that's that now you can also filter

297:47

through the colors if you want to so I'm

297:48

going to just click on all and here you

297:50

can see it uses all of the colors but if

297:52

I want to just get the black color I'm

297:55

going to just click on black and here

297:56

you can see it gives all of these black

297:58

color and I mistakenly put this one

298:01

right here inside a black color as well

298:04

but anyways that's also awesome you can

298:05

also change that if you want to and now

298:07

I'm going to click on a blue it will now

298:09

just use this blue products and now if

298:11

you click on red it will just gives us

298:12

red products right here if you click on

298:14

green it will just gives us these green

298:16

products right here and finally if you

298:18

click on a white so here you can see it

298:20

will now gives us all of the white

298:21

products right here I'm going to click

298:23

on this all products one more time it

298:24

will now gives us all of these products

298:26

right here and so this will be a good

298:29

build and this project will help you

298:31

monster different kind of techniques in

298:33

reactjs like different kind of ways to

298:36

filter through a data using just reactjs

298:39

so we not not going to be using any uh

298:41

Redix toolkit and all of that kind of

298:43

stuff but we are going to be just using

298:45

uh react JS and also react icons for

298:48

these icons and we're not going to be

298:49

also using any um bootstrap U react

298:52

bootstrap and also we're not going to be

298:54

using what do we call it Talon CSS and

298:57

and all of that kind of stuff for

298:58

styling I'm going to be using CSS just a

299:00

pure CSS if you don't want to write it

299:02

so you can also get all of the styling

299:05

from my G repository and by the way all

299:07

of the code will be available in the

299:10

description below you just have to click

299:11

on that link which will bring you to my

299:13

GitHub repository and there you can just

299:16

uh search through different commits or

299:19

you can also get all of the code if you

299:20

want or if you want to follow along with

299:22

this video feel free to do that go back

299:25

first of all and I'm going to just write

299:26

code and then I'm going to just write

299:28

Advan filtering and now I'm going to hit

299:30

enter so here you can see it will now

299:32

open this project right here inside this

299:34

window right here okay so I'm going to

299:36

just zoom in a bit so that you guys can

299:38

see everything a bit better and I'm

299:39

going to going to just hide that up

299:41

above from there all right so here you

299:43

can see my sidebar is right here if

299:45

there annoys you so you can just I don't

299:47

know you can just right click on it and

299:49

send it right here or you know I'm going

299:50

to just stick with this setup right here

299:52

because for a lot of developers that

299:54

would be preferred way to go and what I

299:56

will do is that I'm going to just remove

299:58

this f. CSS file and also this index.

300:02

CSS not this index.js file but just this

300:06

logo svgs and all of that kind of bad

300:08

stuff not bad stuff to be honest so now

300:11

I'm going to just go inside and I'm

300:13

going to remove this gen6 from here and

300:16

I'm going to just write H1 uh let me

300:18

just write H1 right here of hello world

300:22

right here okay and I'm going to also

300:24

remove this logo from up above and also

300:27

this app.js or app.css

300:30

file I'm going to remove the whal from

300:33

here and also that react strict mode as

300:35

well remove this one and also this one

300:38

now I'm going to sell my file and now

300:40

what I will do is that I'm going to

300:41

close this one out and I'm going to just

300:43

write npm start to start my project

300:45

right here okay so I'm going to just

300:47

wait for it to start my project it will

300:49

not okay would you like to run the app

300:52

in another port in okay we've already

300:54

opened this one so I'm going to just

300:55

close that in a few second so I'm going

300:57

to just close that in a second and then

300:59

I'll come back now let me just close

301:01

there hit contrl C now I'm going to just

301:03

use npm start so it will now just start

301:05

this project right here inside this

301:07

window and what we are seeing is this

301:09

hello word right here which we've wrote

301:12

inside this M.J file right here okay I'm

301:15

going to just close this one right here

301:16

from here all right so that's the the

301:19

first thing which I would do is that I'm

301:21

going to create a folder right here and

301:22

I'm going to just give a name of like DB

301:24

and inside this DB folder I'm going to

301:26

just create a new file I'm going to give

301:28

a name of like data.js and inside this

301:30

data.js file I'm going to grab a lot of

301:33

things so I'm going to just grab that

301:36

and I'm going to show you where you can

301:37

find that here you can see I have all of

301:39

these data right here inside this

301:41

project and you can find all of this

301:43

data in my giab repository so it's not

301:45

much but here you can see we are just

301:47

getting this data array and inside this

301:50

data array we have just a few objects

301:52

right here and we are storing the image

301:54

property and we are just specifying

301:56

different kind of images to it and we

301:58

also providing a title for a specific

302:00

product and we have a star which is just

302:02

a icon which we going to be installing

302:04

right here and I just provide a class of

302:06

like rating star and here you can also

302:08

see we have reviews and I just provide

302:10

like one two three you can provide how

302:12

many you want then we have a previous

302:15

price and the previous price is this one

302:17

or used to be this one and the new price

302:19

is $200 or something like that and we

302:22

have a different kind of companies like

302:24

Nike and we have uh I don't know

302:26

different kind of companies like w and

302:28

puma and stuff like that and then we

302:30

have different kind of colors and also

302:32

different kind of categories like

302:33

sneakers and heels and I don't know

302:36

there was a lot of them so what I'll do

302:39

is that I'm going to copy all of that

302:40

content and I'm going to place it inside

302:43

this project right here so I'm going to

302:44

just save this file and this is a lot of

302:47

alms right here and you can specify more

302:50

if you want to and now I'm going to just

302:52

cut this data.js file right here and I'm

302:54

going to close this DB and what else do

302:56

we have to do the first thing I would do

302:58

is that I'm going to just create a

302:59

components folder where we are going to

303:01

be storing just or custom components you

303:04

will see that just in a second so I'm

303:05

going to just write components there we

303:07

go and we are going to be creating a few

303:09

components right here so I'm going to

303:11

just write button.js and I'm going to

303:13

also create a new component I'm going to

303:14

give a name of like card. JS then we

303:16

have another one which is input

303:19

uppercase input. JS there we go and I'm

303:22

also using this extension card let me

303:24

just open that extension uh this es7 and

303:27

react and Redux uh so let me just click

303:30

on there and I'm also using this

303:31

extension if you guys don't know about

303:33

that uh so feel free to check on my

303:35

reactjs course or you can just quick

303:37

Google search like what is that uh

303:39

extens I was talking about so now I'm

303:41

going to just uh close that and I'm

303:43

going to also place this import

303:44

statement right here and let me just

303:46

import it right here so let me just zoom

303:47

in a bit so you guys can see everything

303:49

a bit better I'm going to use RFC and

303:52

I'm going to just cut that I just like

303:54

it that way if you want to put it right

303:57

here like this import Ser right here so

303:58

feel free to do that but in my case I

304:01

just kind of want to work with this kind

304:03

of structure so I like this structure I

304:05

prefer this structure uh and yeah you

304:07

can choose like export segment just in

304:09

one liner but in my case I'm going to be

304:11

using like this and now I'm going to

304:13

just write like

304:14

RFC and I'm going to remove that let me

304:18

just copy it and I'm going to place this

304:20

input right here at the bottom so now we

304:22

successfully created this card component

304:24

input component and that button

304:26

component but we are not going to be

304:27

using it right now so say byebye to this

304:30

components folder right here so now the

304:33

next thing which we are going to be

304:34

creating is that we are going to be

304:35

creating a navigation section then we

304:38

are going to be creating a product

304:39

section then recommend it and inside

304:41

there or not inside but we are going to

304:43

be also creating a side Mar so let me

304:45

just create a new folder I'm going to

304:47

give a name of like navigation there we

304:49

go and now inside this navigation I'm

304:51

going to first of all create a nav do JS

304:54

component and I'm going to also write

304:56

like na. CSS right here as well okay so

304:59

I'll just write like uh R A or RFC and

305:04

I'm going to remove that and I'm going

305:06

to just write my navigation right here

305:08

okay and I'm going to also import my CSS

305:13

inside this file one more time as well

305:15

so I'll just go one level and then now.

305:18

CSS so we're going to be placing all of

305:20

our CSS inside here so what I will do is

305:22

that I'm going to render this component

305:24

to the browser so I'm going to just use

305:26

it right here remove that and I'm going

305:29

to just write a nav right here hit enter

305:32

and it will now grab this na from their

305:34

navigation component right here and I'm

305:36

going to also change the name of it to

305:37

like navigate

305:39

ation there we go I'm going to hit enter

305:41

right here and I'm going to close it

305:43

manually so now if you sell a file so

305:45

here you can see we now just getting NAB

305:47

right here okay so everything is working

305:49

the way we expect them to work and yeah

305:52

that's cool but what else do we have to

305:53

do we have to create another component

305:56

or another folder for products so I'm

305:58

going to just write products inside this

306:00

products I'm going to create two files

306:02

the first one will be just products. JS

306:05

and the second one will be products. CSS

306:07

so the same things will apply right here

306:09

as well remove them I'm going to cut

306:12

this component export products there we

306:16

go and now I'm going to also import this

306:19

um what do we call it products not this

306:21

one but products. CSS there we go okay

306:24

so that's also cool but now what I do is

306:27

that I'm going to use my react fragments

306:29

because I'm going to be rendering a lot

306:31

of components right here and I'm going

306:33

to just use products okay and it will

306:36

just import it by default if if you're

306:37

using visual story Rec corders so that's

306:39

going to be awesome so here you can see

306:41

we have navigation and products and you

306:43

probably know all of these stuff and I'm

306:46

going to close this one as well now let

306:47

me just grate one more which will be

306:49

recommended so recommended there we go r

306:52

e c o m e n d e there we go I'm going to

306:56

copy this one name because it's kind of

306:57

a long name to so we have recommended.

307:00

Js and we have recommended. CSS file so

307:04

I'll just write RFC remove that copy it

307:08

and then we have uh recommend oh come on

307:13

recommended there we go I'm going to

307:15

also get my import statement of uh let

307:18

me just copy this name it's kind of a

307:21

long name to type you know what I'm

307:22

saying so I'm going to just write

307:23

recommended. CSS and also let me just

307:26

grab it from recom not reacton but

307:30

recommend ah r e o m e n d

307:35

d okay it's not helping me in this case

307:37

so I'm going to have to import it import

307:41

recommended there we go recommended come

307:44

on from go level and recommended and we

307:48

have recommended so I'm going to sve my

307:50

file and here you can see we have this

307:51

recommended right here anyway so that's

307:54

cool I don't know why I just close this

307:56

file but now let me just create a

307:58

sidebar and inside that sidebar we going

308:00

to be creating different kind of folders

308:02

so I'm going to just write Side Bar and

308:04

inside this sidebar I'm going to be

308:06

creating different kind of folders

308:08

inside that folders We Are going to be

308:09

having different kind of categories of

308:12

components so I'm going to just write

308:13

category and inside this category I'm

308:16

going to just write Cy g. CSS or not

308:19

just CSS JS would be fine I'm going to

308:22

copy them and we are going to be also

308:24

creating category. CSS as well so I just

308:27

write RFC remove that and come on Cut

308:32

there and

308:34

category and yep let me just grab my cat

308:39

T come on category. do CSS there we go

308:43

save my file remove both of them and now

308:46

inside this sidebar folder I'm going to

308:48

be creating one more folder and I'm

308:50

going to just give a name of like colors

308:53

uppercase colors there we go and inside

308:55

this colors folder what I will do is

308:57

that I'm going to be creating two

308:58

folders or one component and one will be

309:00

for styling like colors. JS and we have

309:03

another colors. CSS is that color yeah I

309:07

I write a colors there we go so cool

309:10

anyway so I'm going to just remove that

309:12

statement copy it and then we have

309:15

colors okay it's kind of a little bit

309:17

challenging for typing and talking so

309:21

sometimes it's kind of it's kind of

309:23

challenging so I'm going to just sell my

309:24

file remove both of them okay so let me

309:27

just save that file let me just create

309:29

one more folder inside there and I'm

309:31

going to give a name of like price and

309:33

inside this price I'm going to just give

309:34

a name of like price. JS price. CSS

309:38

there we go

309:39

now let me just write RFC remove them

309:43

and let me just cut it from here give a

309:46

name of price let me just import my uh

309:50

one let's just go one level above price.

309:53

CSS there we go and now let's just

309:55

remove that and now here you can see our

309:58

folder structure is now totally complete

310:00

inside this navigation section first of

310:02

all I'm going to start from jsx so I'll

310:06

just write navigation as the navigation

310:09

tag and inside this navigation I'm going

310:11

to just write a div with the class of

310:13

nav container because we're going to be

310:15

placing our input inside their container

310:17

and as a type will be set to text we are

310:20

going to be changing that and we are

310:21

going to be also taking care of that own

310:24

change event handler and stuff later on

310:26

but in this section enter you search

310:30

search uh shoes will be fine all right

310:34

that's cool but I'm going to also give a

310:36

clause of something like to style it I'm

310:38

going to just give a class name of like

310:40

search item or search input would be

310:42

fine rather okay so that's going to be

310:45

for this div and inside this div we just

310:47

put or input tag Right Here and Now

310:49

underneath this div what we have to do

310:51

is that we have to create another one so

310:53

which will be a profile container so

310:55

this is kind of a useless one but herey

310:57

we going to be also putting it and I

310:59

forgot to install react icons here we

311:01

going to be using icons so I'll just

311:02

create a new terminal I'm going to open

311:05

new terminal and I'm going to just use

311:07

npm install if you guys can see it npm

311:11

come on man what I will do is that let

311:14

me just go back so you guys can see it

311:16

I'm going to just drag it right here and

311:19

say byebye to this one now let me just

311:21

zoom in a bit so I'm going to just

311:22

install it by using this power shell I'm

311:24

going to use npm install react react

311:28

icons okay hit enter so it will just

311:30

install in a few second all right so

311:33

here you can see we successfully

311:34

installed this react icons so I'm going

311:36

to just close this Powers shell and now

311:38

the first thing that you have to do is

311:39

that you're going to be grabbing a few

311:41

fonts so I'll just grab like fi and then

311:45

heart and I'm going to just import it

311:48

first of all is f i hard kind of awful

311:51

name from

311:53

react um icons and we are going to be

311:56

grabbing this one from fi and we would

311:58

also need to import these parts which is

312:02

AI lure gu I and then we have

312:07

outline and then we have shopping card

312:11

and then we have ai outline user ad okay

312:15

so I'm going to just grab that from

312:17

react icons and go to AI so I'm going to

312:21

sell my file and I'm going to use it

312:23

right here so here you can see we have

312:25

this first anchor tag right here I'm

312:27

going to use it right here so we have fi

312:29

heart and I'm going to just use that and

312:32

I'm going to close it not like that but

312:34

just let me write for Slash and here

312:37

what I will do is that I'm going to just

312:38

give a class of uh nav and also icons as

312:43

well and now let me just save that

312:45

underneath this anchor tag I'm going to

312:46

create one more anchor tag and it will

312:48

go to nowhere and inside that what I do

312:51

is that I'm going to use my AI outline

312:53

user edit or whatever kind of font you

312:55

have okay so now I'm going to add that

312:57

I'm going to just write uh I guess this

313:00

shouldn't be a user add but it should

313:02

have to be a shopping cart there we go

313:04

and I'm going to also provide a cluster

313:06

like n icons okay so I'm going to just

313:08

duplicate there and now I'm going to

313:11

change this icon name to AI outline user

313:15

edit there we go okay so it will go to

313:17

nowhere I'm going to just a for slash

313:20

right here and I'm going to sve my file

313:23

and what are we getting okay AI outline

313:26

shopping cart is not defined let's go to

313:28

the react

313:29

icons all right so here you can see we

313:32

have this react icons right here I'm

313:34

going to just search for a shopping card

313:36

there you go and now let me just grab

313:38

that and I'm going to put it right here

313:41

okay so name was totally awful and the

313:45

second one we have is uh I don't know

313:47

outline user edit or something like that

313:51

uh I guess this this one would be fine

313:53

so I'm going to just click on him and

313:54

I'm going to place it right here sa my

313:56

file and now let me check out and we

313:59

have okay so I'm just meta type I'm

314:01

going to copy it from there and I'm

314:03

going to place it right here semi file

314:05

and here you can see we now getting

314:06

these icons and we have this input box

314:09

right here all right so now let me just

314:10

Prov a little bit of styling to it so

314:12

I'm going to just close this one and

314:14

inside this SRC what I do is that I'm

314:16

going to just create index. CSS file for

314:19

just a resarch so what I do is that I'm

314:22

going to just provide a different kind

314:23

of resarch you can f for if you want to

314:26

so I'm going to just provide margin box

314:28

sizing will be set to totally border box

314:31

font family will be set to S SF and we

314:33

are going to be selecting all of our

314:34

anchor tags and text decoration will be

314:36

now set to none and color uh I'm going

314:39

to just P like RGB of zero not Zer but

314:43

97 if I can get 97 I'm going to copy

314:46

that place it two times so I'm going to

314:48

remove that comma from from the bottom

314:50

and now I'm going to select every Ali

314:52

which we have inside this app and I'm

314:54

going to just remove them like the list

314:56

style will be just remove and then I'm

314:58

going to be creating this uh buttons

315:00

class for later buttons once we are

315:02

going to be jumping into the buttons so

315:04

we are going to be using this class and

315:06

that would be magic so I'm going to just

315:08

provide a background of

315:09

transparent and then we have a border

315:12

I'm going to set that to none and Border

315:15

0.6 pixel solid and totally CCC just a

315:19

lighter border and I'm going to also

315:21

provide border radius not this one but

315:23

border radius will be now set to 5 pixel

315:26

and then we have a color of uh 3 32 3 2

315:30

32 one more time okay so this is going

315:33

to be the color and cursor will be

315:34

pointer we are not going to be using

315:35

this bones not right now and then then

315:39

we have to go to in this na. CSS file

315:43

let me just highlight this so I'm going

315:44

to just go inside this na. CSS file I'm

315:47

going to click on them and I'm going to

315:48

just start from the navigation first of

315:50

all I'm going to be selecting this

315:52

navigation container right here okay so

315:54

I'm going to just select that and I'm

315:56

going to provide display of tot flex and

315:58

Border for the not border radius but

316:00

border for the bottom I'm going to

316:02

provide two pixel of solid F3 F3 F3 so

316:06

this is going to be the color which I'm

316:07

going to be providing justify cont will

316:09

be now set to space yeah space around

316:12

was totally fine and align items was

316:15

totally set to Center and I'm going to

316:16

also provide a little bit of padding all

316:18

around and then we have a z index of 999

316:22

because we are going to be using a

316:23

display of what do we call it display of

316:25

flex so now let me just write margin of

316:28

2 pixel and now let me just save there

316:31

and here you can see we are now just

316:32

getting these icons right here and we

316:35

just getting this input box so now let

316:36

me just go back and H be fine okay so

316:40

you can increase or decrease that if you

316:41

want to but in my case that's going to

316:43

be totally fine now let me get all of

316:45

the inputs which we currently have let

316:48

me just remove this one from here and

316:51

I'm going to provide a padding of 12

316:54

pixel be fine and then 20 pixel and

316:57

Border I'm going to remove all of the

316:58

borders from here and then we have a

317:01

background of this um

317:03

F7 uh F6 F come on F6 one more time okay

317:08

okay so then we have the outline of none

317:12

and then we have a margin for the right

317:13

of 20 pixel and Border a radius I'm

317:16

going to proide is like five pixel be

317:18

fine and Position will be set to totally

317:21

relative and width will be 14

317:24

pixel kind of voice I just metant

317:29

14 go back all right so that's cool and

317:32

now let me just get my nav icons which

317:35

are all of these icons which we provide

317:37

these classes to it you probably noticed

317:40

that but I don't know why I showed that

317:41

1.5 for Ram and then high will be 1.5

317:45

for Ram and we have a margin for the

317:47

left and it will be now set to Two Rim

317:49

so if you s our file and that's looking

317:51

more than awesome here you can see we

317:53

have our input search field and then we

317:56

have this I don't know why we didn't

317:57

specify color to it we have to provide

317:59

some sort of a color to it uh input and

318:03

I forgot to include some sort of a color

318:06

to this anyways we will change that

318:08

layer

318:09

we don't have to worry about that oh

318:11

yeah we can change it right away not

318:14

input but icons let me just change the

318:17

color of them

318:18

to I don't know yep that's looking yeah

318:23

that's fine that's totally fine so this

318:25

is our first navigation section so that

318:27

was it about this navigation section so

318:29

the next thing which you have to do is

318:31

that we have to jump into this product

318:33

section and this product section will be

318:35

responsible for all of the products

318:37

where we are going to be rendering all

318:39

of our products inside the cards and

318:41

stuff so we later we are going to be

318:43

creating a component for cards but for

318:45

this case we are going to be just uh

318:48

rendering a few items so I'm going to

318:50

just write a section right here and I'm

318:51

going to just give a class of like card

318:54

container uh c t i n e r sometimes I

318:57

made a lot of mistakes so that's why I'm

318:59

just double checking these spellings all

319:02

right so that's the card section so the

319:03

next thing which you have to do is that

319:05

we have to create a section for a card

319:08

so now inside discard section we have to

319:10

render our image so for this case I'm

319:12

going to go to my database right here my

319:15

database my DB file so I'm going to just

319:18

copy this image from here and I'm going

319:20

to just place that image right here as

319:21

alternative text I'm going to just write

319:23

like uh Sho and now underneath that what

319:26

do we have to do we also have to create

319:28

a component or not a component but card

319:31

uh

319:32

details section and now inside this card

319:34

details section I'm going to just write

319:36

H3 of the card title I'm going to give a

319:39

class of like card title and now I'll

319:42

just put some sort of a title like I

319:43

don't know Sho and now you need that I'm

319:46

going to also provide different kind of

319:48

section uh not different kind of section

319:50

but just a section with a class of card

319:53

reviews are e v i e WS there we go and

319:57

now inside this cards reviews what do we

320:00

have to do we have to get our uh start

320:02

so I'm going to just click here and I'm

320:04

going to just write star okay so let me

320:07

just get this one I guess this one will

320:09

be fine okay I'm going to copy that and

320:11

I'm going to just place it right here

320:13

and like so and now what do we have to

320:16

do we have to also grab it from or react

320:19

components so not react component but

320:21

from react icon so I'm going to just

320:23

write from and then react uh icons and

320:27

now I'm going to go to the AI okay so

320:29

now if you sell our file here you can

320:30

see we are now getting our shoe we are

320:32

getting the title and we are also

320:34

getting our star but we will need four

320:36

star for this one so 1 2 3 four and now

320:40

if you saell that here you can see we

320:41

now getting four stars right here okay

320:43

so that's cool as well and I'm going to

320:46

also provide a span of total reviews so

320:48

I'll just give a name of like not name

320:50

but class of total reviews and now I'm

320:53

going to just put like I don't know five

320:55

reviews or four reviews would be fine

320:57

okay so underneath this section what we

320:59

have to do we have to create a new

321:00

section with a class of card and then

321:03

price and now inside this carard price

321:05

we have to put or price right here okay

321:08

and now inside this price we are going

321:10

to be writing our Dell and we are going

321:12

to be rendering some like different kind

321:13

of price like uh I don't know $300 would

321:16

be

321:18

$300 would be fine so that price is

321:21

deprecated now we have to add a new

321:23

price so I'm going to just add new price

321:25

of like $200 or something like that and

321:27

let me just put a dollar or you know

321:29

we're not going to be adding any uh

321:31

dollar sign and stuff like that now let

321:33

me just get my bag so I'm going to just

321:35

write bag and now we have to just search

321:37

for a bag

321:39

bag which is I guess this bag will be

321:42

fine so I'm going to oh you know like

321:44

this one would be fine copy them I'm

321:46

going to past it right here like react

321:49

component less than come on less oh my

321:52

goodness less than sign and now we have

321:54

to grab it from our react icons okay so

321:57

I'll just write import and then get this

322:01

from react icons for slbs so now if you

322:05

s file and now let me just refresh my

322:08

browser to render that component so here

322:10

you can see this was a previous uh price

322:12

this is a new price we have four reviews

322:14

and we have this back right here so now

322:16

it's time to style this component and

322:18

then yeah that's going to be it for

322:21

style so that's going to be it so I'm

322:22

going to just go inside this product

322:25

start CSS and I'm going to first of all

322:27

select my car container okay so I'll

322:30

just write display of flex Flex W will

322:33

be now set to W margin for the left will

322:35

be now set to 20 rim and now I'm going

322:37

to also put margin for the top of Two

322:40

Rim and also the Z index will be now set

322:42

to minus 2 right right here I'm going to

322:45

also select my card I'm going to provide

322:47

a margin of 20 pixel and Border will be

322:49

no not just come on what the hell border

322:52

will be come on v d r will be to two

322:57

pixel solid Ed Ed Ed okay and I'm going

323:01

to also provide a pading of 20 pixel and

323:03

cursor will be pointer and also I'm

323:06

going to just select my card image okay

323:09

so did I provide a card image name to it

323:13

I didn't so let me just provide a card

323:16

image so I'm going to save this file I'm

323:18

going to also save this oh you know what

323:19

not going to save this file right now

323:21

I'm going to provide a width of 13 uh 13

323:25

rims and I'm going to also provide a

323:27

margin for the bottom of one

323:29

Rim there we go that's cool and I'm

323:32

going to also select my card title and

323:34

the margin for the bottom I'm going to

323:36

just provide one Rim as as well and now

323:39

underneath that I'm going to select my

323:40

car reviews there we go r e v i e WS let

323:44

me just double check sometime I made a

323:47

lot of typos so that's why I'm double

323:48

cheing it so I'm going to just proide

323:50

margin for the bottom like one Rim would

323:52

be fine and I'm going to also provide a

323:53

display of to flex and underneath that

323:56

I'm going to be selecting my rating star

323:58

which I forgot to include but we will

324:01

provide different kind of colors to it

324:03

so like yellow color will be fine D5 a

324:07

b55 this is going be the color which I'm

324:09

going to be using for a star I'm going

324:11

to copy this class from here and I

324:13

forgot to include it right here because

324:16

uh we are going to be putting all of

324:18

these icons inside our data file we

324:21

already have that but we will take care

324:23

of that later in the refactor section so

324:26

now let me just remove um these stuff

324:29

from

324:30

here like so and we just provide this

324:33

closes to it yep that's cool save my

324:35

file and now I'm going to refresh it and

324:37

I don't know why it's not working that's

324:39

because we didn't import it correctly I

324:41

guess we did import it but I don't know

324:44

what's going on let's just refresh our

324:46

browser why it's not working yep that's

324:49

that's because we didn't save this file

324:51

so we have to save it and here you can

324:52

see we have our recommended Sho and we

324:55

have this card right here okay so now

324:58

that's cool we have this yellow colors

325:00

and we take care of all of them now let

325:02

me just take care of their total reviews

325:05

which is this total reviews where is

325:09

that to reviews all right there we go so

325:12

we going to be taking care of that and

325:15

I'm going to just provide a font size of

325:17

0.9 rims to it and I'm going to also

325:20

provide a margin for the left of 10

325:22

pixel okay so then I'm going to just

325:24

write card price and display will be

325:27

totally flex and justify content will be

325:29

now set to space around and and align

325:34

items will be now set to Center okay so

325:36

finally we have to take care of the this

325:38

bag uh not this bag but we have to take

325:41

care of let me just provide a class of

325:44

bag icon or icon just a singular I'm

325:48

going to save this file and we have to

325:50

get that icon right here and we just

325:52

have to put a color of

325:55

535353 so if you sell our file let me

325:58

just save it and here you can see this

325:59

is how component will look like right

326:01

here so we can duplicate that component

326:04

again and again so let me just go back

326:06

so you guys can see everything a bit

326:07

better I'm going to just select this

326:09

section right here and I'm going to just

326:12

provide a little bit of items to it so

326:13

I'm going to just duplicate that you

326:15

don't have to do that you don't have to

326:17

do that but here you can see all of my

326:18

items will be placed right here let me

326:21

just select all of these items uh

326:23

through here I just kind of want to show

326:25

you like how all of my items will look

326:27

like duplicate there and now let me just

326:29

refresh my browser and here you can see

326:31

this is how all of my products will look

326:33

like right here okay and everything is

326:36

working like the way we expect them to

326:37

work everything is a okay but now we

326:40

have to refactor we are not going to be

326:42

refactoring our code not right now uh

326:45

but we will refactor all of our code

326:47

later but I just kind of want to render

326:49

some items so that we can see something

326:51

first of all and yeah that's going to be

326:53

it for this section and once again we

326:56

are going to be refactoring all of these

326:58

code at the end of this video not at the

327:00

end but just in a few second but uh we

327:03

have to take care of the other stuff but

327:05

we cannot work with them all at once

327:07

we'll have to take care of them one by

327:10

one so we are going to be removing all

327:11

of these jsx from here and we are going

327:13

to be just providing a results just a

327:15

results variable and that's going to be

327:17

it I promise we are going to remove all

327:20

of these jsx from here anyway so that's

327:22

a product section all righty so that was

327:24

a product section so I'm going to just

327:26

close both of them from here and I'm

327:28

going to go to my recommended so I'm

327:30

going to just open my recommended. Js

327:32

and also this CSS right here so what I

327:34

will do is that I'm going to just remove

327:36

this recommended section from here and

327:38

let me just zoom in a bit so you guys

327:40

can see everything a bit better and what

327:42

I'll do is that I'm going to first of

327:43

all using my react fragments and then

327:46

I'm going to be using my div right here

327:47

and then I'll just put some sort of a

327:49

title to it like H2 of ROM r r e o m n d

327:55

e d I'm going to copy this and I'm going

327:58

to place it right here and underneath

328:00

this H2 what I do is that I'm going to

328:02

use my recommended buttons right here

328:05

okay and now inside there we are going

328:07

to be placing a few buttons so I'll just

328:08

write button and we are not going to be

328:11

providing any stuff or you know what I'm

328:13

going to just give a level like all

328:16

products okay so we have all products

328:18

then we have Nike EDS and PMA I'm going

328:20

to remove them I'm going to put Nike or

328:24

Nike some people call Nike and some

328:26

people call it Nike whatever then we

328:29

have a puma and then we have a w w there

328:34

we go I'm going to also provide

328:35

different kind of Cl not different but

328:37

we are going to be in a class to it and

328:39

the class will be just buttons right

328:43

here so if you sell our file and you

328:45

will not see that I don't know why you

328:47

will not see it let me just refresh my

328:49

browser and you have to see that

328:51

somewhere I don't know why it's not

328:52

working maybe messed it up something I

328:55

bet and yep we did okay we are getting

328:58

that recommended section right here at

329:00

the bottom but we shouldn't Appo it

329:02

right

329:02

here I'm going to go to my app and then

329:06

what I'll do is that I'm going to just

329:07

play this recommended section up above

329:10

this um product section or or component

329:13

so I'm going to sell my file and here

329:14

you can see we are now getting all of

329:16

these buttons right here and also this

329:18

style right here as well so now the next

329:20

thing that you have to do is that we

329:22

have to take care of the styling so what

329:24

I will do is that I'm going to just

329:25

select my recommended r e c o m e n d e

329:28

d and then we are going to be providing

329:30

recommended flex and display of Ls and

329:33

I'm going to also provide a margin to

329:34

the left of like 20 rims and also I'll

329:37

just select select my recommended title

329:40

and also I'm going to provide a margin

329:42

for the left of like 20 rims and margin

329:45

for the bottom I'm going to provide 20

329:48

yep pixel be fine and I'm going to also

329:50

provide a margin for the top of 20 pixel

329:52

and F font size will be now set to 20

329:55

pixel as well so if you s our file

329:57

refresh it nothing is going to happen

330:00

because we didn't use these Clauses so

330:02

I'll just copy this class name which is

330:04

recommended flex and I'm going to just

330:06

place it right here in inside or you

330:09

know not inside but inside these items

330:11

so we just provide recommended buttons I

330:13

don't know why I did that I don't have

330:15

any idea why I did that but it should

330:18

have to be a recommended Flex so now if

330:20

you sell that and here you can see it

330:22

will now just push all of our items

330:24

right here and what else do we have to

330:26

do is that we have to also provide

330:28

recommended title right here so I'll

330:30

just provide a class of recommended

330:32

title so if you sell file and here you

330:34

can see it will also push this title

330:36

right here but there's not looking that

330:39

cool uh let me just go inside this

330:42

index. CSS file right here and I'm going

330:45

to just scroll down and I don't know why

330:47

they didn't apply it so I'm going to

330:48

just cut this styling from here and I'm

330:50

going to just place it right here so I'm

330:52

going to just save my file and here you

330:54

can see this is how my buttons look like

330:56

and we can also change this font family

330:57

if you want to so I'll just go to my

331:00

font uh what do you call index. CSS and

331:03

I'm going to just select everything we

331:05

did provide font family of Sor but I

331:07

don't know why it's not working working

331:08

you know I'm going to just close it from

331:10

here and I'm going

331:13

to right here so I'll just put for

331:16

family of s surf right here sem my file

331:19

and let's just refresh it okay I just

331:20

put it in the wrong way I'm going to cut

331:22

it and I'm going to place it right here

331:23

so F family of s ser and that's looking

331:26

cool and here you can see we have our

331:28

buttons we have our search fields and we

331:30

have a few items right here all right so

331:33

that was it about recommended section so

331:35

now the next thing which you have to do

331:36

is that inside this sidebar I'm going to

331:38

be creating one component given name of

331:40

like sidebar. JS I'm going to be also

331:43

writing a sidebar. CSS file as well

331:47

right here okay so inside this component

331:49

I mean like inside this folder but

331:51

outside from this category color and

331:53

price components right here so I'll just

331:55

also write RFC remove that and I'm going

331:58

to just cut it from here and then let me

332:01

just grab my sidebar right here I'm

332:03

going to zoom in a bit and now I'm going

332:05

to go you know first of all let me also

332:07

get my import statement from here like

332:10

sidebar. CSS and now I'm going to go

332:12

inside this sidebar I mean like this app

332:14

right here and we have to use it right

332:17

here and I'm going to be placing it at

332:20

the top so I'll just give a name of like

332:22

sidebar and now I'm going to S my file I

332:24

am going to go inside here and here you

332:26

can see we have the sidebar right here

332:28

okay so we are going to be placing all

332:29

of our content right here so what else

332:31

do we have to do you know what first of

332:33

all I'm going to be writing my uh what

332:35

do we call it um got I forgot the name

332:38

of this one what do you call it okay

332:40

fragments there we go I forgot the name

332:42

of it now let me just create a section

332:44

I'm going to give my name of like

332:45

sidebar and now inside this sidebar I'm

332:47

going to be creating a div with the

332:48

class of logo container and here we are

332:51

going to be just runting H1 and I'm

332:53

going to just place like card logo or

332:55

something like that I'm going to place

332:57

it right here and that's going to be

332:58

fine underneath this div I'm going to be

333:00

creating or you know let me just get my

333:04

category C A come on c a t e g o r y if

333:08

we can get we can't so we have to import

333:11

it manually so I'm going to just go and

333:15

category come on it's not helping me in

333:17

this case I don't know why but let's go

333:20

inside this category and then category

333:22

I'm going to copy that copy this

333:24

category and what else do we have to do

333:27

we have to just place it right here so

333:28

we have our category I'm going to

333:30

duplicate that three times just two

333:32

times not three times and I'm going to

333:34

change that to price and then we we have

333:38

to change that to price and we have to

333:41

go to the price I'm going to change that

333:43

to uh colors and I'm going to remove

333:47

them and let me just put my colors uh

333:50

and inside these colors we are going to

333:52

be just providing that color so I'll

333:54

just copy this uh price from here and

333:57

I'm going to just place it right in here

333:59

and I'm going to also copy this colors

334:02

and I'm going to past it right here so

334:03

I'm going to just zoom out so you guys

334:05

can see everything a bit better so now

334:07

if you SE here you can see we are now

334:09

getting category we are also getting a

334:11

price component and also our colors

334:13

component right here and here we are

334:15

also getting our logos so now the next

334:17

thing which you have to do is that we

334:18

have to style our component so that's

334:21

cool I'm going to go inside the sidebar

334:23

and I'm going to just style it so I'll

334:25

just write sidebar Das title zoom in a

334:28

bit and I'm going to just provide a font

334:29

size of 22 pixel and I'm going to also

334:32

provide a font weight of normal and

334:34

margin for the bottom I'm going to just

334:35

provide like 20 pixel okay so then I'm

334:38

going to be selecting my sidebar and I'm

334:41

going to just provide a

334:42

15% of with to it you can just specify

334:45

however you want and then I'm going to

334:47

just provide a position of fix height

334:49

will be 100% And then we have a border

334:52

uh to the right we have two pixel solid

334:55

and we are going to be reusing E5 E5 E5

334:59

one more time okay so the Z index I'm

335:01

going to just Pro three3 and display

335:04

will be set to polex in this case and F

335:07

next direction will be now set to column

335:09

and align items will be also set to

335:11

Center okay so that's then now if we s

335:13

our file and this is how it looks like

335:15

right here uh this is how currently

335:17

stuff looks likees but we have to put

335:19

this underneath so we have to now select

335:22

our logo container and we have to put

335:26

our

335:27

margin margin uh for the bottom we are

335:31

going to be just writing po rim and also

335:33

we have to select our logo container one

335:36

more time and select our H1 one and

335:38

margin for the top I'm going to provide

335:39

1.3 Rim St it so if you sell file and

335:42

that's looking totally awesome right

335:44

here so here you can see we are almost

335:46

getting there we have our um what do we

335:48

call navigation we have this component

335:50

we have all of our products right here

335:52

and then we have all of our categories

335:54

price and colors right here so now we

335:56

have to take care of each of these

335:58

component one by one so now we are

336:00

totally done with that so now the next

336:02

thing which you have to do is that we

336:03

have to take care of this category

336:06

component so I'm going to go inside this

336:08

category component and what I will do is

336:10

that first of all uh I'm going to just

336:12

remove this category from there and I'm

336:14

going to just write H2 with the class of

336:17

sidebar title right here and I'm going

336:20

to just provide category and I'm going

336:22

to go back so you guys can see

336:24

everything a bit better inside this div

336:26

you're going to be writing a label label

336:28

right here and I'm going to also provide

336:30

a sidebar label container close to it

336:34

okay so we are not going to be providing

336:36

any HTML 4 attributes stent inside this

336:39

level what we have to do we have to just

336:40

write input with a type of radio instead

336:43

of text and we also have to give him

336:45

some sort of a name of like test would

336:46

be fine uh yeah that's going to be fine

336:49

and then we have to finally write or a

336:51

class uh I mean like span with a class

336:53

of check mark there we go and we have to

336:57

specify a label for it so if you just s

336:59

our file and here you can see we are now

337:01

getting this one uh what do we call it

337:04

checkbox or check mark right here where

337:07

specif specifying that oh but we are not

337:09

getting it okay we are getting it right

337:10

here but we have to take care of the

337:12

stying but before we getting into all of

337:14

them we have to duplicate this jsx right

337:16

here and once again I'm going to be

337:19

refactoring all of the jsx into multiple

337:22

components but for now I'm just writing

337:25

all of these jsx so that we can see or

337:27

markup right here okay we're going to be

337:29

also formatting I mean like refactoring

337:31

all of this code again and again so I'll

337:33

just duplicate that I don't know like

337:35

three times no not three times but four

337:37

times so 1 2 3 4 okay and now I'm going

337:41

to just change these labels to something

337:43

else like I don't know we have all then

337:44

we have our

337:46

sneakers uh s n e a n e a k e r s there

337:50

we go and then we have instead of

337:52

sneakers I mean instead of all we are

337:54

going to be also providing flats and

337:57

then we have a sandals so sandals there

338:00

we go and then finally we have our heels

338:03

so heels say our file and yep that's

338:06

looking totally okay so for now I am

338:09

going to be writing a lot of CSS right

338:11

here but if you don't want to write a

338:13

CSS so you can just go to my guub

338:15

repository and you can grab all of these

338:17

CSS from there if you want to so the

338:19

first thing which I would do is that I'm

338:20

going to be selecting my sidebar and

338:23

then sidebar I mean like sidebar title

338:25

and I'm going to be providing a font

338:26

size of 22 pixel and font weight will be

338:29

totally normal and margin for the bottom

338:31

I'm going to just for 20 pixel right

338:33

here and then I'll just provide my

338:35

sidebar items right here and and I don't

338:38

know what the hell I just did I'm going

338:40

to close that and now inside there I'm

338:42

going to be providing a margin for a top

338:44

of 20 pixel and now I'll just go up a

338:48

little bit down and sidebar uh label

338:51

container inside that we are going to be

338:53

writing display of poly block and we

338:56

have position of relative because the

338:58

other one was a fix and then we have

339:00

piring for left and I'm going to just

339:02

provide 35 pixel for the pairing left

339:05

margin for the bottom I'm going to

339:06

provide 12 pixel and then we have cursor

339:09

and set to pointer then we have uh just

339:12

one webcat uh user what do we call it

339:15

select there we go and we're going to be

339:17

set that To None then we have a moves

339:19

for Mozilla and user select will be now

339:23

set to totally none okay we want to just

339:25

remove that then we have MS user and

339:28

then select we are going to be also

339:30

removing that and finally we are going

339:31

to be riding a user select and that will

339:33

be set to totally none s file we are

339:37

totally getting there but that will take

339:39

a little bit of for a while or something

339:43

that will take a little bit of while so

339:45

I'll just write a sidebar and then level

339:47

container one more time and I'm going to

339:49

be selecting my input field I'm going to

339:51

be providing a position of totally

339:53

absolute opens of zero cursor will be

339:55

set to totally pointer and now let me

339:58

get my check mark which is I guess check

340:02

mark was there a check mark or something

340:05

check check mark there we go I'm going

340:07

to place it right here for double

340:09

checking position or totally absolute

340:11

top zero left zero height will be 20

340:14

pixel width will be 20 pixel and also

340:17

the background color will be set to

340:18

totally e e e three times

340:22

e and Bard radius will be set to 50%

340:25

there we go and we are going to be also

340:27

taking care of that sidebar label

340:31

container and once we hover over each

340:34

the input we want to uh select or check

340:38

mark okay so then we going to be also

340:40

writing a background color of to CCC

340:43

that's fine duplicate that and what we

340:46

are going to be doing is that once we

340:48

check instead of how I'm going to remove

340:51

this how from here and I'm going to just

340:53

provide this checked on the input so

340:55

once we checked our checkbox so you want

340:57

to just change the color to 21 uh 9 what

341:01

do we call it uh

341:03

96 uh F3 kind of a blue color but not

341:06

that much blue and we're going to be

341:08

saving them and here you can see this is

341:10

how currently things looks like right

341:12

here so if you click on it and yep

341:14

that's looking totally a okay I'm going

341:15

to just go back and now let me just

341:17

select my check mark one more time and

341:20

I'm going to be using my after Studio

341:22

selector so content nothing position

341:25

absolute and we have a display and let's

341:28

just remove them okay and now I'm going

341:31

to just use uh sidebar items not sidebar

341:34

uh items but label container I'm going

341:37

to be selecting my check mark let me

341:39

just get my check if that's checked so

341:41

what we want to do you want to select

341:43

our check mark and we want to use our

341:45

after selector on it and we want to just

341:47

provide a display of totally block to it

341:50

in this case in this after case we

341:51

provide a check mark of display of none

341:54

and here we are just specify I mean like

341:56

once that's checked like that input is

341:58

checked so you want to just Prov display

341:59

of block to if it's s file I'm going to

342:02

click on it you cannot see that you will

342:03

see that just in a second but let me

342:05

just get it sidebar

342:07

uh label container let me just get that

342:10

let me get my check mark and I'm going

342:11

to be using my after selector right here

342:14

the top will be set to like here I'm

342:16

specifying different kind of widths you

342:17

can increase or decrease that how you

342:19

want uh six uh Point what do we call it

342:22

6.4 pixel and then we have a width of 7

342:26

pixel height of toally 7 pixel and then

342:29

we have a border radius of Border radius

342:33

of 50% just a totally rounded so that's

342:36

why we are providing there and now if

342:38

you sell file and here you can see we

342:40

are now getting that Wide Circle right

342:42

here so if you click on it and that's

342:44

looking more than okay okay so that's

342:47

fine but the final thing which you have

342:48

to do is that we have to get this line

342:51

right here from somewhere so we are

342:52

going to be just writing a line uh we're

342:55

not going to be using this line right

342:56

now so I'm going to just provide three

342:59

rims and Border uh color will be now set

343:02

to just like uh F7 F7 come on F7 F7

343:06

there we go

343:07

and yeah that's totally fine s file

343:09

nothing is going to be changed all right

343:12

so that was totally cool we are totally

343:14

getting there but the second thing which

343:15

you have to do is that we have to take

343:17

care of their price component and color

343:20

component and then we are going to be

343:21

refactoring all of our project and

343:23

finally we are going to be providing our

343:25

functionality to this project all right

343:27

so that's that now let me just take care

343:29

of their price and then we are going to

343:31

be taking care of that colors so it's

343:34

not going to be looking that awful we

343:37

are going to be going into this colors

343:39

you know we are going to be taking care

343:41

of that colors a little bit later or

343:44

yeah can we take a c I don't know you

343:47

know I'm going to go with this price and

343:49

price will be fine now I'm going to

343:52

remove this price from there and I'm

343:54

going to just provide a class name of ml

343:57

to it okay for margin left or yeah

344:00

margin left will be fine and then we

344:02

have Edge two of that same title side uh

344:05

sidebar and title and then we have a

344:08

price title as well because we are going

344:10

to be just providing a little bit of

344:11

styling to that price title and now you

344:14

know I'm going to go inside there and

344:16

I'm going to copy a little bit of code

344:17

from it so I'll just copy this label

344:19

from here and I'm going to place it

344:21

right here so this is going to be for

344:22

one time and then you know I'm going to

344:26

just duplicate this level um what do we

344:28

call jsx a few times so we have uh for

344:31

all then we have for $50 we have 400 150

344:35

and we have 200 okay so I'll just

344:37

provide a test of like I don't know uh

344:40

test of two so I'm going to just select

344:41

one hit contrl d contrl d contrl d or

344:44

command D whatever and I'm going to

344:46

change the label I mean like to name to

344:49

totally test to and here this one will

344:51

be set to all and now this one will be

344:53

now set to Z you know I'm going to just

344:55

provide

344:58

0-50 okay so just $50 will be fine and

345:01

I'm going to copy them their pattern and

345:04

I'm going to just duplicate it right

345:06

here and I'm just change the values to

345:08

like $100 uh 100 will be fine and this

345:11

one will be now set to $50 okay and this

345:13

one will be now set to $100

345:15

$1,000 and this one will be $150 and

345:19

this one will be finally uh over uh $150

345:24

so sell file and here you can see we now

345:27

getting all of these prices right here

345:28

totally fine uh but you know I'm going

345:31

to go inside this ml I mean like this

345:33

price styling and I'm going to just

345:35

select my price title

345:37

like so and I'm going to provide a

345:38

margin for the top of 20 pixel and I'm

345:41

going to also provide I mean like I'm

345:43

going to select the ML and I'm going to

345:45

provide a margin for left of 20 pixel s

345:47

file and that's looking a bit better all

345:50

right so that's also done so now the

345:52

next thing which you have to take care

345:53

of this uh color component so I'll just

345:56

close these files from here I'm going to

345:58

go into my color component I'm going to

346:00

select my color. CSS file as well and

346:03

I'm going to do that same copying and

346:05

pasting one more time and once again I'm

346:08

going to be refactoring all of that code

346:11

from scratch so you know here I'm going

346:15

to remove these colors from here and

346:17

then what I do is that I'm going to just

346:19

pass all of these jsx right here okay so

346:22

we have that same label I'm going to

346:24

change this all you know the first one

346:26

will be all yep the first one will be

346:29

all the second one will be black color

346:31

uh let me just remove these labels or we

346:33

can do this so this one will be now set

346:35

to Black and this one will be now Seton

346:39

blue then we have a red category like so

346:43

and then finally we have our white

346:45

categories we have white but we also

346:48

have a green one as well so let me just

346:50

write uh green and then finally we have

346:55

white cell file and let's just see here

346:58

you can see we have all category black

347:00

blue red green and white finally and

347:03

here I'm going to be also passing my

347:04

color title so we have a color title

347:07

right here semi file and now I'm going

347:09

to go inside this color title right here

347:11

I'm going to select this color title and

347:14

I'm going to just provide a margin for

347:16

the top of two rims and I'm going to

347:18

also select all CLA and here we are not

347:21

using this class but we will very soon

347:24

so I'm going to just use linear gradient

347:26

and I'm going to proide Blue and Crimson

347:29

okay so if you s our file nothing will

347:31

happen except here we are getting just

347:33

all of these components right here so

347:36

now it's time time all right so now we

347:38

are totally done with these components

347:40

so now it's time to do a huge

347:41

refactoring in all of these components

347:44

because currently our code is looking

347:46

more than messy like we have all of

347:49

these components right here but trust me

347:51

this is like totally a mess we have to

347:53

create a component I mean like separate

347:55

component uh for buttons and we are just

347:58

reusing that input again and again and

348:00

we also have this color we are reusing

348:02

it here we we are reusing it right here

348:06

and and we our code is like totally a

348:08

mess so now let's just refactor all of

348:10

our code so before we getting into the

348:13

refactor first of all we have to ask

348:15

ourself a few questions like where we

348:18

are repeating all of our code so now

348:20

what I'll do is that I'm going to go

348:22

inside this product section right here

348:24

and here we are reusing this component

348:27

not a component but this jsx like a lot

348:29

of time like more than a lot of time

348:32

right here okay so what do we have to do

348:34

first of all I'm going to just select

348:36

this one right here and I'm going to

348:38

just select it through this section

348:40

right here okay so I'm going to just

348:42

select it and cut it I'm going to just

348:44

cut it just right click on it and hit

348:47

this uh cut button right here or you can

348:49

also use this shortcut which is control

348:51

or command or control or command X I'm

348:54

going to remove all of the rest of this

348:56

content right here so I'm going to just

348:58

remove all of this content through this

349:01

section right here okay so now we

349:03

successfully remove that content from

349:05

here so now the next thing which you we

349:06

have to do is that we have to go inside

349:08

this component folder and we have to

349:10

find this CJs right here and we have to

349:14

just place all of our GSX which we

349:16

copied right here okay and this is also

349:19

like really messy still but now if you

349:22

sell file but instead of copying and

349:25

pasting all of our uh jsx one by one

349:28

what we are going to be doing is that we

349:29

are going to be getting this card and we

349:31

are going to be just rendering just this

349:33

card okay so I'm going to just save my

349:34

file and it will gives us an error

349:37

that's because we didn't copy it and we

349:39

didn't place this right here so if you

349:41

save that and it will still gives us

349:43

error because we have to import that

349:45

card from that card component card so if

349:47

you sell that and here you can see card

349:51

is not defined card is not defined where

349:54

is there let me just refresh it and here

349:56

you can see it will now just gives us

349:57

one card right here so instead of

349:59

copying and pasting all of these jsx now

350:01

we convert all of that coding into one

350:03

component and we can just reuse this

350:05

component like how many times we want

350:08

see if you s that and here you can see

350:10

it will now gives us all of that uh

350:12

items right here so this is just a first

350:14

refactor but this is also not a great

350:17

refactor to be honest we will come back

350:19

here one more time so let me just

350:21

refresh it and this is how it looks like

350:23

right here so this is just a first

350:25

refactor for this card component so we

350:27

just already created this component and

350:30

we are just reusing that component again

350:32

and again so this was the first

350:34

refractor so now the next refractor

350:35

which we going to be doing is is this uh

350:37

input Fields right here so that's going

350:39

to be totally simple and here let me

350:42

just open this category right here we

350:44

are reparing all of our labels right

350:46

here and input like label and input and

350:49

all of that kind of stuff right here and

350:51

we are also repairing inside this colors

350:54

we are repairing it inside this price

350:55

component as well so what we have to do

350:58

we have to come up here and inside this

351:00

input tag what we want to do we are

351:02

going to be just going into one of them

351:04

and I'm going to just copy this single

351:06

LEL from there and I'm going to just

351:08

replace it with this div okay so I'm

351:10

going to just zoom in a bit so you guys

351:12

can see it a bit better and now I'm

351:14

going to sve my file so here you can see

351:15

we are just getting like um what do you

351:18

call it sidebar and we are just

351:19

providing a sidebar and by the way this

351:21

is not going to be the final refactor we

351:23

are going to be still refactoring this

351:25

component but I just kind of want to

351:27

show you like the second way of

351:28

refactoring or writing this code okay so

351:31

we are going to be still passing a lot

351:32

of props and we are going to be doing

351:34

that once we jump into St management and

351:37

all of that kind of good stuff but for

351:39

now here you can see we just specify

351:41

this input and this level right here

351:43

inside this input container so what we

351:45

have to do I'm going to just uh get my

351:48

input container but before I do I'm

351:50

going to remove all of these inputs from

351:52

here and this input from here as well oh

351:56

no we're not going to be removing that

351:58

but here we are going to be just

351:59

rendering or input container okay so now

352:02

let me just save my file and here you

352:04

can see we we are just getting all and

352:06

we can just duplicate there like a few

352:08

times like we have four times or five

352:11

times right here and here you can see we

352:13

are now just repeating all of our

352:14

component one by one right here okay so

352:17

that's totally okay but we will have to

352:20

take care of that labels and stuff but

352:22

that's totally normal so now let me just

352:24

use that component like that input

352:26

component so I'm going to just use input

352:28

and I'm going to close it and it will

352:30

not import it because there was to level

352:32

up above okay so input like so

352:37

and then we have to go to the components

352:38

folder and then we have to go inside

352:40

this input so if you sa our file let me

352:42

just duplicate that we will take care

352:44

about that a few in a few seconds so

352:47

here you can see we are now reusing that

352:49

component right here one more time and

352:51

now it's time to go inside of colors and

352:54

we have to remove these jsx from here so

352:56

I'm going to select it save by all of

352:59

them and I'm going to get my input

353:01

container right here okay so not like so

353:05

but let me just close them

353:06

sem my file and here you can see uhuh I

353:10

messed up something because I removed

353:12

the label and I shouldn't have done that

353:15

so we have this input title you know I'm

353:18

going to leave this

353:19

all from

353:21

here uh we didn't specify color to it or

353:25

label to it let me just specify some

353:28

sort of a label to it so we can

353:30

differentiate between components so

353:32

sidebar title and then we have color

353:35

title as well so I'll just spr colors

353:37

save my file and here you can see we

353:39

have all of these colors but now I'm

353:41

going to just remove this label from

353:44

here and I'm going to just get my input

353:47

from that semi file and we have

353:50

different kind of inputs and here you

353:51

can see everything is not totally

353:53

reusable anyways so that was just a

353:56

little bit Improvement inside our code

353:58

so we just like really refactor work

354:01

code like a little bit but there is also

354:04

going to be a huge refractor inside all

354:06

of these input component and all of

354:08

these U button component and all of that

354:11

card component so we will have a huge

354:13

refactor later but for now we I just

354:16

kind of want to grab all of that code

354:17

from one component and so that we can

354:19

reuse that component again and again so

354:22

now it's time to provide a little bit of

354:23

functionality to our app and then we are

354:26

going to be reusing I mean like then we

354:27

going to be refactoring all of our

354:29

component to the final version of the

354:32

refactoring okay all right so now it's

354:34

time to provide functionality two or

354:37

apps so here what I do is that I'm going

354:40

to do a little bit of weird thing which

354:42

a lot of people won't like it but I will

354:45

do it anyways because I don't want to

354:47

repeat myself again and again so what

354:49

I'll do is that I'm going to treat this

354:51

app component as a store if you are

354:54

coming from a Redux world so uh which

354:57

means like I'm going to be placing all

354:59

of my state inside this app component

355:01

and then I'm going to be providing that

355:03

St to these components by using a prop

355:06

so if you don't like this approach

355:07

totally a okay like you can go to each

355:10

of these component and then you can

355:12

create your separate State and then you

355:14

can change it there if you want to but

355:16

for me I'm going to treat this app

355:17

component as a store if you're coming

355:20

from a Redux word so the first thing

355:21

which we have to do is that I'm going to

355:24

just write first of all uh selected uh

355:27

query right here or not query but

355:30

category okay so then we are going to be

355:32

just writing set selected C

355:36

and it will be now set to the use stat

355:39

right here and by default I'm going to

355:41

be providing a null value to it so I'm

355:43

going to just provide a little bit of

355:44

spacing in there and now that's there

355:46

but now the next thing which we have to

355:47

do is that we are going to be writing

355:49

our input filter first of all we are

355:52

going to be taking care of that input

355:54

filter then we are going to be jumping

355:56

into their radio buttons so what I will

355:58

do is that I'm going to just create my

356:00

query and then I'll just use like set

356:02

query and it will be equals to the used

356:05

T and by default I'm going to be

356:07

providing a like totally empty value to

356:09

it and now what else do we have to do

356:11

I'm going to be creating a function

356:13

which will be really useful for a lot of

356:15

function for a lot of uh things to be

356:18

precise so I'm going to just write

356:19

handle input change so whenever this

356:23

input changes like whenever user passes

356:25

some data into this component into this

356:28

uh search field so what do you want to

356:30

do we want to get our event right here

356:33

like uh like whatever the user type and

356:36

we are going to be passing it right here

356:38

so event let me just write it event come

356:41

on event. target. value there we go t a

356:45

r g t there we go so now we successfully

356:48

create this one so now the next thing

356:49

which we have to do is that we have to

356:51

get all of our data which we have inside

356:54

this DB folder right here okay so we are

356:56

going to be getting all of that data and

356:59

we are going to be itting over through

357:01

the data all right so the first thing

357:03

that you have to do is that we have to

357:04

import it so I'll just write like a d

357:06

data base right here and I'm going to

357:08

just import my little database so we

357:11

have a data oh you know I'm going to

357:13

give a name of like products okay so

357:15

products will be fine and I'm going to

357:16

go one level and I'm going to go to my

357:19

DB folder and then we have our data

357:21

right here you can give any name you

357:23

want but in my case we are storing a

357:25

product so that's why I give a name of

357:28

products right here you can give a data

357:30

if you want to but here we are going to

357:31

be iterating over through all of these

357:33

items which we currently have inside

357:35

this array and then we're going to be

357:37

performing different kind of filtering

357:39

on uh title on what do we call it on uh

357:43

previous price and also on a company and

357:45

also on a color and on a category as

357:48

well okay so that's going to be awesome

357:50

as well so now the next thing which you

357:52

have to do is that I'm going to just

357:53

write fill uh third items there we go

357:58

and it will be now equals to products.

358:00

items not items but products. filter

358:03

because filter there we go because

358:06

because we are going to be iterating

358:07

over through all of these items right

358:09

here each of these items and what do we

358:11

want to do with them we are going to be

358:13

just specifying or each product and I'm

358:15

going to just set that to like one liner

358:17

so that product title in this case we

358:21

are just iterating orward through all of

358:23

these datas right here like all of these

358:25

items right here and we are just taking

358:28

care of this title like we are just

358:30

getting the styler from all of these

358:32

items right here which we currently have

358:34

okay so we are just using them

358:36

and then let me just convert that to

358:38

lower case as well so it doesn't matter

358:41

if you provide like upper case so it

358:43

will just by default converted to

358:44

lowercase and now I'm going to just

358:46

provide index of and then here I'm going

358:49

to be specifying my query like what are

358:51

the user type and I'm going to be also

358:53

converting that to lower case as well

358:55

and if that's not equal to minus one

358:59

okay so I just mess it up here let me

359:01

just cut that from here I'm going to

359:02

place it right here so if that's not

359:04

equal to minus one so you want to get

359:06

all of that items and we just store that

359:08

inside this filter items right here okay

359:11

so now underneath that so that's going

359:13

to be it for the uh input filter so I'll

359:16

just specify different kind of

359:18

separators right here I'm going to copy

359:20

that I'm going to paste it right here

359:22

and now let's take care of the radio

359:25

filters so we have these radio filters

359:27

right here okay so now let me just

359:29

filter all of the

359:30

data once the user click on this each uh

359:34

what do we call it this each radio

359:36

filter okay so what do we have to do

359:38

first of all I'm going to be just

359:39

writing const handle change and it will

359:42

be now equals to event and here what are

359:45

we doing we are going to be just setting

359:47

the set category selected category which

359:50

we are specifying right here so we have

359:52

selected category and then we have a uh

359:54

set selected category and by default we

359:57

are just specifying the null value to it

360:00

okay so I'll just execute them and here

360:02

what you want to do you are just

360:03

specifying event. Target

360:06

value right here okay like whatever like

360:09

whichever kind of input the user selects

360:11

so you want to get the value from that

360:14

each event right here like whichever

360:16

kind of uh what do you call it custom

360:18

radio selector user select so you want

360:21

to get the value from that selector okay

360:24

so that's how we can get that and we

360:26

store that value inside this handle

360:28

change event right here so that's going

360:30

to be awesome as well so now the next

360:32

thing which we have to do is that we

360:34

have to create a filter

360:36

for what do we call it a buttons so

360:40

buttons so once we click on each of

360:42

these buttons so what do you want to do

360:44

we want to provide a filter for that

360:46

okay so con handle I'm I'm just creating

360:50

all of that functions right here okay

360:52

which we're going to be passing into our

360:53

components by using a props very quickly

360:56

so I'm going to just write Set uh

360:58

selected category once again we are just

361:01

selecting that selected category right

361:04

here and we are just changing that state

361:06

like when when somebody clicks on it so

361:08

what you want to do you want to just get

361:10

the value from there so I'll just write

361:12

like event. target. value okay so that's

361:15

simple that was simple like how to

361:18

filter data and this is also simple like

361:20

when somebody clicks on each of these

361:22

item so you want to filter through all

361:24

of that data okay so that's going to be

361:27

totally fine so now the final thing

361:29

which you have to do not a final thing

361:31

yeah this is going to be the final

361:32

function which you're going to be

361:33

creating inside this app component so

361:35

I'll just write like function and here

361:37

this is going to be the main function

361:39

where we are going to be doing all of

361:40

our filtering so I'll just write

361:43

filter data so this is going to be the

361:46

name of my function and what are we

361:48

getting we are first of all getting all

361:49

of the products and then we are going to

361:51

be providing a selected like whichever

361:54

kind of thing is currently selected are

361:56

we selecting something inside this

361:57

category or inside this price or inside

362:01

this color or we are clicking on

362:03

something right here or we are typing

362:05

something thing inside this input field

362:07

like what are we doing that's why we

362:09

provide this selected um prop or

362:12

perimeter or whatever you want to call

362:13

it and then we are specifying our query

362:15

right here okay so now let me just write

362:19

like let filter data I mean like

362:22

filtered products so filter products and

362:26

will equals to all of our products okay

362:28

so this is going to be the end for our

362:30

products now here let me just write a

362:32

comment for myself like filtering

362:35

filtering

362:36

uh input items okay so now let's just

362:39

take care of that filtering items so I'm

362:41

going to just specify if we have some

362:42

sort of a query like if we selected

362:44

something so what you want to do we are

362:46

we are just going to be selecting that

362:48

filter data not filter data but this

362:50

filter products I'm going to just

362:51

specified right here and it will be

362:53

equals to filter items so filtered items

362:57

right here okay so which we are getting

363:00

from these filter items let me just go

363:02

back so you guys can see everything a

363:03

bit better so here we what we are doing

363:06

if if we have some sort of a query so we

363:09

are going to be just setting this filter

363:11

data like all of the product through

363:13

this new array which we are getting from

363:15

this filter items right here like we are

363:17

iterating o through all of that item and

363:19

we are just specifying it right here and

363:21

this filter data like all of our data uh

363:24

will be now set to that filter data if

363:27

we specify something inside this input

363:29

so that's going to be happening okay so

363:31

this is going to be it for the filtering

363:33

items in filtering input items and then

363:36

underneath that then we are going to be

363:37

also writing a selected uh filter as

363:41

well so let me just zoom in a so you

363:43

guys can see everything a bit better and

363:45

now here what I do is that I'm going to

363:47

just write selected okay if something is

363:50

selected so where is that selected

363:52

coming from that selected is coming from

363:55

right here we are going to be executing

363:56

this function and we are going to be

363:59

providing our first of all our products

364:01

then we are going to be specifying like

364:03

whichever kind of thing is selected are

364:05

we select in something from a category

364:07

or from a price or from a color or like

364:10

where where which kind of selector do we

364:12

have so this is going to be selected

364:14

filter which we are going to be writing

364:16

so so we already have our filtered

364:18

products which is right here and it will

364:20

now equals to filter products one more

364:23

time and then we are going to be using

364:25

our filter method right here so we are

364:27

going to be itting over through this

364:28

filter uh method right here we can

364:30

specify just a singular thing right here

364:32

but here what I will do is that I'm

364:34

going to use my P6 magic so perimeter

364:38

destructuring so I'll just write

364:40

category we are going to be getting our

364:42

category from this data right here so we

364:45

are going to be getting our category we

364:47

are going to be getting our color as

364:49

well like this color from all of these

364:51

item we are going to be also getting our

364:53

company we are going to be also getting

364:55

our new price and we are going to be

364:57

also getting our titles so now let me

364:59

get all of that from all of this data

365:02

right here so what I'll do is we already

365:04

selected or category let me just get my

365:07

color and let me just provide my compy

365:11

there we go CP n i spell company

365:14

correctly or no let me just put it right

365:17

here and that's awesome okay so that's

365:19

that now we are going to be also

365:22

providing a new price to it and then we

365:25

are going to be also getting my title

365:27

right here so we have uh let me just

365:30

show you so we have this new price right

365:32

here and we also have this Tyler right

365:34

here anyway so that's that's looking

365:36

okay oh we are writing this craes like

365:39

extra CRA we shouldn't have done that we

365:42

are going to be writing our equal to

365:44

sign and now what we are going to be

365:46

doing is that we are going to be just

365:48

writing category and it will be now

365:50

equals to selected right here okay and

365:53

if you if you weren't doing this instead

365:56

we are going to be just doing is like we

365:58

were doing like product do uh I don't

366:00

know category and it will be now equals

366:02

to that selected so we will have to do

366:05

this yeah but now we already destructure

366:07

our data right here so we don't have to

366:09

provide this product dot category

366:11

product do title product dot color and

366:13

stuff like that so I'm going to just

366:15

remove excuse me so I'm going to just

366:17

remove that product and we are going to

366:18

be writing I don't know why we are

366:20

getting this error I'm not sure about

366:21

that now we are going to be writing our

366:23

code like this like category uh is equal

366:26

to uh triple equal to selected and then

366:29

we are going to be also checking the

366:30

other stuff but if we weren't writing

366:32

this code like if you weren't

366:33

destructuring or items right here so we

366:36

would have to write first of all product

366:38

products to be uh precise and then we

366:40

going to be selecting our category then

366:42

we will write like products. color and

366:44

then products. company products. new

366:47

price products start title we don't have

366:49

to do that we are going to be just

366:50

destructuring all of that so I'm going

366:52

to remove this products from here and

366:55

now we are going to be writing our old

366:56

statement and color will be now triple

366:59

equal to selected and now let me just

367:01

write one more or statement then we have

367:03

a company and Company will be on also

367:05

set to select it and then we have old

367:08

statement then we have a new price will

367:10

be also set to select it let me just

367:12

write one more statement of or and title

367:15

will be equals to selected so now if you

367:17

sell our file and I am still not getting

367:21

all of that I don't know why we are

367:23

getting some sort of error or

367:25

something uh I guess we are getting some

367:28

sort of error but I'm not sure about uh

367:31

let me just close it right here

367:33

something was wrong in here so I'm going

367:35

to now finally past this Cod right here

367:37

and now I'm going to save my file and

367:40

yeah that's going to be it for a

367:41

selected filter so now the final thing

367:43

which you have to do is that we have to

367:45

return something right here so that's

367:48

going to be it for this F statement and

367:50

also for this selected filter the final

367:53

thing which you have to do is that we

367:54

have to return this filter data and we

367:57

are going to be iterating over through

367:58

that data so we have this filter

368:00

products I'm going to use a map method

368:02

right to iterate over through all of

368:03

that items and here what we are going to

368:05

be doing is that we are going to be

368:06

destructuring a few properties so I'm

368:08

going to just destructure that IMG and

368:11

by the way we are destructuring all of

368:12

that properties and their properties are

368:14

coming from all of these items like we

368:17

are currently iterating over through all

368:18

of these item and we are getting the

368:20

image the title The Star reviews and all

368:23

of that kind of stuff we are

368:24

destructuring right here and we are

368:26

going to be reusing it right here inside

368:28

this card component and we will refactor

368:31

all of this card component in a second

368:33

but for now what what I'm going to do is

368:36

that I'm going to just destructure that

368:38

stuff so I'm going to just write uh

368:39

image title star and make sure the

368:42

spelling is totally correct I'll also do

368:45

my best to write uh the spelling correct

368:47

so I'll just write a new price and then

368:50

we have a new not not new price but yep

368:53

the new

368:54

price yeah new price is totally okay and

368:57

then I'll go back from here and I'm

368:59

going to use my C braces but I don't

369:02

know why we are getting this in eror and

369:04

here we are going to be Ren ring or card

369:07

component so here you can see it will

369:08

now just import it right here at the top

369:11

of the file so now it's time to provide

369:13

all of these data into this card

369:15

component as a prop and then we going to

369:17

be reusing it inside this card component

369:19

so I'll just first of all start with a

369:21

math.

369:22

random and I'm going to just close this

369:24

component right here and that's going to

369:26

be fine okay so here I'm going to just

369:29

save this file so that I get uh that

369:33

formatting so that was it for the key

369:35

and do not write code like this but in

369:37

this case I'm not using any uu ID and

369:40

stuff so I just write M random I'm going

369:43

to just write image and it will be now

369:44

set to image and now what else do we

369:46

have to do we are going to be also

369:48

writing a title and title will be also

369:49

set to title and I am going to also

369:52

provide a star and it will be also set

369:54

to Star the destructuring version of

369:56

that star to be precise and now let me

369:59

just get this reviews and finally we

370:02

have our new price right here and we

370:04

going to be also reiring a new price to

370:06

it now if you s our file so what are we

370:09

currently doing first of all let me just

370:11

review all of that stuff which we are

370:12

currently doing okay so now here you can

370:15

see we are just first of all getting uh

370:18

like these two let me just cut that from

370:20

here and I'm going to place it right

370:22

here like so first of all we are

370:24

specifying this St into this Us St uh

370:27

hook right here so we have selected

370:28

category and then we have select a set

370:30

selected category then we have a query

370:32

and set query and by default we are

370:34

providing the default value of null and

370:37

empty uh string right here so then we

370:39

are creating that function for the input

370:41

filter right here so like when somebody

370:44

okay so if price is not defined uh we do

370:49

have this new price let me just uh come

370:52

in here and then okay we have pre price

370:56

now I'm going to set that to pre price

370:58

and now let me just check him out new

371:01

price is not defined let me just refresh

371:02

my browser still not defined

371:05

okay so we are going to be copying it

371:08

from here I forgot to included semi file

371:11

and now new price will be defined right

371:14

here anyway so that's a great story but

371:17

hey here you can see now if somebody

371:20

types something in that input we are

371:21

going to be getting that value then here

371:24

we are iterating over through every

371:26

single character of that user like

371:29

whatever the user type inside this input

371:31

box right here we are iterating over

371:33

through there and we are just getting

371:34

our filter items then we have our radio

371:36

filter and we are just iterating over

371:39

through all of these filters like if the

371:41

user click on this one or in this one or

371:43

in this one we are just getting the

371:45

value of that or and then we have this

371:47

handle click and which will be

371:49

responsible for these buttons right here

371:51

and then finally we have this function

371:53

right here and inside there we are going

371:55

to be just specifying three parameters

371:57

so we have this products parameter then

371:59

we have selected and query parameter and

372:01

we are going to be specifying the values

372:03

in a just just in a second but here you

372:05

can see we are just declaring a variable

372:08

and we are specifying it into the

372:09

products like whichever kind of products

372:11

the user provide and then what we are

372:13

doing is that we are just providing that

372:17

filter for our input item and then

372:19

inside there we have this filter

372:21

products so what is a filter products

372:23

filter products are all of the products

372:25

which we are specifying right here and

372:27

it will be now equals to filters

372:29

filtered items and then we are providing

372:32

a filter for the selected items like for

372:34

these kind of uh buttons right here we

372:37

can just write this code without a

372:39

destructuring but I write this code with

372:41

destructuring because I don't want to

372:43

write like a code like this like uh

372:45

product Dot and stuff like that then we

372:48

don't have to just write a product so

372:49

then we can just remove that and we can

372:52

just write like product if you wanted to

372:55

we can still write this code and that

372:56

will be totally valid code but I don't

372:59

like this approach I want to use

373:00

destructuring so that's why I

373:02

destructure all of that code right here

373:04

okay so this is

373:05

this might look a little bit confusing

373:07

to for some developer but for me that's

373:10

totally awesome for me that's totally

373:12

okay and then finally we are just

373:14

returning all of our filtered products

373:16

right here so now it's time to call this

373:18

function so we've created this function

373:20

I'm going to just call this function

373:22

right here so I'm going to just call

373:23

this function right here and I'm going

373:25

to provide a few values to it so I'm

373:27

going to first of all providing a

373:29

products which is our database right

373:31

here so we are getting all of that

373:33

products from this database right here

373:35

here and now the next thing which you

373:36

have to do is that we have to also

373:38

provide this selected category and we

373:41

have this selected category right here

373:44

okay so like whichever kind of thing we

373:45

selected so we are going to be

373:47

specifying it right here and then

373:49

finally we have our query and we have

373:51

this query right here for this St right

373:54

here okay so now we successfully call

373:55

this function so now the next thing

373:57

which we have to do is that we have to

373:59

store in some sort of a result variable

374:01

you can give this variable like any name

374:03

you want but for me that's totally okay

374:06

so now let me just save my file that was

374:08

a lot of writing and that was a lot of

374:11

explanation so now the final thing which

374:13

we have to do is that we have to provide

374:15

all of that state values like these

374:17

functions and all of that kind of data

374:20

into this each component right here so

374:22

that we can reuse all of their data

374:24

inside this component so for sidebar

374:27

what are we going to be passing we are

374:29

going to be passing this handle change

374:31

right here so where is that handle

374:33

change we are going to be specifying

374:34

this handle change for the sidebar so

374:36

like whenever click on this button or

374:39

this button or this button I don't care

374:41

like whichever kind of button the user

374:42

click on we want to select and we want

374:45

to get that value and we are specifying

374:48

that inside the set selected category so

374:50

what we have to do I'm going to just

374:52

pass my handle change into handle change

374:55

as a prop so now what I will do is that

374:57

I'm going to come inside this sidebar

375:00

right here let me just go inside the

375:01

sidebar and I can destructure this so

375:04

I'm going to just use my destructuring

375:06

method right here and we can log that

375:08

into our console if you want to so I'll

375:10

just write handle change and now let me

375:12

just open my console right here and now

375:14

let me just refresh it and here you can

375:16

see we are now getting that function

375:18

right here so we have event. target.

375:20

value we can execute that function but

375:22

we are not going to okay so I'm going to

375:24

just remove that from here so now the

375:26

next thing which you have to do is that

375:28

we have to paste this handle change from

375:31

there I'm going to copy that and I'm

375:33

going to place it in both of these area

375:36

as a prop so I'll just pass it as a prop

375:38

right here okay so now if you sell files

375:41

so we have that function available

375:43

inside this category we have that

375:45

function inside this price and we also

375:47

have that function inside this colors so

375:49

like let's suppose if I want to go to

375:50

the colors I mean like the price and we

375:52

can destructure it right here and we can

375:55

also console log it s my file and let's

375:58

just refresh it open my uh console right

376:00

here and here you can see we have that

376:02

function available inside each of these

376:04

these components right here so I'm going

376:06

to just remove that from here so now we

376:09

have this function available in all of

376:11

that components so now the next thing

376:12

which you have to do is that I'm going

376:13

to remove that from here and I am going

376:16

to remove it uh from we are not going to

376:19

be removing it from here but now that

376:21

you know that we are just passing that

376:23

state value like whenever we change

376:25

something so we are just passing it

376:27

inside the sidebar and then we are also

376:29

passing it inside each of these uh

376:32

components right here okay so now the

376:34

next thing which you have to do is that

376:35

we have to come to our input container

376:39

right here I mean like in input uh

376:41

component right here so I'm going to

376:43

just zoom in a bit and here what I will

376:45

do is that I'm going to specify a few

376:47

items like a few parameters so I'll just

376:50

provide like handle change first of all

376:51

so this is going to be the first case

376:54

I'm going to remove

376:55

that I'm going to provide this handle

376:58

change right here so the next parameter

377:00

I'm going to be providing is the value

377:01

is like which kind of value we are going

377:04

to be specifying inside this input

377:06

container then after that I'm going to

377:07

be also providing the title like which

377:09

kind of title we are going to be using

377:10

inside this component and then the name

377:13

and also the color okay so a color we

377:16

are not going to be using it for that

377:17

much reasons but we will pass it right

377:20

here okay so we have this sidebar label

377:23

container right here the next thing

377:24

which I will do is that I'm going to use

377:26

this handle change I'm going to copy

377:28

that and now once we change something so

377:32

we are going to be calling this method

377:34

uh like handle change right here and we

377:36

have the type of radio that's completely

377:38

fine now we have to uh what do we call

377:41

it control this component so if you want

377:43

to control this component so we are

377:45

going to be also passing this value to

377:47

it so I'm going to just pass this value

377:48

right here and now the final thing which

377:50

we have to do is that we also have to

377:52

copy this name from here and I'm going

377:54

to place it right here so let me just

377:56

place it right here as a name and yeah

377:59

that's completely

378:00

okay but now the next thing which you

378:03

have to do is that we also have to

378:05

specify this color so I'm going to just

378:06

copy that and I'm going to also provide

378:09

a style tra and then here what I will do

378:12

is that I'm going to just provide a

378:13

background color of this color right

378:15

here and now the final thing which you

378:17

have to do is that we have to remove

378:19

this all from here and I'm going to copy

378:22

this title from here and I'm going to

378:24

just space it right here randomly so if

378:26

you sell our file let me just remove

378:28

this space from here semi file and here

378:31

you can see we are getting these things

378:33

but that's not working and that's not

378:36

cool hose so what do we have to do we

378:38

have to go inside first of all a sidebar

378:41

right here and then we have to go into

378:43

the categories and we are reusing these

378:45

inputs right here so the first thing

378:48

which you have to do is that uh you know

378:51

what I'm going to remove all of them

378:52

from here and I'm going to just first of

378:55

all write a label and the first one we

378:57

cannot change so this why we are going

378:59

to be writing it manually so sidebar

379:01

label you can check that in your spare

379:04

time if you want want to but I don't

379:05

want to check it right now but we can

379:07

change it like I I think of I think of

379:10

every possible way but we can't change

379:13

it right now but I'm going to change

379:15

that to radio so the first all we have

379:18

to specify that to like uh we have to

379:21

specify that like manually so we have

379:23

this handle change which we are getting

379:26

from this uh as a prop right here so we

379:30

have access to that handle change you

379:31

already know that and now what else do

379:33

you have to do we are going to

379:34

specifying the value of nothing because

379:37

we are going to be selecting everything

379:39

and the name will be now set to test

379:41

okay so that's that I'm going to be also

379:43

providing a spent word with the class of

379:45

check mark and now as a label I am going

379:48

to provide all okay so if you sell file

379:51

and let's just refresh so here you can

379:53

see it now giv us all right here so now

379:55

the next thing which you have to do is

379:57

that we are going to be reusing our

379:59

basic input so I'll just write input

380:01

right here and now let me just close

380:03

that and here we we have to specify all

380:05

of our props so I'm going to just

380:07

provide like handle uh handle change and

380:11

I'm going to copy this handle change

380:12

from here and I'm going to just place it

380:15

right here okay okay so now the next

380:17

thing which you have to do is that we

380:18

have to provide a value for this uh

380:21

input field so we have a sneakers right

380:24

here and I'm going to also provide a

380:26

title of uh sneakers as well underneath

380:30

that I'm going to be also providing a

380:31

name of like uh I don't know man uh test

380:34

would be be fine and I'm going to just

380:36

duplicate this component like one time

380:39

then two time and three time okay so we

380:41

are not going to be changing this one we

380:43

are also not we will change this one so

380:46

we have to change that to from sneakers

380:48

to Flats and also this one to Flats as

380:52

well okay and test would be fine so

380:54

you'll have to just change this value to

380:57

just um I don't know sandal would be

381:00

fine and this one will be also

381:02

sandals and that's going to be fine and

381:04

then finally we have a heels and we have

381:07

a heels right here okay so now if is

381:10

sell file and here you can see we are

381:13

now getting sneakers and flat sandals

381:16

and heels so this component is now

381:18

totally reusable like we can reuse this

381:20

component anywhere inside our

381:23

program anyway so that's done now the

381:26

next thing which we have to do is that

381:27

we have to go inside a price tag so this

381:30

price one right here and first of all

381:33

I'm going to just uh get my handle

381:35

change right here and I'm going to just

381:38

remove this component from here okay and

381:41

I'm going to also copy uh you know I

381:44

just remove that right here so I'm going

381:46

to just copy this component because we

381:48

cannot do anything we have to just

381:50

specify it manually uh value uh and

381:54

stuff like that so this one will be for

381:56

all we have a test uh and this one will

381:59

be test two and we have everything we

382:02

need and that's cool anyway so that's

382:04

cool so now the next thing which we have

382:05

to do is that we have to just get our

382:07

input tag right here which we've been

382:09

already using but I just deleted there

382:12

but we are going to be first of all

382:13

providing a handle change and then we

382:15

have our handle change right here then

382:17

we have a value and it will be now set

382:19

to 50 then we have a title and as a

382:21

title I'm going to just specify the

382:23

string of like $0 to 50 okay so now

382:27

finally I'm going to just provide a name

382:29

of like uh test two right here okay so

382:33

now I'm going to S my file I'm going to

382:35

duplicate that a few times so let me

382:37

just go back and I'm going to just

382:39

duplicate that to like I don't know

382:40

three times so one 2 three and I'm going

382:44

to just change the value inside them so

382:46

it will be now set to 100 and this one

382:48

will be now set to 50 100 like so this

382:53

one will be now set to 150 this one will

382:55

be set to 100 and 150 okay so then

382:59

finally we have a 200 right here and

383:02

then let me just remove that from here

383:05

and I'm going to just specify over

383:09

$150 okay so if you sell our file and

383:12

now here you can see it will now gives

383:13

us all of that labels right here and all

383:15

of that products anyway so that's going

383:17

to be awesome as well so that's working

383:20

the way we expand to work so now the

383:22

next thing which we have to do is that

383:23

we also have to go to the colors as well

383:26

so I'm going to just go to the colors so

383:28

I'll go to the price one more time and

383:30

I'm going to copy that from here and I'm

383:33

going to just replace it right here here

383:35

okay so underneath that I'm going to get

383:36

my input and let me just close it

383:39

manually H come on like so and we have

383:43

to specify these values so we have a

383:45

handle change we'll be now set to handle

383:47

change and are we getting it or not we

383:49

are not so we have to uh destructure it

383:53

from the top and now what we have to do

383:55

we have to just specify value of blank

383:58

and the title will be also set to Black

384:02

and then we have a name of test one okay

384:05

so this is going to be the test one and

384:07

then we have a color of totally black

384:09

one more time and now I'm going to

384:11

duplicate them um I don't know maybe uh

384:14

1 2 3 four times maybe so I'll just

384:18

write 1 2 3 4 so I just duplicate that

384:21

component four times right here so this

384:23

is a black color I'm going to just

384:25

replace that to blue color and also this

384:29

color to toally Blue as well and also

384:32

the color will be set to Blue

384:34

and I'm going to also change that to

384:36

from a black to what do we call it uh

384:40

red would be fine but the title should

384:42

be uppercase and I'm going to select it

384:45

one more time and this one will be set

384:46

to green and this one will be also set

384:49

to green and I'm going to finally select

384:52

it to I don't

384:55

know

384:58

um uh White will be fine so I'll just

385:00

select it to White the title would be

385:03

white but we cannot see the tile and you

385:06

know what I just realized that the final

385:08

one we also have to create it manually

385:11

so like we cannot do anything for this

385:13

one as well so we have a label with a

385:14

class of sidebar and then label and

385:17

container as well okay let's just remove

385:21

the HTML from here and I'm going to just

385:24

specify um what do we call it our input

385:27

area right here and I'm going to just

385:29

change the type to like

385:32

Radio and on change will be now set to a

385:36

hand handle change there we go and now

385:40

after that I'm going to also provide a

385:42

type of radio uh we already provide type

385:45

of radio to it didn't we y we did the

385:47

value will be now set to totally white

385:50

and also I'm going to provide a name of

385:52

test one as well so now underneath this

385:55

input area what do we have to do we have

385:57

to write our span with the class of

386:00

check mark and we also have to specify

386:02

some sort of a styling into it so like

386:04

inline styling so I'll just write

386:06

background it'll be now set to totally

386:08

white and I'm going to also provide a

386:10

border of uh two pixel solid poly black

386:14

okay so now if you sell file and here

386:16

you can see we are now getting all of

386:17

these colors right here so if you click

386:19

on it and all of that colors right here

386:22

but we cannot see that white one we can

386:24

change the label of that if you want to

386:26

uh but you know what I'm going to change

386:28

that color to something else like uh I'm

386:31

going to also provide a color of white

386:33

to not white but black would be fine so

386:36

if you sell that

386:38

and you know what I'm going to remove

386:41

that from here and as a label where is

386:44

that span check

386:47

mark and then we have white where is our

386:51

y text did we just put a y text or

386:53

something okay we have to put it right

386:55

here so I'm going to just place my white

386:57

text and now here you can see we are now

387:00

getting it right there I didn't know

387:02

like okay so now it's St working so we

387:04

have white green blue red and all of

387:06

that but we also have to specify our all

387:09

right here so I'll just provide class

387:11

name of uh class name of all right here

387:15

okay so I'm going to just put all right

387:17

here so if you save that and here you

387:19

can see it will not uses that linear

387:20

gradient right here why is that that's

387:23

because we already declared The Styling

387:25

inside this all uh I mean like inside

387:28

this color. CSS file and this is how we

387:31

can specify and this is how we can Pride

387:33

all right Rus so that was a huge

387:35

refactor so now the next thing which we

387:37

have to do is that we have to take care

387:38

of this card and render appropriate card

387:42

like based on the user selection or

387:44

whichever kind of filter the user

387:46

perform all right so next thing which

387:48

you have to do is that we have to pass

387:51

appropriate data to each of these

387:52

components so what I will do is that I'm

387:54

going to first of all pass my query into

387:57

this navigation so I'll just write query

388:00

and I'm going to also provide like

388:01

handle input change so I'm going to

388:04

going to just copy that and I'm going to

388:05

place it right here so the next thing

388:07

which you have to do is that we also

388:08

have to provide or handle change event

388:10

right here into this component so I'll

388:12

just provide it as a PR so we have

388:14

handle change there we go and not a

388:17

handle change but um handle click to be

388:20

precise not a handle change but handle

388:22

click I'm going to copy that and I'm

388:24

going to place it right here as well so

388:27

the final thing which you have to do is

388:28

that we are going to be passing all of

388:29

our filter data into this products

388:32

component and then we are going to be

388:33

iterating over through that component

388:35

and then we are going to be rendering

388:36

each of these items right here like the

388:38

appropriate image the title and all of

388:40

that kind of stuff so here you can see

388:42

we just have our results right here I'm

388:44

going to copy that and I'm going to

388:45

place it right here as a pro but let me

388:48

just show you like what is this results

388:50

so I've already write all of the code

388:52

for it but here what we are doing is

388:54

that we are getting all of that data

388:56

from that item I mean like from their

388:58

database which we have right here so I'm

389:00

going to just open there real quickly so

389:02

here you can see we have different kind

389:03

of images different kind of title we

389:05

have star reviews new price pre I mean

389:07

like previous price new price Company

389:09

color and all of that categories right

389:11

here so here we are just destructuring

389:14

all of that data from each of that

389:16

component and we are passing all of that

389:18

data to this card component as a prop so

389:21

here you can see we have image we have

389:22

title and all of that kind of stuff

389:24

right here we are passing all of that

389:26

data dynamically into my card component

389:29

so we will have access to all of that

389:30

data dynamically inside my card

389:33

component so what I will do do is that

389:34

I'm going to just s my file right here

389:36

and now the next thing which you have to

389:38

do is that I'm going to go into my

389:40

product section right here and I'm going

389:42

to just remove all of this stuff from

389:44

here I'm going to remove that the next

389:46

thing that you have to do is that we

389:47

already passed this result right here so

389:50

I'm going to just copy there and I'm

389:51

going to destructure it right here so

389:54

I'm going to just destructure there and

389:56

I'm going to just pass it right here

389:59

okay so if you just pass it right here

390:00

if you s file nothing will happen so now

390:04

the last thing which you have to do is

390:06

that we have to go to this card

390:07

component and we have to just refactor

390:09

the a little bit so let me just show you

390:11

that I'm going to just remove that from

390:12

here I'm going to save my file and now

390:15

I'm going to go into my card component

390:17

right here so now here you can see we

390:19

have like the same image right here we

390:21

have the same uh title we have the same

390:24

reviews and all of that same and pre I

390:27

mean like all of their previous um price

390:29

and all of their new price right like

390:31

here you can see we have hardcoded data

390:34

into all of these card component and we

390:35

don't want that we want to render a

390:38

dynamic content into these components so

390:40

like Dynamic image and all of that title

390:42

and rating and all of that kind of stuff

390:44

so I'm going to refactor this component

390:47

from scratch so now if you want to

390:49

refactor this component first of all I'm

390:51

going to go into my app component and

390:53

I'm going to just copy them like this D

390:55

structuring I can type it manually but

390:57

it will take a lot of my time so I'm

390:59

going to just place it right here okay

391:01

so we already D structure all of that

391:03

data which we are passing to this

391:05

component as a prop so here you can see

391:07

we just destructure image and all of

391:08

that kind of data so next thing which

391:10

you have to do is that I'm going to

391:11

leave this CLA and all of that alt right

391:13

here I'm going to just select my image

391:16

and I'm going to just remove them and

391:18

here what I will do is that I am going

391:19

to just copy this IMG and I'm going to

391:22

just past it right here okay so now if I

391:24

do that and if I sell my file and let's

391:27

just wait for it so here you can see it

391:28

will now just render all of their

391:30

Dynamic content right here like all of

391:31

their images right here all right that's

391:33

cool so the next thing which you have to

391:35

do is that we also have to provide that

391:38

title right here so I'm going to just

391:40

pass my title in here just for random

391:42

data and now the next thing which you

391:44

have to do is that here I'm going to

391:45

just remove this shoe and I'm going to

391:47

replace it with my title okay if s file

391:51

so here you can see we have this

391:52

different kind of titles right here and

391:54

don't worry I'm going to change the

391:56

fonts and all of that kind of stuff just

391:57

in a second but I just kind of want to

391:59

provide different kind of data into it

392:01

uh dynamically so next thing which you

392:03

have to do is that I'm going to just

392:04

remove that star from here I mean like

392:07

that icon and I'm going to just replace

392:09

it with star okay so I'll just copy that

392:12

four times you can provide three or two

392:14

times whatever so I'm going to just pass

392:16

it four times I'm going to save my file

392:18

and here we are getting uh this black

392:21

color what was that uh class I pr I

392:24

forgot the name of that class let me

392:25

just go back okay so it's this class I'm

392:28

going to just copy that from one

392:30

component I'm going to delete it then

392:32

I'm going to go into my data and and I'm

392:34

going to select my okay I'm going to

392:37

just select there and I'm going to hit

392:39

controll D and I'm going to select all

392:41

of these items right here so we already

392:44

provide this style but I don't know why

392:45

it's not working class name of there let

392:48

me just pass it manually I guess I

392:49

missed have something in it oh I just

392:51

write ratings instead of rating I just

392:54

proide s in here so I'm going to just

392:56

sve my file and I'm going to save this

392:58

file as well but it will just remove

393:01

these Stars you know I'm going to just

393:02

render it dynamically I'll just write

393:04

star not start but star and four times

393:07

you can put three times if you want to

393:10

but for me four star will be totally

393:12

fine okay so we are totally getting

393:15

there the next thing that you have to do

393:17

is that I am going to also provide um

393:20

reviews right here so I'll just write

393:21

like reviews in here and then finally uh

393:25

as a label I'm going to remove this

393:26

label from here or you know what I'm

393:28

going to just remove this level and I'm

393:31

going to just pass my new not new but uh

393:33

pre price and here I am going to just

393:35

render my new price right here so if you

393:37

sell file and here you can see we have

393:39

our previous price and we have a new

393:41

price right here for each of these items

393:43

right here okay so we have all of this

393:46

Dynamic content right here you can

393:47

provide more than that if you want to

393:49

but for me that's totally okay so here

393:51

you can see we already password um uh

393:54

what do we call it or filter

393:56

functionality right here if I just click

393:57

on a sneakers it will just give a

393:59

sneakers if I click on a Flats okay we

394:02

don't have flots

394:05

uh okay so I'm going to go into my flat

394:08

this component where is the category so

394:10

I'm going to just go into category very

394:13

quickly and instead of

394:15

flats uh I'm going to just change that

394:17

to Flats uh F LS I bet and I'm going to

394:21

change this one right here as well so if

394:23

you s our file and now let me just

394:25

refresh that I'm going to click on Flats

394:27

it will gives a splash sandals and I'm

394:30

not pretty sure about are these sandals

394:33

or I guess these are all Sneakers but I

394:35

don't know I just put a random data in

394:37

here I don't have any idea about all of

394:39

these stuff so heels then we have all of

394:42

the items right here one more time then

394:44

we have uh from $0 to 50 here you can

394:47

see we just getting the $50 uh items

394:50

then we are getting a $100 item then we

394:52

are getting 150 and then finally we have

394:55

$200 of items right here so if you click

394:58

on all of the colors so here you can see

394:59

it will just gives us all of the colors

395:01

right here if you just want a black

395:03

color so I'm going to just click on

395:04

black and it will now give this black

395:06

color right here if you just want to get

395:08

a blue we have red we have green and we

395:10

also have white color right here okay so

395:13

that's looking cool but now I'm going to

395:15

just click on all of the products so

395:17

that's not working that's not working we

395:20

have to take care of that really quickly

395:22

so that's in this recommended component

395:25

so I'm going to just copy the name and

395:27

I'm going to go into there did you saw

395:29

like how much fast I came into this

395:31

component that's because you didn't take

395:34

my visual Studio C course so you got to

395:36

go into that course and you have to take

395:39

that course and this is totally my

395:41

guarantee that by the end of that Visual

395:43

Studio coder course if you took that

395:45

course you are going to be calling

395:47

yourself as a Sonic coder I don't want

395:49

to go that much fast in the recording

395:51

because a lot of people get confused

395:53

like hosan how did you get this fast

395:55

into this component and how did you

395:56

write this code that much fast and all

395:58

of that kind of stuff so that's why I

396:00

don't want to just go that much fast in

396:02

my recording so TR trust me like when

396:04

I'm working on my personal project I

396:06

just go like crazy and if if you're a

396:10

programmer and you sit just uh with me

396:12

you're going to be calling me a crazy

396:14

because I type like a uh you know that's

396:17

another story I'm going to just leave

396:19

that anyways I'm going to go into my app

396:22

component right here and here you can

396:23

see we just pass this handle click right

396:25

here like whenever somebody clicks on

396:27

this component so what do you want to do

396:29

here you can see we have handle click

396:32

right here so we are just getting there

396:33

data and then we are just filtering it

396:36

right here okay so you already know all

396:37

of that stuff but now let me just get

396:40

there which is uh handle click but you

396:44

know what uh I'm going to just remove

396:46

there but first of all let me just

396:48

create a component separate component

396:49

for these buttons they aren't looking

396:51

that

396:52

cool uh we already built that component

396:55

but I forgot to refactor this component

396:57

we just write a button right here so I'm

396:59

going to just take care of that I'm

397:01

going to just provide a few um what do

397:03

you call it I'm going to just pass a few

397:06

values like I'll just pass this values

397:08

like on click a Handler and I'm going to

397:12

also provide a value to it it will take

397:14

some sort of a value and I'm going to

397:15

also provide a title for this button so

397:17

what I will do is that I'm going to just

397:19

remove them and I'm going to just

397:20

replace it with this button right here

397:22

okay so now the next thing which you

397:23

have to do is that I'm going to just

397:25

write on click like when somebody clicks

397:27

on this button we just want to find this

397:29

perimeter right here this parameter um

397:32

event right here which should passing

397:33

and the next thing which we have to do

397:35

is that we also have to pass our value

397:37

which we are getting dynamically and I'm

397:38

going to also provide a value to it okay

397:41

and then I'm going to just give him some

397:42

sort of a class name like buttons would

397:44

be fine okay that's going to be totally

397:47

fine and I'm going to just pass the

397:50

title finally so I'll just write title

397:53

tle there we go now we create this

397:55

component right here so now let's just

397:57

reuse there instead of these buttons I'm

397:59

going to use my own so I what I will do

398:02

is that I'm going to remove there you

398:04

know what um I guess I'm going to leave

398:06

that first one I'm going to just leave

398:08

them and now let me just get my own

398:10

buttons so buttons there we go and now

398:13

I'll just provide on click Handler which

398:16

we are taking and then we are going to

398:17

be just passing or handle uh click event

398:20

right here and I'm going to also provide

398:21

a value of Nike okay uh I guess I'm

398:25

going to have to close there otherwise

398:26

it will giv us uh is there buttons or

398:30

button okay buttons anyways uh uh I am

398:34

going to just close it manually like so

398:36

but why it's giving us this nasty error

398:38

once we have our Mouse ordered identify

398:41

unexpected I'm going to close

398:44

that and yep that's cool but why it's

398:47

giving us an error any time I want to

398:49

pass some sort of a value to it so I'm

398:52

going to P some sort of a value like

398:53

Nike now it's not giving us any error

398:55

and I'm going to also pass the title of

398:57

Nik as well okay so that's cool so I'm

399:00

going to just duplicate there for Ed

399:02

puma and

399:04

and I'm going to just remove this title

399:05

I'm going to select that hit contrl D

399:08

and add add ID there we go and I'm going

399:12

to just select Nike hit control D set

399:15

that to puma and then we have uh Nike

399:18

one more time I'm going to change that

399:20

to W anyways that's cool and for this

399:23

button we cannot do anything with it you

399:25

know what I'm going to also duplicate

399:27

let me just remove this one from here

399:29

and I'm going to duplicate this one so

399:31

instead of value I'm going to just

399:32

remove this value right here and I'm

399:34

going to just pass uh empty value like

399:37

empty string and I'm going to also pass

399:38

my all um products as a level so now I'm

399:41

going to sell my file and now let me

399:43

just refresh that we are not getting any

399:45

kind of error now I'm going to click on

399:47

Nike and then I'm going to click on a

399:49

products and now it's working all right

399:51

so now we are successfully done with all

399:53

of our project but we just have to

399:55

provide a little bit of styling for this

399:57

typography and stuff anyway so I'm going

399:59

to click on all of the product then

400:00

sneakers Flats sandals heels click on

400:03

all of the product then we have 0 50 and

400:06

100 and over 100 and then we have all of

400:09

the colors then we have black color blue

400:11

color red color green color and

400:13

white um black color blue color red

400:17

color green color and white color okay

400:19

everything is working I'm going to click

400:21

on all of the products then we have a

400:22

Nike edid Dan Puma W I'm going to click

400:25

on all of the products one more time and

400:27

let's suppose if I want to get this one

400:29

like Nik Zoom freak so I'm going to just

400:32

P the name of him like on Nike it will

400:34

give us all of the product of the Nik

400:36

and then we have zoom all righty so this

400:39

one is not working and I don't know

400:45

why you won't believe me this error took

400:48

me a lot of time to figure out like

400:50

where in the world is I'm doing

400:53

something

400:54

wrong here you can see I just Rite this

400:57

expression right here I'm going to cut

400:59

that from here and I'm going to just

401:00

place it right here so I'm going to save

401:02

my file finally

401:04

and now let me just search for something

401:05

like Nike Zoom freak if I just write

401:08

Nike right here so it will gives us all

401:09

of the Nik products I am going to just

401:12

search for a zoom it will now just giv

401:14

us like Zoom freak and let's suppose if

401:16

I want to get this one like uh let me

401:18

just copy all of the name and I'm going

401:20

to just place it right here so it will

401:21

not giv us this item right here so this

401:24

book took me a lot of time you know what

401:27

so

401:28

finally what I will do is that I'm going

401:30

to go in here and I'm going to select

401:33

all of that stuff and I going to Pro for

401:36

family of s set of and let me just

401:38

refresh that and why start taking all of

401:41

that uh so we have access to this index.

401:45

CSS right here I bet we didn't use that

401:48

in here so that's why we are not getting

401:50

all of that stuff let me just use um

401:53

import and then we have to our index.

401:56

CSS so now if we sell our file and here

401:59

you can see everything is working that

402:01

way we expect them to work and

402:02

everything is looking a okay so finally

402:05

let me just test this for a final time

402:08

and then we are going to be done for

402:10

this project and if you are watching

402:11

this video in my react course so then we

402:14

are going to be done with or react

402:16

course anyways I'm going to just click

402:18

on all of the products it will give us

402:19

all of the products if you click on a

402:21

sneakers and then we have flat sandals

402:23

Hils I'm going to click on a 0 50 100

402:26

and over 100 I'm going to click on this

402:29

one but I just figure out one more bug

402:31

and that is

402:33

occurring right here so we have to go

402:35

into a sidebar then we have to go to the

402:38

category so here what we are doing is

402:40

that we are just providing a test right

402:41

here and test for all of them that's

402:44

cool I'm going to go into the price and

402:46

here we are just specifying test two

402:48

right here that's also cool but now I'm

402:50

going to go into the colors and we are

402:52

specifying test two right here so I'm

402:55

going to just select that hit control d

402:58

uh and you know what I'm going to just

402:59

specify test three right here I'm going

403:01

to copy that now I'm going to just

403:03

select my test one and all of them and

403:06

here I'm going to just specify test

403:07

three if you s file and now let me just

403:10

uh check that I'm going to click on this

403:12

one click on this product and now that's

403:15

totally working so if I want to just get

403:17

like blue I'm going to get blue then red

403:19

then green then white okay so that's

403:22

also working let's suppose if I want to

403:23

just get this product so I'm going to

403:25

just copy that and I'm going to just

403:27

place it right here so here you can see

403:28

it uses just this one product right here

403:30

and I'm going to just click on the

403:32

sneakers and stuff

403:33

and I'm going to just click on a Nik

403:36

then we have IDs Poma ws and all of

403:38

these

403:39

products in YouTube channel so in this

403:42

video we are going to be learning about

403:44

tcri from scratch so what in the world

403:48

is tcri and why you should care about

403:49

them so to give you a simple answer to

403:52

them you can think about typescript is

403:54

like a JavaScript with super power so

403:57

what does that mean so typescript is

403:59

like more powerful version of JavaScript

404:02

it lets you do every single thing that

404:04

JavaScript already does but it also adds

404:07

some extra features which we are going

404:09

to be learning throughout this course to

404:10

make you life easier when writing a

404:12

larger and more complex programs so does

404:16

it mean that we can only use typescript

404:18

for a larger and complex programs no of

404:21

course not you and for any scale of

404:23

project you can use it for smaller or

404:25

for bigger and all of that so that was

404:27

just a basic intro to what a typescript

404:29

is so now let me just go ahead and go to

404:31

the official page of typescript and how

404:34

they call themselves so if you want to

404:35

come to the same link you can just type

404:37

this in your browser which is typescript

404:40

lang. or and just hit enter and it's

404:42

going to bring you to this website right

404:44

here so here you can see on the official

404:46

page of uh typescript they call them

404:48

themselves as typescript is a JavaScript

404:50

with a Syntax for types like tcri is all

404:55

about types right here Tye here you can

404:58

see we have type and also for the

405:01

JavaScript so you can think about

405:02

typescript like that so which kind of

405:04

feature it provides you can learn more

405:06

about that if you wanted to but you

405:07

don't have to because you're going to be

405:09

learning every single thing uh in this

405:11

course right here typescript add

405:12

additional syntax to a JavaScript to

405:14

support a tire integration with your

405:16

editor catch errors early in your editor

405:19

and also a result you can trust what is

405:22

that mean typescript code converts to

405:24

JavaScript which runs everywhere

405:26

JavaScript runs like for the browser and

405:28

also for node and you don't have to

405:30

worry about Doo uh and in your right

405:33

here and safety at scale typescript

405:36

understand JavaScript and use type

405:38

inferences our inference something which

405:40

we are going to be diving into in a

405:41

really great depth in this course to

405:43

give you great tooling without

405:45

additional code right here so you can go

405:47

ahead and explore more about typescript

405:49

right here so here you can see cannot uh

405:51

find the name of or r i mean like they

405:53

forgot something right here in the code

405:55

and now the typescript is giving them

405:56

complaints right here you can learn more

405:58

about that and this is the official page

406:00

of typescript right here and we we are

406:03

going to be learning every single thing

406:04

that is to learn about typescript in

406:06

this course so yeah that was just it

406:08

about the basic introduction of what a

406:10

typescript is and now let's get into the

406:12

installation so now let's install

406:14

typescript in our machine so I'm going

406:16

to just click on try typescript now I'm

406:18

going to click on this button right here

406:19

you can uh use it in the browser or you

406:22

can say a playground so I'm going to

406:24

just click on on your computer I'm going

406:26

to click on that and it's going to

406:27

brings us to this documentation right

406:29

here so if you want to install this here

406:31

you can see this is the command like n

406:33

PM install typescript D- sell you can

406:35

save that to your dependencies but we

406:37

are not going to be using that we are

406:38

going to be using something called this

406:40

command which is npm install DG

406:43

typescript let me just make that a bit

406:44

bigger so you guys can see everything a

406:46

bit better we are going to be using this

406:48

Command right here I already installed

406:49

there but now let me just show you how

406:51

you're going to be installing there so

406:53

I'm going to just open my terminal right

406:54

here you can open your terminal anywhere

406:56

you want and what I want to do is that

406:59

I'm going to just check if I already

407:01

have typescript or not so I'm going to

407:02

just write ts- V right here oh not ts.

407:06

but TS c-v right here and it's going to

407:09

gives us the time script compiler

407:11

version which I'm using right here for

407:13

this course which is

407:14

5.2.2 right here so if you already

407:17

installed the cool if you did not

407:19

install that you can just go ahead and

407:21

copy this Command right here which is

407:22

npm install DG and typescript and by the

407:25

way I forgot to show you something you

407:28

have to have the nodejs installed

407:29

already in your machine so I'm going to

407:31

just write like nodejs start .org I

407:34

guess I'm going to go ahead and go to

407:36

the nodejs right here and you just have

407:37

to install each one of them like so you

407:39

can install this version or you can also

407:41

install this version right here so once

407:42

you do just click on next next next and

407:44

it's going to install in your machine

407:46

and then you just have to write no- V so

407:48

it's can also give you the version right

407:50

here so currently I'm using 21.1 or

407:53

something like that and this is my

407:55

guarantee by the time you're watching

407:57

this video this version will be totally

407:59

different than mine you're going to be

408:01

using I don't know like 22 or maybe 25

408:04

or something like that but nodejs does

408:06

not have to do anything with tcri right

408:09

here I mean like there are a few things

408:11

which we are going to be also discussing

408:12

throughout the course but the versioning

408:14

doesn't matter you can install like as

408:17

long as the version is like greater than

408:18

eight you are totally good to go but if

408:21

you using some version less than eight

408:23

then you are not in a great spot my

408:25

friend so now let me just close that oh

408:28

I forgot to show you that I just closed

408:29

it let me just right click on that and

408:31

open my terminal right here and let me

408:33

just reinstall the typescript right here

408:36

so now let me just make that a bit

408:37

bigger and install that right here I'm

408:39

going to just copy this command let me

408:41

just copy that I'm going to right click

408:43

on that and here you can see I have npm

408:45

install DG typescript I'm going to hit

408:47

enter right here and here you can see I

408:49

already installed it so it's going to

408:50

give us only this U message right here

408:52

in your case it's going to be something

408:54

different but anyways as long as you

408:56

don't see any errors you are totally

408:58

good to go so yeah that's then now the

409:00

next thing which I want to show you is

409:02

that you also have to install something

409:04

called um TS node as well so I'm going

409:06

to just write like npm and I and then

409:09

you just have to write DG ts- node you

409:12

have to do that right here okay so I

409:14

want you to just type this command in

409:16

your machine and install that I want you

409:18

to install that because throughout the

409:20

course I mean like just for the

409:21

beginning of the course we are not going

409:23

to be using like all of that uh npm

409:25

stuff like how to make a typescript

409:27

configuration and all of that we are

409:29

going to be using a vs code extension

409:31

and trust me then like supremely amazing

409:34

for types script you're going to fall in

409:36

love with that I promise but what I want

409:38

you to do is that I want you to also

409:40

install this one as well so I want you

409:42

to just hit enter right here I already

409:44

installed that and it's going to

409:45

reinstall that once again for me okay so

409:48

yeah here you can see that's also

409:49

install and there we go the next thing

409:52

which I want you to do is that I want

409:54

you to make a folder anywhere you like

409:56

in my case I'm going to create my folder

409:57

inside my desktop and you can give any

409:59

name you want like the name doesn't

410:01

matter I'm going to just give a name of

410:02

like has uh playground or something like

410:05

that come on playr right here and you

410:08

can give any name you want I'm going to

410:09

right click on that and then I'm going

410:11

to open this folder in my vs code right

410:13

here okay so this is how my vs code

410:15

looks like and chances are your vs code

410:18

will not look exactly the same like mine

410:21

but if you're wondering like Huzan I

410:23

really like your vs code and your vs

410:25

code extension and all of that kind of

410:26

stuff you can go ahead and watch my vs

410:29

code customization video and trust me

410:31

you're going to fall in love with my

410:32

customization and the theme I'm using

410:35

right here anyway so that's out of the

410:36

course now I'm going to go ahead and go

410:38

to the extension and let's just click on

410:41

that in my case I'm using uh this

410:42

shortcut right here but in your case

410:44

it's going to look something like this

410:45

I'm going to just go ahead and go to

410:47

like code. vs code.com or something like

410:50

that let me just go ahead oh that's not

410:53

the thing uh I don't know vs code or

410:55

something like that and let me just open

410:58

that and code. visual studio.com my bad

411:01

and we are going to be using this score

411:02

throughout the course and you are more

411:04

than welcome to use whichever kind of

411:06

editor you I like yeah editor you like

411:09

and in your case if you want to go to

411:10

the extension area you're going to have

411:12

to click on this button right here and

411:14

it's going to bring you this similar

411:15

interface right here so the first thing

411:17

which I want you to install is this

411:18

extension right here which is Javascript

411:20

and also typescript nightly okay so just

411:23

install that and it is created by

411:25

Microsoft so yeah we are to in the great

411:27

hands and also install this code Runner

411:30

right here because throughout the code

411:32

course I mean like just for the

411:33

beginning of this course we are going to

411:34

be using this code Runner a lot and

411:37

trust me you're going to fall in love

411:39

with this code Runner right here just

411:41

click on that install button and it's

411:42

going to install it in your machine so

411:44

now I'm going to go ahead and create a

411:45

file right here you can give any name

411:47

you want I'm going to just give name of

411:49

like index.ts right here and we are

411:51

using a typescript so for this case we

411:54

have to specify the TS extension right

411:56

here if you are using a JavaScript so we

411:58

just have to write JS right here we are

412:00

now currently working with this DS I

412:02

mean like we are currently working with

412:03

typescript so we have to specify TS at

412:05

the end as an extension so now I'm going

412:07

to just hit enter right here and you

412:09

don't have to do nothing else now let me

412:11

just create a binder or a shortcut

412:14

whatever you want to call that so now

412:16

I'm going to just write a bit of

412:17

typescript code which you don't have to

412:18

worry about right now so I'm going to

412:20

just write like I don't know type of uh

412:22

person or something like that and this

412:24

person will have like I don't know name

412:26

of string I guess that would be fine we

412:27

don't have to worry about anything else

412:29

I'm going to also provide this person

412:31

right here you don't have to do anything

412:32

else you just have to write this code

412:35

right here just this code nothing else

412:37

and now if you want to run this code by

412:39

using a

412:45

timecrimes not right now but we are

412:48

going to be going into all of that stuff

412:50

a bit later in a really great great

412:52

detail but not right now but let's

412:54

suppose if I want to run this file how

412:56

can I go about doing that and you know

412:58

what let me just log to the console

412:59

something like I'm going to just log to

413:01

the console like person name right here

413:03

and now if I sell this file and now if I

413:05

want to run this code how in the world

413:07

should I go about doing that this is how

413:10

you're going to be doing there okay so

413:12

here you can see we now getting John so

413:14

now you might be asking like hosan how

413:16

did you do that tell me I'm telling you

413:19

but you have to give me a few seconds

413:21

you already installed this extension

413:23

right here which we have uh this code

413:25

Runner extension right here you already

413:26

installed that the next thing which I

413:28

want you to do is that I want you to

413:29

open your command pallet I don't know

413:32

know how you're going to be opening the

413:34

command pet in the Linux operating

413:36

system and I also don't know how you're

413:38

going to be opening your command pallet

413:40

in the what do we call it in the Mac OS

413:42

operating system but I do know how

413:44

you're going to be opening your command

413:46

pallet in Windows operating system right

413:49

here but you got to search that for your

413:51

own operating system for Windows users

413:54

you just have to hit F1 and there we go

413:57

okay and here I want you to just search

413:58

for uh what do you call it the keyboard

414:02

shortcuts right here so here you can see

414:04

we have like open keyboard shortcuts I'm

414:06

going to click on them and here you just

414:08

have to search for the code Runner right

414:10

here and here I want you to just select

414:12

this one right here by default it's

414:14

going to be set to something else I want

414:15

you to just double click on that it's

414:17

going to give you this input field right

414:19

here and just provide shift and enter

414:22

and there we go I want you to just hit

414:24

enter one more time and this is how

414:26

you're going to be creating a shortcut

414:28

for uh this code Runner right here okay

414:30

so yeah that's amazing I'm going to just

414:32

hold my shift and hit enter and boom

414:35

there we go so here you can see we are

414:37

now getting the result of JN right here

414:39

now I'm going to right click on there

414:41

then I'm going to go ahead and go to my

414:42

panel position right here then I'm going

414:44

to just set that to right if you like

414:46

this layout feel free to make it like

414:48

this if you don't like this layout so

414:50

you can just right click on that come on

414:52

you can just right click on that go to

414:53

the panel and you can make it to the

414:55

left or also to the bottom itself okay

414:57

so yeah throughout the course we're

414:59

going to be writing our code like this

415:01

or maybe in some some situation we are

415:03

going to be also diving into the

415:04

terminal and this is something which I

415:06

will discuss in a really great detail

415:08

right here now we don't have to do

415:10

nothing else and there we go I'm going

415:13

to delete this code right here and save

415:14

my file and here you can see we don't

415:16

even have any compile file right here so

415:18

yeah that's also amazing so now let's

415:20

get into the first technical topic of

415:22

this course which will be annotations in

415:24

typescript so annotation are used to

415:26

specify the data type of a variable

415:29

parameter function return values and

415:31

other types of values

415:32

so we are going to be learning about how

415:34

to work with uh annotation for the

415:36

functions and we're going to be also

415:37

learning it for the strings for booleans

415:39

and all of that kind of stuff okay which

415:41

are coming in a few se so now that we

415:43

know what annotations is so what's the

415:45

purpose of annotations so annotations

415:48

help developers sketch errors early in

415:49

the development by allowing them to

415:51

specify what type of values can be

415:53

assigned to a given variable or pass as

415:56

an argument to a function okay so as I

415:58

said that we are going to be learning

415:59

about annotation for different kind of

416:01

things which are coming up in a few

416:03

seconds so now let me just show you the

416:05

first example of using annotation so

416:07

here you can see we have annotation for

416:08

string so how the syntax will look like

416:10

first of all we are going to be creating

416:12

some sort of a variable right here then

416:14

we are going to be providing this

416:15

separat right here which you can see and

416:17

then we have to provide some sort of a

416:19

type so this is known as annotating or

416:22

variable or you can say like annotation

416:24

whatever you want to call that and

416:26

finally we are going to be using the

416:27

equal to sign and then some sort of a

416:29

value which we are going to be storing

416:31

based on this type right here so yeah I

416:33

know that sounds a bit confusing but

416:35

here is the actual example of that so

416:37

how we're going to be using that first

416:39

of all we are going to be creating a

416:40

variable right here it doesn't matter if

416:42

you want to create your variable by

416:43

using the L keyword the cons or the war

416:46

it doesn't even matter it's totally up

416:47

to you but if you want to annotate there

416:49

first of all you have to specify this

416:51

separate right here then you have to

416:53

provide some sort of a type like which

416:55

type of data this variable is going to

416:57

be holding so in this case we are

416:58

providing like the string value so here

417:01

you can see so we anot or variable by

417:03

string right here so yeah this is how

417:06

the syntax will look like right here and

417:07

you can provide some other value by just

417:09

using the equal to sign and if you log

417:11

there to the console it's going to give

417:13

you like another value in this case

417:14

because we are changing this value right

417:16

here but on the other hand I want you to

417:18

keep that in mind if we annotate there

417:21

by using a string but if we provide that

417:24

like some sort of a number to it it's

417:25

going to throw us an error right here so

417:27

I want you to just keep this diagram in

417:29

mind so this was for a string we can

417:31

also write annotation for the numbers as

417:33

well and the syntax will be totally the

417:35

same so here you can see first of all we

417:37

are declaring our variable then we are

417:38

annotating there by using a number and

417:41

we are providing some sort of value of

417:42

like seven and we can just add uh some

417:44

other value to it but I want you to keep

417:46

in mind that if you try to add some

417:48

other type of value like in this case we

417:50

are specifying the string 11 right here

417:53

this will not fly it's going to throw

417:55

you an error or if you specify some sort

417:57

of a Boolean value like true or false or

418:00

something like that it's going to also

418:01

give you an error and I'm going to also

418:03

show you that in a few seconds so that

418:06

was for a string this one was for a

418:08

number and now let's talk about boans so

418:10

here you can see the syntax will be

418:12

totally the same like if you try to add

418:15

some other value for instance like

418:17

number or string it's going to throw you

418:19

an error so I want you to just keep this

418:20

syntax in mind and now let's get into

418:22

the coding then you'll get to know what

418:24

I'm talking about so first of all we are

418:25

going to be learning about annotation

418:27

for the strings then we are going to be

418:29

also learning it for the numbers and

418:31

also for the boot as well okay so now

418:33

let's talk about for the string so first

418:35

of all I'm going to create some sort of

418:36

variable like I don't know my name or

418:38

something like that and now if you want

418:40

to annotate then so for that we are

418:42

going to be using this uh colon right

418:44

here and then we are going to be

418:45

providing some sort of a type so in this

418:46

case I'm going to provide a type of

418:48

string right here and then we have to

418:50

write the equal to sign and which kind

418:52

of value we want to store so like let's

418:54

suppose if I want to store the value of

418:56

like 12 it's going to gives us an error

418:58

why is that if I hover my mouse overd

419:00

it's going to gives us this error right

419:02

here like type number is not assignable

419:04

to the type string right here so why on

419:07

Earth we are getting this error you

419:09

already know why we are getting this

419:10

error right here that's because we

419:12

provide this string I mean like we

419:13

annoted there is a string and we are

419:15

storing the value of 12 right here if

419:18

you change that to some sort of a string

419:19

like uh I don't know I'm going to just

419:21

store my name like Huzan webd right here

419:24

and if I just uh log that to the console

419:25

like my name let me just go back and let

419:28

me just run this code right here so here

419:30

you can see it's going to take a bit of

419:32

time and here you can see it's going to

419:33

pronounce my name right here if you try

419:35

to add or if you change the value of

419:38

that like my name and it's going to be

419:40

equal to like some uh other person or

419:43

something like that person there we go

419:45

and now let me just save that and just

419:46

run that and here you can see it's going

419:49

to give us like some I mean like

419:50

something other person right here okay

419:53

so yeah this is how we are going to be

419:55

um creating a variable this is how we

419:58

are going to be annotating that and this

420:00

is how we are going to be changing the

420:01

value of them and yeah you already know

420:04

how we are going to be logging there to

420:05

the console so now let me just remove

420:07

them and now let's talk about for the

420:08

numbers so what I want to do is that I'm

420:10

going to create a variable like f number

420:13

and I'm going to annotate that with a

420:15

number and it's going to be equal to

420:17

like I don't know it would be fine and

420:18

now let me just log that to the console

420:20

like Fair number and now let me just

420:21

save that and run there let me just

420:23

close that and rerun there once again so

420:26

here you can see we are now getting it

420:27

right here why is that because we

420:29

annoted that as a number and we are

420:31

storing the value of at right here on

420:33

the other hand let me just comment this

420:35

line out if I try to add some sort of

420:37

other value like I don't know true in

420:38

this case and you already know it's

420:40

going to gives us an error like um type

420:42

Boolean is not assignable to a type

420:44

number but anyways I'm going to just

420:46

save this file and run that and come on

420:49

man I just zoomed in let me just rerun

420:51

that once again and here you can see

420:53

it's going of gives us this nasty error

420:55

and it is saying that um unable to

420:58

compile like we cannot compile them and

421:00

here you can see the error like type

421:02

Boolean is not assignable to the type

421:04

number right here okay so you already

421:06

get the error and this is how it looks

421:08

like right here I'm going to just store

421:10

the value of like 12 or something like

421:11

that and finally now let's also create

421:13

one for the Boolean as well I'm going to

421:15

just create a variable like is

421:17

typescript hard or something like that

421:19

and I'm going to annotate that by using

421:21

a Boolean and it's going to be now

421:22

equals to false by default and now let

421:24

me just log that to the console like is

421:26

typescript come on is typescript or not

421:29

typescript or typescript hard there we

421:31

go now let me just set that and run that

421:33

and here you can see it's going to give

421:34

us a false right here why is that

421:37

because we are now annotating that as a

421:39

what do we call it Boolean right here

421:41

and we are storing the value of Boolean

421:43

there we go so now let me just provide

421:44

some other value like TSH hard like

421:46

typescript hard and I'm going to just

421:48

provide like uh true right here and now

421:50

let me just saell that and run that and

421:52

here you can see it's going to gives us

421:53

true right here because we are changing

421:55

the value of there right here okay so

421:57

that's cool but let's suppose if I try

421:58

to access or let's suppose if I try to

422:01

provide like know 12 or something like

422:03

that and now let me just H my mouse over

422:05

to it so type number is not assignable

422:08

to the type Boolean right here so this

422:10

is how you are going to be providing

422:11

annotation for your variables right here

422:14

so now let me just save them so that was

422:16

it about for annotation and now let's

422:17

talk about a type inference in

422:19

typescript so what is a type inference

422:21

and why you should care about that so

422:23

the type inference is a feature in

422:24

typescript that allow the compiler to

422:26

automatically determine the type of

422:27

variable based on its value baby in

422:32

other words if you declare variable with

422:34

explicitly specifying its type

422:36

typescript will try to infert the type

422:38

based on its value you assigned to it I

422:41

know that was a lot of gibberish now let

422:42

me just show you some code then you will

422:44

get to know what I'm talking about so

422:45

yeah here is the code so here you can

422:47

see we are not providing any annotations

422:50

right here and here you can see we are

422:51

now inferring this type or I can

422:54

pronounce this for iner inferring or

422:57

inferring whatever you want to call them

422:59

this type here you can see we are

423:00

declaring variable we are provid the

423:02

value of string right here then we are

423:03

providing the add then we are providing

423:05

the true as a Boolean right here on the

423:07

other hand if I just provide like uh for

423:09

the string variable if I provide a

423:11

Boolean it's going to gives us an error

423:12

if I provide like um what do we call it

423:15

for number I provide some sort of a

423:17

string it's going to gives us an error

423:18

and for also for Boolean if you specify

423:21

some sort of a number or a string it's

423:23

going to also gives us an error so now

423:24

let me just write some code then you'll

423:26

get to know what I'm talking about I'm

423:27

going to delete all of that code and you

423:28

will found all of that code in the in

423:31

yeah the description below which will

423:33

bring you to my gab repository and you

423:35

will found all of that code so now let

423:36

me just declare a variable um and I'm

423:38

going to just give of like Tech and it's

423:40

going to be equals to like I don't know

423:42

typescript right here so what I did is

423:44

that I just declare a variable right

423:46

here if I H my mouse over to it so what

423:49

are we getting we are getting this

423:51

annotations right here let me just

423:53

highlight that for you here you can see

423:55

we are now getting this annotation right

423:57

here by default so now let me just log

424:00

that to the console and see what's going

424:01

to happen happen and I'm going to just

424:02

write tag and now let me just log that

424:04

to the console and you probably already

424:06

know like uh which kind of fre oh I

424:08

forgot to sve the file now let me just

424:10

save that and rerun that and here you

424:12

can see we are now getting the type of

424:14

typescript right I mean like the value

424:16

of typescript right here now let me just

424:18

check the type of this Tech right here

424:20

semi file and rerun that it's going to

424:22

gives us a string right here cool that's

424:25

amazing but now let's suppose if I

424:27

provide like some other value to it like

424:29

I don't know maybe um I'm going to

424:32

provide some sort of like 12 variable or

424:34

something like that if I have my mouse

424:35

over to it it's going to give us an err

424:38

it's going to say like type number is

424:39

not assignable to a string right here

424:42

this is not allowed because you are

424:44

currently working with a typescript not

424:46

a JavaScript but if you are using like a

424:48

JavaScript now let me just change that

424:49

to the JS right here you already know

424:52

it's not going to gives us any errors or

424:53

anything like that let's just remove

424:55

that save my file and run there it's

424:57

going to give us 12 right here but on

424:59

the other hand if we change that to TS

425:01

just to that anyway so if I just run

425:03

this uh code right here it's going to

425:05

throw us a beautiful error saying like

425:07

um type number is not assignable to a

425:09

type string right here and amazing you

425:12

already know that now let me just infert

425:14

some other value like I don't know F

425:16

number or something like that and it's

425:18

going to be equal to 8 and now if you

425:20

sell them and if I hold my mouse over to

425:22

it so here you can see what are we

425:24

getting we are getting The annotation of

425:26

number right here so it will

425:28

automatically invert the value of number

425:31

so if I try to change the value of to

425:33

like something else like I don't know

425:35

string so here you can see it's going to

425:37

give us an error and you already know

425:39

why now let me just remove that and now

425:41

let me just create also is or not is but

425:44

TS hard and it's going to be equals to

425:46

like true now let me just sa there if I

425:48

H my mouse over to it it's going to give

425:50

us The annotation of Boolean right here

425:53

so it's going to infert the value of

425:54

Boolean you can say like that now let me

425:57

just duplicate them and change that to

425:59

Fair number and I'm going to also

426:01

provide the TS hard word here sa my file

426:03

and run them come on save my file and

426:06

run them and here you can see we now

426:08

getting typescript and and also true

426:10

right here now come on let me just write

426:13

a type off and save my file and run that

426:16

come on you can't see I'm sorry I'm

426:19

doing that again and again but I have to

426:21

so the first value we are getting a

426:22

number I me like string and the second

426:24

one we are getting a number and the

426:25

third one we are getting the Boolean

426:27

word here so that was a type inference

426:29

or infering the type how however you

426:31

want to pronounce that in typescript so

426:33

now let's talk about one of the o one of

426:37

the I canone say it but yeah one of the

426:40

weirdest type in typescript which is

426:43

called any type so what is the any type

426:46

and why you should care about there so

426:47

time script has a special yeah Special

426:50

so time script has a special any type

426:52

that can be used to represent any type

426:55

so like let's suppose when a variable is

426:57

annotated with any type typ script will

426:59

allow it to have any value and disable

427:02

all the type checking for that variable

427:04

and its properties yeah that's totally

427:06

awful like why on Earth we would use a

427:09

typescript uh if you want to provide the

427:11

any type so now let me dig into this

427:13

Rabbit Hole a bit more so warning while

427:16

the any type can be useful in certain

427:18

situation yeah obviously uh it should be

427:22

used sparingly um or use of any can

427:25

leate to un type code and make it harder

427:27

to catch type related bugs during the

427:29

development and it's certainly better to

427:31

use a specific type whenever possible to

427:33

get the benefits of typescript type

427:35

checking yep there we go so how that's

427:38

going to look like well you don't have

427:39

to do nothing but you just have to

427:41

declare variable and provide the any

427:43

type to it and you can provide like I

427:45

don't know the type of number the type

427:48

of string the type of whatever you want

427:50

you can even um you can even call it as

427:52

a come on you can even call it as a

427:54

function right here you can provide the

427:56

two uppercase and all of that stuff and

427:58

then St the oful the any type can be in

428:02

some situation useful but not all the

428:04

time and be aware of that and here you

428:07

can see I mentioned that in this slide

428:09

so I want you to always keep that in

428:10

mind and now let's get into the coding

428:12

so I'm going to just remove all of that

428:14

stuff from here and I'm going to just

428:15

declare a variable called colors and I'm

428:17

going to provide or annotate that with

428:19

the any right here and I'm going to just

428:21

set that to Crimson or anything like

428:23

that now let me just log that to the

428:25

console like you already know what it

428:26

will give us in return so here you can

428:28

see we are now getting the color of

428:30

crimson obviously and now let me just

428:32

provide something else uh like I don't

428:34

know color of 20 and now if I sell them

428:37

and rerun there and run that and here

428:40

you can see it's going to give us 20

428:42

right here we can also provide like uh I

428:44

don't know we can provide anything we

428:46

want I'm going to just change that to

428:47

like uh I don't know true we can provide

428:50

uh I don't know let me just call that as

428:51

a function you know I'm going to just uh

428:53

comment this line out let me just sell

428:55

that and rerun that and here you can see

428:57

it's kind of gives us true right here

428:59

but now let me just call that right here

429:01

say my file and run this file once again

429:04

and here you can see it's it's going to

429:06

obviously gives us an a like uh color is

429:09

not a function or an object right here

429:11

so here you can see it's going of gives

429:12

us an error it's not going to gives us

429:14

any error inside our editor but once we

429:16

run this code it's going to give us an

429:18

error right here and that any is the

429:21

most awful type you can ever find on

429:23

typescript right here if you change that

429:25

to something else like I don't know if I

429:27

just um provided annotation of string

429:29

right here it's going to gives us an

429:30

error here you can see if I have my

429:32

mouse over to it so type number is not

429:34

assignable to the type string and also

429:36

type bu is also not assignable to a

429:38

string if I hold my mouse over to it so

429:40

this expression is not callable type

429:42

string has no call signatures okay so

429:45

yeah that was it about for the type any

429:48

and I already show you the slides so now

429:51

let's learn about a function parameters

429:52

anotations in typescript so function

429:54

parameter annotation in types scrip are

429:56

used to specify the expected types of a

429:58

parameters that a function should take

430:01

okay so how that's going to look like

430:03

this is how it's going to look like

430:04

right here you don't have to do nothing

430:06

but here you just have to annotate the

430:08

perimeter of your function to some

430:10

something right here like which type of

430:12

data this parameter should be taking

430:14

like in this case uh we are currently

430:16

adding a number so here you can see we

430:17

are now providing this number as

430:19

perimeter and we are inating that with

430:21

the number right here and then we would

430:22

be able to perform this operation uh

430:25

that was string so then we won't be able

430:26

to provide uh This plus right here and

430:28

it's going to gives us an error and this

430:30

is a regular function flavor and this is

430:32

the error function flavor right here

430:34

okay so if you have like multiple uh

430:36

perameters you can also annotate there

430:38

right here like X and uh anot with

430:40

number and also we have y and anot there

430:43

and this is how we can work with the

430:44

function perimeter annotation with a

430:46

regular function and also for the error

430:48

functions as well so now let me just

430:49

write some code and then you will get to

430:51

know what I'm talking about so first of

430:52

all we going to be inating the regular

430:55

function right here okay so I'm going to

430:57

just create a function I'm going to give

430:58

a name of like add one and here you can

431:01

see see my ID automatically provide a

431:02

type for that so I'm going to just

431:04

provide a num and we are going to be

431:06

annotating that with a number right here

431:08

okay so inside that I'm going to just

431:09

return the numb plus one and now let me

431:12

just create some sort of res like con

431:13

resin it's going to be equals to like

431:15

add one and now let me just provide a

431:17

three or something like that now let me

431:19

just log that to the console go back and

431:21

run that come on uh run that once again

431:25

and here you can see it's going to gives

431:27

us four right here why is that oh why on

431:30

Earth oh there we go because we are

431:32

providing one to it here we are

431:33

specifying three this number is going to

431:36

tag that three and we are just adding

431:38

this one right here so it's going to

431:40

give us four anyway so if I just change

431:42

that to string let me just change that

431:43

to string and here you can see if I have

431:45

my mouse over to it it's going to give

431:47

us this um error right here let me just

431:49

highlight that for you argument of type

431:51

number is not assignable to the

431:53

perimeter of a type string okay so it's

431:56

going to obviously gives us an error and

431:58

there we go now let me just provide a

432:00

Boolean I want to show you single thing

432:02

and it's going to also gives us an error

432:03

if I hold my mouse over to it so

432:05

operator plus cannot be applied to a Ty

432:07

Boolean a number um and here you can

432:10

also see that same error now let me just

432:12

change that to like um number once again

432:15

and there we go and now let me just show

432:17

you for the arrow functions as well so

432:19

Arrow functions or Funk would be fine

432:23

rather now let me just sell them and yep

432:26

so now let me just create a double

432:27

function and it's going to take two

432:29

parameters the first one is going to

432:30

take is for x and it's going to also

432:33

take the Y as well come on let me just

432:34

proide a comma and Y and we are going to

432:37

be just providing like x * y right here

432:40

and now if I just log that to the

432:41

console like double or you know I'm not

432:43

going to log that to the console I'm

432:44

going to just write conso res and it's

432:45

going to be equals to double and I'm

432:47

going to provide like two and 10 right

432:49

here okay so if I hold my mouse over to

432:52

it so it's going to give us like

432:53

perimeter X implicitly has the any type

432:57

right here by default as I said that you

432:59

got to keep that in mind mind so here

433:02

you can see it's going to give us like

433:03

by default the type of any because time

433:06

script do not know which kind of data we

433:08

are going to be specifying it for this

433:10

parameter right here like either we are

433:12

going to be providing the number or we

433:14

are going to be providing some sort of a

433:15

string or we are going to be providing

433:17

some sort of a Boolean or something like

433:18

that typescript don't have any idea what

433:21

we are going to be providing right here

433:22

inside a double so that's why the

433:24

typescript will by default provide the

433:26

implicit type of any rid here okay so

433:30

what I want to do is then I'm going to

433:31

just change that to uh number right here

433:33

so I'm going to just annotate that with

433:35

number and I'm going to also change this

433:37

one to number as well and this one is

433:39

going to giv us an error because we

433:41

redeclare uh block scope I didn't know

433:44

that now let me you know let's just or

433:47

you know I'm going to just comment this

433:49

line out and now uh let me just log

433:52

there to the console like res and now

433:54

let me just saell there go back run my

433:56

code and here you can see it's going to

433:58

gives us 20 right here why is that

434:00

because we are providing a two for the

434:02

first parameter and we are providing 10

434:04

for the second one so that's why we are

434:05

now getting two right here okay so this

434:08

is how the any Ty work this is how

434:09

you're going to be annotating your

434:11

function parameters right here oh I

434:13

forgot to show you something uh let me

434:15

just show you that right here let's

434:17

suppose if you provide more values than

434:19

we specified inside a perimeter uh

434:21

signature right here it's going to gives

434:23

us an error so also notice typescript

434:25

will give you a warning if you provide

434:27

more or less argument then you specify

434:29

in the perimeter area right here okay so

434:31

now let me just provide something like

434:33

uh I don't know it's going to take two

434:35

parameters like X and also the Y so I'm

434:37

going to just specify like uh I don't

434:39

know maybe 20 and here you can see it's

434:41

going to give us an error if I H my

434:43

mouse over to it it's going to give us

434:45

like unexpected two arguments but got

434:47

three or let's suppose if I just remove

434:50

both of them and we just provide one to

434:52

it if I have my mouse over to it

434:54

expected two arguments but got one right

434:56

here so it's going to gives us this

434:58

error as well so I want you to also keep

435:01

keep that in mind as well so now let's

435:03

talk about the default parameter values

435:05

in typescript so nowadays in JavaScript

435:08

we also have this feature available in

435:09

es6 like modern JavaScript we can

435:12

specify the default value to our

435:15

perimeter right here so if you want to

435:17

provide a default value for your

435:18

parameter in uh in a function by using a

435:20

typescript you have to annotate that

435:22

right here so you just have to provide

435:24

this annotation and you can specify any

435:26

value you want so in this case we're

435:28

just creating this function and blah

435:29

blah blah

435:31

yeah I know that was quick so now let me

435:32

just write some code because I don't

435:34

want to waste your time now let me just

435:36

write some code and then you'll get to

435:37

know what I'm talking about so now let

435:38

me just remove that and I'm going to

435:40

just create a function give a name of

435:41

like greed or something like that and

435:44

also I'm going to provide a person and

435:46

let me just remove that right here and I

435:48

want to set that to like I don't know

435:50

anus I don't even know how to spell the

435:53

anonymous but anyways now let me just

435:55

return like I don't know hello and

435:58

person right here okay and also I'm

436:00

going to just for cons rest and uh greed

436:03

and I'm not going to provide any value

436:04

for them let me just log this rest to

436:06

the console let me just go back and sell

436:08

my file so what do you think will be the

436:10

result if I run this file and hello

436:13

Anonymous right here which means like

436:15

this is working totally a okay if I have

436:19

my mouse over to it so what are we

436:20

getting we are getting the default

436:23

inferring in typescript right here so

436:25

person is now currently set to string so

436:28

that's what we are getting right here

436:29

like totally a okay but but if you want

436:31

to provide a specific annotation for

436:33

this person we going to be doing it like

436:35

so so I'm going to just provide my

436:36

separator and then I'm going to write my

436:38

string you can provide like number if I

436:40

just write number it's going to

436:41

obviously gives us an error it's going

436:43

to say like type string is not

436:44

assignable to a type number right here

436:47

let's just change that to string baby

436:49

let me just save that and rerun that

436:51

once again and hello Anonymous right

436:53

here but if I want to provide some sort

436:55

of value like hosan semi file it's going

436:58

to give us like hello hosan there we go

437:01

as I said like time script is not that

437:03

hard and we are almost there baby we are

437:06

almost there so now let's talk about the

437:08

return value anotations for a function

437:11

in typescript so what do I mean by that

437:13

so let's suppose in this function you

437:15

are going to be returning some sort of a

437:17

value so like in this case we are now

437:19

returning the number right here we're

437:21

providing the X and we are annotating

437:23

there by number so obviously we are

437:25

going to be returning some sort of a

437:26

number for this function so if you want

437:28

to annotate the return statement as as

437:31

well so for that outside from the

437:33

perimeter area you are going to be

437:35

providing your annotations right here

437:37

and then you can do whatever you want

437:39

okay so this is for a regular function

437:40

now let's talk about for the aror

437:42

functions as well so here you can see we

437:44

are just creating our double two and if

437:45

you want to annotate the perimeter value

437:47

so this is how you're are going to be

437:48

annotating that but if you want to

437:50

annotate the return value so for that

437:53

you are going to be writing syntax like

437:55

this right here so this one will be for

437:57

the return annotation and then you can

437:59

do whatever you want to do inside that

438:01

function and this is how you're going to

438:03

be logging there to the console so now

438:05

let me just write some code then you'll

438:06

get to know what I'm talking about so

438:08

first of all for the regular function

438:10

right here and I'm going to just create

438:11

a function give a name of like double

438:14

it's going to come on let me just do

438:16

that once again function and I'm going

438:18

to give a name of like double one right

438:20

here it's going to take the perimeter of

438:21

X and the type will be set to number

438:24

right here so for this function we are

438:26

going to be returning like X time x so

438:29

which means like we are going to be

438:30

returning the value from this function

438:32

if I have my mouse over today here you

438:34

can see the typescript will

438:35

automatically infer the value of number

438:38

right here we can also provide that by

438:40

ourselves so I'm going to just provide

438:41

the separator and I'm going to just

438:42

provide a number right here and there we

438:44

go so now let me just write con and it's

438:47

going to be equals to like double one

438:48

and in this case we are going to be just

438:50

writing two now let me just log this

438:52

rest to the console sa my file run it

438:54

it's going to give us four right here

438:56

now we are doubling uh the value of this

438:59

function so I know that's not not that

439:01

much difficult thing to learn but if you

439:02

want to annotate the return type uh I

439:05

mean like if you want to annotate the

439:07

return value so this is how you're going

439:09

to be doing that by using a regular

439:10

function and now let's talk about for

439:12

the arrow functions as well okay so let

439:15

me just create an arrow Funk and inside

439:17

there what do you want to do we just

439:18

want to create a double two and it's

439:20

going to be equals to like um it's going

439:22

to take some sort of a perimeter like X

439:24

and we're going to be annotating that as

439:25

a number and I'm going to just provide

439:27

like a number and it's going to take x *

439:30

X next there we go now let me just log

439:32

that double and provider two or

439:34

something like that let's just save that

439:36

and run that come on I just way zoomed

439:39

in okay so here you can see it's going

439:41

of gives us four and there we go this is

439:43

how you're going to be annotating the

439:45

return value which you are going to be

439:47

getting from this function sometime you

439:49

would know that and a lot of time you

439:52

don't so typescript will by default

439:54

infert the value right here but yeah you

439:58

get the idea so now let's talk about the

440:00

wide in typescript so what is a wide and

440:03

why you should care about that so wi is

440:05

a type that represents the absence of

440:07

any value so it is often used as the

440:10

return type for the function that do not

440:13

return any value okay so then we're

440:16

going to be using this wi okay and this

440:18

is how the code will look like so here

440:20

you can see we have this function which

440:22

is not returning something but we are

440:24

just logging like this is my message or

440:26

something like that to the console so

440:27

here we have to specify W right here you

440:30

don't have to do nothing but you just

440:31

have to specify this word and it's going

440:33

to do it for you okay so now let me just

440:35

write some code then you'll get to know

440:36

what I'm talking about I'm going to

440:38

delete all of that code I'm going to

440:39

create a function once again give a name

440:41

of like print message or something like

440:43

that it's going to take like a message

440:45

as a perimeter come on just a message

440:47

and we're going to be specifying the

440:49

string value to and you can in that with

440:51

anything you want and now let me just

440:53

console log some value like this is my

440:56

and let's just render or message right

440:58

here and now let me just write and

440:59

provide a message right here let me just

441:01

save that go back and run that come on I

441:04

got to do that manually and here you can

441:05

see uh this is my message right here

441:08

which is totally working if I hold my

441:10

mouse over to it so here you can see

441:12

what are we getting we are getting this

441:14

white right here why is that because for

441:17

this function we are not even returning

441:20

anything if I just write like return and

441:22

message and let's just close there and

441:24

if I hold my mouse over to it right now

441:27

it's going to inate there with a string

441:29

right here so we can ALS to do that

441:31

manually so we just have to write this

441:32

separator and white and here you can see

441:35

if I have my mouse over to it so we are

441:37

now getting white right here okay so

441:39

yeah this is aoide and you should avoid

441:43

because you should return some value

441:44

from your function so now let's talk

441:46

about the brother the sister the mother

441:49

or whatever you want to call that the

441:51

grandfather of any keyword so what are

441:54

we talking about we are talking about

441:56

the never resert keyword in typescript

441:58

so what is the never the never keyword

442:00

is is used to indicate that a function

442:02

will not return anything but trust me

442:05

it's totally different than the white or

442:07

that a variable can never have a value

442:10

the never type is useful for indicating

442:12

that a certain code path should never be

442:15

reached or that a certain values are

442:17

impossible it can help catch errors at

442:20

compile time instead of run time so how

442:22

on Earth we are going to be using the NK

442:23

keyword we are going to be using that

442:26

for three cases so like a function that

442:28

always throw an error we are going to be

442:30

using never keyword for that or a

442:32

function that has a infinite Loop we are

442:34

going to be using a never for that or a

442:36

variable that can never have any value

442:39

so for that we can use the never keyword

442:42

so now let me just give you the example

442:43

of that so now let's talk about the

442:45

function that always throw an error so

442:47

if you've already worked with a mer Stag

442:49

and specifically in the express JS and

442:52

I'm not assuming that you already work

442:53

with that but I'm going to just say like

442:55

for some of you if you already work with

442:57

a mer stack and specifically for the

442:59

express yes a middle words for um you

443:02

know what that's other story let's just

443:04

get the hell out you know what that's

443:06

just other story so here you can see we

443:08

now creating a function we are providing

443:10

some sort of a message to it and we are

443:12

now providing an error for that message

443:14

so for that we can annotate that with a

443:16

never resert keyword right here okay so

443:18

now let's talk about uh for the infinite

443:20

Loop so now in this case we are just

443:21

providing the infinite Loop so for that

443:23

we can also use the never Reser keyword

443:25

for like recursion or something like

443:28

that we can also use the never keyword

443:30

and by by the way this never keyword can

443:31

be rarely used in this kind of situation

443:33

like when we are throwing some sort of

443:35

error and I have never used that some

443:38

sort of a what do we call it for um

443:41

infinite Loop or something like that you

443:43

can also use it like a variable that can

443:45

never have a value so here you can see

443:47

we are declaring variable and we are

443:49

specifying or annotating there with the

443:51

never desert keyword right here and also

443:54

in this function we are providing the

443:55

infinite Loop so that's why we provide a

443:57

never Reser keyword and now this x is

443:59

going to be equal to this uh infinite

444:02

Loop function so this line will cause a

444:04

compile time error because the function

444:06

never returns so then uh it's going to

444:09

be equals to the never resert keyword

444:10

right here I know that sounds confusing

444:12

but now let me just write some code and

444:14

then you'll get to know what I'm talking

444:15

about and this one isn't that much use

444:18

but I want to include it in this course

444:19

anyways for some of you who cares about

444:22

it so I'm going to just write

444:24

through uh I don't know throw error

444:26

something like that I'm going to provide

444:28

a message and we are going to just

444:30

annotating that as a string and I'm

444:32

going to just Pro like throw new error

444:34

of message and we can annotate that with

444:37

never resert key right here and now if I

444:40

have my mouse over to it so here you can

444:41

see we are now getting the never um God

444:45

damn it if I have my mouse over to it so

444:47

here you can see we now getting the

444:48

never resert keyword right here okay so

444:51

yeah you can use that if you wanted to

444:52

now let me just give you another example

444:54

of infinite Loop so I'm going to just

444:56

write infinite or in fi come on in fi my

445:00

nit Loop and we're going to be just not

445:04

providing anything at all and I'm going

445:05

to just annotate that with the never

445:07

Reser keyword and inside that we are

445:09

going to be using the while and true if

445:12

that's true so we would get some sort of

445:14

infinite Loop and you already know all

445:16

of that stuff so I'm going to just write

445:17

let X and we are going to be annotating

445:19

there with the N Reser keyword and let

445:22

me just create some sort of a function

445:24

and

445:25

never uh returns will be fine we're not

445:28

going to be putting anything right here

445:30

and I'm going to just annotate that with

445:31

a new resert keyword and while true it's

445:35

going to gives us an infinite Loop and

445:37

we are going to be also providing the x

445:39

is equal to never returns and there we

445:41

go so now let me just go back so you can

445:44

use the never Reser keyword when you are

445:45

throwing some sort of error you can also

445:48

provide it for the function which uh

445:51

loop and you can also use it for a

445:53

variable who does not have any value

445:54

right here okay so that was a never

445:56

resert keyword in typescript so now

445:59

let's talk about arrays in typescript so

446:01

arrays are a type of object that can

446:03

store multiple vales of the same data

446:05

type okay so arrays in typescript are

446:08

type okay this is something which I'm

446:10

going to be discussing right now which

446:12

means you can specify the type of values

446:14

that an array can hold okay so yeah that

446:17

was just a basic definition of arrays in

446:19

typescript now let me just give you

446:20

example of that but before I do there

446:23

are two flavors of creating an array in

446:25

typescript so the first one is using a

446:28

bracket notation and the second one is

446:30

is using this kind of I don't know HTML

446:33

is HTML is kind of syntax right here

446:37

okay so now let me just show you the

446:38

first one which uses the bracket

446:40

notation so first of all we are going to

446:42

be creating our regular array right here

446:44

like we're going to be first of all

446:46

declaring our variable then we're going

446:47

to be storing some sort of values by

446:49

using a bracket notation but if you want

446:51

to infert that first of all we are going

446:53

to be using the separator then we are

446:55

going to be providing some sort of a

446:56

type like which type of data this

446:59

variable or this array is going to be

447:01

holding it's going to be holding the

447:03

arrays of numbers right here but if we

447:05

try to provide like I don't know strings

447:07

or booleans or uh function SC or objects

447:10

or something like that it's going to

447:11

throw us an error something which I'm

447:13

going to show you in a few seconds and

447:15

this one is the second syntax of

447:17

creating an array uh inside a typescript

447:20

and this one is totally old nobody use

447:23

this syntax anymore okay so yeah this is

447:25

how you're are going to be creating an

447:26

array in typescript so now let me just

447:29

give you example of that then you'll get

447:30

to know what I'm talking about so now

447:32

let me just remove all of that code

447:33

right here so now let me just create a

447:35

nums variable or nums variable like so

447:38

and I'm going to just annotate that with

447:40

the number of arrays right here and it's

447:42

going to be equals to uh some sort of a

447:44

number like I don't know one two 4 six

447:46

or whatever you want to call that now

447:48

let me just log this nums to the console

447:51

right here sa my file go ahead and run

447:53

that it's going to give us like 1 2 4 6

447:56

and all of that data which we are

447:57

already specifying it inside this area

448:00

right here now let me just get into it

448:02

let's suppose if I just specify

448:03

something else like I don't know if I

448:06

want to provide like string so string on

448:09

string and if I want to provide some

448:10

sort of other value like true or

448:12

something like that it's going to gives

448:13

us an error why is that because

448:16

currently we are specifying like this

448:18

array should hold the numbers array only

448:21

numbers nothing else later we are going

448:23

to be also learning about this operator

448:26

but we are not there yet so we are not

448:27

going to be discussing that right now so

448:29

if i h my mouse over to it so type

448:32

string is not assignable to the type

448:33

number right here if I H my mouse over

448:35

to this one so type Boolean is not

448:37

assignable so type number right here so

448:40

we will get an error right here let me

448:42

just remove them and this one was a

448:44

first Flav or you know what let me just

448:46

also give you example of strings as well

448:48

so stir and I'm going to annotate that

448:51

uh with string right here and it's going

448:53

to be equals to like I don't know one

448:55

two or something like that three maybe

448:58

now let me just log that to the console

448:59

like you already know what it really

449:01

gives us but now let me just run there

449:03

anyways it's going to give us like

449:04

arrays of uh strings like one two and

449:07

three right here so yeah that's the

449:10

first flavor now let me just uh comment

449:12

or you know let me just delete that disc

449:13

code right here or you know let me just

449:15

leave that right here and let's talk

449:17

about the second flavor uh of creating

449:19

an array so before I get into the second

449:23

flavor uh I'm going to just uh show you

449:26

something right here you know first of

449:28

all let me just create an empty array so

449:30

items and it's going to be equals to

449:32

string and we are not going to be

449:33

providing anything right here let's

449:35

suppose if you want to push item to this

449:37

array so I'm going to just write like

449:38

items. push you already know what push

449:40

will do push will just insert an element

449:43

at the end of this array so I'm going to

449:45

just proide like I don't know keyboard

449:47

or something like that and now if I log

449:49

these items to the console what do you

449:51

think will be the result if I save this

449:52

file and push that item right push that

449:55

item but run that file right here so

449:58

it's going to gives us the keyboard

449:59

right here which is totally working a

450:01

okay but if I just duplicate that and if

450:04

I just proide like I don't know 12 or

450:06

something like that and now if I just

450:08

run my code it's going to obviously

450:10

gives us this error right here it's

450:12

going to say that um come on uh argument

450:16

of type number is not assignable to the

450:18

perimeter of type string right here so

450:21

it's going to gives us an error so time

450:23

script is supremely strict and it

450:25

already knows every single thing right

450:27

here okay so it already know knows the

450:30

types that's why it is called the

450:32

typescript baby welcome to the

450:34

typescript words so you cannot do that

450:37

crazy stuff which you used to do in the

450:39

regular JavaScript okay so that's then

450:42

and what I want to do is then you know

450:44

let me just give you one more example of

450:45

a numbers because I know some people

450:47

will say like Huzan will it work for the

450:50

numbers as well or will it work for the

450:52

array and something like that yeah

450:56

it excuse me all righty so now let me

451:00

just write a number that was a horrible

451:02

Voice by the way and it's going to be

451:03

equals to this array right here and I'm

451:05

going to just write number of list and

451:07

let me just push like 20 it's going to

451:09

obviously work now let me just write

451:11

number of list s this file

451:13

and come on H we don't have a lot of

451:17

time and we are now getting 20 that's

451:19

cool but let's suppose if I just

451:21

duplicate there and try to provide true

451:23

right here and I'm providing the

451:25

positivity but we are now getting the

451:27

negativity right here argument of type

451:30

Boolean is not assignable to the

451:31

perimeter of number cool okay so it's

451:34

going to give us that error let me just

451:35

show you that and there we go you got

451:37

your own favorite error which is

451:39

argument is blah blah blah so yeah

451:42

that's then now let me just show you the

451:43

alternative syntax of creating an array

451:45

in typescript which is not deprecated

451:48

yet but I'm going to show it to you

451:50

anyways if you want to create an array

451:52

by using the I don't even know what to

451:54

call this synex but I'm going to just

451:56

call it like HTML kind of synex I'm

451:59

going to just WR item or items and it's

452:01

going to be equals to first of all we

452:03

have to write this array and inside

452:05

there we are going to be writing or

452:06

annotation like string in this case and

452:08

now it's going to be equals to this uh

452:11

array right here so let's suppose if I

452:13

just um I don't know let me just log

452:15

that to the console oh we are getting an

452:18

error why is that oh that's because we

452:20

providing the equal to sign right here

452:22

we have to annotate there and now if I

452:25

just copy these items put it right here

452:27

it's not going to gives us anything

452:29

because this is totally empty okay so

452:31

now let me just run that it's not going

452:33

to gives us anything it's going to gives

452:34

us the empty array because we did not

452:37

store anything inside there if you want

452:39

to create one for the numbers as well so

452:41

you can just put numbers and now let me

452:43

just save that and let me just put like

452:46

I don't know one two or come on four or

452:49

something like that let me just save

452:51

that and run my file so here you can see

452:53

we now getting the numbers array but

452:55

let's suppose if I try to provide

452:57

something like string and also the

453:00

Boolean and also let me provide the

453:02

object or something like that and it's

453:04

going to obviously gives us an if I out

453:06

my mouse over to so type object is not

453:09

assignable to the type number right here

453:11

okay so this one is the second flavor of

453:14

creating an arrays in typescript so now

453:16

let's talk about a multi-dimensional

453:18

arrays or you can also call it Matrix or

453:20

you can also call it the nested arrays

453:23

if you want it to so for the sake of

453:25

this lecture I'm going to call it a

453:26

multi-dimensional array and you can call

453:28

it whatever you want to call it So What

453:30

on earth is a multi-dimensional arrays

453:31

and why you should care about that so A

453:33

multi-dimensional array is an array that

453:36

contains other arrays as its elements so

453:39

multi-dimensional array can be defined

453:41

using the same notation as

453:42

onedimensional arrays but with nested

453:45

square brackets baby so how that's going

453:48

to look like this is how it's going to

453:49

look like so here you can see if you

453:52

want to annotate that so we are going to

453:53

be just providing a number one bracket

453:55

and also another bracket as well and

453:57

inside there we're going to be creating

453:59

our next array or multi-dimensional

454:01

array right here so now let me just

454:03

write some code for that and then you'll

454:05

get to know what I'm talking about so

454:06

now let me just remove there and I'm

454:08

going to just go ahead and create a

454:09

single die like single dimensional array

454:12

and I'm going to just create a number

454:14

and annotate that as a number right here

454:16

come on I should annotate that I always

454:18

forget that and now let me just write

454:20

like one two three four five or

454:23

something like that now let me just

454:24

create a two-dimensional or

454:26

multi-dimensional array so I'm going to

454:28

just write const and mult uh

454:31

multi multi-dimensional array and it's

454:33

going to be equals to number and let's

454:35

just provide two pair of brackets right

454:37

here and it's going to be equals to like

454:39

arrays and you can provide ENT and

454:41

provide you a n array like there but in

454:43

my case I'm going to just provide one

454:44

more array right here like one two and

454:47

three come on four and five like this

454:49

one and now let me just create one for

454:51

the Triple dimensional array so

454:54

triple and it's going to be equals to

454:56

number and let's just provide three

454:58

pairs of brackets right here I know you

455:01

guys won't go that much crazy but I'm

455:03

going to just show you the syntax

455:04

anyways so we have array then inside the

455:07

array we have yet another array and now

455:09

inside this nested array we have yet

455:12

another nested array right here okay so

455:14

let's just provide one two 3 four five

455:18

if you are coming from the linear

455:20

algebra stuff so you already know all of

455:22

that syntax uh anyways you don't even

455:24

have to know a linear algebra in

455:26

mathematics so now let me just write a

455:28

console log of single D let's just

455:30

duplicate that three times and multi-

455:32

die and we also have for the Triple come

455:35

on not this one uh triple die right here

455:38

and now let me just save that and let's

455:40

just run that baby it's going to give us

455:42

first of all the single Dimension array

455:44

it's going to give us the Double Di or

455:46

multi-dimension whatever you want to

455:47

call that and finally it's going to

455:49

gives us the um triple Dimension or

455:52

whatever you want to call that so yeah

455:54

that was it about for the

455:55

multi-dimensional arrays in typescript

455:58

so now let's talk about objects in

455:59

typescript so an object in typescript is

456:01

a structure data type that represents a

456:04

collection of properties each with key

456:06

and Associated values the properties of

456:08

object can have a specific type and the

456:11

object itself can be annotated with a

456:12

type often defined using an interfaces

456:15

or type aliases both we did not learn

456:18

yet like we didn't learn the interfaces

456:20

and also the type aliases not right now

456:23

but we are going to be learning there in

456:25

a few seconds so typescript uses

456:27

something called a structural I and say

456:30

this for structural typing meaning the

456:33

shape of an object is structure or

456:35

properties is what matters for the type

456:38

comparability so how the syntax of

456:40

object will look like this is how the

456:42

syntax of object will look like and I

456:44

know a lot of people will say like oh my

456:46

God hus what the hell is that I don't

456:47

even know what the hell is going on but

456:49

first of all like just creating a

456:51

variable right here and and here we have

456:53

to specify The annotation and also a

456:55

specific TI for The annotation it's

456:58

going to be equals to the property and

456:59

can value so how that's going to look

457:01

like this is how it's going to look like

457:03

right here so first of all we are just

457:05

creating our variable right here and

457:07

then we are providing a property and

457:09

also annotation for that uh property

457:11

right here and then we are providing the

457:14

equal to sign and here inside there we

457:16

are providing our first property like

457:18

what we are going to be returning or

457:20

like which kind of data or which type of

457:22

data we are going to be storing inside

457:24

this person right here okay so in this

457:26

case we are just returning like first

457:28

name String last name String and also

457:29

the edge so you have to provide that

457:32

properties and it values right here

457:34

inside this person object right here so

457:36

now let me just give you a quick example

457:38

of that or you know what uh I also want

457:40

to show you the this one right here oh

457:42

you know let's just say that okay so you

457:44

can also provide a return value for the

457:46

function like let's suppose for some

457:48

function like if you already know the

457:50

factory function from my JavaScript

457:52

course I mean like you don't have to

457:54

know that but if you already know what a

457:56

factory function is from my course so

457:58

you already know uh what's going on

458:00

right here but now let me just explain

458:01

it for those who don't know what's going

458:03

on so here you can see we are just

458:05

creating a function a regular function

458:06

right here and I want you to do not pay

458:08

attention to this type right here not

458:10

for now so we are just creating a

458:12

function right here inside this function

458:14

we are just returning an object so

458:16

inside this object we have a name Alex

458:18

age 19 and location United States of

458:21

America so now if you want to return

458:23

this object from this specific function

458:24

right here so we can also provide this

458:27

annotation uh or what whatever you want

458:29

to call that for the return value right

458:31

here okay so this is known as a factory

458:33

function if you guys know it cool if you

458:36

don't know it cool too so yeah now let

458:39

me just write some code and then you'll

458:41

get to know what I'm talking about okay

458:43

so I'm going to just remove that and

458:45

first of all define a person object oh

458:48

you know let's just remove that let me

458:50

just do that right away so person is

458:51

going to be equals to uh this annotation

458:54

first of all so what are we going to be

458:55

storing inside this object we are going

458:58

to be storing the first name right here

458:59

and now let's just provide uh the type

459:01

of string right here and we are not

459:03

going to be providing a comma in this

459:04

case we are going to be providing uh I

459:07

don't even know what to call this one

459:09

semicolon there we go and last name and

459:12

I'm going to also provide a string and

459:13

provide a column and also the edge and

459:16

the edge will be set to number let me

459:17

just go back and then we are going to be

459:20

providing the equal to sign and inside

459:22

there we are going to be just writing

459:23

our brackets right here so here we have

459:25

to specify these values right here like

459:27

for the first name it will be set to

459:29

John last name will be set to D and Edge

459:31

will be set to 30 right here okay so now

459:34

if I want to access that so now let me

459:35

just write cons log of I know name will

459:38

be now coming from the person. first

459:40

name and we can also get uh what do we

459:43

call it person do last name and we can

459:46

also get the edge right here Edge there

459:49

we go person. edge and now let me just

459:52

save that and run there right here so

459:55

what are we getting we are now getting

459:56

the name John do and we are also getting

459:58

the edge which will be set to 30 right

460:00

here but now let's suppose if I just

460:02

remove that edge right here so now if I

460:04

have my mouse over to it so it's going

460:06

to give us this error right here it's

460:08

going to say like property Edge is

460:10

missing in the type this definition

460:12

which we are already providing right

460:13

here but required in the type um

460:16

annotation right here so you have to

460:18

specify that edge right here which we

460:21

which we remove it inside this

460:23

definition right here okay so you have

460:25

to specify their Edge otherwise going to

460:27

throw you their error and now let me

460:29

just show you how this error is going to

460:30

look like so now let me just run that

460:32

and it will give you that same error

460:35

message right here as well if you

460:36

specify some sort of a signature right

460:38

here then you have to provide all of

460:40

that values for that signature so now

460:42

let me just write 10 and there we go so

460:45

that was for the object literal

460:47

notations and now let's talk about for

460:49

the function parameters as well so now

460:51

let me just create a function I'm going

460:53

to give a name of like uh print user or

460:55

something like that and it's not going

460:57

to take any perimeter or anything like

460:58

that and for the return value what I

461:01

want to do is that I'm going to just

461:02

provide this same you know what I don't

461:04

want to copy that let me just type that

461:07

because I know some of you will say like

461:09

who then you just copy and paste the

461:10

code so yeah that's now let me just

461:13

write Edge and Ed is going to be set to

461:14

number we are getting some sort of error

461:16

but I don't know why let's just put a

461:18

number and there we go and I

461:21

forgot something on what's up a function

461:23

whose declared types is neither

461:26

undefined void nor any must be returned

461:29

C the H on man we are just returning

461:32

this type right here and there we go oh

461:35

what's up type object is missing the

461:37

following properties just give me a

461:39

break brother I don't even finish typing

461:42

and you throwing me some sort of random

461:44

errors and now let me just write name of

461:46

hosan and I'm going to also provide the

461:49

edge of 20 and also the location will be

461:53

yeah yeah Chinese hosan I'm going to

461:56

just provide China right here Chinese

461:59

and woohoo and now let me just log that

462:01

to the or you know I don't want to log

462:02

there let's just write cons res and

462:05

print user and we're not going to be

462:07

specifying anything to it but I'm going

462:09

to just write res let's just save there

462:11

baby and run there and come the hell on

462:15

run that once again and we are now

462:16

getting the name of hosan age of 20

462:18

location of China there we go baby so

462:22

yeah this is how we are going to be

462:23

providing a signature for the return

462:25

value of a function and this is how we

462:27

are going to be annotating uh or object

462:30

right here okay and I'm pretty much sure

462:34

that I did not forget anything so now

462:36

let's get into the type aliases so now

462:38

let's talk about a type aliases in

462:40

typescript so a type Alias is a way to

462:43

create a new name for existing type and

462:45

it allow you to define a custom type

462:47

that refers to another type and give it

462:50

a more meaningful or descriptive name

462:52

and a type aliases are defined using the

462:54

type resert keyword followed by the name

462:57

of the Alias and equal to sign and the

462:59

type it refers to so this is how the

463:01

syntax will look like and how we are

463:03

going to be writing that in a real word

463:05

example this is how it's going to be

463:07

looking like so here you can see first

463:08

of all we are providing the type resert

463:11

keyword and this type resert keyword is

463:13

a special keyword like you have to

463:15

specify the type uh keyword whenever you

463:17

are creating a custom type and then we

463:19

are giving the name of like person you

463:21

can give banana you can give any name

463:23

you want and it's going to be equals to

463:24

this object and inside there we can

463:26

specify our properties and a spef

463:29

specific types for their properties

463:30

right here so like we don't have to no

463:32

longer do this stuff again and again so

463:34

in this case we are just uh providing a

463:36

name and it will be now set to string

463:38

and then we are creating an edge and we

463:39

are providing a number for that and also

463:41

for location we don't have to do that

463:43

again and again we can just create a

463:45

person type or a custom type whatever

463:47

you want to call that and then we will

463:49

be able to use it right here and here

463:50

you can see we can also use that for the

463:52

object itself and even in the definition

463:54

I already told you that you can create

463:57

interfaces or type alias

463:59

so now they we learn about type aliases

464:01

so we are going to be learning about

464:02

interfaces in a few seconds which are

464:05

more powerful than type aliases but we

464:07

are not there yet okay so now let's get

464:09

into the type alas is code so now let me

464:12

just remove all of that code right here

464:14

and I want to define a custom type so

464:16

I'm going to just give a name of like

464:18

user in this case and inside this user

464:20

we are going to be providing a name of

464:21

string I'm going to also provide the

464:23

edge of number and I'm going to also

464:25

provide a location of string as well you

464:28

can provide array as a location but yeah

464:31

uh anyway so now let me just create some

464:33

sort of a function cons print user info

464:36

or something like that and it's going to

464:37

take the user and here we are going to

464:40

be providing our type alas or you can

464:42

say a custom type whatever you want to

464:44

call them so we are now providing like

464:46

all of that types as a perimeter right

464:48

here okay so it's going to be equals to

464:50

this function and inside there if I just

464:52

write return and if I just write name uh

464:55

and if I just write like user.name in

464:58

this case if I H my mouse over to there

465:00

so what are we getting we are getting

465:02

the user and annotated with the user

465:05

type right here okay so that's why we

465:06

are now successfully able to get this

465:08

name from this user right here and we

465:10

can also provide the what do we call the

465:12

edge or you know let's just wrap there

465:14

with some sort of a parenthesis so that

465:16

we get an amazing output I'm going to

465:18

also provide Edge and inside there we're

465:21

going to be using the user. edge and

465:23

also let me just write for the location

465:25

as well so uh let's just write come on

465:29

was then you can do that let me just for

465:31

user. location and there we go okay so

465:33

now finally let's just go back oh my God

465:36

what the hell am I doing okay so now fin

465:39

let's just go back and create a result

465:41

and result is going to be equals to like

465:42

print info or print user info right here

465:45

and inside there we're going to be

465:47

providing the name and the name will be

465:48

set to Alex and I'm going to also

465:50

specify the edge and the edge will be

465:53

now set to 20 or something like that and

465:57

let me just also provide I don't know

465:58

location or something come on I like

466:01

that location and location is going to

466:02

be equals to United State of America and

466:07

string is not

466:08

assignable oh it's because I'm providing

466:10

a string right here uh I shouldn't be

466:13

doing that and now let me just log the

466:15

rest to the console and there we go I'm

466:17

going to save this file and run that and

466:19

we are now getting the name of Alex we

466:21

are also getting the edge of 20 and we

466:23

are also getting the uh location of

466:25

United State and yeah this is how we are

466:27

going to be defining or custom type

466:30

Alias and this is how we are going to be

466:31

using the inside a function so we are

466:33

not just limited to use these types

466:35

inside of functions later we are going

466:37

to be using it for a different kind of

466:39

things but for now uh I want you to just

466:41

keep in mind the syntax of how to create

466:43

a type aliases in type script right here

466:45

so it's like not that much difficult

466:47

thing to remember you just have to

466:49

remember this type and the rest is

466:51

totally object right here and the

466:52

convention is to make it the upper case

466:55

like the first letter you should make

466:56

the upper case for here let me just

466:58

change that to I guess it's going to

466:59

give you an error if you just change

467:01

that to lower case nope it's not going

467:03

to give you an error the convention is

467:05

to use the upper case but you can go

467:07

with lower case as well and I just

467:09

learned that so now let's talk about

467:11

optional properties in typescript so you

467:12

can make a certain property optional in

467:14

an object type by just adding a question

467:17

mark after the property name for example

467:19

let's say you have object type of an

467:22

person like name aged and email but you

467:24

want to make the email property optional

467:26

so you can just provide like question

467:27

mark and that would be totally optional

467:30

so here you can see in this example we

467:31

are just creating our uh type Alias

467:34

right here so we have a name property we

467:35

also have the edge and let's suppose if

467:38

you want to make the email property

467:39

optional so for that we just have to

467:41

write this question mark and it's going

467:43

to make it totally optional so how in

467:45

the world we are going to be using there

467:47

this is how we are going to be using

467:48

there so now when you create an object

467:50

of type person you can choose whether or

467:52

not to include the email property like

467:54

it's toally on you if you want to

467:55

provide it you can if you don't want to

467:57

provide it you don't have to okay

467:59

because we already make the optional

468:01

right here inside or type right here so

468:04

now in this example the endless object

468:05

does not include the email property

468:07

while the bomb object does because the

468:09

email property is marked as an optional

468:11

in the person type definition it is

468:14

valid to create an object with or

468:16

without it there we go so now let me

468:18

just give you a quick example of that

468:20

and then you'll get to know what I'm

468:21

talking about so now let me just remove

468:22

all of that code from here and I'm going

468:24

to just create a type of user and inside

468:27

that oh I forgot to include equal to

468:29

sign and inside that we're going to be

468:30

giv name of like some name and it's

468:33

going to be set to string and we're

468:34

going to be also providing Edge and Edge

468:36

will be set to number and I'm going to

468:38

also provide a location of string as

468:40

well but now in this case I want to make

468:43

this Edge totally optional so I can just

468:45

provide a question mark right here or

468:47

you can also say uh optional property

468:50

whatever you want to call that and now

468:52

it's toally on us if you want to provide

468:55

uh this Edge right here so we totally

468:57

can if you don't want to provide this

468:58

Edge we don't have to so now let me just

469:01

create a user object and the type I'm

469:03

going to provide this uh user type right

469:05

here and inside that we're going to be

469:07

using like the name and the name will be

469:08

set to my own name and I'm going to also

469:10

specify 20 right here and I'm going to

469:12

also specify the

469:14

location the location of China yeah

469:17

there we go and now let me just go ahead

469:19

and log there to the cons and by the way

469:21

I really love China really want to go to

469:23

China sometime but I don't have enough

469:26

money to visit to some other country so

469:28

yeah that's that anyway so now let me

469:30

just create a name right here and I'm

469:33

going to just write like username and

469:35

I'm going to just write Edge and here

469:37

I'm going to just write like user. Edge

469:40

and also for the location I'm going to

469:42

just render like user. location right

469:44

here okay so I'm going to go back and

469:46

now let me just saell that and run my

469:48

code so you will get to see the result

469:50

in a few second if I rerun that once

469:52

again here you can see name is set to

469:54

husan Edge is set to 20 location is set

469:56

to China but now let's suppose if I want

469:58

to remove this Edge right here if I just

470:01

remove that save my file and here you

470:03

can see inside our coder we are not

470:05

getting any errors but if I just rerun

470:07

that and here you can see we are not

470:09

even getting any errors right here

470:11

instead we are getting undefined like is

470:13

requiring some property I mean like we

470:15

are providing some property right here

470:17

but which is currently undefined like we

470:19

did not Define that so that's why we are

470:22

now getting undefined rather than some

470:23

sort of error okay so let's suppose if I

470:26

just remove this question mark from here

470:28

so here you can see instantly we are

470:30

getting this error if I hold my mouse

470:31

overr so the property Edge is missing in

470:34

the type this definition but requireed

470:36

inside the user here you can see it is

470:39

requiring there we are not providing

470:41

there so that's why it is now throwing

470:42

us this error but if I just make that

470:45

optional we don't have to do anything

470:47

okay so yeah I'm going to just leave

470:49

this code the way it is and then was

470:51

there about for the optional properties

470:52

in typescript so we are already here so

470:56

now let me just talk to you about one

470:58

other property which is called the read

471:00

only property and I did not make a slide

471:02

for that because this is totally simple

471:05

and easy so yeah that's why I didn't

471:07

make a slide for the SNM suggest that it

471:09

will make our property read only which

471:12

means like we can only read this

471:13

property but we cannot change the value

471:15

of that so here you can see we make this

471:17

property read only we are setting that

471:20

to China but let's suppose if I have

471:22

like uh user. location and you want to

471:25

set that to something else right here so

471:27

we are already getting this error if I H

471:29

my mouse over to it so cannot assign to

471:31

the location because it is read only

471:34

property right here okay so you just

471:36

have to keep that in mind on the other

471:38

hand if I want to change the name so I'm

471:40

going to just write like name and here

471:42

you can see we're not getting any errors

471:43

whatsoever but we make this one read

471:46

only so that's why if we try to uh

471:49

change the value of that so it's going

471:50

to give us an error so now let me just

471:52

change that to location or something

471:54

else and if I just run that it's going

471:56

to gives us that beautiful error it's

471:58

going to say like cannot assign to the

472:00

location because it is a readon property

472:02

so you just have to keep that also in

472:06

mind so now let's talk about

472:07

intersection types or intersection types

472:12

in time script but I'm not here to tell

472:14

you about the English intersection

472:16

anyway so what in the word is

472:18

intersection types and why you should

472:19

care about that so an intersection type

472:21

is a way to combine multiple types into

472:23

a single type that includes all the

472:25

properties and method of each constitute

472:27

type and intersection type is denoted by

472:31

just the ENT sign right here just the

472:34

ENT sign so how we are going to be using

472:36

that this is how we are going to be

472:37

using there first of all we are going to

472:39

be creating two types right here so we

472:41

have a a person type inside this person

472:43

type we have a name of string the edge

472:45

of number we also have the employee type

472:48

uh and inside that we are providing a

472:50

number and ALS I mean like the ID and

472:52

also the title and then if you want to

472:55

combine or intersect this person and

472:58

also so this employee together so for

473:00

that we can just create some sort of

473:02

other type and we can use person and a

473:05

person right here I want you to keep

473:07

that in mind this ENT and then another

473:09

type right here and then you can use

473:12

this combined type right in here baby so

473:14

let's suppose if you are creating some

473:16

sort of a u person object so here you

473:18

can see we have Alis and we are

473:19

providing this combined or intersected

473:22

type right here so we are now providing

473:24

the name of Alice the edge of 30 the ID

473:26

of 1 2 three and the title of manager

473:28

right here so now let me just give you a

473:29

quick example of that and then you'll

473:31

get to know what I'm talking about I'm

473:33

going to delete all of that code right

473:34

here and I'm going to just create two

473:36

type first of all to intersect them with

473:38

each other or to combine them with each

473:40

other combine is a better word so now

473:43

let me just create a user info and it's

473:45

going to be equals to uh this type and

473:47

let's just provide the first oh my god

473:49

let's just provide the first and the

473:51

first is going to be equals to string

473:52

and also provide a loss and the loss is

473:54

going to be also set to string and I'm

473:56

going to create an edge and the edge

473:57

will be set number right here now let me

473:59

just also create the account details

474:03

it's going to be equals to this object

474:04

it's going to take the email it's going

474:06

to also tag some sort of a password as

474:08

well now let me just go back so here you

474:09

can see we have two types right here but

474:12

if you want to combine both of these

474:14

types into one type so for that first of

474:16

all let's just create a variable or not

474:18

a variable let's just create a separate

474:21

type I'm going to give a name of like

474:22

user and it's going to be equals to the

474:24

user info and I want you to just keep

474:27

this in in your mind I want you to keep

474:31

this nend in your mind so this n will

474:34

combine both of these types right here

474:35

so I'm going to just WR a user info and

474:37

also the Account Details right here and

474:40

now we can totally use that so these are

474:42

our types and now we combine them into

474:45

only this user type which means like

474:47

whenever we use this user we have to

474:49

specify the first name last name Edge

474:51

and we also have to specify the email

474:53

and also the password itself okay so now

474:56

let me just create some sort of a user

474:57

like myself and it's going to be equals

474:59

to uh that user which we are combining

475:02

and inside that oh my God not like we

475:05

have to anot there like so and inside

475:08

there what it requires now let me just

475:10

hold my mouse over to it so the type

475:12

object is not assignable to a type user

475:14

what the hell are you talking about um

475:16

yeah type um type object is missing the

475:20

okay there we go so type object is

475:22

missing a few properties and user info

475:24

first name last name and Edge and blah

475:26

blah blah okay so now let's just do that

475:28

right here so I'm going to just write a

475:29

first name and the first name will be

475:31

set to husan I'm going to also provide a

475:33

loss yeah loss will be fine and it's

475:36

going to be set to web dev right here

475:38

and I'm going to also provide um this

475:41

password right here so the password I'm

475:43

going to provide like password one two

475:45

or something like that let me just

475:47

provide my own email address which will

475:49

be

475:50

@gmail.com right here okay and AG is 25

475:54

there we go uh let's just change that to

475:56

20 now let me just save that and let's

475:58

just use that right here whether

476:00

everything is working or not and by the

476:02

way here you can see that eror is also

476:04

totally gone let's suppose if I just

476:06

remove one of these properties here you

476:07

can see that error came back right here

476:09

okay so if I just F my password once

476:11

again and there we go everything is

476:13

working a okay so now let me just L to

476:15

the console like I don't know my

476:18

name um I'm going to just write hen our

476:21

first name and also Zen last name as

476:26

well and Edge come on edge is going to

476:30

be equals to hen. Ed and I'm going to

476:32

also put the email for the email address

476:34

I'm going to write hen. email address

476:37

and also the password itself okay so now

476:40

let's just render hen. password yeah

476:43

totally authenticated project right here

476:46

okay so now let me just run that here

476:48

you can see we now getting the name H

476:50

webd age is now set to 20 we are also

476:52

getting the email of hen gmail.com and

476:55

the password is password one2 right here

476:57

okay so that is known as the

477:00

intersection type in typescript right

477:02

here which will combine more than one

477:05

types at once yep that's it for the

477:08

intersection types in typescript so time

477:10

to talk about Union types in typescript

477:13

yeah that's kind of a poetry like time

477:15

to talk about Union types in typescript

477:18

anyways so unions are used to declare a

477:20

type that can have one or several

477:22

possible types so Union are useful when

477:25

you want to allow a variable or a

477:26

perimeter to accept multiple types so

477:29

the syntax is we just have to use the

477:31

pipe symbol you just have to hold a

477:33

shift key and hit um which is underneath

477:37

or you know not underneath but which is

477:39

above the inner button there we go so

477:41

how we are going to be using that this

477:43

is how we are going to be using that for

477:45

example we want to create a variable

477:47

which can either be number or a string

477:49

so we are going to have to just write

477:50

this pipe symbol right here okay so

477:52

there we go and we can also use it for a

477:54

function parameter we're going to be

477:56

using it like this so we're going to be

477:58

just writing some sort of perimeter and

478:00

the perimeter either should be string or

478:03

also the string of array like if you're

478:05

working with some sort of asynchronous

478:06

function so yeah that's that and we can

478:09

also use it for the interfaces but we

478:11

did not discuss what interfaces are and

478:14

so I'm not going to discuss the union

478:16

type inside interface so now let me just

478:17

write some code and then you'll get to

478:19

know what I'm talking about so I'm going

478:21

to just remove all of that code right

478:22

here and I'm going to just create some

478:24

sort of a password um come on p a s w Rd

478:28

and password variable should either be

478:30

string or uh Union type number right

478:33

here and by default I'm going to specify

478:35

the value of 20 right here it is totally

478:38

working but if I just try to provide

478:39

something else like string okay so it is

478:42

totally working as well but let's

478:43

suppose if I just write a true it's

478:45

going to gives us an error why is that

478:47

because we only write a union type for

478:49

either a string or a number so that's

478:52

why it is now giving us this uh error

478:54

right here so now let me just set the to

478:56

20 and there we go and we can also write

478:58

a unit type for types as well so now let

479:00

me just create a user info type it's

479:02

going to take the first and I'm going to

479:04

provide a string right here it's going

479:06

to also take oh my God last and last

479:09

will be also set to string I'm going to

479:10

also put the edge of yeah edge of number

479:13

now let me just create one for the

479:15

account details once again so Account

479:18

Details and it's going to be equals to

479:20

this type right here so we're going to

479:21

be providing the email and the email

479:23

will be set to string and also the

479:25

password will be set to string as well

479:27

here we want to use the that Union type

479:29

so I'm going to just create a user

479:30

object and I'm going to just annotate

479:32

this so you either have to use the user

479:34

info which requires the first name and

479:37

also the last name and also the edge

479:39

itself or we can use the union type

479:43

right here or use the Account Details

479:45

right here so it's going to be equals to

479:48

Let's suppose let's try it with uh the

479:51

first name and last name like for the

479:52

user info so let's try it for the user

479:55

info so we have first name of John the

479:57

last name of to an edge of 20 right here

479:59

everything is totally working because

480:02

here we are providing or we are

480:04

specifying all of the properties right

480:06

here all of the properties which this

480:08

user info currently have right here okay

480:11

so we are not providing all of that

480:12

property but if I just remove that and

480:14

now let's work with this account details

480:16

so I'm going to just specify like a

480:17

email and the email will be like uh some

480:21

uh come on someone gmail.com or

480:23

something like that and now I'm going to

480:25

also provide the password as well a

480:28

password will be like password or

480:29

something like that so here you can see

480:31

it's not going to giv us any error but

480:33

if I just remove this password and here

480:35

you can see we are now getting this

480:36

error like something is missing like

480:38

password is missing you have to provide

480:40

that password and there we go okay so we

480:42

can use it for um come on we can use it

480:45

for objects we can use it for types we

480:47

can also use it for a single variable

480:49

and later we are going to be also

480:50

learning about uh something called the

480:53

interfaces so we are going to be using

480:55

it inside interfaces as well so now let

480:57

me just use the inside array so we can

480:58

just write items and here we have to

481:01

write first of all our parenthesis

481:03

because first of all we have to specify

481:04

the type okay so I'm going to just write

481:06

a number or uh it should be using the

481:10

string of array so either the number of

481:12

array or the strings of array right here

481:15

so you can either use the number array

481:17

and you can also use both of them as

481:18

well you can even also use like both the

481:21

user info and also the account detail as

481:23

well like both of them at once I forgot

481:25

to show you that but you can try that by

481:27

yourself so in this case let's just

481:29

provide a values for them so I'm going

481:31

to just first of all specify values for

481:33

a number so I'm going to just say like

481:35

one and five or four or something like

481:38

that and I'm going to also specify some

481:40

sort of a string right here like hello

481:42

or something like that I can also Pro

481:44

but I can provide the Boolean if I just

481:46

write it true it's going to giv us a

481:48

cool little error and you already know

481:50

which kind of error it will gives us it

481:52

will gives us like type of Boolean is

481:53

not assignable to the type of string or

481:56

number okay so it's going to give their

481:58

error now let me just remove them and we

482:00

can log the items to the console baby

482:02

let's just go back and run them and here

482:05

you can see it's going to give us the

482:07

array with uh come on with a number and

482:09

also with a string as well so that was

482:12

it about for the union type in

482:13

typescript so now let's learn about

482:15

literal types in typescript so literal

482:17

types allow you to specify a value that

482:20

can only be one specific literal value

482:24

okay so this means that the variable

482:26

with the literal type can only have have

482:28

one specific value and no others okay so

482:31

how the syntax will look like this is

482:33

how the syntax will look like so we can

482:34

use it for a string we can use it for

482:36

Boolean and also for numbers as well so

482:39

here you can see we have some sort of

482:41

variable right here so we can either

482:43

provide the value of red blue or green

482:46

okay nothing else like like if I just

482:48

provide a value of red poorly valid if I

482:51

provide a yellow which we don't have

482:53

inside this list it's going to gives us

482:55

an invalid and it will not work on the

482:58

other hand let's try it for the numbers

482:59

so here you can see we are providing a

483:01

literal values like one two or three

483:04

like either one or two or three okay so

483:08

let's suppose if you provide like the

483:09

number of one to it totally valid you

483:12

can totally work with that but now we

483:15

are specifying four to it which is not

483:17

available inside this list so it's going

483:18

to gives us an invalid which means like

483:20

it's going to throw some sort of error

483:22

and the same will goes for the booleans

483:24

so we are just declaring the what do we

483:26

call it oh my God we just declaring a

483:28

variable and we are assigning the value

483:30

of true to it and but if you provide the

483:32

value of false to it so it's going to

483:34

gives us some sort of Errors now let me

483:35

just give you example of that then

483:37

you'll get to know what I'm talking

483:38

about so now let me just remove all of

483:39

that code and I'm going to just write

483:41

let color and the color we are going to

483:43

be specifying some sort of a uh color

483:45

like red and I'm going to also PR the

483:48

color of crimson and I'm going to also

483:51

PR the color of

483:53

fuchia okay so now let me just provide

483:55

these colors and I'm going to just

483:57

provide a color and the color will be

483:59

set to uh red in this case totally

484:03

accessible totally working like we are

484:04

not getting any errors nothing right

484:06

here if I log there to the console like

484:08

color s my file go back and run that

484:11

come on let's just remove that crap and

484:14

rerun that once again and here you can

484:16

see we are now getting red right here

484:18

which is totally working but if I just

484:20

duplicate that and change that to like

484:22

yellow and here you can see it's going

484:24

to gives us an error and the type yellow

484:27

is not assignable to the type red or

484:30

Crimson or fuchsia which means like this

484:33

type which you are providing right here

484:34

is not inside this list so that's why we

484:37

are now getting an error right here if I

484:39

just run that obviously we are going to

484:40

be getting a cool little error oh I

484:43

didn't sell that let's just save that

484:45

and rerun that once again and here you

484:47

can see it's going to gives us that same

484:48

error right here okay so that's totally

484:52

cool uh but now let me just give you

484:54

example of a numbers or you know Boolean

484:56

L is true

484:58

so the Boolean can either be true or

485:00

false no other values so now let me just

485:03

write is true and it's going to be

485:04

equals to True right here okay so we can

485:07

log that to the console and you already

485:09

know what it will gives us but if I just

485:10

write like is true is equal to like

485:12

something else and you already know it's

485:15

going to gives us an error so that was

485:16

it for the booleans now let me just give

485:18

you the example of some sort of a you

485:21

already know how that's going to work

485:22

for the numbers so I'm not going to give

485:24

you the numbers example but now let me

485:25

just create some sort of a password and

485:27

I'm going to provide the value of like

485:29

SEC c t password like a secret password

485:33

secret password and it's going to be

485:34

equals to uh that secret P I'm going to

485:37

copy that and now let me just place that

485:39

right here go back okay so we are now

485:41

providing this specific value for this

485:43

specific uh password right here now

485:46

inside that what I want to use that if I

485:48

just log to the console this password

485:50

let me just go back and run that let me

485:52

go back and run that and here you can

485:54

see it's going to gives us a secret

485:56

password let's suppose if I want to

485:57

change the value of that like password

486:00

is equal to like something else and here

486:02

you can see we are now getting this

486:04

error like something else is not

486:06

assignable to the secret password right

486:08

here okay so if I just run that it's

486:10

going to give us that error right here

486:12

oh come on I always forgot to save that

486:14

grap and here you can see it's going to

486:16

gives us that a full error right here so

486:19

that was it about uh what do we call it

486:21

that was it about for the literal types

486:23

in typescript now let's learn about a

486:25

Python programming language topic which

486:27

is called tobbles do you have to know

486:29

Python programming language of course

486:31

not but yeah this is already available

486:34

inside of python if you wanted to check

486:35

it out so what is a TPL or topples or

486:38

whatever you want to call them so Tuple

486:41

or topples uh is a type that represents

486:44

an array with a fixed number of elements

486:46

where each element can have a different

486:48

type the order of these types in the

486:50

twole definition corresponds to the

486:52

order of the values in the actual array

486:55

so tubes are similar to arrays but then

486:57

they have a specific

487:00

structure and can be used with model

487:02

finite sequence with known length Okay

487:05

so that was just a definition of what a

487:06

tuples or tles is now let's learn about

487:09

how we are going to be using them this

487:11

is how we are going to be using them it

487:13

is similar to arrays but the syntax is a

487:15

bit different and we already discussed

487:17

there so we are going to be annotating

487:19

there right here inside of brackets not

487:21

outside from the brackets but inside the

487:23

bracket we are going to be using either

487:24

string or number so we can provide some

487:26

sort of a structur forward data which we

487:28

are going to be storing inside this

487:30

twole like the first value will be set

487:32

to string so we are now storing the

487:34

string value and the second one will be

487:36

set to number so here you can see we now

487:38

providing the number right here so it's

487:40

going to giv us their hello and also uh

487:43

what do we call the number as well and

487:45

by the way this is also a zero index B

487:47

so I want you to keep that in mind as

487:49

well now let's also learn about a d

487:51

structuring you don't even have to worry

487:53

about destructuring but I'm discussing

487:56

this topic for those who cares if you

487:58

don't care about that you don't even

488:00

have to worry about that so how we are

488:02

going to be restructuring the value of

488:03

that well we are going to be just using

488:05

these brackets so we are going to be

488:07

destructuring the value of hello and we

488:10

are going to be giving it the name of

488:11

first you can give it any name you want

488:14

and then we're going to be destructuring

488:15

the value of number and we I mean like

488:17

this p and we're going to give a name of

488:19

like second so if you lock to the

488:20

console first and second so for the

488:22

first one we are going to be getting a

488:23

hello for the second one we are going to

488:25

be getting 42 right here so now let me

488:28

just write some code then you'll get to

488:29

know what I'm talking about so what I

488:31

want to do is that first of all I'm

488:32

going to just create a simple tube let

488:36

my two uh P I guess this is how you

488:39

spell it and now we are going to be

488:40

providing The annotation so we are going

488:42

to be providing a structure like which

488:44

kind of data or which kind of structure

488:46

we are going to be using for our data so

488:48

we are going to be specifying the number

488:50

and also the string as well and now let

488:52

me just specify some sort of value St

488:54

like my tub and it's going to be equals

488:56

to First of all we are requiring the

488:59

number so in this case we have to

489:01

specify some sort of a number right here

489:03

so in this case I'm going to just

489:04

specify like 10 and then we have to

489:07

specify the string value so for the

489:09

string value I'm going to just say like

489:11

Hello World there we go and now let me

489:14

just log there to the console like my

489:15

Tuple there we go let me just sell there

489:18

and run there and here you can see it

489:20

will give us like 10 and also hello word

489:23

on the other hand let me just try

489:25

something else if I cut this 10 from

489:27

here and if I just place it right here

489:30

and let's just save there and it's going

489:32

to give us an error why is that if I H

489:34

my mouse over to it so type string is

489:37

not assignable to the type number why is

489:40

that because we made a structure like

489:42

this first of all we would require some

489:45

sort of a number then we would require

489:47

some sort of a string so in this case we

489:49

are providing first of all the string

489:50

and then the number that's not

489:52

acceptable that's a big no no in two PS

489:55

okay so yeah that's the only reason we

489:57

are going to be using tuples in the

489:59

first place and you are violating that

490:01

rules so typescript is not going to be

490:03

happy with that okay so I'm going to

490:04

just comment this line out and now let

490:06

me just create some other or you know um

490:10

let me just create a tle for a product

490:12

so I'm going to just write con products

490:14

and it's going to be equals to it's

490:16

going to take either number or the

490:18

string of one uh array and it's going to

490:21

be equals to like I don't know item one

490:23

and I'm going to also provide one two

490:25

right here okay now let me just go back

490:27

back and if I log that products to the

490:29

console you already know which kind of

490:30

resor you would get why oh there we go I

490:33

always forgot this uh annotation right

490:36

here let's just run that come on and

490:39

here you can see it's going to give us

490:40

item one and also 12 right here which is

490:43

totally cool so I'm going to delete that

490:46

now let me just give you one more

490:47

example for the string string string so

490:50

now let me just write a games and it's

490:52

going to take the structure like string

490:54

and also string and also yet again

490:57

string and come the helmon I'm going to

491:00

provide The annotation sign rather than

491:02

the equal sign and here I'm going to

491:04

just write like game one and I'm going

491:06

to just s like game two and also the

491:09

game three as well now let me just log

491:12

these games to the console semi file and

491:14

run them it's going to give us game one

491:16

game two game three but if I just write

491:19

like for the middle one I want to get a

491:21

number right here so if I just save them

491:24

it's going to gives us an error if I

491:26

just H my mouse over to them

491:27

oh my God it's going to say like type

491:29

string is not assignable to the type

491:31

number because here we require the

491:34

number we have to specify some sort of a

491:36

number right here okay so we can create

491:38

some sort of a structure like um the

491:41

game name will be a string the game

491:43

ratings will be some sort of a number

491:46

and the game true rating will be some

491:48

sort of Boolean so I'm going to just

491:49

write bull or Boolean rather and here

491:52

I'm going to just specify true and now

491:54

let me just save that and run that here

491:56

you can see is going to giv us like game

491:58

one the rating will be set to two and

492:00

also the real rating will be set to uh

492:04

true right here so this is how we are

492:05

going to be creating a tuple and this is

492:08

how we are going to be using a tups in

492:10

typescript now let's learn about enums

492:12

in typescript So enim is a way to define

492:15

a set of name constants so enum allow

492:18

you to define a collection of related

492:20

values that can be used interchangeably

492:23

in your code so how that's going to look

492:25

like this is how it's going to look like

492:27

like for example let's say you are

492:29

building a weather app and you want to

492:30

define a set of possible weather

492:32

condition like sunny cloudy rainy and

492:34

snowy you could Define an enom like this

492:37

you going to be first of all writing the

492:39

enom Reserve keyword then you can give

492:41

some sort of a name to that and then you

492:42

have to write the curly braces you don't

492:45

have to specify some notation or a

492:47

notation to be precise and you don't

492:49

even have to use the equal to sign for

492:51

that and then you can specify your

492:53

constants like sunny cloudy rainy snowy

492:55

or whatever so in this example wether

492:58

condition is the name of the enum and

493:00

each of the values for example sunny

493:02

cloudy Etc is assigned to automatic

493:04

numeric value starting from zero okay so

493:08

this one will be zero this one will be

493:09

one two and three and so on and you can

493:12

even specify your own values like this

493:14

okay so you're going to be just writing

493:16

the equal to sign and you can specify

493:18

sunny cloudy whatever you want this is

493:21

how the syntax will look like and now

493:22

let me just give you some sort of

493:24

example and then you will get to know

493:25

what I'm talking about and you know what

493:27

before getting into the example first of

493:29

all I want to show you how you're going

493:30

to be using the em I forgot to show you

493:32

that so this is how you're going to be

493:34

using there like let's suppose some sort

493:36

of a variable and then you are going to

493:38

be getting that enim name and then the

493:40

don't end then you would be able to

493:42

specify which kind of property you want

493:44

to access so here you can see the name

493:46

of our enim is set two weather

493:48

conditions and then inside that weather

493:50

condition we have the sunny property

493:52

right here which is currently set to

493:53

Sunny and this is how we are going to be

493:56

getting there so conso log the current

493:58

weather is current weather and we are

494:00

now getting sunny right here as output

494:02

so this how we are going to be creating

494:04

an enum and this how we're going to be

494:05

using an enum inside our project so I'm

494:08

going to delete this code right here and

494:09

I'm going to just create my enum and do

494:12

we have yeah there we go uh we don't

494:16

want that let's just remove the right

494:17

here en once again and where w t h e r

494:22

conditions there we go and we're not

494:24

going to be providing the equal to sign

494:26

but we are going to be just just

494:27

providing the curly braces right here

494:29

I'm going to specify Sun cloudy rainy

494:31

and now if I just log that to the

494:33

console or you know first of all let me

494:34

just uh write like weather condition.

494:37

sunny sunny let me just go back and see

494:40

what it will gives us now let me just

494:42

save that and run it and here you can

494:44

see it's going to give us a zero because

494:46

this is a zero index space and we did

494:48

not specify any values to it so it's

494:51

going to gives us by default zero right

494:52

here so these are our constants or enms

494:55

whatever you want to call them

494:57

let's suppose if you want to get the

494:59

value of like I don't know rainy you

495:01

already know what it will gives us but I

495:02

want to run it anyways it's going to

495:04

gives us two right here because this one

495:06

is zero this one is one and this one is

495:08

two so that's why we are now getting two

495:10

right here inside a console now the next

495:12

thing which I want to show you is that

495:13

how we are going to be assigning a

495:14

values to our enm properties so we are

495:16

going to be just using the equal to sign

495:18

and sunny we can also use like I don't

495:21

know cloudy sunic and money and

495:24

something like that sunny cloudy uh c l

495:27

o u d y I guess this is how you spell it

495:30

I'm not quite sure about that but now

495:32

let me just write rainy and I'm going to

495:34

just create one more for the

495:36

snowy okay snow I don't even know if

495:39

that's a real word or not but I'm going

495:41

to just provide it anyways and run that

495:44

it's going to gives us rainy right here

495:46

why is there because currently we are

495:48

accessing the value of rainy and we are

495:50

providing it right here so that's why we

495:52

are now getting rainy but if I just

495:54

remove that and save my file and run it

495:57

and it's going to give us sunny sunny

495:59

cloudy cloudy rainy rainy snowy snowy

496:03

okay so it's going to gives us all of

496:04

that properties right here now what I

496:06

want to do is I want to store there some

496:08

sort of variable like con Uh current or

496:12

weather or something like that so

496:14

weather condition and currently it is

496:17

snowy here so I'm going to just specify

496:19

snowy right here and I'm going to just

496:21

write cons. log the current weather uh

496:24

is and let's just render the current

496:26

weather right here now let me just save

496:28

that and run that and here you can see

496:30

the current weather is snowy right here

496:33

so yep that was enum and you can provide

496:36

more crazy functionality than that it is

496:39

nothing but we just use that for like a

496:41

real word uh constant right here so yeah

496:44

you can go crazier than that but that

496:46

was just our basic weather application

496:48

in typescript no I'm just kidding so now

496:51

let's learn about a classes in

496:53

typescript but a word of caution if you

496:56

don't know objective oriented

496:58

programming in JavaScript so you don't

497:01

have to watch this section I mean like

497:02

if you don't care about the oop kind of

497:05

stuff so you can totally skip this

497:06

section you don't even have to worry

497:08

about all of the classes and all of that

497:10

kind of stuff but if you do care about

497:13

that and if you already learned that so

497:16

good on you and welcome to the section

497:18

if you want to learn about oop I have an

497:21

entire course on there you can check out

497:23

my complete JavaScript course and I have

497:25

an entire section about oh o op and

497:27

craziness of oop anyway so now let's get

497:30

into the classes so I'm assuming that

497:32

you guys already know what a classes is

497:34

in javascripts I'm not going to be

497:36

explaining what a classes is but I'm

497:37

going to be explaining the classes in

497:40

the tcri point of view anyway so classes

497:43

properties annotation so you can

497:44

annotate class properties with a type

497:46

this allow you to define a data type of

497:48

a property and ensures that it is always

497:51

consistent so this is how the syntax

497:52

will look like so here you can see we

497:54

have some sort of a field like name and

497:56

we can also annotate there like for

497:58

string and we also have like Edge and we

498:00

can annotate there with a number and we

498:02

can even also annotate these names as

498:05

well right here if you wanted to okay so

498:07

that was the basic annotation example

498:09

which I'm going to also show you in a

498:10

real world example but you know what I

498:13

want to get into the modifiers but you

498:16

know first of all let me just write some

498:17

code then you'll get to know what I'm

498:18

talking about so now let me just remove

498:20

them and I'm going to just create a

498:22

class right here and I'm going to give a

498:24

name of like person I'm going to create

498:26

a name and I'm going to provide a type

498:28

of string right here this is totally

498:30

simple and easy we just have to specify

498:31

the types in typescript so here you can

498:33

see I just set that to number we can

498:35

also provide a field right here so now

498:37

let me just write like name and we can

498:39

change the name of that to like string I

498:41

mean like the type of that to string and

498:42

we can also provide an edge and the edge

498:44

will be set to number as well okay now

498:47

let me just use the this Reser keyword

498:49

and this will be now set to name and

498:51

also this. Edge will be now set to Edge

498:54

as well now let me just create a quick

498:56

simple instance of this class right here

498:58

let me just go back I'm going to just

498:59

create a person and new person and

499:02

inside this person I'm going to give him

499:04

some sort of a name like uh I don't know

499:06

John would be fine and he would be like

499:08

20 years old or something like that and

499:10

if you also log there to the console

499:11

sell file and run there and here you can

499:14

see it's going to give us a like person

499:16

the name will be set to John and also

499:18

the edge will be set to 20 right here

499:20

you already know all of that stuff but

499:22

you just have to specify these types to

499:24

it right here okay so that's then now

499:26

the next thing which I want to talk to

499:27

you about is that you can also make the

499:29

properties read only which we already

499:31

learned but now let me just show you

499:33

that quickly once again so I'm going to

499:34

just write like read only and there we

499:37

go so we can totally access these

499:39

properties but we cannot change the

499:41

value of these properties right here so

499:43

if I just save them and if I just run it

499:45

so obviously we are going to be getting

499:47

the same result right here but if I try

499:49

to like uh change the value of that to

499:51

something else you know what I already

499:53

show you that I don't want to bother

499:55

that once again so let's just remove

499:56

that from here and there we go this is

499:58

how we going to be working with the

500:00

classes in typescript now let's talk

500:02

about something called modifiers in

500:04

typescript so what are modifiers and why

500:06

you should care about that so in

500:08

JavaScript we do not have the concept of

500:11

modifiers I mean like we can achieve the

500:13

same result like uh these keywords which

500:16

I'm about to show you we can totally use

500:18

that but for that we have to perform

500:20

Advance concept like closures and we

500:22

also have to use encapsulation

500:25

polymorphism and all of that big words

500:27

which I already discussed in my uh

500:29

JavaScript course if you are interested

500:30

and you want to check it out so feel

500:32

free to check it out anyway so what are

500:34

access modifiers or just modifiers

500:37

whatever you want to call them so in

500:38

tcri you can use the access modifiers to

500:40

control the visibility of class members

500:43

properties and methods you already know

500:45

that access modifier determine the way

500:47

in which class members can be accessed

500:49

from within and outside the class so how

500:53

many exess modifiers do we have we only

500:55

have three just like a Java programming

500:58

language if you're already coming from a

500:59

jav or maybe if you are coming from a

501:01

C++ background so you already know uh

501:04

all of these modifiers but anyways um

501:07

let's talk about it so here you can see

501:09

we have only these three modifiers so

501:11

the first one we have a public the

501:12

second one we have a private and we have

501:14

a protected one as well so now let's

501:16

just discuss each of them one by one so

501:18

first of all we have a public modifier

501:20

so public as the name suggest like

501:23

Members Mark as a public can be accessed

501:25

from anywhere

501:27

both inside and outside in the class but

501:30

if you talk about a private modifier so

501:32

the private modifier like member Mark as

501:34

a private can only be accessed within in

501:37

the class they are defined in not

501:40

outside in this case you can access your

501:43

modified both inside and outside inside

501:45

a public but on the other hand if you

501:47

are working with a private so you can

501:49

only access your property or your method

501:52

inside the class in which they are

501:54

defined in but not outside but now let's

501:57

talk about the protected one Members

502:00

Mark as protected can be accessed from

502:02

within the class they are defined in as

502:04

well as any sub Clauses that extends the

502:07

Clause so you already know about the

502:09

extend Reser keyword so uh for if you

502:12

mark a specific property or method by

502:15

using a protected modifier so they can

502:18

be only accessible inside their specific

502:20

class in which they are defined in and

502:22

also uh when you extend a certain class

502:25

and you want to use the there they can

502:27

be also accessible there on the other

502:29

hand if you are working with the private

502:31

one they can only be accessible within

502:34

the class but not outside from the class

502:36

but if you are working with the public

502:38

class so they can be accessed anywhere

502:40

you want so yeah that's the love of

502:42

typescript so how that's going to look

502:44

like now let me just show you that I

502:46

know this is a lot of code and you don't

502:48

even have to worry about that but here

502:49

you can see we can mark for property by

502:51

either providing the public modifier the

502:53

private or the protected one right here

502:56

okay so by public it can be accessible

502:58

anywhere inside your program but if you

503:01

mark that as a private it can only be

503:03

accessible inside this animal uh class

503:07

right here but if you mark this

503:08

protected one it can be accessible

503:10

inside the animal and also if we extend

503:14

some uh some animal like dog or

503:16

something like that it can also be

503:18

accessible there and I hope that makes

503:20

sense if it doesn't yeah now let me just

503:23

write some code and then you'll get to

503:24

know what I'm talking about first of all

503:27

let me just create my class once again

503:29

so I'm going to just create a class I'm

503:31

going to give a name of like P come the

503:33

hell man person once again let me just

503:36

Pro a few properties like first name

503:37

will be set to string and also we have a

503:40

last and it's going to be also set to

503:41

Strings as well now let me just provide

503:43

my first and it's going to be equals to

503:45

string and I'm going to make that as

503:48

public so if I just write public there

503:50

we go it is now working and I'm going to

503:52

also make this one public as well like

503:54

for the last one as well so now inside

503:56

there what I want to do is that I'm

503:58

going to just use this do first and also

503:59

this do last and now let me just create

504:01

an instance of them so I'm going to go

504:03

back and this how we're going to be

504:05

creating an instance of them like oh my

504:07

God uh person yeah personall okay and

504:11

now let me just log there to the console

504:13

like

504:14

P1 dot I don't know do first name right

504:17

here so now let me just save that and

504:19

here you can see it's going to gives us

504:21

John right here if you try to log the

504:23

last name if you just write LA s file

504:25

and run that it's going to gives us the

504:27

D right here which means like totally

504:29

accessible right here and now if I make

504:33

them uh private right here if I just

504:35

mark this one as private if I save them

504:38

and here you can see if I just write

504:40

first uh come the hel on First and if I

504:43

save that it's going to already give us

504:45

this are like property first is private

504:47

and only be accessible within the class

504:50

uh person right here in which we are

504:51

creating it right here okay so let me

504:54

just create some sort of a method like I

504:56

don't know get name yep that's cool so

504:58

I'm going to just uh create this get

504:59

name so we are writing a this. first

505:01

name and also this. last name right here

505:04

and we are also annotating that right

505:06

here okay so what I want to do is that

505:08

instead of writing a get uh I mean like

505:10

instead of writing a first which is not

505:12

accessible outside from this person

505:14

right here but it is now totally

505:16

accessible inside this person class so

505:19

here you can see we can totally have

505:22

access to that so instead of writing

505:23

this first I'm going to just copy this

505:25

get name and let me just put there right

505:27

here and execute that so now if I sve

505:29

this file so what do you think will be

505:31

the result if I run this code okay let

505:34

me just remove that and run that once

505:36

again so we are now getting John down

505:40

which means like everything is

505:41

successfully working and we can only use

505:44

this first property which we Mark as a

505:47

private only inside this person object

505:51

right here let me just highlight that we

505:53

can only use this property which is

505:55

marked as a private keyword only inside

506:00

this person

506:01

class

506:03

not outside from this person class okay

506:07

so this is how we are now getting there

506:09

anyway so that was it about for the

506:10

public and also for the private as well

506:13

so now let me just create one more for

506:14

like protected so protected and I'm

506:17

going to just specify like Edge or

506:18

something like that and Edge will be set

506:20

to totally number now let me just save

506:22

there so what this protect is going to

506:23

do for us this protect it means like we

506:26

we can totally use this property inside

506:29

this person right here not outside from

506:32

this person but if we just extend or if

506:35

we borrow the functionality from this

506:37

person to yet another person and we

506:39

create instance of that we can totally

506:41

access that edge there okay so what I

506:43

want to do is that here I'm going to

506:45

just write like Edge and I'm going to

506:47

just set that to um Edge right here or

506:51

you know this start Edge rather okay so

506:53

it's going to totally work and it's not

506:55

going to give us any errors right here

506:56

but if you try to provide some sort of a

506:59

number right here like 20 in this case

507:01

it is going to gives us this error like

507:03

unexpected two arguments but got three

507:06

oh that's because we have to register

507:08

the anyways but you get the idea like it

507:10

will give us that error right here so

507:12

now you get the idea like we can totally

507:14

access this. Edge inside this person and

507:17

we can also access it by creating some

507:20

sort of a instance right here and now

507:22

let me just create some sort of a user

507:23

like class and then I'm going to just

507:25

create myself right here or you know

507:27

what uh human this one should be human

507:32

this one should be human so I'm going to

507:33

just select that hit control D and I'm

507:35

going to just change that to human and

507:37

this one should be myself or person

507:40

rather I'm going to just Sate a person

507:42

and we are going to be extending which

507:44

means like we are going to be borrowing

507:46

the functionality from this human right

507:48

here and we are going to be providing it

507:50

right here so uh we are going to be

507:52

getting the functionality from the human

507:54

and this is how it looks like and we

507:55

just only only need this functionality

507:57

right here so we have a first name we

507:59

have a last name and we have every

508:00

single thing right here and we can also

508:02

use this Edge right here so let's

508:04

suppose if I just create some sort of

508:06

you know let me just delete that from

508:07

here I'm going to also delete this one

508:09

from here let me just go back and I'm

508:11

going to just create an instance of this

508:13

person right here not a human but a

508:16

person so I'm going to just write like

508:18

con hosen it's going to be equals to

508:19

person and we have to specify the first

508:22

name so I'm going to just write like hen

508:24

for the first name oh we got to include

508:26

the new resert keyword uh why are we

508:29

getting this

508:31

error uh oh there we go it accept three

508:34

parameters so we have to specify for the

508:36

last one like webd and I'm going to also

508:39

specify one for the edge so which is set

508:42

to number I am 20 years old and there we

508:44

go we are now totally able to access

508:47

this property which is set to protect it

508:49

inside this extended class right here so

508:52

now let me just log that to the console

508:54

so I'm going to just use like Huzan this

508:56

file and run there so we are now oh God

508:59

damn it where in the world we even

509:01

getting the error H property Edge has no

509:05

initializer and not definitely assigned

509:07

in the Constructor yep you're totally

509:10

right brother let me just assign that

509:13

right here I'm going to just put a comma

509:15

and I'm going to just use like Edge and

509:18

Edge is going to be set to number right

509:20

here and let's just duplicate that and

509:23

I'm going to just set that not number

509:25

but not it's going to set to uh Edge

509:28

right here I'm going to also copy this

509:29

Edge and I forgot to do that so I'm

509:31

going to just remove this Edge from here

509:33

and I'm going to just specify it right

509:35

here for the edge and now let me just

509:37

run that and here you can see we are now

509:39

getting the person first name we be now

509:41

set to hose the last name will be set to

509:43

web dev and also the age will be set to

509:44

20 and that's it baby that was it about

509:47

for the modifiers and also for uh this

509:51

annotation in classes okay so yeah I

509:54

guess there is only one left which is

509:56

called the gets and Setters yeah now

509:58

let's just discuss the gets and Setters

510:00

and they will be for the oop section of

510:03

typescript so what is a Getters and

510:05

Setters and why you should care about

510:06

them so Getters and Setters are used to

510:08

access and modify class properties and

510:10

Getters and Setters allow you to define

510:12

a property in a class that looks like a

510:14

simple variable but internally has

510:17

additional Logic for getting and setting

510:19

the value okay so how that's going to

510:21

look like so here you can see we have a

510:23

class and we have this private property

510:24

which is currently set to zero and then

510:27

we can just specify this get res keyword

510:29

to get the specific property and we can

510:31

also use the set and to set the specific

510:34

logic inside there okay so we're not

510:36

going to do anything crazy so now let me

510:38

just show you that totally quickly so

510:41

what I want to do is that first of all

510:42

I'm going to just create my class I'm

510:44

going to give a name of like my class

510:46

baby you can give any class you want I'm

510:49

not going to be providing any parameters

510:50

to it but now let me just make this

510:52

first property as private and which will

510:55

be my

510:56

property would be fine and I'm going to

510:59

just annotate that as a number because

511:01

we're going to be providing the initial

511:02

value of number right here for the

511:04

Constructor I don't want to write you

511:06

the Constructor so now let me just

511:07

remove that let me just save that but

511:09

underneath this property we are going to

511:10

be just creating our get method and I'm

511:12

going to just say like my uh proper come

511:16

on my p r o p rty y and now let me just

511:20

annotate there with a number and I'm

511:21

going to just return this dot my

511:23

property which is now initially set to

511:26

zero and we are providing it uh and we

511:28

are providing a type of number to it so

511:30

this is how we are going to be getting

511:31

something now let's learn about a Setter

511:33

okay so I'm going to just write a set

511:34

Reser keyword and my property it's going

511:36

to take a value and the value should be

511:38

a number and inside that we are just

511:40

setting this property like this start my

511:42

property and we are providing that value

511:44

to it okay so now let me just create an

511:46

instance of that now let me just save

511:48

there and go back and create a quick

511:49

instance of this so I'm going to just

511:51

use like cons my instance you can give

511:54

any name you want but the naming doesn't

511:55

matter some my class and let's just

511:58

create instance of there and we already

512:00

use the gets and sets but I'm going to

512:02

just log there to the console like

512:04

current value come on current value uh

512:07

and here we just have to use like my

512:10

instance do my property right here okay

512:13

so we just have to only use that now let

512:15

me just save that and let's just run

512:17

that right here so here you can see

512:19

we're now getting this data which is

512:21

currently set to private but we now

512:23

getting this data by using this function

512:25

which we just cred right here okay so

512:27

now if you want to assign a value to

512:29

that so how can you go about doing that

512:31

and that's totally easy as well we we

512:33

don't have to do nothing but we just

512:34

have to write like my instance do my

512:37

property we just have to access this

512:39

property which we have right here and

512:41

also we have to specify some sort of a

512:42

number like I don't know maybe 10 would

512:44

be fine and this is how we're going to

512:46

be assigning a number and now let me

512:47

just log that to the console like uh

512:49

let's just cut that cut that copy this

512:53

one and put it right here and now let me

512:55

just save there and run there initially

512:57

it's going to be set to zero and now we

512:59

are changing there or we are setting a

513:01

new value today so that's why we are now

513:03

getting this 10 right here and yep that

513:06

was it about the oop section for the

513:09

typescript and I hope you enjoy it now

513:11

let's learn about interfaces in

513:13

typescript so now let's talk about one

513:15

of my favorite Topic in typescript which

513:17

is called interface so what in the world

513:19

all interfaces and why you should care

513:21

about them the interface is a way to

513:23

define a contract for a shape of an

513:25

object it specify the properties and

513:27

their types that an object must have and

513:30

the keyword is must have interfaces are

513:33

powerful tools for enforcing a certain

513:35

structure in your code so how in the

513:38

world we are going to be creating a

513:39

interface and how all of that works okay

513:42

like yeah I know that's a lot of

513:44

gibberish which I just said like how in

513:46

the word we're going to be creating an

513:47

interface and how all of that works so

513:50

this is how we are going to be defining

513:52

an interface so first of all we have to

513:54

just write interface Reser keyword then

513:56

we have to give some sort of a name for

513:57

or interface then we have to specify the

513:59

properties and their types and there we

514:01

go we can also Define the methods which

514:04

we are going to be also discussing in a

514:05

few seconds and if you want to use the

514:07

interface you just have to annotate that

514:09

right here and then you have to specify

514:12

all of the properties which currently

514:14

this interface has okay so we have first

514:16

name last name and Edge and we are not

514:18

providing the first name last name and

514:20

Edge right here so that was our basic

514:22

interface but that's not it while

514:26

interfaces are commonly used to define

514:27

the structure of objects they are not

514:30

limited to just objects interfaces in

514:39

timecrimson classes and also for the

514:43

objects as well so now let's talk about

514:45

it so if you want to create an interface

514:47

for a function so this is how you're

514:48

going to be doing there okay so here you

514:50

can see you just have to create an

514:52

interface like the syntax will be

514:53

totally the same but if you want to

514:55

create some sort of a structure for a

514:57

function so you just have to create that

514:58

structure right here like in this case

515:00

it will take a two parameter like X and

515:02

also the Y and both of them will be

515:04

number and the return type will be also

515:06

number okay so this is how we are going

515:08

to be doing that here you can see we

515:10

have a add function and a add Arrow

515:12

function right here and we are providing

515:14

our interface call right here like math

515:17

operation we are now providing this X

515:19

and also the Y so we have to specify

515:22

there right here and it's going to take

515:23

the A and also the B and we are just

515:25

adding there right here and we can also

515:27

use for the subtract and we can log the

515:30

values like uh for the add we are going

515:32

to be using it like this and also for

515:33

subtract we can also provide different

515:35

kind of values right here I know that

515:37

sounds confusing like oh my God you are

515:39

just showing us the slide show some code

515:41

yeah I am going to show you a code in a

515:43

few seconds but first of all let me just

515:45

explain all of that stuff in the slides

515:47

then we're going to be jumping into the

515:48

code okay so this is how we are going to

515:52

be using interfaces for a class so here

515:54

you can see we have a interface and as I

515:56

said that we can also provide a method

515:58

for that so we have a vehicle interface

516:01

right here and as a methods we have a

516:02

start and it's going to take wide

516:04

because we're not even returning

516:06

something from there and we also have a

516:08

stop so we are going to be also

516:09

annotating that as a wide because we're

516:11

also not returning something from there

516:13

and here you can see we are going to be

516:15

using the implements okay not extends

516:19

but implements right here so it's going

516:21

to implement the vehicle interface right

516:23

here and then we can Define I mean then

516:26

we should Define the start and also the

516:28

stop because we have to specify these

516:30

properties which are currently available

516:32

for this interface so we have a start

516:34

and we also have a stop and we can use

516:36

it like that so this is how we're going

516:38

to be using interfaces and we have yet

516:40

another topic which is called

516:41

declaration and merging I'm going to

516:43

discuss that in a few seconds but first

516:45

of all now let's just create interface

516:47

the basic interface how this work and we

516:50

are going to be also creating it for a

516:51

function and also for the class as well

516:54

and then we are going to be jumping into

516:55

the Declaration and merging so I'm going

516:58

to select everything and I'm going to

517:00

delete that and let's just Define our

517:02

first interface right here so I'm going

517:04

to just create interface and interface

517:06

is a resert keyword which means like it

517:08

have some sort of a special meaning

517:09

inside a typescript and I'm going to

517:11

just create a simple interface for

517:14

computer the computer is going to have

517:16

some sort of a name and it's going to

517:17

also have some sort of a ram and the ram

517:19

will be set to number I'm going to also

517:21

provide the hard disk drive and it's

517:24

going to be also set to number as well

517:26

and now if you want to use this

517:27

interface which we just created right

517:29

here so how can we go about doing that

517:32

first of all we are going to be using

517:33

that with an object then we're going to

517:35

be jumping into the functions and all of

517:37

that kind of stuff so now let me just

517:39

create like computer exam Comm ex M and

517:44

here we just have to specify that

517:46

interface name right here there we go we

517:48

just have to write the interface name

517:50

which we are declaring it right here and

517:52

we just have to specify right here and

517:54

we also have to put the equal to sign

517:56

now it will instantly gives us an error

517:59

and it's going to say like yeah you have

518:00

to provide the name you also have to

518:02

provide the RAM and also the hard dis

518:04

drive as well so we can proide a name

518:06

and the name will be like I don't know

518:08

i7 or something like that and I'm going

518:10

to also provide the RAM and the ram will

518:12

be 8 gabt and the hard dis Drive will be

518:15

I don't know 100 GB or something like

518:18

that now let me just go back and now let

518:20

me just log all of these values right

518:22

here so I'm going to just use like

518:23

computer uh come on comp oh the name is

518:27

ah computer exam

518:31

examle there we go now let me just copy

518:33

that and put that right here and I'm

518:35

going to just access the name so now let

518:37

me just access the name and run that so

518:40

it's going to gives us the i7th right

518:42

here I'm going to duplicate that a

518:43

multiple times so I'm going to just

518:45

change that to Ram I'm going to also

518:47

change this one to hardest Drive okay

518:50

not three D but two D so now let me just

518:52

save there and here you can see it's

518:54

going to gives us the i7 and and also

518:57

100 and everything is totally working

519:00

and this is how we are going to be

519:01

defining the interface this is how we

519:03

are going to be using the interface

519:05

right here so that was the first example

519:07

now let me just give you one more

519:08

example of interface because interfaces

519:10

are supremely important right here so

519:13

now let me just give you the example of

519:15

movie okay so I'm going to just provide

519:18

some sort of a name for the movie you

519:19

can give a title if you want and I'm

519:21

going to annotate that with a string I'm

519:24

going to also provide some for array

519:26

come on r a t n gs and ratings will be

519:28

also set to number and I'm going to also

519:30

specify the genre and genre will be also

519:33

set to string but what I want to show

519:35

you is a few things we can also make a

519:38

certain property read only like let's

519:40

suppose if we want to just um change the

519:43

not rating but let's suppose if you want

519:45

to just make the name totally read only

519:47

and by now you already know what read

519:49

only means so you can just specify this

519:52

read only Reser keyword and it's going

519:53

to make this property totally read only

519:56

right here and we can also use this

519:59

question mark which we already discussed

520:01

the optional property or optional

520:02

chaining property whatever you want to

520:04

call that so it's going to make this

520:06

property totally optional like if you

520:08

want to provide this genre property you

520:10

totally can if you don't want to provide

520:12

it you don't have to okay so now let me

520:14

just create some sort of like I don't

520:16

know movie one and it's going to be

520:18

equals to this movie interface which we

520:20

already created and inside they we're

520:22

going to be just specifying like the

520:23

name of Star Wars the ratings will be .9

520:26

and genre will be set to action right

520:27

here okay so yeah now I'm going to go

520:31

back and I'm going to just L to the

520:32

console like uh I don't know movie one

520:36

and now let me just save that and here

520:38

it's going to give us all of their

520:39

properties which currently this movie

520:42

have but let's suppose if I want to

520:44

access like the name if I just write a

520:46

name semi file it's going to obviously

520:47

give us the name it's going to gives a

520:49

Star Wars now let me just remove that

520:52

but if I try to uh rechange the value of

520:54

that to like uh some other movie or

520:58

something like that so what are we

520:59

getting we are now getting the error

521:01

cannot assign to the name because it is

521:03

a read only property you cannot change

521:06

that because we Mark that as a read only

521:09

so you cannot change the value of that

521:11

okay so you also have to keep that in

521:13

mind let's suppose if you don't want to

521:14

proide this genre I'm going to cut that

521:16

from here and nothing is happening right

521:18

here like everything is a okay but let's

521:21

suppose if I just remove this question

521:22

mark from there and we are now getting

521:24

this School error right here okay so

521:28

yeah that was the basics of interfaces

521:30

now let's create interfaces for the

521:32

functions I'm going to create an

521:34

interface right here give a name of like

521:35

math or operation or something like that

521:38

and inside that we're going to be just

521:40

creating this signature right here so X

521:42

is going to be a number and also the Y

521:44

is going to be a number and we are going

521:46

to be also providing a return type of

521:48

number as well and there we go now let

521:50

me just use the right here so let's

521:52

suppose we have a add function and we

521:54

want to provide that math operations

521:56

right here and also we are going to be

521:59

providing the A and also the Y and we're

522:01

going to be just using like a plus b oh

522:03

not A+ y but a plus b rather I forgot to

522:07

provide this B right here okay what the

522:10

hell am I doing and now let me just log

522:12

there to the console like R 2 comma 2 or

522:16

something like that now let me just save

522:17

there and run my file so it's going to

522:19

gives us full right here why is that

522:22

because everything is successfully

522:23

working that's why if I have my mouse

522:25

over to it so here you can see it's

522:27

going to give us like math operation and

522:29

the x value is set to number and also

522:31

the Y value is set to number and the

522:34

return value is also set to number so

522:36

everything is okay so let's suppose if

522:38

you want to create one for the subtract

522:40

so I'm going to just write like subtract

522:42

baby and instead of writing this plus

522:44

symbol I'm going to just change that to

522:46

minus symbol let me just duplicate that

522:49

and I'm going to just remove 10 from 20

522:51

or something like that let me just save

522:53

that so it's going to gives us 10

522:55

ah we are adding there we are adding

522:58

there oh that's because we are still

523:00

using add we have to copy the subtract

523:02

and put it right here save my file and

523:04

run that so here you can see it's going

523:07

to give us minus 4 which is not correct

523:10

oh we are doing the other way around

523:12

anyways so it doesn't even matter but

523:14

this is how we are going to be creating

523:15

an interface and this is how we are

523:16

going to be using that inside a function

523:18

so now let's learn about interfaces with

523:21

methods so we can also specify the

523:23

methods inside the interface we can just

523:25

create a person interface right here I'm

523:27

going to provide a first name and the

523:29

first name will be set to string the

523:31

last name will be also set to string and

523:33

I'm going to also specify the edge will

523:35

be set to number and say hello this

523:38

person will be also able to say hello

523:40

right here and we're not going to be

523:42

returning anything so that's why we have

523:43

to set there to Wi so now let me just

523:45

create a function I'm going to give a

523:46

name of like greed and also for the

523:49

perimeter it's going to take a person

523:51

and for a time it's going to take that

523:53

uh that interface which we already

523:55

created right here so this one should be

523:57

lower case and there we go and now

523:59

inside this function body we're not

524:00

going to be doing anything crazy but we

524:02

are going to be just loging to the

524:03

console like hello and uh person. first

524:06

name and also the person. last name as

524:10

well now let me just go back and I'm

524:12

going to just use like person. say hello

524:15

right here and execute that so now if i

524:17

s that what I want to do is that I

524:20

wanted to create that first name last

524:22

name I want to create a separate object

524:23

right here it is already giving us right

524:25

so I'm going to just provide all of

524:27

these properties like first name of John

524:29

the last name of Dow The Edge will be 30

524:32

and say Hello uh let's just remove that

524:35

right here sell my file and say hello

524:37

and inside that we are just providing

524:39

like uh I don't know hi there or you

524:41

know I'm going to just write like hi

524:43

there right here instead of hello so

524:45

this is how we are going to be creating

524:47

uh or this is how we are going to be

524:48

providing interface for the object as

524:50

well we can also provide that method

524:52

body right here and here you can see we

524:54

have this John and that's that now let

524:58

me just duplicate that right here I'm

524:59

going to just duplicate that I'm going

525:01

to just create one more person so I'm

525:03

going to just change the name up there

525:04

to like husan and I'm going to also

525:06

change this not this one come on I'm

525:08

going to change this name to husan and

525:11

also let's just change this name to webd

525:14

and the age will be 20 and I'm going to

525:17

just say like what's good or you know

525:19

what uh was good would be fine okay now

525:22

let me just use that grid method right

525:24

here which we already created right here

525:27

I'm going to just create that greed

525:29

method and I'm going to specify the John

525:31

and also hosan right here so now let me

525:33

just save that and now let's just run

525:35

that right here we are getting all of

525:37

their results but that's not looking

525:39

that much cool so I'm going to just run

525:41

it once again and we are getting like

525:42

hello John do hi there hello hose web

525:46

what's good okay so this is how we are

525:48

going to be defining our interface this

525:50

is how we are going to be using that

525:52

interface inside this function this is

525:54

how we we going to be creating an object

525:56

based on this same interface right here

525:58

we have two objects and this how we're

526:00

going to be providing a value for this

526:01

same interface right here now let me

526:03

just give you one more example because I

526:05

want to give you a lot of example uh for

526:07

these interfaces because I know a lot of

526:09

instructors say like oh my God

526:11

interfaces are supremely awful and I

526:14

cannot give a lot of example oh God damn

526:17

it my throat kind of

526:20

hurts I got to stop doing that now let

526:23

me just write my interface once again

526:25

and I'm going to just create an

526:26

interface of song and I'm going to just

526:28

write a song name you can also provide a

526:30

title whatever and I'm going to also

526:32

provide a singer name and singer name

526:35

will be string and also for the print

526:38

song in come on print song info uh what

526:43

we are going to be doing is that we are

526:44

going to be providing the song name and

526:46

the song name will be set to string and

526:48

I'm going to also specify the single

526:50

name and the single name will be also

526:52

set to string and we're going to be also

526:53

providing it for the return as well now

526:56

let me just go back and I'm going to

526:57

just create a song one right here and

526:59

it's going to be equals to the song

527:00

interface and now inside this object

527:02

we're going to be using like song name

527:04

and it's going to be equals to like

527:07

natural okay and the singer name will be

527:10

equals to uh imagine and also print song

527:16

info and we are going to be providing

527:18

the song name first of all and we're

527:20

going to be also providing the singer

527:21

name and inside there what do we want to

527:24

do

527:26

we are going to be just returning like

527:27

uh I don't know song and first of all we

527:30

have to render the singer name so not a

527:33

singer but a song name right here and

527:36

then we also have to render the singer

527:39

also as well so I'm going to just use

527:41

like singer name singer if you already

527:44

have that let me just copy the singer

527:46

name and put it right here but why on

527:48

Earth we are getting this error oh I

527:50

forgot to include these annotations

527:52

right here there we go now that's

527:53

looking better I'm going to save this

527:55

file and I'm going to just use that

527:57

right here so I'm going to use like song

527:59

one. print song print song info and I'm

528:02

going to just provide natural we already

528:05

provide the but yeah I'm going to just

528:07

do it right here once again and I'm

528:10

going to provide like

528:11

imagine uh dragon right here so now let

528:14

me just save that and execute that once

528:16

again so here you can see we're now

528:17

getting the song name which will be set

528:19

to natural and we also have a singer

528:21

Imagine Dragon right here everything is

528:24

okay and that was just it about for

528:26

interfaces using with function and also

528:30

with methods as well now let's learn

528:32

about how we are going to be extending

528:34

the interfaces or borrowing the

528:36

functionality from the parent interface

528:38

to the children interface so how can I

528:40

go about doing that I'm going to create

528:42

an interface right here and I'm going to

528:44

give a name of like movie details the

528:46

first property I'm going to set that to

528:48

read only and I'm going to just set that

528:50

to name and string I'm going to also

528:52

provide ratings to it so the ratings

528:54

will be set to number number and also

528:55

for the print movie info right here what

528:58

you want to do we just want to provide a

529:00

name it's going to take a string we also

529:02

have to provide a price as well and the

529:05

price will be set to number and we also

529:07

want to provide a ratings uh and the

529:09

ratings will be also set to number as

529:11

well now let's just provide for the

529:13

return so we are going to be either

529:14

using a string or number right here now

529:18

outside from there what do you want to

529:19

do we just want to uh extend both of the

529:22

interfaces so I'm going to just write

529:23

interface I'm I'm going to give a name

529:25

of like movie genre and I'm going to

529:28

extend EXT NDS extends this movie uh

529:32

detail right here so what I'm doing is

529:35

that I'm creating a new interface and I

529:38

am borrowing all of the functionality

529:40

which we currently have inside this

529:42

interface to this movie genre right here

529:45

okay so this is what I'm doing right now

529:47

and I'm going to just write like genre

529:49

and set that to string okay and what I

529:52

want to do is then I'm going to just

529:53

create a movie right here like con movie

529:55

one and it's going to be equals to some

529:57

sort of a movie like movie genre so now

530:00

we are using this movie genre so which

530:02

means like we are also extending the

530:04

functionality from this movie D so we

530:06

have to first of all satisfy this one

530:08

then we have to satisfy this movie genra

530:10

or this specific genre right here so now

530:13

let me just write a code then you'll get

530:14

to know what I'm talking about so I'm

530:15

going to just use like name and I'm

530:17

going to just fill it with this one

530:18

right here so the first one requires a

530:20

name I already provide that name and it

530:22

requires the ratings I already PR the

530:25

ratings then we are using this movie uh

530:27

genre right here you can put that at the

530:30

end you can put it anywhere you want but

530:32

I just put it right here so we have a

530:33

genre as well and then we have the

530:36

Sprint movie info so we satisfy both of

530:39

these interfaces right here in this case

530:42

what we are doing is that we are

530:43

borrowing all of the functionality of

530:45

this interface and we are putting it

530:48

right here in this interface right here

530:50

okay then we are providing that movie

530:52

genre interface right here so which

530:54

means like we have to now satisfy both

530:56

of these interfaces like this interface

530:58

and also this interface as well so there

531:01

we go we already provided values for

531:03

them so now let me just create a

531:04

response like cons response and we're

531:07

going to be providing a movie one. print

531:09

movie in for right here and I'm going to

531:11

just specify like John Vick and I'm

531:14

going to also provide uh I don't know

531:16

the price of 100 and the ratings of ADD

531:19

and there we go now I can log there to

531:21

the console successfully now let me just

531:22

run that and here you can see we have a

531:25

movie name of John Wick the price is 100

531:28

and also we have a ratings of a right

531:30

here amazing so yeah this is how we are

531:33

going to be extending interface from

531:35

another interface now finally let's

531:37

learn about interfaces with classes baby

531:40

so what I want to do is I'm going to

531:42

just create an interface give a name of

531:44

like vehicle and inside this interface

531:46

we would have like uh two method like I

531:48

don't know start and it's going to be

531:51

also a wi because we're not going to be

531:54

uh getting some sort of a return

531:56

statement so it's going to be wide and

531:57

we also have a stop one as well I'm

531:59

going to execute this one as well and

532:01

it's going to be wide as well now let me

532:03

just create a class I'm going to give a

532:05

name of like car and we are going to be

532:07

using the implements right here IM l m

532:11

NTS if I can spell that today and

532:14

vehicle okay so we are going to be

532:16

providing this vehicle right here so now

532:18

we are using this vehicle interface

532:20

inside this car or we are implementing

532:23

that so we have to just use this

532:24

Implement resert keyword right here okay

532:26

so I'm going to just satisfy this

532:28

interface which we already using so I'm

532:30

going to use like start method and I'm

532:32

going to just write like car is starting

532:34

and now I'm going to just duplicate that

532:36

part a comma change that to stop and by

532:40

the way we don't have to specify the

532:41

Comm I don't even know why I did that

532:43

and car is stopping uh or stopped uh s o

532:49

p let's just remove that I'm going to go

532:52

back and this is how we are going to be

532:54

using there this is how we are going to

532:55

be defining our interface and this is

532:57

how we are going to be using that and

532:58

this is how we are going to be

532:59

satisfying all of the properties or

533:02

methods in this case of this vehicle

533:04

interface right here okay so now how the

533:06

what we are going to be using this so

533:07

I'm going to just use like C my car and

533:10

it's going to be equals to new car

533:12

because this is a class and we can now

533:14

use like my car. start we can start the

533:17

car now let me just start the car and

533:19

saell them and car is starting right

533:21

here if I want to stop them I'm going to

533:23

just duplicate head there and change

533:25

that to stop sem my file and run there

533:27

so we have car is starting and we also

533:30

have car is stop right here okay so this

533:32

is how we are going to be using the

533:34

interfaces with classes baby so now

533:37

there is only one topic left which is

533:39

called declaration merging so now let's

533:41

talk about the Declaration merging so

533:43

once the interface is declared it cannot

533:45

be directly modified however typescript

533:48

allows what is informally referred to as

533:51

declaration merging or interface

533:53

extensions which is often misconstructed

533:56

as reopening some people like call it

533:59

reopening so all of these three names

534:01

work if you want to call it whatever you

534:02

want to call it so what is a declaration

534:04

merging declaration merging in

534:06

typescript refers to ability to extend

534:08

or argument an existing declaration

534:11

including interfaces as well and this

534:13

can be useful when you want to add a new

534:15

Properties or methods to existing

534:17

interface without modifying the original

534:19

declaration okay so how in the word we

534:21

are going to be doing there the syntaxes

534:24

to simple like once we Define some sort

534:26

of interface we provide a property we

534:28

provide our method and we want to later

534:30

provide something else so we can totally

534:32

do that or if you want to change the

534:34

existing ones so we are going to be

534:37

using this exact same syntax like this

534:40

exact name this exact syntax and in this

534:43

case we are going to be providing this

534:44

new uh properties right here like model

534:46

will be set to string and also we have a

534:48

stop method right here in this case we

534:50

have a brand of string and we also have

534:52

a start method but now in in this case

534:54

we are using a declaration merging or

534:56

you can also say the interface extension

534:59

or some people also call it God forbid

535:02

reopening an interface so yeah this is

535:05

how we are going to be using that so you

535:07

just have to specify your interface name

535:09

and then you just have to satisfy there

535:11

but this is how we are going to be doing

535:13

a declaration merging so what I want to

535:15

do is I'm going to delete all of the

535:16

code and now let's talk about a

535:18

declaration merging so I'm going to just

535:19

write like original interface right here

535:22

so first of all we are going to be

535:23

creating original interface so interface

535:27

and I'm going to just give a name of

535:28

like car and inside this car we would

535:31

have a brand and it's going to be set to

535:33

string and I'm going to also provide a

535:34

start method right here so a start

535:36

method would be set to wide right here

535:39

so later in some cases if I want to

535:41

change specific property or if I want to

535:43

provide a new ones to it so then what we

535:45

are going to be doing we are going to be

535:47

doing a declaration merging or you can

535:50

also say like interface

535:52

extend or whatever you want to call that

535:55

now let me just delete that stuff from

535:57

here and I'm going to just write model

535:59

and model will be set to string and I'm

536:01

going to also specify the Stop and this

536:03

is going to be the method and I'm going

536:05

to just set that to Wi now let me just

536:07

create my card so I'm going to just

536:08

create like C my carard and this going

536:10

to be uh the car interface and we are

536:13

going to be just satisfying all of that

536:15

methods and this is how we're going to

536:16

be satisfying all of that methods so we

536:18

have a brand of BMW we have a start

536:21

method we also have a stop method but

536:23

did we forgot something

536:25

else brand oh we also forgot this uh the

536:29

model I don't even know what a model is

536:31

but I'm going to just write a model of

536:34

Yep this one

536:36

M3 thank you so much AI so now let me

536:39

just save that and this is how we are

536:41

going to be satisfying them so now let

536:43

me just go ahead and use that right here

536:45

so I'm going to just loog to the console

536:47

like my car do I don't know start method

536:50

I'm going to just save that and run that

536:52

so it's going to gives us start and

536:55

undefined uh oh that's because we are

536:57

already console logging there that's why

536:59

we get this undefined so now let me just

537:01

remove then and save that it's going to

537:03

only give a start right here we can even

537:05

stop work car let's just stop work car

537:08

baby stop run that and it's going to

537:11

stop our car it's going to first of all

537:13

start it and then it's going to also

537:14

stop it right here and you can have

537:16

access to the brand and also the moral

537:18

as well and that was it about the Deep

537:21

dive into the interfaces in typescript

537:24

so now let's talk about one of the best

537:26

feature in typescript which is called

537:28

generics so what in the world are

537:30

generics and why you should care about

537:32

them so in tcri generics allow you to

537:34

create reusable component that work with

537:36

a variety of types like generics makes

537:38

it possible for you to Define function

537:40

classes and interfaces that can work

537:42

with different data types without having

537:44

to duplicate or code and here the

537:46

keyword is different data types now you

537:48

might be thinking like husan isn't that

537:51

any type like if we use the any type we

537:53

can provide any data type no generics

537:56

are totally different than that so we

537:58

can also create a generic function and

538:00

we can also create a generic classes

538:02

which we are going to be also learning

538:03

in this section now let me just give you

538:05

some sort of a code without using a

538:08

generic function and then we are going

538:09

to be refactoring that code to use a

538:11

generic function so here you can see we

538:13

have like three Arrow functions right

538:14

here the first one will only take a

538:16

string value like here we have to

538:18

specify string value right here because

538:21

here we are now annotating our parameter

538:23

as a string so here you can see we have

538:25

to specify a string right here if we

538:27

specify like I don't know some sort of a

538:29

number or I don't know if some sort of

538:31

like a Boolean value so it's going to

538:33

throw us an error and here you can see

538:34

for the next function we have to specify

538:37

the number if you specify something else

538:39

like string or Boolean or something like

538:42

that it's going to throw us an error why

538:44

is that because here we are requiring

538:47

the number right here like we are

538:48

inating our perimeter as a number so

538:51

here we have to specify number right

538:53

here now the the final one we'll also do

538:55

the same like for Boolean we have to

538:57

specify a Boolean right here if we

538:58

specify some sort of a number or string

539:01

it's going to throw us an error so now

539:03

the one way to solve this problem is to

539:05

use one of the orful typescript feature

539:08

which is called uh any so we have to

539:10

remove this string we also have to

539:12

remove this number and also the Boolean

539:14

so here we have to just replace them

539:15

with any type and that's going to do it

539:17

for us but that's not a best practice we

539:20

have to figure out some way so that we

539:22

create some sort of a function and we

539:24

provide some specific type for that

539:26

function and then we have to specify

539:28

some sort of value based on that

539:30

specific type okay so for them we are

539:32

going to be using generics and how we

539:34

are going to be creating a generics this

539:36

is how we are going to be creating a

539:37

generics like totally easy but the thing

539:41

is here you can see for this function

539:43

let me just say that here you can see

539:45

for this function we are specifically

539:47

providing or we are specifically

539:49

annotating that to the string to the

539:51

number and also to the Boolean as well

539:54

and what are these thing called These

539:56

are called a function perimeter area

539:59

right here like all of these things are

540:01

called a function perimeter right here

540:03

now on the other hand let me just show

540:05

you this this is a typ perimeter right

540:09

here like anytime we want to create some

540:10

sort of a generic function here this

540:13

area we can also specify type right here

540:16

or we can also just abbreviate that to T

540:18

in this case I just abbreviate that to T

540:20

but you can also write a type if you

540:21

wanted to so this area here you can see

540:24

that I just highlight that this area is

540:26

known as a type perimeter like which

540:29

kind of type we are going to be

540:31

specifying right here for the specific

540:33

function this area which you can see

540:35

right here is a function perimeter area

540:38

right here also I want you to notice

540:40

like also this area is a tie perimeter

540:44

area right like for this area we have to

540:47

specify some sort of a value like we can

540:49

either provide a string we can provide a

540:50

number we can also provide a Boolean

540:52

word here and it's going to gives us

540:54

based on there like here you can see the

540:55

first one is going to gives us a hello

540:57

because we are now annotating there or

540:59

we are specifying the value for this

541:01

perimeter area right here the string

541:03

type so here you can see we have to

541:05

specify the string value right here and

541:07

it's going to gives us the result of

541:08

string then for the number we are

541:10

providing a number and we are also

541:12

getting the number right here then

541:13

finally for the Boolean we are providing

541:15

a Boolean and finally we are getting the

541:16

Boolean value right here okay so yeah

541:19

that was a lot of talking so now let me

541:21

just give you some sort of example and

541:22

then you'll get to know what I'm talking

541:24

about so the first thing which I want to

541:25

do is that I'm going to create a lot of

541:27

function and they are not going to be a

541:29

generic function so I'm going to just

541:30

create a regular like typescript or

541:32

JavaScript function right here the first

541:34

one will be for the print number right

541:36

here and it's going to take the

541:37

perimeter of like item or something like

541:39

that and I'm going to otate there with a

541:40

number and I'm going to also specify

541:42

default value here like come on default

541:45

and here I'm going to just specify the

541:46

number right here and I also forgot to

541:49

include the return type as well so it's

541:51

going to take a number and also the

541:52

number as well so now let just go back

541:55

and here inside this function what do

541:56

you have to do we are going to be just

541:58

returning the item and also the default

542:00

value right here okay so instead of

542:02

writing a default I'm going to just

542:03

change that to like uh default value or

542:06

something like that and here you can see

542:08

that error is gone so now if I want to

542:10

run this code so what do I have to do

542:12

for that well I'm going to just write

542:13

like I don't know con number is going to

542:15

be equals to this Sprint number number

542:17

right here and I can specify any number

542:19

I want and now let me just loog to the

542:21

console this number right here what is

542:23

is going on print number expect two

542:26

parameter right here so I'm going to

542:27

just specify like 12 and 20 right here

542:29

now let me just save that and run my

542:31

file so here you can see it's going of

542:33

gives us array of 12 and also 20 right

542:35

here which is a okay so let's suppose if

542:38

I specify something else like string now

542:40

let me just write like something and I'm

542:42

going to also specify the Boolean right

542:44

here like true and now if I sell that

542:46

and if I run that it's going to give us

542:47

this air like argument of type string is

542:50

not assignable to a perimeter of type

542:52

number right here you got to do

542:53

something about that so now let me just

542:55

remove that from here now let me just

542:57

provide one and I'm going to also

542:59

specify two right here so which means

543:01

like we can only specify the number

543:03

values right here we cannot specify the

543:05

string we cannot specify the Boolean or

543:08

anything like that so the next thing

543:09

which I want to do is I'm going to just

543:10

create one for like I don't know for a

543:12

string like I don't know print string or

543:15

something like that and I guess that

543:17

would be it so now let me just duplicate

543:18

them and change this one to stir for a

543:21

string and also print string right here

543:24

and in this case we are not able to

543:26

provide let me just write a St right

543:28

here and by the way I forgot to also

543:31

change this to string right here so now

543:33

let me just change that to

543:36

string and here you can see it is now

543:38

giving us an error if I have my mouse

543:39

over to it so it is also giving us that

543:41

same error like argument of type number

543:43

is not assignable to a perimeter of type

543:45

string so yeah we have to specify some

543:47

sort of a string value right here so I'm

543:49

going to just write like uh I don't know

543:50

hello and I'm going to also specify word

543:53

or something something like that and now

543:54

if I sell my file and run that and let's

543:57

just remove that from here and let me

544:00

just rerun that once again so here you

544:02

can see it's going to gives us hello and

544:03

also the word right here so now let me

544:05

just also write one function for the

544:07

booleans as well so I'm going to just

544:08

write like print bull bull or Boolean

544:11

rather I'm going to change the timee to

544:13

Boolean and now I'm going to just

544:16

duplicate this line of code change this

544:18

one to BU or something like that and

544:21

print bull right here or Boolean rather

544:24

so it's going to give us that like

544:25

argument of type string is not

544:26

assignable to a parameter of type

544:28

Boolean we have to specify some sort of

544:30

a Boolean value right here okay so if I

544:32

just write like true and false and now

544:35

if I save that and let's just log that

544:37

bull to the console as let me just save

544:39

this file and run there so here you can

544:41

see we are now getting true and also the

544:43

false value right here which means like

544:45

everything is totally working a okay but

544:48

the problem which we are currently

544:50

facing is that uh we have to specify

544:53

number for this print number right here

544:55

we have to specify string for the print

544:56

string function and we have to specify

544:59

the Boolean for this print Boolean

545:00

function right here like we cannot

545:02

provide a number for the Boolean we

545:04

cannot provide a number for a string and

545:05

also Boolean for a string we cannot

545:07

provide Boolean or number I mean like we

545:09

cannot provide Boolean or string for

545:11

this print number function right here we

545:13

have to do something about that well the

545:16

first answer is now let me just remove

545:18

that and also these other functions as

545:20

well now let me just remove that I can

545:22

just specify the any type of right here

545:24

if I just write any I don't even have to

545:26

like annotate that with any right here

545:28

but anyways if I just save that now let

545:30

me just log to the console this num and

545:32

I'm going to specify um yeah a number

545:36

will be for the first one and for the

545:38

second one I'm going to just write like

545:39

something and it's not going to take

545:41

three parameters so yeah that's it now

545:43

let me just save that and run that and

545:45

here you can see it's going to give us

545:46

one for a number and also something as a

545:48

string word here now our problem is

545:50

totally solved but I want to ask you a

545:53

question like in this code where in the

545:55

word is typescript playing their role

545:58

well nowhere like we are not even using

546:00

a typescript for that we are just

546:02

writing this extra code right here we

546:04

are not using typescript anywhere inside

546:06

this code and typescript is all about

546:08

types and we have to do something about

546:10

that okay so to do something about that

546:13

we are going to be refactoring all of

546:15

that code which I just wrote right here

546:17

we are going to be refactoring all of

546:18

that code to one simple function which

546:21

is called generic function and trust me

546:24

the syntax is totally simple and awesome

546:27

so now let me just create a generic

546:29

function right here so anytime you want

546:31

to create a generic function we are not

546:33

going to be doing anything special but

546:34

we are going to be just creating our

546:36

function just like that let me just

546:37

highlight there for you we're going to

546:39

first of all providing the function

546:40

Reser keyboard then specific name for

546:42

our function then the perimeter area and

546:44

also our curly braces right here but now

546:47

I'm going to just specify some sort of a

546:48

name right here let me just zoom in a

546:50

bit I'm going to specify some sort of a

546:51

name like unique data

546:54

type come on typs I guess that's going

546:56

to be fine or unique data types function

546:58

would be fine rather and I'm going to

547:00

also remove this prems and I'm going to

547:02

just change that to like uh I don't know

547:04

item and I'm going to just annotate that

547:07

with something but you know first of all

547:09

let me just write a comma and then the

547:10

default value so I'm not going to even

547:13

annotate that and I'm not going to

547:14

provide any annotation for the return

547:16

value as well so the first thing that

547:18

you have to keep in mind anytime you

547:19

want to create a generic function is

547:21

that how many data types this function

547:23

is going to take as a value so in this

547:26

case I'm going to just specify one right

547:28

here just for this specific example

547:29

we're not going to do anything crazy not

547:31

right now but we will very soon so I'm

547:34

going to just write a less than sign

547:35

come on less than sign and here we have

547:37

to specify type right here and I'm going

547:39

to close that this area is a type

547:42

perimeter area right here and also this

547:45

area is a function perimeter area right

547:48

here so now that we make clear that you

547:50

can specify any type you want right here

547:53

this a type perimeter area right here

547:55

like we have to specify some sort of a

547:57

type for that so type is declared but

547:59

its value is never readed okay so we are

548:01

going to take care of that in a few

548:02

seconds now the next thing which you

548:04

have to do is that we have to use this

548:05

type somewhere inside our function so

548:08

where we are going to be using that I'm

548:09

going to copy that and I'm going to

548:11

annotate that for the item now let me

548:13

just write item and I'm going to just

548:14

specify this type right here and I'm

548:16

going to also specify it for the default

548:19

value as well and I'm going to also

548:21

specify it for the return value of this

548:23

function

548:24

as well or you know what we're going to

548:26

be returning like two values so I'm

548:27

going to just write array of type and

548:29

also the type right here just like for

548:31

this function we are returning like uh

548:33

two values right here so we are now just

548:36

annotating them like this okay so this

548:39

is how we are going to be creating our

548:40

generic function and I know that's going

548:42

to look a bit weird but trust me this is

548:44

not that much weird thing to learn in

548:46

typescript but yeah let me just say that

548:48

once again first of all we are going to

548:49

be creating some sort of a JavaScript or

548:51

typescript function we can give it any

548:53

name we want and then we have to specify

548:56

some sort of a type right here like this

548:58

area is known as a perimeter area you

549:01

have to specify some sort of a value for

549:03

this perimeter right here and then we

549:05

are reusing that perimeter right here

549:07

and also here as well and also for this

549:09

return type as well so currently we are

549:12

not even specifying or we are not even

549:13

returning something from our function so

549:15

that's why we are now getting this error

549:17

right here but now what I want to do is

549:20

that I'm going to just return that item

549:22

and also the default value as well okay

549:25

so now let me just return that the next

549:27

thing which I want to do is that you

549:28

know let me just save this file and it's

549:30

going to format my code like that but

549:32

now we have to use this um unique

549:35

function right or unique data type

549:36

function somewhere I'm going to copy the

549:38

name of that so now let me just ask you

549:40

a question I'm going to just place it

549:41

right here so now let me just ask you a

549:43

question like what in the world we are

549:45

going to be doing right now well the

549:47

first thing which you have to do is that

549:49

we have to specify some sort of a value

549:51

for this type right here so how we are

549:53

going to be doing there this is how we

549:56

are going to be doing there I'm going to

549:57

just write a less than sign and here we

549:59

have to specify like which kind of type

550:01

we are going to be providing for this

550:02

specific type perimeter right here like

550:04

this is going to be the perimeter area

550:06

and here we have to specify some sort of

550:07

an argument for this specific type right

550:09

here so in this case uh you know what

550:11

I'm going to just specify like number

550:13

right here so I'm going to just write

550:14

number and I'm going to have to close

550:16

that the next thing which you have to do

550:17

like this area is totally done now the

550:20

next thing which you have to do is that

550:21

we have to take care of the function

550:23

perimeter right here or function takes

550:25

two parameter like the first perimeter

550:27

it takes is the item and the second one

550:29

it takes is a default value right here

550:31

so now we have to specify some sort of a

550:32

value for the item and also for the

550:34

default value right here so I'm going to

550:36

just write my all like parentheses like

550:38

that you know let me just remove that

550:40

for a second so now let me just specify

550:42

some sort of value for the item and also

550:43

for this default value right here okay

550:45

so I'm going to just specify like 10 for

550:47

the item and also 20 for the default

550:49

value right here so that is totally

550:51

satisfied so now here I'm going to just

550:53

write this code once again it did not

550:55

confuse you so this is how we are going

550:57

to be registering or creating our first

550:59

generic function and this is how we are

551:01

going to be using that so we can also

551:03

wrap that with a console log but you

551:05

know what let me just throw in some sort

551:06

of variable like cons and it's going to

551:08

be equals to this uh generic function

551:10

call and now let me just log this res

551:12

right here to the console okay so if I

551:14

save this file and now let me just run

551:16

that so it's going to gives us like 10

551:18

and also the 20 right here which is

551:21

totally amazing you you can like

551:23

re-watch this video if you wanted to but

551:25

you don't have to like I explain every

551:27

single thing about generics right here

551:29

so now the question is here we can

551:31

specify the number right here can we

551:33

also specify the string as well yep you

551:36

totally can now let me just duplicate

551:38

that and here instead of writing a

551:40

number I'm going to just specify string

551:42

right here but here we also have to

551:44

specify the string value so I'm going to

551:46

just write like I don't know hello and

551:48

I'm going to also write word right here

551:51

and let's just change that to like stir

551:53

or something like that this one will be

551:55

just num and I'm going to duplicate that

551:59

change this one to num and this one to

552:01

stir for a string now let me just save

552:03

my file and now if I run that what do

552:05

you think will be the result you already

552:07

know the result but hey here you can see

552:09

we are now getting hello and we are also

552:11

getting the word right here so I want

552:13

you to think about generic functions is

552:15

like a component a component which you

552:18

can use throughout your project here you

552:19

can see we're using it for a number we

552:21

can also use that for a string and you

552:23

can also use it for Boolean as well so

552:25

now let me just write Boolean and here

552:27

we have to just um change that to Bull

552:30

or something like that I'm going to

552:31

duplicate this kind of code and let me

552:33

just write a bull and instead of writing

552:35

hello let me just remove that hello from

552:37

here and true um I don't know true once

552:41

again or you know let me just write a

552:42

false right here now let me just save

552:44

that and if I run my code you already

552:46

know what it will gives us it's going to

552:47

gives us true and false right here for

552:50

the values so if this is the first time

552:52

you're watching a generic function so it

552:54

may look a little bit intimidating but

552:55

trust me it's not here we have to

552:57

specify some sort of a perimeter for um

553:00

come on for a type and here we have to

553:02

specify our own perimeter for a specific

553:05

function if you want it to you totally

553:07

can but if you don't want it to you

553:09

don't have to okay so now let me just

553:11

remove this type I'm going to just hold

553:12

control and hit D hit d d d instead of

553:16

writing this type we can also change

553:17

that to T right here okay now let me

553:19

just save them and this is how we

553:21

usually write or generic function right

553:24

here and now I'm going to give you a lot

553:26

of example by using generic functions so

553:29

you're are going to have a lot of

553:30

experience right now so you know what

553:32

before we move on to next topics uh I

553:35

want to explain one more thing now let

553:37

me just remove there also remove this

553:39

one as well let me just create some sort

553:41

of interface so now let me just write

553:42

like interface I'm going to give a name

553:44

of like dog and inside this dog we're

553:46

going to have some sort of a name which

553:47

will be string and also the breed itself

553:50

and the breed will be also string right

553:52

here so you know in instead of providing

553:53

a number or a string or a Boolean we can

553:56

also specify our own type or our own

553:59

interface right here to a generic

554:01

function so how we are going to be doing

554:02

that so this is how we going to be doing

554:04

there so I'm going to just write cons

554:06

dog one or something like that and it's

554:08

going to be equals to that specific

554:09

function so the first thing you have to

554:11

do is that we have to specify some sort

554:13

of value for this perimeter right here

554:15

so we are going to be specifying the

554:17

type of dog so now let me just specify

554:19

that and we can also specify our own

554:21

values for this item and and also for

554:23

the default value as well so what I want

554:25

to do is that I'm going to just specify

554:27

some sort of value for the name uh I

554:30

totally can yeah you know what let me

554:32

just provide like some sort of a name

554:33

right here and the name will be I don't

554:34

know buddy or something like that I'm

554:36

not that much good with dog so now let

554:38

me just write breed and the breed will

554:40

be this breed right here I can't even

554:41

pronounce this name let me also put a

554:44

comma and I'm going to also specify the

554:46

name once again and the name will be set

554:47

to default and also let me just provide

554:50

some sort of a breed and the breed will

554:52

be like unknown or something like that

554:54

now let me just save there the next

554:56

thing which I want to use I'm going to

554:57

just log there to a console like dog one

554:59

let's just save there and run there so

555:01

it's going to give us like a name of

555:03

this name which you can see right here

555:05

like the name of biry the breed of this

555:07

breed and also we have another one like

555:09

name will be set to default and breed

555:10

will be set to unknown okay so that's

555:13

the now let me just clear this out and

555:16

that's the so now the next thing which I

555:18

want to do is that I'm going to remove

555:20

every single thing from here and now let

555:21

me just give you one more example which

555:23

will be a generic functions to get a

555:24

random key value pairs from an object so

555:28

how we are going to be doing that well

555:30

first of all we have to create our

555:31

generic function so let me just write

555:33

get random uh key value pair or

555:36

something like that and I'm going to

555:38

specify the type of uh you know first of

555:40

all let me just write my generic

555:42

signature right here so it's going to

555:43

take one t like type parameter right

555:46

here and I'm going to specify some sort

555:48

of object and I'm going to inate that as

555:50

a key let me just put a key and it's

555:53

going to take that key as a string and

555:55

also outside from this object we are

555:57

going to be also providing our own type

555:59

right here which we specified right here

556:01

inside this perimeter area Okay so

556:03

that's that or you know what not outside

556:06

from that now let me just cut that and

556:07

put it right here and now let me just

556:09

specify for the return value so I'm

556:11

going to just write like uh I don't know

556:12

the object of key which will be string

556:15

and I'm going to also specify the value

556:17

which will be set to type or yeah the

556:19

type which we are going to be specifying

556:21

in a few seconds so that's then now let

556:23

me just sa there and if I have my mouse

556:25

over to it so a function whose decare

556:27

types is neither undefined white nor any

556:29

must return some values come on time

556:31

script give me a break now let me just

556:34

write the code then you'll get to know

556:35

what I'm talking about so you know let

556:37

me just write some sort of a return

556:38

statement so it stop giving me that

556:40

error right here so now let me just

556:42

write or logic so I'm going to just

556:43

write like cons keys and it's going to

556:45

be equals to this object. keys right

556:47

here and here we have to specify our

556:49

object which we are getting as a

556:51

perimeter and all so let me just get a

556:53

random keys or Rand key or something

556:56

like that it's going to be equals to

556:57

that keys and here we have to use our

556:59

met. floor and let me just provide a

557:02

math. random so we want to get a random

557:04

number from there from where from the

557:06

keys do come on keys do oh my God not

557:10

that not L there we go so that's then

557:12

now underneath this random Keys what do

557:14

you want to do we just have to return

557:16

something so what do you want to return

557:17

we just want to return the key of random

557:19

key and I'm going to also return the

557:21

value and the value I'm going to just

557:23

return the object and here we have to

557:25

specify that random key right here now

557:27

let me just save that but I don't know

557:28

why we getting this error right here oh

557:31

instead of writing this array we have to

557:33

change that to object so now let me just

557:34

change that to object and also remove

557:36

that so yeah now let me just use it

557:39

right here so the first thing which I

557:40

want to do is I'm going to just create

557:41

some sort of object then from that

557:43

object we're going to be getting some

557:44

sort of a random um keys right here so

557:47

now let me just do that so the first

557:49

thing which I want to do is I'm going to

557:50

just create some sort of a string object

557:52

so con ring obj or object rather and

557:55

it's going to be equals to this object

557:57

and I'm going to just provide the

557:58

property of a and it's going to be

558:00

equals to Apple and I'm going to also

558:02

specify the B of banana and also one for

558:05

the cherry or I don't know whatever you

558:07

want to call that so yeah that's then

558:10

now let me just log to the console or

558:11

you know why we are not even using our

558:13

function so now let me just use my

558:15

generic functions to get random values

558:17

from this object right here so I'm going

558:19

to just write like get random values my

558:21

function name and the first thing you

558:23

have to do is that we have to satisfy

558:25

the type okay so the type I'm going to

558:27

provide like uh string right here

558:29

because currently we are working with a

558:30

string and then we have to specify the

558:32

value which this object is taking right

558:33

so I already created this object right

558:35

here so I'm going to copy that and put

558:36

it right here so now let me just log

558:38

there to the console so cons and log

558:40

there to the console like res save my

558:42

file and run that so it's going to gives

558:44

us like key of A and value of apples so

558:48

now let me just rerun that once again

558:50

and it's going to give us the qy ofc and

558:52

the value be cherry or cherry whatever

558:54

you want to call that and here you can

558:56

see we have the key of B and the value

558:58

of banana right here so it's going to

559:00

give us a random keys from this object

559:02

right here so this is how we're going to

559:04

be testing for a string so now let me

559:06

just duplicate that and put that right

559:08

here at the end I'm going to change that

559:09

to number object and it's going to be

559:12

equals to like some sort of a number

559:13

like I'm going to change this one to one

559:15

and this one to two and this one to

559:19

three right here I'm going to also

559:21

change this a b and c I'm going to just

559:23

change it to one and two and also this

559:26

one to three and I'm going to use my

559:29

function my generic function to be

559:31

precise so first of all I'm going to use

559:33

like get random values and in this case

559:35

we have to specify the number because we

559:37

are taking the number right here and

559:39

here we have to specify for the

559:40

parenthesis we have to specify this

559:42

object so now let me just copy that and

559:43

place that right here and now I'm going

559:45

to also log that to the cons like uh

559:47

instead of writing res I'm going to

559:49

write like random number here and now

559:52

let me just just log that random number

559:54

pen not

559:56

string let me just copy that put it

559:58

right here s my file and run that so

560:00

it's going to give us uh the key I me

560:03

like it's going to give us yeah the key

560:04

of two and the value of two right here

560:06

okay so now let me just rerun that once

560:08

again so it's going to give us the key

560:10

of three and also the value of three so

560:12

yeah we test it and it is working

560:14

totally a okay now the next thing which

560:16

I want to do is I'm going to just create

560:17

a generic function that filter array

560:20

based on a condition so yeah we totally

560:22

can provide a conditions as well so now

560:24

let me just remove this coding from here

560:26

and by the way you can find all of the

560:28

coding in my gab repository and Link

560:30

will be in the description below so now

560:31

let me just create a function I'm going

560:32

to give a name of like

560:34

filter uh array or something like that

560:37

and I'm going to also specify the type

560:39

parameter and in this case I'm going to

560:41

also have to specify this array right

560:43

here and the type will be set to type of

560:45

arrays and I'm going to also specify the

560:48

condition so condition there we go and

560:50

the condition will be item and also so

560:52

that type right here and it's going to

560:54

return the Boolean come on Boolean if I

560:57

can get that let me just go back and for

560:59

the return value I'm going to specify

561:01

the type of arrays right here so now let

561:03

me just write my code so I'm going to

561:05

just write like return array. filter or

561:08

JavaScript like or regular JavaScript

561:10

filter method and I'm going to specify

561:12

the item in this case and here we have

561:13

to write our condition and for this

561:15

condition we have to specify the

561:17

perimeter of item right here so now the

561:19

next thing which we have to do is that

561:20

we have to create some sort of array so

561:22

that we can iterate or through the array

561:24

and we can perform some sort of a logic

561:25

on that array so I'm going to just write

561:27

like con number array and it's going to

561:29

be equals to like uh I don't know 1 2 3

561:31

4 5 6 7 8 9 10 I guess 10 would be fine

561:36

so what I want to do is I'm going to

561:37

just get a even numbers from there so

561:39

I'm going to just use like con even

561:41

numbers and it's going to be equals to

561:42

my filter array uh generic function

561:45

right here so the first thing which I

561:46

want to use I'm going to just specify

561:47

the number and the next thing which I

561:49

want to do is then I'm going to just

561:50

specify the number array right here

561:52

which is this number array and the next

561:54

thing which you have to do is that we

561:55

have to specify the condition function

561:57

right here so I'm going to provide a

561:58

comma and now let me just specify the

562:01

condition function so I'm going to

562:02

specify the number and I'm going to also

562:04

just use like if num mod 2 is equals to

562:07

zero triple equals to zero so it's going

562:09

to gives us the even numbers now let me

562:11

just log there to the console like even

562:13

numbers now let me just go back and save

562:15

my file and this is how it looks like

562:17

now let me just run my code so it's

562:19

going to give us like 2 4 6 8 and 10

562:22

which are totally correct and these are

562:24

even numbers in MA mathematics and yeah

562:27

and also typescript as well okay so what

562:30

I want to do is that the next example is

562:33

using the array of strings so let me

562:35

just create array of strings so con

562:37

string array and it's going to be equals

562:39

to like uh I don't know apple and also

562:42

banana and also some sort of a cherry or

562:45

cherry whatever you want to call that

562:47

and that or whatever so now let me just

562:49

get a short words from this array so I'm

562:51

going to use like Shard words and it's

562:54

going to be equals to like filter array

562:56

my generic function and I'm going to

562:57

specify the string value and for my

563:00

actual parameter I'm going to specify

563:02

like string array which we are already

563:04

creating and now let me just specify the

563:06

condition uh and for this Condition it's

563:08

going to take a word and word come on

563:10

word. length uh is less than six so only

563:15

gives us them so like short words if i s

563:18

my file and run that so it's going to

563:19

only gives us the short array so here

563:21

you can see we have a apple and we also

563:23

have a dead so yeah that's also totally

563:26

correct and yeah now the next thing

563:28

which I want to do is that I'm going to

563:30

also create an interface right here so

563:32

now let me just create an interface I'm

563:34

going to just write like interface and

563:36

I'm going to also specify the fruit name

563:38

to it and the name will be set to some

563:40

sort of a string and I'm going to also

563:41

specify some sort of a color like string

563:44

as well now let me just use con uh PR f

563:48

r UI T PR array and here we have to

563:52

enter right there with our fruit

563:54

interface right here it's going to be

563:55

equals to this array and here we can

563:57

specify a lot of fruits right here like

563:59

I don't know apple and also the color

564:02

will be set to red and they shouldn't be

564:04

array it should be an object rather so

564:07

now let me just change that to object

564:09

let me proide my comma and just put a

564:11

little bit more like I don't know banana

564:14

banana is

564:16

yellow yep and I'm going to also specify

564:19

the Sherry of red as well I'm going to

564:22

also make this one uppercase R and also

564:25

this one uppercase r as well so now let

564:27

me just use my uh generic function which

564:29

is filter array let me just use that on

564:31

this array right here so what I want to

564:34

do is I'm going to just get a red roots

564:36

from the array so it's going to be

564:38

equals to filter array and here we have

564:40

to specify that fruit and close that and

564:43

the next thing which you have to do is

564:44

that we also have to satisfy or uh

564:46

perimeter area so now let me just copy

564:48

there and put our array and I'm going to

564:50

also specify our condition so fruit and

564:53

here what you have to do we have to

564:54

specify if fruit. color is triple equals

564:58

to Red so what do you want to do we just

565:00

wanted to log the red fruits right here

565:03

so if I sell my file and run that so

565:05

it's going to gives us um these fruits

565:07

right here the color will be red so here

565:10

you can see we have a name of apple and

565:12

the color is red and we also have a

565:14

cherry or cherry and the color is also

565:17

red so we are now getting there inside a

565:19

console so which means like they are

565:21

totally working okay and we learn about

565:24

generic functions a lot but that's not

565:26

it baby we got to do a lot more than

565:28

that now let me just talk to you about

565:30

generic function but which takes uh

565:33

multiple types now let me just create a

565:35

generic function which reverts the order

565:37

of two values so I'm going to just

565:38

create my generic function so I'm going

565:40

to give a name of like reverse um pair

565:43

or something like that and in this case

565:45

we have to specify two types of uh

565:48

perimeter right here okay so two types

565:50

of perimeter you can abbreviate that to

565:53

T and U or you can abbreviate that to

565:55

anything you want and now let me just

565:57

write like value one right here and for

566:00

the value one we are going to be

566:02

specifying T and now let me just also

566:03

write a value of two and for the value

566:06

two we can specify the U right here so

566:08

now let me just return the U and T and

566:11

we are going to be just reversing the

566:12

order of there like we're not going to

566:14

be doing anything crazy but we just have

566:16

write like value two and value one right

566:18

here and there we go so now let me just

566:20

create some sort of example like

566:22

reversed uh let's just change that to

566:24

cons reversed pair and it's going to be

566:27

equals to the reverse pair right here

566:29

and inside there we have to specify like

566:31

hello and also 20 or something like that

566:34

and now let me just log to the console

566:36

this reversed I'm going to copy then and

566:38

place it right here sa my file now let

566:40

me just run that so it's going to gives

566:42

us like uh 20 and hello right here here

566:45

we are specifying hello and 20 so it's

566:48

going to give us like 20 and hello I

566:50

don't know why but it is not G us some

566:52

sort of an error so now let me just

566:53

clear out the terminal once again and

566:56

rerun that so in this case it's going to

566:58

give us like 20 and hello which is

567:00

totally amazing so here you can see this

567:02

is how we are going to be specifying

567:04

multiple types of perimeter right here

567:06

so the final thing which you have to

567:07

learn about generics is a generic

567:09

classes so we are not going to be doing

567:11

anything crazy but we are going to be

567:12

just creating a class and I'm going to

567:14

just give a name of like box and here we

567:16

have to specify the dynamic or not a

567:18

dynamic but the perimeter for a type

567:21

right here so I'm going to specify the

567:23

property of private and content right

567:26

here it's going to also tag their

567:27

perimeter right here and for the

567:29

Constructor what do you have to do I'm

567:30

going to remove this parameter and I'm

567:32

going to just set that to initial

567:33

content right here and initial content

567:35

will be also set to this type and I'm

567:37

going to just say like this. content is

567:39

now equals to this initial content right

567:42

here underneath that we're going to be

567:43

defining two methods of get content and

567:46

get content is not going to take any

567:48

parameter so inside there what do you

567:50

want to do we just want to return like

567:52

this. content just to get the content

567:54

right here and we can also set the

567:56

content so set z t NT and I'm going to

567:59

just specify like new content and that

568:01

new content will tag that perimeter and

568:04

I'm not going to return anything from

568:05

that so I'm going to just specify the

568:06

white to it now let me just go back and

568:09

here we have to just write like this.

568:10

content is now equals to the new content

568:13

right here now let me just save that and

568:15

execute there now the next thing which I

568:16

want to do is that I'm going to just uh

568:18

create instance off there so I'm going

568:20

to use like new box and here we have to

568:22

specify some sort of a value for the

568:24

perimeter or type perimeter so I'm going

568:26

to just use like string and I'm going to

568:29

just provide a actual value for that

568:30

function some or not function but class

568:33

like hello typescript and now let me

568:35

just store in some sort of variable like

568:37

string box or something like that and

568:39

now let me just uh log to the console

568:41

like string box uh which we have right

568:44

here and we are going to be just getting

568:46

or executing this method right here like

568:48

get content and now let me just execute

568:50

that go back this is the code looks like

568:53

and now if I run there so it's going to

568:54

gives us uh wow it's is not giving us an

568:57

error oh it should not be equals to we

569:00

have to annotate that come on let me

569:03

just save that and rerun that once again

569:05

so it's going to gives us hello

569:07

typescript right here but we can do

569:09

crazier stuff than there so I can also

569:12

set the content so I'm going to just

569:13

write like uh I don't know string box do

569:16

set content and I can specify any

569:19

content I want like new content edit or

569:22

or something like that and you know I'm

569:24

going to just put this one right here

569:26

duplicate that and put it also at the

569:28

end as well so now let me just save that

569:30

and run there once again so it's going

569:32

to gives us like uh hello typescript and

569:35

new content edit right here okay so

569:37

which is totally okay so now let me just

569:40

also run this specific class for the

569:42

numbers as well so I'm going to just

569:44

remove that from here and let me just

569:46

zoom in I'm going to create a number box

569:49

and it's going to be equals to like new

569:51

box and for the premier I'm going to

569:53

specify number and also 20 or something

569:56

like that and underneath that we're

569:57

going to be also using like you know let

569:59

me just log their value to the console

570:01

like number box. get content and execute

570:04

that if I save there and run that so

570:06

it's going to give us like 20 totally

570:08

working now let me just use that for

570:10

setting the value number Box come on if

570:13

I can just oh my God number box there we

570:15

go do set content is now going to take

570:18

like 100 right here and I'm going to

570:20

also log that to the conso let me just

570:22

copy that and place it right here s my

570:24

file and run that so it's going to gives

570:26

us like 20 and also the 100 right here

570:29

so yeah that was it about generics in

570:31

typescript and I hope you love them okay

570:35

so yeah next we're going to be learning

570:36

about type narrowing in typescript so

570:39

now let's learn about a type narrowing

570:41

in typescript so type narrowing is the

570:43

process of refining a variable's type

570:44

within a conditional block of code and

570:46

this allow you to write more precise and

570:48

type save code so how in the word we are

570:50

going to be achieving a type narrowing

570:52

there are a lot of way to achieve the

570:54

type narrowing but in this specific

570:56

section we're going to be just learning

570:57

about the type guards the instance of

570:59

and also the insertion types okay so now

571:01

let's just start from the first one

571:03

which is a type guards so type guard are

571:05

mechanism that help typescript

571:07

understand and narrow down the types

571:08

more precisely and one common type gun

571:11

is the type of operator right here so

571:13

how the code's going to look like this

571:15

is how the code's going to look like so

571:16

you can take a screenshot of that or you

571:18

can just pause the video and write The

571:20

Code by yourself but now I'm going to go

571:23

ahead and write the code and then you'll

571:24

get to know what I'm talking about so

571:25

the first thing which I want to do is

571:27

I'm going to just Define a union type

571:29

like my type and it's going to be equals

571:30

to a string or a number right here so

571:33

now underneath there we're going to be

571:34

also creating a function I'm going to

571:35

give a name of like example or function

571:38

rather it's going to take a value and

571:40

the value type will be my type right

571:42

here and for the return statement what

571:44

do you have to do I'm going to just

571:46

specify the white because we are not

571:47

going to be returning any value from

571:49

that so that's why we specify white

571:51

right here so now let me just use my

571:52

first type guard which is called the

571:54

type of right here if the type of the

571:57

value is triple equals to string so what

571:59

do you want to do we just want to lock

572:01

to the console uh value. two uppercase

572:04

right here and now let me just execute

572:05

there so if I save my file so what are

572:08

we currently doing right here so if I H

572:10

my mouse over to the value so what are

572:11

we getting we are now getting the value

572:14

is now currently set to string so what's

572:17

going on if I just put that right here

572:18

at the top and now let me just save that

572:20

and here you can see very quick it's

572:22

going to giv us this error right here if

572:23

I have my mouse over to it so it's going

572:25

to gives us this error like um property.

572:27

two uppercase does not exist on a type

572:30

my type right here but if I put that

572:32

right here inside this F statement we

572:34

are now telling the tcri compiler if the

572:36

type of value is set to string then run

572:40

this code if that's not set to string so

572:42

what do you want to do we just want to

572:43

log to the console like value. two fix

572:46

right here it is going to be some sort

572:47

of a number like we are just sing that

572:49

to the compiler So within this block of

572:51

code typescript knows that the value

572:53

will be string and outside from their

572:56

first block now outside from this block

572:58

of code inside the else block this types

573:02

compiler will already know that the

573:03

value will be some sort of a number so

573:05

if I H my mouse over to that so here you

573:07

can see we are now getting the number

573:09

right so this is how we are going to be

573:10

narrowing the types right here so now

573:12

let me just use them I'm going to go

573:13

back and I'm going to just call my

573:15

function with the string of hello so

573:18

it's going to gives us like uppercase

573:19

hello right here so if I sve my file and

573:21

run that so it's going to gives us

573:23

uppercase hello right here which is

573:25

totally cool now let me just duplicate

573:27

that or you know let me just write

573:28

example function once again and if I

573:30

just write like 20 so it's going to

573:32

gives us 20 right here so if I save that

573:34

or not 20 but uh 20.0 0 because we use

573:37

this method of two fix right here and we

573:39

specified two so that's why we are now

573:41

getting this uh dot z0 right here so

573:44

that was the first way of type narrowing

573:46

so now let's learn about a type

573:48

narrowing with the instance of operator

573:50

right here so the instance of op is

573:52

another type guard that allow you to

573:54

check whether an object is an instance

573:56

of a particular class or a Constructor

573:58

function so this is how the code's going

574:00

to look like and I know that's a lot of

574:02

code so here you can see we have first

574:04

of all like two classes right here and

574:05

then we are creating some sort of a

574:07

function and for the type of perimeter

574:09

we are passing either the dog or the cat

574:12

clause and we're not returning something

574:14

so that's why we put white white here so

574:15

you know what let me just write this

574:16

code and then you'll get to know what

574:18

I'm talking about so now let me just

574:19

remove that and I'm going to just Define

574:21

a CL I'm going to give a name of like

574:23

dog and now I'm not going to even bother

574:25

providing a Constructor function I'm

574:27

going to just use like a Bar Method

574:29

right here we are not going to be

574:30

returning something from there so I'm

574:32

going to just write a white and inside

574:34

this function we are going to be just

574:35

using like wo or something like that I'm

574:38

going to duplicate this uh class right

574:39

here now let me just create one for the

574:41

cat as well and for the cat we would

574:44

have a meow like that or I guess this

574:47

how you spell it meow or something like

574:50

that and here I'm going to also just

574:51

write like meow something like so you

574:55

know let me just sve my file and this is

574:57

how we are going to be creating two

574:58

classes and now the next thing which you

575:00

have to do is that we have to create a

575:02

function and inside that function we're

575:03

going to be using the type narrowing by

575:06

using the instance of operator right

575:08

here so I'm going to give a name of like

575:10

animal sound and it's going to take the

575:12

perimeter of animal and I'm going to

575:14

also provide the type of you know what

575:16

not animal sound uh animal I guess

575:20

animal would be fine and for the type

575:22

I'm going to specify either the dog

575:24

class or the cat class which we are

575:26

creating right here up above so we have

575:28

this dog class and we also have this cat

575:30

class right here so we are not going to

575:32

be returning something from that so I'm

575:33

going to just specify the word right

575:35

here and now let me just check if the

575:37

animal is the type or not type but the

575:40

instance of uh dog so what do you want

575:43

to do in that case we just want to write

575:44

an animal bark right here and I'm going

575:47

to execute that and now here you can see

575:49

if I hold my mouse over to the the

575:51

animal is annotated with the dog right

575:53

here not a cat but with a dog because

575:56

here you can see we're using the type

575:58

narrowing we are narrowing down over

576:00

type right here so that's why inside

576:03

this block of code the animal type

576:05

should be a dog right here so now for

576:07

the else class what do you want to do

576:09

let me just write that and I'm going to

576:11

just write animal. meow and now let me

576:14

just execute that right here so if I

576:15

hold my mouse over to this one so here

576:17

you can see for this one we have animal

576:19

of cat if I my mouse over to this first

576:22

one it's going to gives us the animal

576:24

off Dog right here so yeah that's the

576:28

now let me just use that right here so

576:29

I'm going to just create two instances

576:31

so I'm going to write like my dog it's

576:32

going to be equals to like new dog and

576:34

execute that and I'm going to also

576:36

create my cat it's going to be equals to

576:39

the Cat part here and we're not going to

576:41

be ping anything because we did not

576:43

require anything so now let me just use

576:45

my animal sound and I'm going to specify

576:47

my dog or you know what let me just log

576:49

to the console my dog so that you can

576:50

see uh you already know all of that

576:52

stuff but now let me just loog to the

576:54

console there s file and run there so

576:56

here you can see it's going of gives us

576:57

the dog and also the cat classes right

577:00

here okay so that's cool now we have to

577:02

provide this uh dog and also this cat to

577:05

this animal sound right here so I'm

577:06

going to just specify my dog and it's

577:08

going to gives us for the output of woof

577:11

or woof woof I guess because currently

577:14

we are providing this wo wo so it's

577:15

going to give us that result and if I

577:17

just write like animal sound once again

577:19

and if I just write like my cat and it's

577:21

going to gives us me or something like

577:24

that and now let me just save my file

577:26

and if I just run that it's going to

577:28

gives us wo wo for the first one and

577:30

it's going to giv us meow for this cat

577:32

right here so yeah and this is how we

577:34

are going to be narrowing down our types

577:37

by using a typescript type off operator

577:39

right here so now let's learn about a

577:41

type narrowing by using the intersection

577:43

types in typescript so you already know

577:46

like I already discuss what

577:47

intersections is but if you don't know

577:50

that let me just read the for you so

577:52

intersection types in types scrip allow

577:53

you to combine multiple types into a

577:55

single type and the resulting type will

577:57

have all the properties of each

577:58

individual type and you can create

578:00

intersection types using the end

578:02

operator right here and this is how the

578:04

code is going to look like so here you

578:05

can see we have two types of like the

578:07

first one we have a employee the second

578:09

one we have a manager and we are now

578:11

just using this intersection operator

578:13

right here or intersection type whatever

578:15

you want to call that and it will now

578:17

combine both of these values or these

578:19

types to this one right here and we can

578:21

use that anywhere we want so now let me

578:23

just write a code for that and then

578:24

you'll get to know what I'm talking

578:25

about so I'm going to just delete all of

578:27

that code and I'm going to zoom in and

578:29

I'm going to first of all Define uh two

578:32

types right here like employee or

578:34

something like that and inside there I'm

578:36

going to specify the IDE of number to it

578:38

and also the name will be some sort of a

578:39

string and that's that now I already

578:43

forgot to include the equal to sign and

578:45

here I have to just write a manager and

578:47

the manager is going to be equals to the

578:49

department the TM and and for the

578:53

Department I'm going to specify the

578:54

string and for the role I'm going to

578:56

specify the string as well and so these

578:58

are our two types now let me just create

579:01

uh or not create but now let me just use

579:03

my intersection type right here so I'm

579:05

going to just write like type of manager

579:08

m n a on manager uh manager with

579:14

mloy info something like that will be

579:17

now equals to the employee and the

579:19

manager right here so now I am going to

579:22

use that right here so I'm going to just

579:23

write like manager come on Lower G cons

579:26

and manager and now let me just annotate

579:28

that with this manager with employee

579:31

information is going to be equals to uh

579:34

this object right here so first of all

579:36

I'm going to specify values to the ID

579:38

then I'm going to specify the value to

579:39

the name and also to the department and

579:41

Rule right here because currently we are

579:43

combining both of them to this one right

579:45

here and we're now providing that right

579:47

here for this object so I have to write

579:48

all of that value so ID will be now set

579:50

to like one 2 three or something like

579:52

that and I'm going to also specify some

579:54

sort of a name like Alex meren or

579:56

something like that and I'm going to

579:58

also provide a department and the

580:00

department will be engineering and also

580:02

the role will be some sort of like team

580:04

lead or something like that and finally

580:06

now let me just log there to the console

580:08

I'm going to go back and now let me just

580:10

log to the console like manager. ID if I

580:13

just write ID and now let me just

580:15

execute there so it's going to gives us

580:17

like one two three right here and now

580:19

let me just duplicate that a few times

580:21

and I'm going to just get like name and

580:23

I'm going to also get the department and

580:26

also for the rule as well so if I sell

580:28

my file and run there it's going to giv

580:31

US 1 2 3 4 ID Alex smon as a name and

580:34

Engineering as a department and role

580:36

will be team lead right here okay so

580:38

that was it about our type narrowing in

580:41

typescript so now let me just make a

580:42

genuine setup for writing a typescript

580:44

code because currently we've been using

580:47

this extension called this code Runner

580:49

right here and trust me we love this

580:52

extension but the thing is that in real

580:54

world project we are not going to be

580:56

using the code Runner we have to compile

580:58

or typescript code to the JavaScript

581:01

because uh our compiler don't have any

581:04

idea like what the hell is a type what

581:06

the hell is all of that insertion

581:08

operator all of the thing that we learn

581:11

about

581:14

timecrimes JavaScript for the front end

581:16

and also for the back end and we don't

581:19

use the typescript code for the front

581:21

end and for the back end we have to

581:22

compile our typescript code into the

581:24

JavaScript code so how we are going to

581:26

be doing that okay so to do that I mean

581:30

like to compile our code into the

581:31

JavaScript code we don't have to do

581:33

nothing but we just have to write a TSC

581:35

which we already installed in the

581:37

beginning of the course and we are going

581:38

to be just writing a dash and and if I

581:41

hit enter and what are we getting we are

581:43

now getting this TS config file right

581:45

here and there are a lot of stuff inside

581:48

this TS config file now let me just

581:50

close my terminal right here and I'm

581:52

going to open my ts config file and here

581:54

you can see we have like crazy amount of

581:56

stuff right here you can learn more

581:58

about this uh TS config file by your own

582:01

but I'm going to just explain a few

582:02

things right here so now let me just go

582:04

ahead and go to this TS config right

582:07

here if I hit enter this going to brings

582:09

us to this TS config right here I'm

582:11

going to have to go to the top and this

582:13

is how it's going to look like right

582:14

here so you can learn about a compiler

582:16

option type checking modules inid

582:18

JavaScript support and all of that kind

582:20

of stuff but what we are currently

582:22

interested in is that how in the world

582:24

we are going to be compiling work code

582:26

well we don't have to do nothing let me

582:28

just zoom in a bit we don't have to do

582:30

nothing but we just have to open our

582:32

terminal right here and we also already

582:34

have our TS config file right here so

582:37

everything is already set up so we just

582:39

have to use like TSC and then we have to

582:42

include the specific path of the file

582:44

which you want to compile so I'm going

582:45

to just write I and d and if I hit Tab

582:48

and if I hit enter right here it's going

582:50

to give us that adj file right here so

582:52

here you can see it is now giving us

582:54

this index.js file right here but we

582:57

would have some sort of a problem if I

582:58

open this uh Javascript file right here

583:01

we are getting all of that same code

583:03

right not a same code but we are now

583:05

getting totally a JavaScript code right

583:06

here but the thing is that we are using

583:09

the war resert keyword and this is not

583:12

the newer way of writing a JavaScript

583:14

code oh you know what let me just give

583:15

you some sort of example like uh I'm

583:17

going to go ahead and go to my

583:18

typescript code right here I'm going to

583:19

remove every single thing which I

583:21

currently have right here and I'm going

583:23

to just create some sort of error

583:24

function like const add and it's going

583:25

to be equals to like uh I don't know x

583:29

uh and the X will be set to number and

583:31

I'm going to also specify the Y and the

583:33

Y will be also a number and now let me

583:35

just annotate that to the number as well

583:38

and I'm going to also specify the X + Y

583:41

right here as a return value and now let

583:43

me just go back and here you can see

583:45

this is the newer way of writing a

583:47

JavaScript code like here you can see

583:49

we're using the arrow function and all

583:50

of that so now if you want to compile

583:52

that now let me just compile that right

583:54

here if I just use this TSC right here

583:57

let me just clear that and if I just use

583:59

like TSC and then this index.js or not

584:03

JS in this case we have to write this TS

584:05

right here if I hit enter so now it's

584:08

going to replace all of their previous

584:10

code to this code right here so now let

584:12

me just show you that if I sell my file

584:13

so here you can see it is now using the

584:15

function expression but this is the

584:17

older way of creating a function like

584:19

here you can see we're using the one

584:20

Reser keyword and we are using the

584:22

function resert keyword and we are also

584:24

returning there right here but in the

584:26

typescript right here we use this Arrow

584:29

function and we are not getting the

584:30

arrow functions right here so how in the

584:32

world we're going to be doing there so

584:34

well for that we have to go ahead and go

584:36

to our configuration file and I'm going

584:39

to just scroll down and what are we

584:40

getting we are now getting this target

584:42

right here and the target is now

584:44

currently set to the es 2016 or ES um 16

584:48

whatever you want to call that so I'm

584:50

going to just uh click on this hash

584:52

right here and I'm going to specify the

584:55

Target and if I hit so here you can see

584:57

it's going of brings us to this target

584:59

documentation right here you can learn

585:00

more about that if you wanted to but

585:02

basically what this target means is that

585:05

in which kind of version of JavaScript

585:07

we have to compile this typescript code

585:09

into okay so currently It Is by default

585:12

set to this es 2016 I'm going to just

585:14

remove that and I'm going to just hold

585:16

control and hit space so it's going to

585:18

give us 2015 16 17 18 19 till this 2023

585:23

and also we have the es next right here

585:25

but currently I want to just compile my

585:27

code to the es6 way so I'm going to just

585:29

click on this es6 right here and if I

585:31

sell my file nothing will happen so yeah

585:35

I want you to keep that in mind nothing

585:37

will happen if I just delete this file

585:40

and now instead of writing like TSC and

585:42

index and all of that we just have to

585:45

write this TSC that said baby we just

585:48

have to write this TSC and if I hit

585:50

enter right here here you can see it's

585:52

going to giv us that compile file and

585:54

now hopefully if I open that it's going

585:57

to gives us that aror function right

585:58

here which means like we are now using

586:01

the newer way of writing a typescript I

586:02

mean like JavaScript code right here so

586:05

that's totally amazing so that was it

586:06

about for the Target and now let's learn

586:09

about um compilation so here you can see

586:11

it's going to compile all of the file

586:13

right here let's suppose if I have a lot

586:15

of files now let me just delete that I'm

586:17

going to just delete that right here

586:18

just like that and I'm going to just

586:21

create a few other uh function right

586:24

here now let me just duplicate that and

586:26

I'm going to give a name of like

586:27

multiply or something like that and

586:29

instead of writing this plus symbol I'm

586:31

going to just change that to like uh

586:33

time symbol right here we don't have to

586:35

worry about the code right now I'm going

586:36

to cut this code from here and I'm going

586:38

to just create a file give a name of

586:40

like something now let me just make that

586:41

a bit bigger I'm going to create a file

586:43

give a name of like M.S for

586:46

multiplication. typescript okay so for

586:49

real word project we are going to have a

586:50

lot of typescript files so in this case

586:53

we just have like mt. TS right here I'm

586:55

going to just put my code inside this m.

586:57

TS right here and also I'm going to just

587:00

create a folder give name of like SRC or

587:03

you know I don't have to create a folder

587:04

not right now now let me just show you

587:06

that so here you can see we have this

587:08

mult .ts file right here I'm going to

587:10

also cut this code from here and now let

587:12

me just create one more file give a name

587:13

of like .ts for adding two numbers so

587:16

I'm going to just place this code right

587:18

here now let me just go back so you guys

587:20

can see everything I better so here you

587:21

can see we have three files the first

587:23

one we have is this .ts file then we

587:25

have a mult like multiplication. TS file

587:28

and I'm going to also just write like

587:30

subtract right here inside this um index

587:32

file so I'm going to just write subtract

587:34

or something like that and I'm going to

587:36

just put my minus right here so if I

587:38

save that so currently we have three

587:40

files right here the first one we have

587:42

is ADD which is responsible for adding

587:44

two numbers then we have a index which

587:46

is responsible for subtracting two

587:48

numbers and then we have a multiple

587:49

multiplication okay so if I just write

587:52

TSC right here in this case if I just

587:54

write TSC and if I hit enter and here

587:57

you can see it's going to compile all of

587:59

the code right all of the file which we

588:01

currently have inside our directory so

588:03

if I open this Mt it's going to provide

588:05

that same code right here it's going to

588:07

compile there and if I open this one

588:09

same will go for the add and all of that

588:11

but in some situation we don't want to

588:13

compile all of the file we just only

588:15

want to compile a certain file like a

588:17

certain typescript file so now let me

588:19

just delete this compilation file

588:21

and now I'm going to go ahead and search

588:23

for the files right here so I guess that

588:25

was a files files I'm going to hit enter

588:28

right here so it's going to brings us to

588:30

this documentation right here so find

588:32

specify the allow of the file to include

588:35

in the program and error will occur if

588:37

you don't have that file already created

588:39

right here so how the syntax going to

588:41

look like this is how the syntax going

588:43

to look like but I want you to keep in

588:45

mind something it will be underneath

588:48

this compiler option n inside there like

588:51

for this compiler option we have a lot

588:54

of things now let me just show you that

588:55

if I go to the uh TS config file I'm

588:58

going to go to the top first of all so

589:00

here you can see we have only one object

589:02

right here inside this Json so which is

589:05

currently set to this compiler options

589:07

if I go to the bottom we don't have

589:09

anything we just only have that so if

589:11

you want to provide that files I'm going

589:13

to just provide a comma there and now

589:15

let me just even copy that right here

589:17

I'm going to copy that and place it

589:18

right here and I'm going to just remove

589:21

almost every single thing right here but

589:23

I want to just leave like I don't know

589:25

maybe index so I'm going to just write

589:27

index.ts right here I'm going to sve my

589:29

file right now okay so if I just save my

589:31

file right now and if I run that once

589:34

again like that TSC once again and if I

589:36

hit enter in this case it's going to

589:38

only compile this index.ts right here so

589:42

here you can see it's going to only

589:43

compile that and it's going to ignore

589:45

the rest of the file right here so yeah

589:47

that was the first way of compiling

589:49

something or ignore something by using

589:51

these files now let me just show you the

589:53

include and also the exclude as well so

589:55

I'm going to comment this line out and

589:57

now let me just search for include so

589:59

include like which kind of file you want

590:02

to include to be compiled okay so you

590:04

can learn more about that so this is how

590:06

the directory will look like like all of

590:08

these file which you can see right here

590:10

they will not be compiled and the rest

590:12

of them will be compiled so you know

590:14

what I'm going to just cut that from

590:16

here and I'm going to just create a

590:18

folder given name of like SRC and I'm

590:20

I'm going to also create one more for

590:21

the disc because in the disc folder we

590:23

are going to be providing our

590:24

compilation file like the compile code

590:27

so we're going to take care of that a

590:29

bit later but I'm going to just cut out

590:31

all of that files and I'm going to just

590:32

put it inside this SRC directory Right

590:34

Here and Now inside this DS config file

590:36

what do I have to do I'm going to just

590:38

specify this include right here okay so

590:40

now let me just copy that and I'm going

590:43

to just write double Cotes and pro that

590:45

include and here we have to specify the

590:47

array but I'm going to also have to

590:49

specify that uh comma right here to get

590:51

rid of that error right here okay so I'm

590:53

going to just copy that and now let me

590:55

just place that right here so what this

590:57

syntax means is that every single thing

591:00

which are currently available inside the

591:02

SRC folder I want you to compile all of

591:05

them like leave none of them compile all

591:08

of them so if I just save that and now

591:11

if I just write a TSC command one more

591:13

time so if I just write TSC and if I hit

591:15

enter so it's going to compile all of

591:17

that file right here so here you can see

591:19

it's going to compile all of these files

591:21

and I don't want that like in some

591:23

situation we would want to compile all

591:25

of that files but a lot of times we

591:27

don't want to compile all of the files

591:28

so how in the word we are going to be

591:30

omitting there I'm going to open there

591:31

once again so now let me just show you

591:33

the documentation as well you can even

591:35

also specify a single file if you wanted

591:37

to like let's suppose if you want to

591:38

just compile this index.ts right here

591:40

I'm going to just write index.ts right

591:42

here and if I save there and now let me

591:44

just run my TSC one more time and if I

591:46

hit enter so it's going to only gives us

591:48

that index.js right here like it will

591:50

only compile this index.ts but we don't

591:53

want that we can also use the exclude

591:55

right here so I'm going to just write

591:57

like exclude ex ex c l u d e and it's

592:00

going to brings us to this documentation

592:01

right here I'm going to copy that and

592:04

underneath this one I'm going to specify

592:06

this exclude right here and I'm going to

592:09

just write the array and inside this

592:11

array we are going to be specifying all

592:13

of the files which you want to ignore

592:15

for the compilation so I'm going to just

592:16

write SRC folder because inside this SRC

592:19

folder we are going to be compiling or

592:22

ignoring the file so now let's suppose

592:24

if I want to just ignore this

592:25

multiplication file but I want to

592:27

compile the rest of them so we are going

592:29

to be just writing like mt or I guess

592:31

that was mold mt. TS yep I'm going to

592:35

just provide this mold. TS and inside

592:37

there let me just copy there once again

592:40

uh I'm going to just copy like every

592:42

single thing right here like I want to

592:43

compile every single thing so I'm going

592:45

to just pass this syntax right here like

592:48

I want you to compile every single thing

592:50

but I want you to just remove this mult

592:52

do or I want you to just ignore this

592:54

mold. TS file okay so now let me just

592:57

compile that and if I hit enter so here

592:59

you can see it's going to compile all of

593:01

the file but it will not compile this

593:03

M.S file right here so here you can see

593:06

we have this index and we also have this

593:08

.js right here which is totally okay so

593:12

now I'm going to just delete this ad and

593:14

also this index compilation file and now

593:16

let's learn about the outdor right here

593:19

outdor I'm going to hit enter right here

593:22

so you can learn more about this outer

593:23

like what it will do for you but now let

593:25

me just show you in action so for this

593:28

out there we are going to be specifying

593:30

where we wanted to put our compiled code

593:32

so now if I just use like TSC one more

593:34

time it's going to compile all of the

593:36

code right here inside this SRC folder

593:38

but we don't want that I'm going to just

593:40

delete these files right here I want all

593:42

of the compiled code to be inside this T

593:45

folder right here so how in the what we

593:47

are going to be doing there I'm going to

593:48

just open my ts config right here and

593:50

I'm going to just search for the out

593:53

right here the out directory okay so I'm

593:56

going to just uncomment that and first

593:58

of all I'm going to just Pro I'm going

594:00

to hold control and hit space and you

594:02

know what I'm going to just provide a

594:03

disc right here in this case so if I

594:05

just save that in this case we want to

594:07

compile all of our code into this disc

594:09

folder so here you can see we provide

594:11

the path of this disc right here okay so

594:13

now let me just close that and finger

594:16

crossed and if I just run that so here

594:19

you can see going to compile all of our

594:21

code into this test folder right here so

594:24

we can also just

594:26

remove uh this one right here I'm going

594:28

to just remove this exclude I'm going to

594:30

comment this line out and now let me

594:32

just delete all of that files once again

594:35

and now let me just rerun that TSC one

594:37

time so if I run that so it's going to

594:39

compile all of the code into this DS

594:41

folder or D folder right here so that

594:44

was there about the genuine setup of

594:46

typescript so we're going to be writing

594:48

our typescript code by using this

594:50

extension which is the TS extension but

594:53

we have to compile our code into a

594:55

JavaScript code so that we can work with

594:57

the real word JavaScript right here okay

594:59

so that was it about the typescript

595:01

genuine set or whatever you want to call

595:03

that so that was it about compilation

595:06

and all of that now let's learn about

595:07

our declaration files I'm going to just

595:10

copy that and put it right here and I'm

595:12

going to go ahead and go to this

595:14

typescript .org right here and I'm going

595:17

to just click on this docs right here

595:19

then I'm going to just scroll down to

595:21

this declaration file so I'm going to

595:22

just click on there and I'm not going to

595:24

read you through all of that

595:26

documentation but trust me declaration

595:28

files are totally simple and amazing and

595:31

straightforward so what in the word all

595:34

declaration files and why you should

595:35

care about them well you don't have to

595:37

worry about any of the Declaration file

595:39

but these are the files which can be end

595:41

with this extension right here DTS

595:44

extension so you know what instead of

595:45

wasting your time I'm going to just go

595:47

ahead and remove this test folder right

595:49

here and I'm going to also remove all of

595:51

that folder I mean like I'm going to

595:53

also remove this folder right here as

595:54

well and I'm going to just create like

595:56

index. uh TS file right here and I'm

595:58

going to lock to the console like

596:00

console or not console or I'm going to

596:02

just lock to the console like I don't

596:04

know document would be fine so now let's

596:06

just uh work with a little bit of

596:07

document object model we're not going to

596:09

be working with the document object

596:11

model because typescript know every

596:13

single thing about that and we don't

596:14

have to worry about the document object

596:16

model uh types as well so if I H my

596:18

mouse over to this so the typescript

596:20

compiler already know which type of uh

596:24

data this uh document will be holding so

596:26

here you can see it is now currently set

596:28

to document right here so if you're

596:30

using a vs code so I want you to just

596:31

hold control and click on that so it's

596:35

going to brings us to these declaration

596:37

files right here so now let me just take

596:39

a screenshot of that so here you can see

596:41

it's going to brings us to this lip.

596:43

dum. D.S file right here so we are not

596:46

going to be providing any other stuff

596:48

inside this uh declaration files but

596:50

inside this declaration files we are

596:52

going to be only like only specifying

596:56

the types okay so just a types nothing

596:59

else so here you can see we have a event

597:01

object so it's going to be either the

597:03

event or undefined and you can learn

597:05

more about that so if I just search for

597:07

like I don't know document not a

597:09

document but get element by ID or

597:11

something like that so if I just click

597:14

on that so here you can see we have that

597:15

get element by ID method right here and

597:18

the type of that will be set to

597:20

this HTML element right here so if I

597:23

hold control and click on that so here

597:25

you can see it's going to only include

597:27

the types right here so inside this

597:29

declaration file you are not going to

597:31

found any real code but you will just

597:34

found uh what do we call it the

597:36

Declaration or the types right here okay

597:38

so that was it about the Declaration

597:40

file and this is how the typescript

597:42

compiler knows every single thing about

597:44

the Dom and all of that kind of stuff

597:46

like third party libraries but now let

597:48

me just show you or before before I show

597:50

you that first of all let me just

597:52

install one library right here and if

597:55

you already know exus totally cool if

597:58

you don't know xus you don't have to

598:00

worry about xus because we're not going

598:02

to be writing a lot of xus code I'm

598:04

going to just write a little bit of xus

598:06

code and you don't even have to worry

598:07

about that so xus is the library which

598:10

already comes with the Declaration file

598:12

so what I want to do is that I already

598:15

make a setup for them I'm going to just

598:17

remove that stuff from here which I

598:19

specified right here here I want to

598:20

compile all of the files right here so

598:22

I'm going to just remove that and yep I

598:24

guess the rest of them will be totally

598:26

the same I'm going to just remove that

598:28

and now what I want to do is that I'm

598:30

going to just use like npm uh init d d

598:33

or not d d but Dy right here I'm going

598:36

to hit enter right here so it's going to

598:38

just gives us this package.json file it

598:40

is nothing but it will just keep track

598:42

of all of the dependencies which we are

598:43

going to be installing for this project

598:45

So currently we just only want to

598:47

install the xuse if you already know

598:49

xuse cool if you don't know xus you

598:52

don't have to worry about that but now

598:54

let me just use like npmi and xus and if

598:57

I hit enter so it's going to install

598:58

this xus library inside my machine and

599:01

yep that's totally installed the next

599:03

thing which I want to do is that I have

599:05

to use that xus right here somewhere so

599:07

I already created this index.ts file

599:10

right here and the next thing which I

599:11

want to do is that if I just write like

599:13

import xuse from xus right here and if I

599:17

sve that and if I hold control and C

599:20

click on this exus right here so it

599:22

already comes with the types right here

599:24

like the Declaration files and here you

599:26

can see we have a lot of types right

599:28

here like we don't have any actual code

599:31

but we have a lot of types right here

599:34

yeah xus already comes with uh the types

599:37

like not even exus there are a lot of

599:39

libraries and Frameworks which already

599:42

comes with the typescript types right

599:44

here so now let me just show you where

599:46

you can found that I guess that was uh

599:48

not quite sure about that about

599:50

typescript types uh GitHub or something

599:53

like that I'm going to just search for

599:55

that and there we go this one definitely

599:57

type right here so if I open that if I

600:00

go ahead and go to this definitely type

600:02

I'm going to go to that and yeah this

600:04

repo is super popular right here and you

600:07

can even contribute to that by yourself

600:10

if you have some sort of a library or

600:11

framework and that needs uh types so you

600:14

can also provide this now let me just

600:15

open this types right here and here it's

600:18

going to gives us an error let's just wa

600:20

for that here you can see it's going to

600:21

gives us this error it's going oh not

600:23

even error it's I guess a warning sorry

600:26

we have to truncate this directory

600:27

because it includes over 1,000 files I

600:32

mean like it can only show you the 1,000

600:34

files but yeah it will just fail to load

600:36

all that files so here you can see we

600:38

have a lot of types for every single

600:41

thing right here but there are still a

600:43

lot of projects like uh for instance you

600:46

can think about X not xus but you can

600:48

think about exess Express yes Express

600:50

yes does not come with the built-in

600:52

types so yeah now let me just write a

600:54

Lowes I guess lades does not include

600:57

their types so now let me just write low

600:59

Dash come on low Dash and this

601:01

repository is supremely awful because it

601:05

is totally big I'm going to just click

601:06

on this loaded and yeah it is loading a

601:10

lot anyway so here you can see we don't

601:12

have anything else but we have like all

601:15

of their files right here which ends

601:17

with this D andt yes right here so we

601:21

have all of that files for all of the

601:23

things so if I just open this head right

601:25

here and here you can see we have just

601:27

simple one file right here uh you know

601:29

that's other story you don't have to

601:31

worry about that but anyways you already

601:33

learned about what a type declaration

601:34

are and how it works so you know what

601:36

let me just use this xus right here I'm

601:39

going to just create a function P data

601:41

and it's going to be equals to this as

601:42

synchronous function and I already

601:44

assume that you guys already know all of

601:46

that stuff so I'm going to use the try

601:47

and catch for a tri block what do you

601:49

want all you know first of all now let

601:50

me just take care of the else log so I'm

601:53

going to use like console you know

601:55

console. error and I'm going to just

601:58

write some sort of error right here and

602:00

for this one we're going to be just

602:01

writing error. message m e s a g e there

602:05

we go and we are getting this awesome

602:08

error message right here which we are

602:10

going to be taking care of in a few

602:11

seconds so yeah so next thing which I

602:14

want to do is that I have to fit some

602:15

sort of a data so I'm going to just

602:17

write like Json come on Json place

602:19

folder P database right here and I have

602:23

to fix some sort of a data from there

602:25

I'm going to just copy this to-do right

602:26

here and I'm going to just write like

602:29

cons response and it's going to be

602:32

equals to um this x use response right

602:35

here come on X here oh we have first of

602:38

all import it right here okay so I'm

602:40

going to just provide a comma and I'm

602:42

going to just import like X use response

602:44

right here I can get that right here and

602:47

now we have to use that so I'm going to

602:48

just write like X

602:50

response what the hell is going on now

602:53

let me just copy that place it right

602:54

here and here we have to annotate that

602:56

with the to-do like which kind of data

602:59

which we are going to be getting from

603:00

this specific API right here now let me

603:02

just copy them place it right here so we

603:04

are now getting this data like the user

603:06

ID is going to be equals oh come

603:08

on like the user ID is going to be

603:10

equals to one the ID will be set to one

603:12

the title will be set to some string and

603:14

also the complicator will be set to some

603:16

sort of a Boolean value right here so we

603:18

can also create order to do right here

603:20

now let me just create interface uh I'm

603:23

going to give a name of like interface

603:24

to do and inside there we can specify a

603:27

type for the user id id title

603:29

complicated right here so I'm going to

603:30

just write like user ID and it's going

603:33

to be equals to the number I'm going to

603:34

also provide the ID will be also set to

603:36

a number and also we would have some

603:39

sort of a title which will be set to

603:40

string and also we would have a

603:42

completed not complicated did I say

603:45

complicated it's completed okay so yeah

603:48

we already import that and we are using

603:50

that right here but I forgot to use the

603:53

aent uh a and xuse and then we have to

603:56

specify the link where we want to get

603:58

that data so I'm going to just write

604:00

like do get and we are going to be

604:01

getting our data from this um uh URL

604:04

right here I'm going to copy that and

604:06

now let me just place that right here uh

604:08

I have to write the inside of quotes

604:10

let's just go back and why in the word

604:12

we are getting this response and if I

604:14

hold my mouse over to this so cannot

604:16

extend interface x a come on I'm using

604:19

the equ two sign right here I have to

604:21

annotate that with this to do and also

604:24

this xus response right here and now let

604:25

me just save that and r e s p o n s e

604:30

not i s e okay so underneath them we're

604:32

going to be just logging into the

604:33

console like some sort of a to do and

604:36

I'm going to specify this response what

604:39

the hell am I doing right now so

604:40

response to data there we go okay so

604:43

yeah for the error the error is going to

604:45

be any error right here like yeah we

604:47

don't know which kind of error it's

604:49

going to throw us so we can specify any

604:51

error well you know what let me just

604:53

handle that properly so I'm going to cut

604:55

that from here and here what I want to

604:57

do is that I'm going to just search for

604:58

like if x use dot is X use error uh and

605:03

here we have to specify that error right

605:05

here so if that's the case so I'm going

605:07

to just write like console. error now

605:09

let me just write console. error and I'm

605:11

going to just say like xos error and

605:14

also let me put error. message right

605:17

here which kind of message we are going

605:18

to be getting from that error and

605:20

underneath that what we have to do we

605:22

have to just search for that error

605:24

response uh if you have the error

605:26

response so what you want to do we just

605:27

want to log to the console the status so

605:29

status and I'm going to just write like

605:31

error response. status right here I'm

605:34

going to duplicate that and change this

605:36

status to data right here and we're

605:38

going to be getting the data from that

605:40

response and also let me just sa that

605:43

for this L CL what do I have to do I'm

605:45

going to just write like um console.

605:47

error and here we just have right that

605:50

error come on error. message right here

605:53

now let me just save that and now let me

605:55

just execute this method right here I'm

605:57

going to just execute that right here

605:59

I'm going to send my file and I'm going

606:01

to just run my code right here so it's

606:03

going to giv us all of that data right

606:05

here it's going to take a bit of time so

606:07

here you can see we have to do and to do

606:09

is equals to this object right here so

606:11

we are now getting the user ID also the

606:13

ID and also the title and completed is

606:16

now set to false right here so which

606:17

means like everything is a okay and this

606:20

is how we going to be using a typescript

606:22

with exus Library do you have to know

606:24

that you don't have to know that but

606:26

yeah that was a typescript with XU so

606:29

now finally I'm going to just show you

606:30

some sort of a library which does not

606:32

automatically comes with a typescript

606:35

types so for that we're going to have to

606:37

install a separate type so what I want

606:39

to do is that I'm going to just install

606:41

the express JS right here so I'm going

606:43

to just use like uh npm come on npmi and

606:48

express and we're not not going to be

606:49

writing a lot of express code but I'm

606:51

going to just make a general setup of

606:53

Express JS so yeah it's going to take a

606:55

bit of time to install this Express J

606:56

into my machine and I'm going to just

606:58

leave it to do its thing and there we go

607:00

it is now successfully installed I'm

607:02

going to go ahead and go to my

607:03

package.json right here and now let me

607:05

just write some sort of a uh script for

607:08

myself you don't even have to worry

607:09

about what Express JS is if you do care

607:12

about this so I have a complete course

607:13

on there if you want to check it out but

607:15

if you don't care about that so you

607:16

don't have to let me just write a start

607:19

come on start and I'm going to just

607:21

write like ts- node SRC directory and

607:24

I'm going to just run my index I mean

607:27

like uh index.ts right here now I'm

607:29

going to just create SRC folder right

607:31

here and I'm going to just put my

607:33

index.js right there and there we go so

607:37

yeah I'm going to open my index.ts file

607:39

right here now let me just remove that

607:42

inside there what do I have to do if I

607:43

just write like uh import Express uh

607:46

from Express right here so if I hold my

607:49

SC to there so Express is declared but

607:52

value is never read we can take care of

607:54

there in a few second but could not find

607:56

a declaration file or a module expressjs

608:00

right here so we successfully install

608:01

expressjs but we also have to install

608:03

the Declaration files for the so if I

608:05

have my mouse over to that and here you

608:08

will see that quick fix right here uh

608:10

I'm going to just click on that so here

608:12

you can see either install the types or

608:14

just remove them okay so here you can

608:16

see if you want to install them manually

608:18

by using a terminal so you're going to

608:20

have to write this command which is

608:22

first of all write npmi and then you

608:24

have to use like uh add types and then

608:27

for/ expressjs right here but if you're

608:29

using a vs code so you just have to H

608:31

your mouse over to that click on a quick

608:34

fix and then click on this install right

608:35

here so it's going to automatically

608:37

install it into your machine so yeah I'm

608:39

going to have to wait for that to

608:40

install all of that types so here you

608:42

can see that it is successfully gone and

608:44

I'm going to just write like cons app

608:45

and it's going to be equals to like

608:47

Express chz come on Express

608:50

uh

608:51

exps yeah and now I have to just write

608:56

Express e and also e here as well now

608:59

let me just create some sort of a port

609:01

and it's going to be equals to like oh

609:02

my God 3,000 right here and now let me

609:05

just use like app. listen and we want to

609:08

listen to the port and also now let me

609:10

just execute con. log and come on server

609:15

running on Port and now let me just

609:17

render my port right here let's just go

609:20

back and I'm going to use my back text

609:23

right here like that and that's it I'm

609:26

going to also create one route right

609:27

here so I'm going to use like f. getet

609:29

it's going to go to the home and let's

609:31

just provide or request and also the

609:34

response as well and here what do you

609:37

have to do you just have to write rest.

609:39

not oh yeah response there we go

609:41

response. send you can also abbreviate

609:43

that to the rck and res but request and

609:45

response would be good so I'm going to

609:46

just write hello typescript uh press

609:49

just or something like that and now if I

609:52

hold my mouse over to this response

609:54

right here so response is response any

609:56

response and yeah this is our generic

609:59

function right here but we can also

610:00

import the responses manually so I'm

610:02

going to just have to write a comma and

610:04

I'm going to just get the request and

610:06

also the response as well okay so if I

610:09

get there we can also provide a types

610:11

for there so I'm going to just copy

610:13

there and annotate that as a request and

610:16

I can also copy this response and

610:18

annotate there with this response right

610:21

here okay so now let me just save that

610:23

and I'm going to just use my terminal

610:25

and I'm going to just say like npm Star

610:27

to start my server and I guess that

610:30

would be it okay so here you can see

610:32

everything is starting a okay but it's

610:34

going to take a bit of time so server is

610:36

running on Port 3,000 so I'm going to

610:39

just write like a local host of 3,000

610:41

and if I hit there so here you can see

610:43

we now getting like hello typescript

610:45

with Express JS okay so in your case

610:47

it's going to look something like this

610:49

so yeah that was the end of this course

610:52

and there are still like two section

610:53

left if you want me to make a course on

610:55

that like typescript with reactjs and

610:57

also typescript with nextjs I can

611:00

totally make a courses on them but this

611:02

course was just for those people who

611:04

wants to learn typescript and want to

611:06

use it in their projects so that was all

611:09

of the things I know about typescript

611:11

and I use that daily so that was the end

611:14

of this course and I only have one

611:17

request from you guys

611:20

let me just say that if you guys want to

611:22

support me so I'm going to give you a

611:23

link in the description below uh and it

611:25

will bring you to my GitHub repository

611:28

and you can just start that repo and you

611:30

can provide um you can for that repo and

611:33

you can do whatever you want to do with

611:34

that repo so what I'm asking you from

611:36

you guys is that please follow me on

611:40

GitHub and if you want to support to

611:42

this channel so feel free to subscribe

611:44

so if you don't want to support so yeah

611:45

thanks for watching anyways and maybe

611:48

I'm going to see you in the next SC

611:49

bye-bye from now and love you

612:03

all all right guys so now we are going

612:06

to be using a typescript with reactjs so

612:09

if you guys don't know what a typescript

612:10

is I have a complete course on there

612:13

right here so this is going to be like

612:16

more than a crazy course like if you

612:18

care about learning T script this is

612:20

going to be the last course for you to

612:21

learn okay so yeah learn that and then

612:24

come back to this video and now we are

612:26

going to be learning about typescript

612:28

with reactjs so to do that first of all

612:30

we have to make a setup so I'm going to

612:31

open my terminal right here and now I'm

612:33

going to be using npm Create we at

612:36

latest now if I hit enter now we have to

612:39

give it some sort of a name like TS

612:41

demos or something like that in this

612:43

case I'm going to be choosing reactjs

612:45

and also typescript we are not going to

612:47

be choosing JavaScript we're going to be

612:49

choosing typescript so if I just hit

612:51

enter now we have to go into this TS

612:53

demos and now if I hit enter and I'm

612:55

going to be using a code dot to open

612:57

there right here next let me open my

612:59

terminal and I'm going to be using npmi

613:01

to install all of their dependencies and

613:04

all of their dependencies are now

613:05

successfully installed so here you can

613:07

see we have our SRC folder and now

613:09

inside this SRC folder we are now using

613:12

TSX extension right here you can either

613:15

use TS or you can also use TSX instead

613:18

of a GSX

613:19

now we are working with time scripts so

613:21

for that we have to use a TSX so I can

613:23

just clean up every single thing we

613:24

don't need there so I'll just remove all

613:27

of there and let's just say byby to this

613:29

one and I guess that's going to be fine

613:31

but I'm going to have to remove this

613:32

index. CSS file from there we have to go

613:35

into the app and I'm going to just

613:36

remove every single thing from here and

613:38

let's just use our RFC and that's going

613:41

to be fine I'm going to also remove this

613:43

public folder because we also don't need

613:45

that and now if I save my file and open

613:47

that inside my browser by using npm run

613:50

Dev and here you can see we are now

613:51

getting our app so the setup is now

613:54

totally done next we are going to be

613:55

learning about component props in action

613:58

so to do that first of all we're going

613:59

to be creating a component so I'll just

614:01

create a components folder and inside

614:03

this folder I'm going to create like

614:05

user. TSX we are now working with

614:07

typescript so we have to specify TSX as

614:09

extension now inside we're going to be

614:11

using our rfcu to create our component

614:14

right here save my file now I'm going to

614:16

go into my app component and now I'll

614:18

just just remove this app and instead of

614:20

that app I'm going to just replace that

614:21

with this user we going to be importing

614:24

that totally directly in N semi file and

614:27

we are now getting our user right here

614:28

which is amazing so what I'm going to do

614:30

is that I'm going to pass a few props

614:32

through it so I'll just use like name

614:34

and name can be anything like Alex or

614:35

hosan or something like that I'm going

614:37

to also specify the age of 20 to him and

614:40

also the is student is a student or not

614:43

so I'll just specify True Value and as

614:45

soon as I do that I'm now getting this

614:47

error right here so if I hold my mouse

614:48

over there it is now telling me that the

614:51

type this prop which you are specifying

614:53

right here is not assignable to the type

614:56

intrinsic attribute okay like you have

614:58

to do something about that like you're

615:00

providing these props but you're not

615:02

using them inside this component and to

615:05

use them you already know how we going

615:06

to be using there so we can just use

615:08

like props right here and now we can

615:10

totally use the right here in server

615:12

component so I'll just use like I don't

615:14

know maybe H2 and we're going to be

615:15

using like problems. name first of all

615:18

let me just duplicate a few times prop.

615:20

Ed and also is student right here so if

615:23

I sell my file and as you can see we are

615:25

now getting Alex and also 20 and we

615:28

cannot see the E student because this is

615:30

a Boolean value and now here if I hold

615:32

my mouse over today it is giving me an

615:34

error like perimeter prompts implicitly

615:37

has any time like which simply means you

615:39

are not using any typescript so if you

615:42

want to use typescript you got to do

615:43

something about that so I want to use

615:46

typescript so for that I'm going to have

615:47

to specify a type for the name for the

615:50

age and also for the student and why is

615:52

there because we are now passing this

615:54

data and we are not providing any type

615:57

for there so to provide a type for there

615:59

we going to be annotating our prop like

616:01

this okay I'll just first of all take

616:03

care of the name and name is a string

616:05

value which I already know because we're

616:07

now specifying a string value and now we

616:09

know that we also have a edge and Edge

616:12

is a number and also we have a a student

616:15

property which is a Boolean okay so as

616:17

soon as I provide the in s my file here

616:20

you can see we are no longer getting

616:22

that error and why is there because we

616:24

are now explicitly telling our compiler

616:26

that the name should be a string The

616:29

Edge should be come on let me just get

616:31

the Ed should be a number and also the

616:34

student should be a Boolean value so

616:36

that's why our typescript compiler now

616:38

know which type to use so now if I save

616:41

my file and just refresh there we are

616:42

still getting that same result and we

616:44

are not getting any errors inside our vs

616:46

code now that's the first way but in

616:48

some situation we would also want to

616:50

restructure our values from this props

616:52

so how are we going to be doing there

616:54

well we already provided a type for

616:56

there we just have to destructure all of

616:58

that value so I'll just remove these

616:59

prompts and I'll just replace them with

617:01

these curly braces you want to

617:03

destructure the name the ede and also

617:05

the E student right here so as soon as I

617:08

do that here you can see I'm now getting

617:09

like cannot find name of prop like we're

617:11

not using a prop so that's why we are

617:13

getting this error so I'm going to

617:14

select that first one hit contr d contr

617:16

d and remove there so as soon as I just

617:19

remove the semi file this is how my

617:22

formatting will look like I know it

617:24

seems a bit crazy but yeah this is how

617:26

we are going to be destructuring our

617:29

data and this is how we are going to be

617:31

providing a types for our data so I want

617:34

you to keep that in mind so this is just

617:36

a basic way of providing our prop now

617:38

let me show you how we're going to be

617:39

extracting all of their types into

617:42

either a separate shape or a separate

617:44

type okay so I'll just cut that from

617:46

here and I'm going to also remove that

617:47

from here and once again we are getting

617:49

all of that errors right here so to do

617:51

that we can either create a type you

617:53

already know how to create a type if you

617:55

are coming from my typescript course but

617:57

if you don't know how to create a type

617:59

you should go ahead and watch my

618:00

typescript course now I'll just create

618:02

my type and I'm going to give it the

618:03

name of like user shape you can

618:05

basically give it any name that you like

618:06

and now inside there we are going to be

618:08

just spacing our types right here so we

618:10

are now creating our user shape but now

618:13

we have to tell our component that we

618:15

want to use this user shape so I'm going

618:16

to copy that from here and I'm going to

618:18

just rate my component props to this

618:20

user shape so as soon as I do that I'm

618:23

going to save my file and refresh that

618:24

and still we're getting that same result

618:27

and that errors are now successfully

618:28

gone so that's the first way now I can

618:31

totally comment this line out and we can

618:33

also create an interface for this so

618:34

I'll just use like interface and I'm

618:36

going to give it the name of like user

618:37

shape one more time and we're not going

618:39

to be using any equals to sign because

618:40

we're now working with the interface and

618:42

now inside there we can use like name

618:44

will be a string and age will be a

618:46

number and also we have the property of

618:48

is student come on is student and that's

618:52

going to be the Boolean value so as soon

618:54

as I do that sa my file and here you can

618:56

see we're getting the same result and we

618:58

are no longer getting their error

618:59

messages right here this is how we are

619:01

going to be working with the prompts

619:03

with the component but now in some

619:04

situation we would also want to use the

619:06

children so now let me just remove that

619:08

from here I'm going to call my component

619:10

as this way so we want to pass some sort

619:13

of GSX inside there I'm not going to do

619:15

anything crazy but I'll just put a

619:16

paragraph which you just say like hello

619:18

which means like we want to use our

619:20

children right here so to use them for

619:22

that we are going to be using our

619:24

children so we have to destructure our

619:26

children right here come on children I'm

619:29

going to copy that and we have to

619:30

replace that with this H1 or maybe H2

619:34

and we have to render our children right

619:36

here so if I save my file still we are

619:38

getting this error right here because

619:40

this children has no property and it is

619:42

not available inside this user shap so

619:45

I'm going to remove that from here and I

619:47

can just write like children and now

619:49

what will be the type of this children

619:52

like this is not a prop this is neither

619:54

a string nor a number or Boolean or

619:57

undefined or anything like this so what

619:59

in the world we are going to be

620:00

specifying for this children so we are

620:03

going to be using something called the

620:05

react node okay so if I just use like

620:07

react node and if I hit enter so it's

620:09

going to Auto Import it right here as

620:11

you can see so if I sell my file here

620:13

you can see we are not getting any

620:15

errors and here you can see we are

620:16

getting what hello but now want is see

620:18

like what is inside this react node so

620:21

if I hold my control or command and if I

620:23

click on that so it's going to brings us

620:25

to you guessed index. d. TS which means

620:29

like this kind of brings us to types

620:30

file like this file only includes the

620:33

types nothing else than there so this

620:35

react node can either be a react element

620:37

either a string number a triable portal

620:40

Boolean null undefined and there are a

620:42

lot of things that you can explore in

620:44

this file but I will never recommend you

620:47

to like explore this file there are a

620:49

lot of things going on right here okay

620:51

so I'll just remove that from here and

620:53

this is how we going to be specifying or

620:55

react node for our children now this is

620:57

the modern way of providing our shap for

621:00

our prop but there is also another way

621:02

you will found like in the documentation

621:04

or somebody else code so I also want to

621:06

show you there so which is called the FC

621:09

or functional component so what I'm

621:10

going to do is that I'm going to just

621:11

remove that from here and I'm going to

621:13

go back to my old prop like we have the

621:16

name Edge and also the student I'm going

621:19

to save that file I'm going to also

621:20

remove that from here we also don't need

621:22

these children so let's just remove that

621:24

and also remove this okay so we only

621:26

have this user shape and I'm going to

621:28

uncomment there right now save my file

621:30

now I'm going to also destructure my

621:32

name ede and also the E student property

621:34

right here and now let me show you the

621:36

older way of providing a prop for our

621:38

typescript so this is how we going to be

621:40

doing there first of all we have to

621:41

provide our colon then we have to write

621:43

FC which will be coming from the reactjs

621:46

as you can see right here FC like a

621:48

function function component is coming

621:49

from the reactjs and now we have to

621:51

write like less than sign and here we

621:53

have to specify like a user shape and we

621:55

have to close there and once you close

621:58

there and if I have my mouse over to

621:59

there it is saying like all D structure

622:01

element are unused like you are not

622:03

using the inside your code and now to

622:06

fix this problem we going to be using

622:07

this I'll just use like H1 I'll write my

622:10

name and then H and then finally is

622:12

student property right here so if I save

622:15

that and here you can see this is yet

622:16

another way of pro providing a prop to

622:19

our component welcome to the react

622:21

typescript first challenge so in this

622:22

one I want you to create the button

622:24

component which will take three prop

622:26

like label on click and disable so label

622:28

will be just a label forward button and

622:31

the on click will be a function which

622:32

will be executed whenever somebody

622:34

clicks on our button and also the

622:36

disable will be a state like uh we can

622:38

indicate either the true or false and

622:40

it's going to make our button either

622:42

disable or enable so then finally you

622:45

have to import that component inside the

622:46

app. TSX file and just run that and and

622:49

make sure that you didn't get any errors

622:51

so give it your best shot if you can do

622:53

it that's completely okay then come back

622:55

and watch the solution and I'm going to

622:56

give you my solution so what I'm going

622:59

to do is that I'm going to create my

623:00

component and inside this component I

623:02

just create my b. TSX in this case

623:04

because we are now working with

623:15

timecrimes there like so as I mentioned

623:18

this going to take three prompts I'll

623:19

just WR a label and the label will be

623:21

set to click so I'll just write a click

623:23

right here and also the on click event

623:26

handler in this case we're going to be

623:27

passing our Arrow function and I'll just

623:29

say like con log and click like so and

623:33

I'm going to also past the disabl state

623:35

so d s a b l e d and for the disabled

623:37

state I'm going to set that to false now

623:39

that we successfully provided our prop

623:41

we have to get that prop inside our

623:43

component so how can you go about doing

623:45

that and this is how we going to be

623:47

consuming or accessing that props I'll

623:50

use the prop and here we also have to

623:52

define a type for there so I'll just use

623:53

like label for the label that's going to

623:55

be a string we're going to be also

623:57

passing the on click event handler and

623:59

this going to be a function so we have

624:01

to just provide a wi right here because

624:03

we're not going to be returning anything

624:04

from there and also the disabled State

624:07

and for the disabled that's going to be

624:08

a Boolean value so we also have to otate

624:11

there now we have to use the inside our

624:13

UI so I'll just remove this button and

624:15

replace the with this button actual

624:17

button right here and here we are going

624:18

to be passing like prop. LEL and also we

624:22

have to provide the on click event

624:23

handler and for the on click event

624:25

handler we are going to be using like on

624:27

on click like so we're going to be also

624:29

ping the disable okay and that's going

624:31

to be equals to that prop. disable so

624:34

I'm going to sell my file open my

624:36

terminal and use npm run Dev so it's

624:39

going to run the inside my browser so

624:41

that's cool and everything like we are

624:42

getting our button we're not getting any

624:44

errors right here but we can also

624:45

refactor this code to user destructuring

624:47

so I'll just remove these props and I'm

624:49

going to write like label and on click

624:52

event handler and also the disabled

624:54

State you no longer have to provide

624:56

these props and dots I'll just select

624:57

one and hit control d contr d and remove

625:00

them now let me just save my file and

625:02

this is how my code looks like and yeah

625:04

we can click on our button and it's

625:06

going to gives us like something inside

625:08

our console as you can see welcome to

625:10

the reusable prop typing with reactjs

625:13

and typescript challenge so the first

625:15

thing that I want you to do is that I

625:16

want you to create a file with the name

625:17

of typ .ts inside the SRC directory then

625:21

Define the info type and extend the

625:23

admin info list inside the types. TS

625:25

file so what is the info type this type

625:28

represents the best information shared

625:29

by all users it includes essential

625:32

properties like ID name and email about

625:34

a specific user and yeah that's going to

625:37

be the first portion of this Challenge

625:38

and in the next portion you're going to

625:40

have to create a component with the name

625:41

of user info and that component will

625:44

display the user information based on

625:46

the info type then create ad info

625:48

component and that will display the user

625:50

information and additional admin detail

625:53

based on the admin info list type okay

625:55

and finally you have to import all of

625:57

them inside the app. TSX file and just

625:59

see like if you got some sort of error

626:01

or not so give it your best shot if you

626:03

can do it that's completely okay then

626:05

come back and watch the solution and now

626:07

let me just give you my solution so I'm

626:08

going to remove that and create first of

626:10

all my component user info. TSX and also

626:14

admin info. TSX so I'll just create like

626:17

RFC in inside this one and also the rafc

626:20

inside the admin info component now let

626:23

me go ahead and go to my app and

626:24

register both of that component right

626:26

here so I'll use like user info and grab

626:29

there I'm going to also use the admin

626:31

info and also grab there right here now

626:34

let me create some sort of a data so

626:36

what I'm going to do is that I'm going

626:37

to create my user and that user will

626:40

have the ID and that's going to be set

626:41

to like one and also have the name which

626:43

will be like I don't know John do and

626:46

also the email will be set to John

626:50

gmail.com so that's going to be just for

626:52

a normal user we're going to be also

626:54

creating one for the admin and the admin

626:56

will have the ID of Two And also the

626:58

name will be set to Janny Smith or

627:01

something and also we're going to be

627:03

providing an email and this can be set

627:05

to jany

627:06

gmail.com okay and now we are going to

627:09

be providing a role and the role will be

627:10

set to admin come on admin like so and

627:14

we going to be also providing the last

627:16

login so I'll just use like new update

627:18

and it's going to giv us the last login

627:20

now here you can see we've defined our

627:22

data and now we're going to be passing

627:24

that data but we also have to create a

627:26

type for this data so how can you go

627:28

about doing that I'm going to show you

627:30

how we can do that but now let me just P

627:31

this data as a prop so I'll just write

627:33

like user and user and I'm going to also

627:36

specify the admin and which will be set

627:37

to this admin data okay so now let me go

627:40

ahead and create my types right here

627:42

inside this SRC folder so I'll just

627:44

create like type or types. TS and here

627:47

we're going to defining word types like

627:49

let me just show you all of them like so

627:51

ID is now set to one so first of all I'm

627:54

going to just Define like type of info

627:57

and this going to be a type so the ID is

627:58

now set to number so we're going to be

628:00

providing a number and also come on I

628:02

forgot to include the equal to sign I

628:04

thought I was just creating some sort of

628:06

object anyway so the name is set to

628:08

string also the email is set to string

628:11

okay now underneath that we're going to

628:12

be also defining another type which will

628:15

be the admin info list type and that's

628:17

going to be coming from the info like we

628:19

want every single thing that the info

628:21

have and we also want to attach this new

628:24

one so for the role here you can see we

628:27

already get all of their data or all of

628:29

their types from this info and now you

628:31

want to attach the role and also the

628:33

last login role will be set to string

628:35

and the last login will be set to date

628:38

okay and finally we have to export that

628:40

so we can use the inside our file so

628:42

I'll just export there but we have to

628:44

explicitly tell it like this is a type

628:45

so I'll just use like info and type type

628:48

of admin list info right here okay so

628:51

now that we successfully created there

628:53

we also exported there but now we have

628:54

to use the inside Word file okay so to

628:57

use them I'm going to grab first of all

628:59

my info and also the admin list or admin

629:03

info list to be precise and we also have

629:06

to inverted this list or this user with

629:08

our type so I'll just use like info and

629:11

I'm going to also provide my admin right

629:14

here so I'll use like uh admin list or

629:17

admin info list right here okay so now

629:19

that's to done now let me just go ahead

629:21

and go to my component grab all of their

629:23

data let me just zoom in a bit and the

629:25

first thing that I want to do is that I

629:27

want to grab my info from my types file

629:30

and here we're going to be defining our

629:31

own type so I'll just use like type um

629:35

user info prop will be fine and that's

629:37

going to be equal to the user and for

629:40

the user we're going to be defining all

629:41

of that type so I'll just use like the

629:43

older way of providing a prop so I'll

629:45

use like react let me just get there and

629:47

I'm going to use like fc4 functional

629:49

component and here we're going to be

629:50

providing our user info prop and I'm

629:53

going to close that I'm going to also

629:54

destructure the user like all of the

629:56

data which we are now providing for this

629:58

user and we have to render that inside

630:00

this component so we use like H2 which

630:03

will say like user info or information

630:06

would be fine and underneath that we're

630:08

going to be creating our ID which will

630:10

just use us like user. ID and I'm going

630:12

to duplicate that a few times so we have

630:14

a name and we also have the email

630:17

address so I'm going to just change this

630:18

value to like name and also change this

630:21

ID to email and that's going to be fine

630:23

we'll be doing exactly the same thing

630:25

for the admin info component so what I'm

630:28

going to do is that first of all I'm

630:29

going to grab my admin info list okay so

630:33

once we grab them I'm going to create my

630:35

type of admin info props and here we're

630:38

going to be using like for the admin

630:40

we're going to be providing like admin

630:41

info list like this one right here we're

630:45

going to be placing that here okay now

630:47

I'm going to also use my react so I'll

630:49

just use like

630:50

react uh. FC for the functional

630:53

component and I'm going to provide my

630:55

admin in full list right here it's going

630:57

to also take the perimeter or not

630:59

perimeter but the prop of admin so we

631:01

have to take that and we have to use

631:03

that inside our component so I'm going

631:05

to remove them and I'll use like H2 of

631:08

admin

631:09

information like so and provide a

631:12

paragraph with the ID of uh admin. ID

631:16

and just duplicate there a few time two

631:19

the name and also email and also the

631:23

rule and finally we have to just replace

631:26

there with or you know what yeah we have

631:27

to write like admin. last login and from

631:30

there we going to be getting like two

631:32

local string okay and I'm going to

631:34

execute there instead of providing the

631:36

ID I'm going to just change that to a

631:38

name and I'm going to also provide the

631:40

email here and also the role and finally

631:43

we going to be getting the last login

631:46

like so I don't know why we getting this

631:48

error does not exist on what type let me

631:52

just grab that and put this one right

631:54

here now that successfully gone and this

631:57

should be local string now let me sa my

632:00

file and check this out so here you can

632:02

see we are now getting the user

632:03

information and we are also getting the

632:05

admin information and anytime I sell my

632:07

file it's going to gives us a different

632:09

second right here which is cool but now

632:12

we are no longer getting any errors and

632:14

we are now successfully providing our

632:16

types for each of the compon component

632:18

prop okay so now let's talk about the

632:20

reusable types so to show you there

632:22

first of all I'm going to be creating my

632:23

components folder and we will have like

632:26

user info. TSX and I'm going to also

632:28

create here another component which will

632:30

be for the admin info. TSX and I'm going

632:33

to go into my app component but first of

632:35

all we have to write our RFC inside this

632:37

component and also inside this component

632:40

as well I'm going to go into my app

632:42

component and first of all I'm going to

632:43

be importing my user info component and

632:46

save there and I'm going to also import

632:48

my admin info component and save there

632:50

as well I'll just provide a bit of label

632:52

right here like H1 and user info and

632:56

then I'm going to select this downand

632:58

and I'm going to also copy there and now

633:00

let me just place it here and let's just

633:02

change this one to the admin info so I'm

633:04

going to save this file and as you can

633:06

see right here first of all we have our

633:08

user info component and then we have our

633:10

admin info component right here so now

633:12

I'm going to pass a bit of prop to it so

633:14

I'll just use like username and username

633:16

will be Alex let me just write Alex

633:18

right here and we are going to be also

633:20

specifying the email like Alex gmail.com

633:23

and I'm going to also provide the edge

633:25

and Edge will be set to 20 and I'm going

633:27

to also provide a location and location

633:29

will be I don't know Earth and also

633:32

United State I'm going to save this file

633:34

and now I'm going to copy every single

633:36

thing from this component let me just

633:38

place it right here to the admin

633:39

component as well so we providing a name

633:41

of Alex we're also providing the email

633:43

Ed and also the location you know let me

633:46

just change this location to something

633:48

else like Mars or something and unknown

633:51

and I'm going to also provide the admin

633:53

property and this will be a totally

633:55

unique property like this component does

633:58

not have the prob of admin and this

634:00

component has the prop of admin right

634:03

here okay so what I'm going to do is

634:05

that I'm going to go into my user info

634:06

component right here and first of all I

634:08

want to create my info so I'll just

634:10

write like type of info you can create

634:12

interface if you want it to so it's

634:14

going to take like a username and

634:15

username will be a string you're going

634:17

to be also providing an email and email

634:19

will be a string as well this is provide

634:21

a edge and Edge will be a number and

634:22

provide a location and location will be

634:25

a string of array so now we have to use

634:27

that inside our user component I'll

634:29

first of all destructure my username

634:31

then email and then Edge and also the

634:33

location and we will annotate there with

634:36

this info component not a component but

634:38

a type now if I sa my file it's going to

634:40

say that we have to use all of these

634:42

props inside our component so to do that

634:45

I'm going to change this D to the UL and

634:47

now inside this UL we're going to be

634:48

defining a few allies like uh Ali for

634:51

the username and also let's just

634:53

duplicate there a few time for the email

634:56

and also for the edge and I'm going to

634:58

use my uh json. stringify so you can see

635:02

the value of this location so I'll just

635:03

Pro like location and now I'm going to

635:05

save my file and I'm getting some sort

635:07

of error l o c a t i o n c a t i o n

635:11

there we go so now if I save my file we

635:13

are getting all of that data which is

635:14

looking amazing I'm going to basically

635:16

copy every single thing from this

635:17

component now let me just place that

635:20

inside this component right here so my

635:23

file now we also have to destructure the

635:25

username email and also the edge copy

635:27

them and place that right here so now

635:30

I'm going to copy this info we're going

635:31

to go into our admin component and now

635:33

let me just place that here and instead

635:35

I'm going to change that to a info like

635:37

for the admin component info I'm going

635:39

to copy there and now let me place it

635:41

and as you can see right here we are not

635:43

getting any errors but if I go into my

635:45

app. TSX component here you can see we

635:48

are getting this error like this admin

635:50

is not defined so if I go ahead and go

635:52

to my admin component and if I just use

635:54

like what a comma and provide my admin

635:57

right here sa my file I just going to

635:58

complain like Huzan you have to register

636:01

there inside your a info type so to do

636:03

that I'm going to use like admin and

636:06

provide a string right here so here you

636:07

can see that it is now successfully gone

636:10

but did you notice one thing we are now

636:12

repeating ourself we are copying this

636:15

type and we are now placing there right

636:17

here here just because of this one admin

636:20

and why are we doing that that's because

636:24

this admin is unique to this component

636:26

we can totally use it right here so if I

636:28

just copy there and now I can totally

636:30

use my admin right here say my file

636:32

that's totally done and because of this

636:34

admin prop we are now copying the entire

636:37

thing and we are now placing there right

636:39

here so if you don't want to use that so

636:41

for that we are going to be using the

636:43

reusable component inside the typescript

636:45

so how are we going to be doing that to

636:47

do that I'm going to go into my users

636:48

info and I will just provide the export

636:51

right here so if I just provide this

636:53

export so which means like I can totally

636:55

use this type anywhere I want in any

636:57

component I want okay so now if I go

637:00

ahead and go to my admin component I can

637:02

totally remove there and now I can

637:04

import my info right here so if I hit

637:06

enter right here so it's going to import

637:08

that from the user info I'm going to

637:10

copy there and now let me just place it

637:11

right here sa my file once again we are

637:13

getting an error for this admin so to

637:16

fix that we have to find another type so

637:18

I'll just use like admin info list and

637:22

we are going to be using first of all

637:24

the info like all of the props which are

637:26

already available inside this info we

637:29

also want to use all of them and we are

637:31

going to be providing an end and now we

637:33

have to Define our new one so we also

637:36

want to use the admin and admin will be

637:38

a string okay so if I copy there and now

637:40

let me just place it right here come on

637:42

let me just place it right here save my

637:44

file and as you can see right here those

637:46

errors are now successfully gone so this

637:49

is how we going to be defining the type

637:50

for our prop in one component we just

637:53

have to export there this is how we are

637:55

going to be importing there and now

637:57

later if you decide to add some more

637:59

prop so this is how we are going to be

638:01

attaching there by using this end

638:02

operator okay now the final thing I want

638:04

to show you is that you can explicitly

638:06

type A type right here which means like

638:09

we are now telling our typescript

638:10

compiler like this is going to be some

638:12

sort of a type this is not a component

638:14

this is not some sort of a data

638:16

available inside other file

638:18

these are types so now we are telling

638:20

our compiler like these are the types so

638:22

it's going to treat it as a type okay so

638:25

yeah that was the reusable component and

638:28

next we're going to be learning about

638:30

the used St types okay so now let's talk

638:32

about how we are going to be using a

638:34

types for or used so to do that I'm

638:36

going to create my components folder and

638:38

I'm going to Define my counter. not jsx

638:41

but TSX right here let's just use our

638:43

rafc save my file and registered that

638:46

counter ins inside my app so I'll just

638:48

use like counter and now let's just

638:50

register there right here so if I save

638:52

my file and as you can see we are now

638:53

getting our counter which is looking

638:55

amazing so the first thing that I want

638:56

to do is that I want to Define my count

638:58

so I'll just use like const uh count and

639:01

then set count will be equals to the us

639:04

and we're going to be providing the

639:06

initial value of zero today okay so it

639:08

is not complaining but if you want to

639:11

provide a type forward used it this is

639:13

how we are going to be doing there so if

639:15

I H my mouse over today and as you can

639:17

see right here this is a generic

639:19

function which means like we can provide

639:21

more types at once and if you guys don't

639:23

know what a generic function is or

639:25

generics are so you should definitely go

639:27

ahead and watch my typescript course and

639:29

there I explain generics in a more great

639:31

detail so I'll just specify the type of

639:34

number right here and here you can see

639:36

we can specify the number we can specify

639:38

the string we can provide like undefined

639:41

we we can provide null if you want we

639:43

can provide any kind of type so I'm

639:44

going to just specify like number and

639:46

this is how we're going to be defining a

639:48

used St inside our typescript component

639:50

okay so now we can totally use it we can

639:52

do like basically anything we want to do

639:54

with this I'll just use like counter app

639:56

and inside that we're going to be

639:58

creating our count as a paragraph and

640:00

I'm going to specify count as a value

640:02

underneath that we're going to be

640:03

creating our button which will just say

640:05

increment and also we are going to be

640:07

creating a component and let me just

640:09

duplicate that and change that to

640:11

decrement and let's just provide a bit

640:13

of the on click on there when somebody

640:16

clicks on that so what we have to do in

640:18

that situation we're going to be using

640:20

our set count in the first case we're

640:22

going to be incrementing our counter by

640:25

one and in the second case we're going

640:26

to be decrementing our counter by one so

640:28

now if I save my file and as you can see

640:30

right here I can increment my counter

640:32

and I can also decrement my counter so

640:35

yeah this is how we're going to be

640:37

providing a type for our user welcome to

640:39

the user challenge with reactjs in

640:41

typescript so the first thing that you

640:43

have to do is that you have to define a

640:45

state variable by using the U state and

640:47

type that explicitly so I will recommend

640:49

you to create a counter component by

640:51

using the US and annotate there with a

640:53

number okay so if you can even do this

640:55

one you don't even have to do the first

640:57

step to be honest now for the Second

640:59

Step you have to create a user profile

641:00

component and then inside that profile

641:03

component you're going to be defining

641:04

your state by using the US state which

641:06

will hold the object with the user

641:08

information and type it accordingly okay

641:10

like basically you're going to be

641:11

creating some sort of object which will

641:13

have like the username Edge and some

641:15

sort of location or something like that

641:17

you can put like basically any kind of

641:19

user information if you wanted to next

641:21

you have to create a to-do list. TSX

641:23

Define a state variable for the to-do

641:25

list item and type that accordingly so

641:27

give it your best shot if you can do it

641:29

that's completely okay then come back

641:30

and watch the solution and now let me

641:32

just give you my solution so I'm going

641:33

to create a user profile oh you know

641:36

we're not going to do that not right now

641:38

first of all let me just show you uh the

641:40

counter component so I'll just create

641:41

like cons count and then set count come

641:45

on set count like so and that's going to

641:48

be equals to the used State and the

641:50

initial value will be zero and now if

641:51

you want to annotate there with the

641:53

number so this is how we going to be

641:54

doing there so we can also just write

641:56

our H1 and here we're going to be

641:58

defining our counter or count to be

642:00

precise and next we have to create our

642:02

button which will allows us to increment

642:04

or counter so I'll write like on click

642:06

and when somebody clicks on there we're

642:07

going to be firing this function so I'll

642:09

just use like cons increment function

642:12

and inside this function we're going to

642:14

be using the set count and let's just

642:15

provide our previous uh yeah previous

642:18

count would be fine and then previous

642:20

count plus one so now if I save my file

642:22

and I'm going to use my npm run Dev to

642:24

run there and here you can see we are

642:26

now getting our counter if I click on

642:28

this it's going to just increment there

642:29

by one so that was the easy part now we

642:32

are going to be also creating our user

642:33

component and we're going to be typing

642:36

there so I'll use like user profile do

642:39

not jsx but TSX in this case let me just

642:41

use my RFC inside there go to the bottom

642:44

and here we're going to be rendering or

642:47

user profile component like so and this

642:49

is how it will look like right here so

642:51

what I'm going to do is that first of

642:53

all I'm going to Define my state so I'll

642:54

just use Like Us St and here we're going

642:56

to be passing an object and first of all

642:58

I'm going to past like a name we're

643:00

going to be also providing a edge of

643:01

zero and the email will be set to empty

643:04

string okay so I'll just annotate there

643:06

with the interface or you can also

643:07

create the type if you wanted to so I'll

643:09

just create an interface and the

643:10

interface name will be user profile or

643:14

yeah user profile state or something so

643:16

I'll write a name which will be a string

643:18

I'll also write the edge which will be a

643:19

number and also the email which will be

643:22

a string okay so I'm going to copy this

643:24

user profile you know what user profile

643:27

uh state would be fine so I'm going to

643:29

copy them and now let me put there right

643:31

here or annotate there here like so and

643:35

what I want to do is that I want to

643:36

create my profile and also set profile

643:40

it's going to be equals to this us next

643:43

we have to use it so I'm going to remove

643:44

this user profile and I will just write

643:46

like user profile inside the H2 and I'm

643:50

going to also write the input field and

643:51

inside this input field uh the type will

643:53

be set to text and I'm going to also

643:55

provide the placeholder of name today

643:57

and the value will be set to profile.

644:00

name and I'm going to also provide the

644:02

on change event handler when somebody

644:04

change something or type something

644:06

inside this input Fields we're going to

644:08

be firing this function which will say

644:09

like update name this is the function

644:12

which we going to be creating in a few

644:13

second and it's going to take the event.

644:15

target. value do value and it's going to

644:18

past it for this function and you know

644:20

what I'm going to just create this

644:21

function right away so yeah I'll just do

644:24

that right now I'll use like cons update

644:27

name it's going to take the name and we

644:29

will annotate there with the string and

644:31

inside there we're going to be using a

644:32

set profile it's going to take the

644:34

previous profile and here we just have

644:37

to use like um first of all we have to

644:39

copy our previous profile come on

644:42

previous p r e v i o u s or pre profile

644:46

to be size and we're going to be also

644:48

providing a new value too there okay so

644:50

this is how we're going to be defining

644:52

our update name and let me just see so

644:55

if I just type something but I cannot

644:57

submit there so that's why we cannot see

644:59

there anyways you will get there in a

645:01

few second I'm going to also Define yet

645:03

another input field so I'll use like

645:05

input with the type of number in this

645:07

case and here we're going to be

645:09

providing the placeholder of hge today

645:11

I'm going to also provide the value and

645:13

for this value we are going to be using

645:15

like profile. is great greater than zero

645:18

if that's the case we're going to be

645:19

getting like profile. Edge but if that's

645:21

not the case we're going to be setting

645:23

there to empty string and also when

645:26

somebody change or type something inside

645:28

there we're going to be firing this

645:30

update Edge function update Ed function

645:33

which we're going to be creating in a

645:34

few second and I'm going to paste like

645:36

event. target. value inside there and

645:38

now underneath this input field we're

645:40

going to be defining yet another input

645:42

field so I'll use like input and the

645:44

type will be set to email we're going to

645:46

be also passing the value and value will

645:48

be coming from the profile. email and

645:51

when somebody types something inside

645:53

there we're going to be firing the event

645:54

object and creating this update email

645:57

function in a few second and I'll use

645:59

like event. target. value finally we

646:02

have to render or content I'll used like

646:04

H3 and here we're going to be writing

646:06

like profile summary and underneath them

646:09

we're going to be creating our paragraph

646:11

and first of all let me just render my

646:13

profile. name and I'm going to duplicate

646:15

there like three time so we have a

646:16

profile. Edge and also profile. email

646:20

okay so let's just change that to Edge

646:22

and change this one to email and yeah I

646:25

guess that's going to be fine but we

646:27

also have to create this update Edge and

646:29

also the update email so I'm going to

646:31

just create there right here PA update

646:33

Edge it's going to take Edge as a

646:35

parameter and we will just annotate that

646:37

as a string okay so now inside there uh

646:41

we are going to be using like set

646:42

profile and here we have to provide our

646:44

previous profile and inside there we're

646:47

going to be first of all cloning or

646:49

previous come on previous profile and

646:52

then we have to just provide a new value

646:54

to them okay so we're going to be

646:55

passing an edge and now we want that

646:58

edge to be a number so we can convert

647:00

this Edge to a number like so by using

647:03

this number Constructor or we can just

647:05

write a plus so it's going also convert

647:07

there to a number and now underneath

647:09

them we're going to be also defining our

647:10

update email so I'll use like update

647:12

email and it's going to take the email

647:14

as a perimeter and there going to be a

647:16

string so we also have to annotate them

647:19

and I'm going to use like set profile

647:21

and here we once again we have to

647:22

provide our previous profile and then

647:24

we're going to be making a clone of

647:25

there by using dot dot dot previous

647:28

profile come on p r o f i l e and I'm

647:31

going to also provide the new email to

647:33

there okay

647:35

so that was a lot of talking so let me

647:38

just see here you can see we have our uh

647:40

user profile we don't have nothing for

647:42

the name for the edge we have like only

647:44

zero and for the email we don't have

647:47

anything so if I just write like my own

647:48

name and it's going to add the right

647:50

here for this name I can also change the

647:53

age to like 22 and I can also provide

647:55

the email like test gmail.com it's going

647:58

to add there right here so this is going

648:00

to be my profile summary so that's done

648:03

now it's time to create or to-do list

648:05

application so I'm going to go ahead and

648:07

create my to-do uh. TSX or

648:11

too come yeah today list. TSX would be

648:14

fine I don't know what the hell am I

648:16

thinking right now so let's oh my

648:19

God you know what too would be fine so

648:22

Tod do. TSX is fine and I'm going to

648:24

write my rafc inside there and I'm going

648:27

to go ahead and go to my app and

648:28

register there right here so let's just

648:30

find what to do and register there and

648:33

the first thing that I want to do is

648:34

that I want to write like todos or yeah

648:37

todos would be fine and then set todos

648:39

and that's going to be equals to the US

648:41

state and the initial value will be just

648:43

empty array I'm going to also create an

648:45

interface for that because because we're

648:47

going to be creating our to-dos which

648:48

will have a interface of to-do I'm going

648:50

to provide the ID and ID will be a

648:52

number I'm going to also provide the

648:54

task and the task will be a string and

648:56

the completed will be set to Boolean and

648:59

now let me get this to do interface and

649:01

we have to annotate our state to there

649:03

so let's just write where to do and here

649:05

we have to inate there like so and now

649:07

let me go to the UI and change this UI

649:09

so I'll use like H2 to-do list and

649:12

underneath there we're going to be

649:14

creating a button which will say like

649:16

add too like so and for this button when

649:19

somebody clicks on there we're going to

649:21

be firing this function so let's just

649:22

use like um add too and we're going to

649:26

be providing God damn it add Todo and

649:30

we're going to be providing a new to-do

649:31

inside there let me just create this

649:33

function right away so I'll just create

649:35

that right here and yeah I guess that's

649:38

going to be fine so let's just create

649:39

the add too and it's going to take a

649:41

task as a perimeter and we will annotate

649:44

that as a string okay so inside there

649:46

first of all we are going to be creating

649:47

a new to-do and I'm going to also

649:49

annotate that with this to-do and here

649:52

that's going to be equals to this object

649:53

so it's going to take the ID and ID will

649:55

be coming from to-dos do length + one so

649:58

that's going to be just basically my ID

650:00

and we're going to be also providing a

650:02

task which we are taking as a perimeter

650:04

and we're going to be providing there

650:05

for this function and I'll also provide

650:07

the completed and that's going to be set

650:09

to false just like a I'm going to have

650:12

to provide a commas instead of providing

650:14

that whatever that was let this is

650:16

provide a set to-dos and finally we have

650:18

to write a previous to-do or to yeah

650:21

to-dos would be fine and here we have to

650:23

just make a clone of previous to-dos so

650:25

let's just WR our pre to-dos and I'm

650:27

going to add my new to-do to there okay

650:30

so let's just hide this one I'm going to

650:33

put that at the top we're going to be

650:35

rendering our to-do so I'll use like you

650:37

and I'm going to iterate over through

650:39

all of the to-dos by using the map it's

650:40

going to take a to-do as a perimeter and

650:42

inside then we're going to be using our

650:44

Ali to render or each to-do so for each

650:47

of the to-do I'm going to write like

650:48

too. task and then I'm going to write

650:51

like is it completed or not so I'm going

650:53

to use like to-do do competed completed

650:57

God damn it so just to do. completed if

651:00

that's the case completed if that's the

651:02

case we're going to be just writing like

651:04

uh completed but if that's not the case

651:07

so we are going to be setting there to

651:09

empty string okay and I'll also provide

651:12

a key so I'll just write like to do. ID

651:15

as a key I'm save this file and finally

651:18

let me go into my ab. TSX we already

651:20

provided all of them so let's just test

651:22

this out so here you can see we have our

651:24

a to do I'm going to click on this so

651:26

it's going to just add a new to-do

651:27

anytime I click on that so yeah that was

651:31

uh our example about the user and we

651:33

learned a lot about how we can annotate

651:35

or used so that was it about for the

651:38

count example for the user profile

651:40

example and also the to-do list example

651:43

as well now we are going to be covering

651:45

three topics at ones like use ref forms

651:48

and events like how we are going to be

651:50

providing up types for the US ref forms

651:53

and also for the events so what I'm

651:55

going to do is that I'm going to create

651:56

my components folder and inside this

651:59

component folder we're going to be

652:00

providing our form. TSX and inside there

652:04

I'm going to just use my RFC save my

652:06

file and we also have to register there

652:08

inside our app component so I'll just

652:10

use my form and if I hit enter so it's

652:12

going to grab that from my components

652:14

folder so what I'm going to do is St

652:16

first of all I'm going to Define my

652:18

state which will be like submitted and

652:21

also set

652:22

submitted data and we're going to be

652:25

storing that inside the used St and for

652:27

the initial value I'm going to specify

652:29

the name and name will be set to empty

652:31

string we're going to be also providing

652:33

an email and email will be set to string

652:35

and we also have a password and password

652:37

will be also empty string so now we can

652:39

create a separate type for all of them

652:42

to do that I'm going to be using a type

652:44

and I'm going to give it the name of

652:45

like form data and inside there we're

652:47

going to be defining a name which will

652:48

be a string I'm going to also provide

652:50

the email which will be a string and

652:52

also the password which will be also a

652:54

string okay so I'm going to copy this

652:56

data right here and now we have to

652:58

annotate where used state with this data

653:01

I'm going to be using my form data and

653:02

now let's just anot what used it with

653:04

that data so now that's slly done next

653:07

we're going to be also using the US rep

653:09

so I'll just use like con name and we

653:11

are going to be using a use RI for there

653:14

and if I hit enter so it's going to aut

653:15

to import there from the reactjs we

653:17

don't need the reducer so let's say

653:19

bye-bye to that and the initial value

653:20

will be set to null okay and I'm going

653:23

to just duplicate there a few times so

653:24

I'm going to just change the variable

653:26

name to like email and also to the

653:28

password as well so now we have to

653:31

specify a specific type for this us ref

653:33

so we are going to be using this us ref

653:36

inside our form and inside our specific

653:38

HTML input element so we have to tell

653:41

our user ref that we are going to be

653:43

using this name email and password

653:45

inside the HT L input element okay so

653:48

I'll just use like HTML input and if I

653:50

hit enter and here you can see we are

653:52

going to be using our type on the HTML

653:55

input element so I'm going to copy that

653:57

from here let me just use that here and

653:59

also here okay so this is how we're

654:01

going to be providing a type for the US

654:03

ref and now let's just use the inside

654:05

our component so what I'm going to do is

654:07

that I'm going to just uh remove this de

654:09

and I'm going to change that with this

654:11

form I'll just remove this form from

654:13

here and now I'm going to provide my

654:14

input field and that input F will take

654:16

the type of text we're going to be also

654:19

providing a placeholder which will say

654:20

like enter your name and also I'm going

654:22

to be defining my ref come on my ref and

654:26

it's going to be referencing to this

654:27

name okay so I can totally duplicate

654:30

there a few times I'm going to just

654:31

change that to email and also to the

654:34

password as well okay so I'll also

654:36

change these to email and also this one

654:39

to password as well so if I sa my file

654:42

that's everything that we have to do for

654:44

now but I'm going to also create a

654:45

button which will say uh submit okay and

654:49

we're going to be also providing a type

654:50

for there and the type will be set to

654:53

submit now underneath that we want to

654:54

show our data so I'm going to just write

654:57

a section and now inside this section

654:59

I'm going to write my H1 which will be

655:00

set to name and first of all we have to

655:02

grab our submitted data and we're going

655:05

to be using the dot name property on the

655:08

okay so as you can see right here so we

655:10

have our submitted data and we have the

655:12

name we also have the email and also the

655:14

password if you want to see all of the

655:15

data so I'm going to just duplicate

655:17

there like a few time we have to change

655:19

that to the email and also change this

655:21

one to the password as well just like

655:24

this I'll just change this one to the

655:25

email and I'm going to also change this

655:27

one to the password so if I save my file

655:30

and that's everything that we have to do

655:31

for the UI but now we're going to be

655:33

attaching our event on the form so when

655:35

somebody submit that form like when

655:37

somebody fill that form and submit there

655:40

and if you want to provide our Arrow

655:42

function right here like this we don't

655:44

have to specify a type for the but if

655:46

you want to extract all of that logic

655:48

into a separate function so for that we

655:50

have to specify some sort of a type for

655:52

that so I'll just use like handle submit

655:55

and I'm going to copy them and let's

655:56

just create what handle submit right

655:58

here okay so I'm going to be using like

655:59

cons handle submit it's going to take

656:01

the event and as you can see right here

656:04

we now getting this error so to fix this

656:06

error we have to tell our typescript

656:09

that we are using a form event like we

656:12

are using a event on the form right here

656:15

and we also have to tell it that we are

656:17

going to be firing this function on the

656:19

HTML form element like this one okay so

656:22

we also have to tell it there I'm going

656:23

to be using like HTML form element and

656:26

now if I hit enter so this is how we are

656:28

going to be telling our compiler that we

656:30

are going to be firing this event on the

656:32

form event and then we're going to be

656:34

using the on the HTML form element okay

656:36

so I can just use like event. prevent

656:39

default so it's going to just prevent

656:41

our default behavior and now you can

656:42

just grab like uh con name value like

656:46

whatever user type inside this input

656:48

field right here like the name input

656:50

field so what I'm going to do is that

656:51

I'm going to just use like name and I'm

656:53

going to be getting a current property

656:55

that's because of this name right here

656:57

which is now set to this reference and

656:59

now if I just use the dot value and what

657:02

are we getting we are now getting an

657:03

error if I how my mouse over to there it

657:06

is now giving us like name do current is

657:08

possibly null it is null not possibly

657:12

because we already set there to null so

657:14

how can we fix this error to fix this

657:16

error we can use the null insertion

657:18

operator right here which we already

657:20

covered in my typescript course if you

657:22

guys don't know about this so you can

657:24

definitely watch my typescript course

657:26

but if you guys already know that that's

657:28

cool so basically we are now telling our

657:30

compiler like you don't have to worry

657:32

about this code like it can never be

657:33

null and it can never be undefined we

657:36

are now telling this to our compiler

657:38

like you don't have to worry about our

657:39

code okay so now I'm going to just

657:41

duplicate there like a few time maybe

657:43

two times more and I'm going to change

657:45

this VAR aable name to like a email

657:47

value and I'm going to also change this

657:50

one to the password value as well okay

657:54

so we can totally log that to the

657:55

console or we can just submit that to

657:57

our Dom so I'll just use like set

657:59

submitted data and we are going to be

658:01

providing our object let's just provide

658:03

a name and for the name we're going to

658:05

be providing like a name value which is

658:07

this variable right here I'm going to

658:09

also provide a comma and let's just

658:10

provide a email and that's going to be

658:12

the email video and also for the

658:14

password we are going to be using the

658:16

password value or password value rather

658:20

so if I save my file now we no longer

658:22

have any errors right here because we

658:24

successfully type types or we

658:26

successfully provided a types for

658:28

everything and now here you can see we

658:31

are now getting this U so anything I

658:33

type inside there like for instance if I

658:35

specify my name of Huzan and my email

658:38

will be test at G come on test and

658:41

gmail.com and uh what is the password

658:45

enter your email enter your email and

658:50

enter your password there we go so if I

658:53

save that now I can write like

658:56

uh my real password and now if I submit

659:01

that here you can see oh we are getting

659:03

husan husan husan once again and I'm

659:05

providing a test and my real password

659:08

why is that oh that's because we're

659:10

using a name again and again we have to

659:12

change that to the email and also we

659:14

have to change that to the pen transfer

659:16

right here so if I save my file now and

659:18

if I submit there now we are getting a

659:20

name as husan email as a test gmail.com

659:23

and password my real password right here

659:26

so if I just refresh there and let me

659:28

type something something at gmail.com

659:31

and something cool and now let me click

659:34

on the submit and this is how we are

659:36

going to be getting all of that data

659:38

right here okay so this is how we are

659:40

going to be providing a types for the

659:42

prompt for the form and also for the

659:44

event and also for the use ref create a

659:47

file with the name of focus input. TSX

659:49

inside the SRC directory and Define a

659:51

component that use a US ref to focus on

659:53

the input field when the button is

659:54

clicked type the ref appropriately so

659:56

that's going to be the first part in the

659:58

second part create a file with the name

660:00

of contact form. TSX inside the SRC

660:02

directory and then Define a form

660:04

component with the type of state and

660:06

form Handler after that create a file

660:09

with the name of event handling. TSX

660:10

inside the SRC directory and Define a

660:12

component that demonstrate typing

660:14

different event handlers so you your

660:16

best shot if you can do it that's

660:18

completely okay then come back and watch

660:19

the solution and now let me give you my

660:22

solution so what I'm going to do is that

660:24

I'm going to Define my focus input. ESX

660:28

I'm going to use my RFC inside there go

660:30

to my app first of all let's just say

660:32

there and register my focus oh God damn

660:36

it f o c u

660:38

s oh my God f o c s if I can type it

660:42

today so Focus input right here and now

660:44

if I check this out so here you can can

660:46

see we are now getting our Focus input

660:47

which is looking cool and what I'm going

660:49

to do is that I'm going to be using the

660:51

use ref which not reducer use ref which

660:55

will be coming from the reactj and here

660:58

we're going to be providing the initial

660:59

value of null to them I'll store in the

661:02

variable with the name of like input ref

661:04

and that's going to be equals to this

661:05

use ref and we will also annotate there

661:07

with the HTML input element which will

661:10

be coming from the definition file so if

661:12

I hold control and click on there and

661:14

here you can see we can now get like all

661:16

of that um what do we call it that types

661:18

from the types script so yeah that's the

661:21

first thing now next we have to use this

661:23

so I'll just write like input field with

661:24

the type of text and I'm going to also

661:27

write the ref and we will just reference

661:29

that to the input ref let me Define my

661:32

placeholder which will say like uh click

661:34

the button to focus me like so and

661:39

finally we are going to be also

661:40

providing a button and when somebody

661:42

clicks on that button you're going to be

661:44

firing a function which will be a handle

661:45

Focus uh yeah handle Focus would be fine

661:48

and focus input will be the label now

661:50

let me create this handle Focus right

661:52

here underneath this input ref so I'll

661:55

just use like con const handle focus and

661:58

that's going to be an aror function

662:00

we're going to be getting our input ref.

662:03

current value and we are going to be

662:04

only using the focus inside there so now

662:07

let me save my file and check this out

662:09

so anytime I click on this input field

662:12

so it's going to focus my input field

662:14

and this is how we going to be anot

662:15

creting there so that was the first step

662:17

now for the next step we're going to be

662:19

creating our contact form so contact

662:22

form uh. TSX and here let's just use our

662:26

RFC and register the right here so we

662:29

have our contact form and register the

662:31

and sa there so what I'm going to do is

662:34

that first of all I'm going to use my Us

662:36

St and here we're going to be providing

662:38

our object and inside this object we

662:41

will have our name and also we would

662:43

have our email email like so and we're

662:46

going to be destructuring the form data

662:49

and also set form data it's going to be

662:52

equals to this used dat now for this

662:54

form data we are going to be annotating

662:56

there with the interface so now let me

662:57

just create an interface for there so

662:59

we're not going to be doing anything

663:00

crazy you can either create a type if

663:02

you want it to put in my case I'm going

663:03

to create an interface with the name of

663:05

like contact form St and basically you

663:08

can give it like any name that you

663:09

prefer and I'm going to write a name and

663:11

annotate there with the string and email

663:14

and annotate them

663:16

come on email with the email and otate

663:21

with the string as well so I'm going to

663:23

copy there and I'm going to annotate my

663:25

U state with this contact form state

663:27

right here so what I'm going to do is

663:29

that I'm going to just remove this div

663:31

and I'm going to replace that with the

663:32

form and I'm going to also replace this

663:34

other one to the form as well so let's

663:37

just create our div inside this div

663:38

we're going to be creating our label

663:40

remove this HTML 4 from there and I'm

663:42

going to also provide my name inside

663:44

there first of all we are going to be

663:45

register string the input field and this

663:47

input field will have the type of text

663:49

name will be set to name and we're going

663:51

to be also providing a value and that

663:52

value will be coming from the form data.

663:55

name okay so we're going to be also

663:57

providing the own change event handler

663:58

and when somebody types something inside

664:00

there so we're going to be fting this

664:02

handle change event now let me duplicate

664:04

this uh d right here for the email so I

664:08

just duplicate there and change there to

664:10

email and also change this text to email

664:15

and we're going be also changing the

664:16

name to the email as well okay so change

664:19

the name to the email and in this case

664:22

we're going to be still providing this

664:23

handle change and underneath this div

664:25

we're going to be creating our button

664:27

which will say like submit and for this

664:29

button we're going to be providing the

664:30

type of submit to there okay like so and

664:33

now finally we have to just create our

664:34

handle change function inside this

664:37

component so I'll use like con handle

664:39

change it's going to take the event

664:41

object and we're going to be annotating

664:43

there by using the change event so let's

664:46

just write our change event and here for

664:48

this change event we're going to be

664:49

using the on the HTML input field so we

664:52

also have to explicitly specify that

664:55

HTML input field as well okay so from

664:57

the event. target we're going to be

664:59

destructuring the name and also the

665:01

value so now let me just destructure the

665:03

name and also the value out of this

665:05

event. target okay so here we're going

665:07

to be using like set form data and let's

665:10

just provide our previous state today

665:12

and once again we are going to be making

665:13

a clown of our prev previous state and

665:17

here we're going to be defining a name

665:19

and then we have to provide a newer

665:21

value which we are now getting from this

665:23

event. target right here okay so now I'm

665:25

going to save that and that's going to

665:26

be it for our handle change next we also

665:28

have to Define our on submit function so

665:31

whenever our form is submitted so we're

665:33

going to be firing our handle submit

665:34

function I'm going to copy there and

665:37

create my handle submit right here

665:39

provide our event and we will annotate

665:41

there with the form event and here we

665:44

also have to tell it that we are going

665:46

to be using there on the HTML form

665:48

element HTML f o RM and then element

665:51

like so okay so here we have to use our

665:54

Arrow function we're going to be

665:55

preventing the default behavior and also

665:58

underneath that we have to just loog to

665:59

the console or form data and here uh we

666:03

are going to be using some sort of a

666:05

label like form submitted like so okay

666:10

that was a lot of talking and yeah you

666:12

know what let me just test this out so

666:13

here you can see we have our name and

666:15

email for the name I'm going to specify

666:17

my own name for the email I'll just

666:19

write like test gmail.com and now if I

666:21

click on this submit and open my console

666:24

so it's going to gives us all of the

666:25

data right here but we are getting some

666:26

sort of error I type hen and test

666:30

gmail.com and click on there now we are

666:32

getting our form submitted and also our

666:34

email and our name data so which means

666:37

like everything is working the way we

666:38

expect him to work and this is how we

666:41

are going to be providing an annotation

666:43

or typescript for our event object and

666:46

this is how we're going to be providing

666:47

the or this is how we're going to be

666:49

creating an interface forward State now

666:51

let me create the final component which

666:53

will be for the event handling so we're

666:55

going to be using like event handling.

666:57

DSX I'm going to use my RFC inside there

667:00

go to my app and registered that

667:02

component right here so event handling

667:05

and I'm going to just call this

667:06

component check this out and we have our

667:08

EV event handling which is looking

667:10

amazing the first thing that I want to

667:12

do is that I want to create my H2 which

667:13

will say like uh event handling example

667:17

and now underneath that I'll just create

667:19

a button and that button will say like

667:21

click me and here we also have to

667:24

provide the own click and Handler and

667:26

when somebody C clicks on the handle

667:29

click so in that situation we're going

667:31

to be just firing this function like

667:33

handle click and we're going to be also

667:35

creating an event for this one so like

667:37

when somebody Mouse enter so in this

667:40

situation we're going to be firing this

667:42

function like handle Mouse enter okay so

667:45

what I'm going to do is that I'm going

667:46

to Define both of these function so

667:48

first of all let's just Define this

667:50

handle click one then we're going to be

667:51

defining this handle Mouse enter okay so

667:54

I'm going to copy there and create my

667:56

handle click it's going to take the

667:58

event object and we're going to be

667:59

annotating there with the mouse event

668:01

and we also have to explicitly tell it

668:04

that we are going to be firing that

668:05

event on the HTML button element like so

668:09

and here inside there we're going to be

668:10

logg to the console like event. current

668:13

come on c c u r n current Target and

668:19

also we have to just provide some sort

668:20

of a level like button click or

668:22

something like that I'm going to sve my

668:24

file and we are getting some sort of

668:26

error oh that's because we have to write

668:28

a react dot so I'm going to use react

668:31

and hit enter so is going to grab this

668:32

react react from the reactjs that's the

668:35

first thing now we also have to Define

668:38

this function so what I'm going to do is

668:40

that I'm going to Define there right

668:41

here so const handle Mouse enter it's

668:44

going to also take the event object and

668:45

we're going to be annotating there by

668:47

using react. Mouse and mouse event and

668:51

then we're going to be telling it that

668:52

we're going to be firing there on the

668:54

HTML Dev element okay so I'm going to

668:58

also provide uh what do we call it cons.

669:01

log and here we're going to be using

669:03

like e do current Target right here and

669:06

I'm going to also provide some sort of a

669:07

label which will say like Mouse entered

669:11

or something now let me save there and

669:13

test this out and here you can see we

669:15

have our uh label and we also have our

669:18

button let me just refresh there and

669:20

whenever I H my mouse over to there so

669:22

it's going to gives us that Mouse enter

669:24

and it's going to also gives us you know

669:26

let me just show you it's going to also

669:27

gives us that specific div so now inside

669:30

this div we have our event handling

669:31

example and also our button and now if I

669:34

H my mouse over to this click me it's

669:37

going to also gives us like Mouse enter

669:39

it's going to give us that data so yeah

669:42

that was example or that was a challenge

669:44

for the let me just show you the focus

669:47

input contact form and also the event

669:49

handling now let's talk about how we are

669:51

going to be using a typescript with

669:53

context API so to do that I'm going to

669:55

create a folder with the name of context

669:56

and now inside this folder I'll just

669:58

create like my context. TSX and now

670:01

inside there first of all we're going to

670:03

have to import our create context from

670:05

reactjs and now the next thing that we

670:07

have to do is that we have to create an

670:08

instance of the so I'll use my export

670:11

and then cons my context and that's

670:13

going to be equals to the create context

670:15

so we're going to be creating an

670:16

instance of there and now for the

670:18

initial value I'm going to provide a

670:19

count and count will be equal to zero

670:21

and we're going to be also creating a

670:23

increment function which will just

670:24

return nothing for now and then we are

670:27

going to be also creating one more

670:28

function for the decrement okay so I'm

670:30

going to save this file and now if you

670:32

want to add a types script forward

670:34

context so this is how we going to be

670:35

doing there you can either create a type

670:37

or you can also create an interface if

670:39

you wanted to so I'll just create my

670:40

interface right here and I'm going to

670:42

give it the name of like my context

670:44

props and now inside there we have a

670:46

count which will be a number and we also

670:48

have a increment function and from this

670:51

increment function we are going to be

670:52

only returning the wide like nothing for

670:54

now then we are going to be also

670:56

creating one for the decrement so now

670:57

let me just duplicate there and create

670:59

our decrement function and now if you

671:01

want to add there so I'll just write my

671:03

less than sign and then I'll write like

671:05

my context prop and I'm going to close

671:06

that at this way okay so this is how we

671:08

going to be defining our context and now

671:10

let's talk about how we are going to be

671:12

creating our provider so to create our

671:14

provider I'm going to just write like

671:15

cons my provider come on my provider

671:18

there we go it's going to take a

671:20

children as a prop and then inside there

671:23

we are going to be using like const and

671:25

then count and then set count this is

671:27

going to be the state which you want to

671:28

pass into our component so we are going

671:30

to be using Like Us St and the initial

671:32

value will be set to zero so it is now

671:34

taking a children so we have to provide

671:36

a type for there as well so I'll just

671:37

use like my FC like my functional

671:40

component which will be coming from the

671:42

Rea and then we have to provide uh or

671:45

prop right here so this is how we're

671:47

going to be creating the I'll use my

671:48

interface and then my provider yeah

671:51

that's that's going to be fine we're

671:52

going to importing a children and that's

671:54

going to be coming from the react node

671:56

and if I hit enter so it's going to Auto

671:57

Import there right here okay so now I'm

672:00

going to take that and I'm going to put

672:01

that right here sem my file and now it's

672:03

going to gives us an error because we

672:05

have to use it now first of all let me

672:06

just export this so that we can use it

672:08

in other file so I'll use like export

672:10

default and then my provider come on my

672:14

provider likes so save my file and now

672:17

inside this my provider I'm going to

672:19

just return first of all my my context

672:22

and come on what the hell am I doing and

672:24

then I'm going to use the provider

672:26

method on there okay so I'll just close

672:28

there inside this provider I'm going to

672:30

have to P some sort of data so I'll use

672:32

like value and for the value we are

672:34

going to be passing a count which we've

672:35

already defined right here and now let

672:37

me just use my increment and decrement

672:39

function so I'll use like increment and

672:41

now inside this increment we're not

672:43

going to be doing anything crazy but I

672:45

just use like set count and then count +

672:47

one and I'm going to also create one

672:49

more function for the decrement as well

672:51

so I'll use like decrement right here

672:54

and I'm going to decrement my value

672:56

right here I'll just write a minus and

672:58

I'm going to also copy both of them and

673:00

place there right here along with the

673:02

count so I'll just Place their increment

673:04

and I'm going to also copy the decrement

673:06

and I'm going to place the okay so if I

673:08

save my file and here you can see all of

673:10

the errors are now gone and obviously we

673:12

have to use this children inside our jsx

673:14

so I'll just word there right here like

673:17

so so if I save my file and this is how

673:19

we are going to be providing a type for

673:20

our context now I'm going to go into my

673:22

main component and we have to use that

673:24

right here so the first thing that I

673:26

want to do is that I want to grab my

673:28

provider right here I'm going to copy

673:30

that from there and let's just use there

673:32

on all of the entire app okay so I'm

673:34

going to put the here sa my file and

673:36

this is how we are going to be

673:37

successfully adding there but now I'll

673:39

just create a counter component I'll

673:41

write like component and then counter.

673:44

TSX would fine I'm going to use my rafc

673:47

semi file go into my app component and

673:50

let's just register that counter right

673:52

here so that we can see what's going on

673:55

okay so I'm going to just register my

673:56

counter component right here and now we

673:58

have to use our context inside this

674:00

counter component so to do that first of

674:02

all we are going to be importing the use

674:04

context from the reactjs and then we are

674:06

going to be also importing our own

674:08

context like my context okay from the

674:11

context folder and now to use that the

674:13

first thing that I want to do is that I

674:15

want to write my FC so I'll just use

674:17

like FC for the functional component and

674:20

I guess that's going to be fine and

674:22

inside there I will use my use context

674:24

I'm going to provide my own context

674:26

today like my context and we are going

674:28

to be destructuring a lot of things from

674:30

it so like uh I need the count and also

674:33

the increment function and also the

674:34

decrement function from my context or my

674:37

use context so now inside there let's

674:39

just use the inside our component I'm

674:41

going to remove this D from here and

674:43

provide my paragraph and provide the

674:45

count and the initial value for this

674:47

count will be set to that count which is

674:49

coming from our context we're going to

674:51

be also creating a button which will say

674:53

like increment come on increment and

674:56

also this is create one for the

674:58

decrement and attach event handler on

675:00

both of these button the first one will

675:02

take the increment and the second will

675:04

take the decrement so now if I save my

675:06

file and here you can see you're now

675:07

getting our count if I click on this

675:09

it's going to increment my counter and

675:11

if I click on this one so it's going to

675:12

decrement my counter right here by one

675:15

so yeah this is how we are going to be

675:17

providing a typescript forward context

675:20

now let's talk about how we are going to

675:22

be providing a type for our use reducer

675:24

so I'll just create a components folder

675:26

and inside that we're going to be

675:27

creating our counter. TSX and I'm going

675:30

to use my rafc so that I can see

675:32

something on the screen and here you're

675:35

going to be registering our counter

675:36

component so if I save my file and check

675:39

this out so here you can see we now

675:40

getting our counter which is looking

675:41

amazing now inside this counter

675:43

component the first thing that I want to

675:45

do is that I want to import the use

675:46

reducer from the reactjs and then we

675:48

have to use the inside work counter

675:50

component so I'll use like use reducer

675:52

is going to take the reducer function

675:54

and and also the initial stat so we're

675:56

going to be providing like count and

675:57

count will be set to zero okay so we are

676:00

going to be destructuring our state and

676:01

dispatch functions so I'll just use like

676:03

State and also the dispatch and now that

676:05

we have to create our reducer and also

676:07

we have to provide a type for this St

676:10

okay so what I'm going to do is that I'm

676:11

going to just create my reducer function

676:13

right here I'll just give it the name of

676:14

like redu it's going to take the Strate

676:16

and also the action and now in this

676:18

function we're going to be using our

676:20

switch and cases one more time and first

676:22

of all we are going to be providing if

676:23

the action. type come on let me just

676:25

write a type is set to increment i n c r

676:29

e m e n there we go so in this situation

676:31

we are going to be only returning the

676:33

count and count is going to be coming

676:35

from the state. count + one and if

676:37

that's not the case and the case is

676:40

decrement so in this situation what we

676:42

have to do we have to once again return

676:44

work count and count will be coming from

676:46

the state. count minus one okay and also

676:50

if that's not the case so for the

676:51

default value we're going to be

676:52

providing our start right here I'm going

676:54

to remove that and here you can see we

676:55

now getting an error like what is a

676:57

start and what is a action so to do that

676:59

we're going to have to provide a type

677:01

for that so now I'm going to just create

677:02

a type right here with the name of

677:04

action or actions I guess action would

677:07

be fine because we going to be doing

677:09

only one action and I'm going to provide

677:10

the property of type to that and that

677:13

type can be either increment or that

677:16

type can be come on let me just write

677:18

type can be set to decrement as we've

677:21

already specified there right here like

677:22

either increment or decrement so now we

677:25

have to use that right here for this

677:26

action so I'm going to just anate there

677:28

with this action the next thing that we

677:30

have to do is we have to take care of

677:31

the state so we're going to be also

677:33

creating a type for the state as well so

677:36

I'll use like type and then let's just

677:38

use a state and now inside there we are

677:40

going to be specifying a count and count

677:42

is now set to number and we have to take

677:44

this state we have to provide there

677:46

right here and we are going to be also

677:48

returning a count property from there so

677:50

we can also inate this entire function

677:53

as a state okay so this is what we have

677:55

to do first of all we have to create an

677:57

action type and we have to specify

677:59

therefore for the actions then we have

678:00

to create a state type and we have to

678:02

specify there for the state okay so this

678:04

is what we have to do for this reducer

678:07

function and now let's just use the

678:08

state and also this dispatch function

678:10

inside this UI so to use that I'm going

678:12

to be using a paragraph and I'll just

678:14

for a count and that count will be

678:16

coming from the st. count and now

678:18

underneath that we're going to be

678:19

creating a button which will just say

678:21

like increment and also we're going to

678:23

be creating one for the decrement EC m n

678:27

there we go I'm going to provide on

678:29

click event handler on both of them

678:31

which will just fire this dispatch

678:33

function let's just fire this dispatch

678:35

function and we're going to be providing

678:37

the type of increment for the first one

678:39

and decrement for the second one so

678:41

let's just use our decrement there we go

678:44

and now if I save my file and everything

678:47

should work the way we expect him to

678:48

work so if I click on this button it

678:50

will now increment our counter and if I

678:52

click on this button is going to

678:53

decrement our counter okay so yeah this

678:56

is how we're going to be providing a typ

678:58

for our use reducer this is a lot of

679:01

instructions so basically you're going

679:02

to be creating a counter by using the

679:04

used reducer and you're going to be also

679:06

providing the appropriate types to this

679:08

so give it your best shot if you can do

679:10

it that's completely okay then come back

679:12

and watch the solution and I'm going to

679:13

give you my solution so here first of

679:15

all I'm going to just create like a

679:16

folder with the name of reducers and

679:18

inside there we're going to be defining

679:20

our counter reducer dots and here we're

679:24

going to be just defining our reducer so

679:25

I'll use like counter reducer and it's

679:28

going to take the state and it's going

679:29

to also take the action and here inside

679:33

there we're going to be using our switch

679:35

and cases not like that but switch and

679:37

cases like so so for the switch we're

679:39

going to be defining our action. type

679:42

typ with the E and for the first case we

679:45

going to be providing an increment to

679:47

there okay so if that is set to

679:50

increment we're going to be returning

679:52

the count in count will be coming from

679:53

the state. count + one we're going to be

679:56

only incrementing there but if the case

679:58

is set to decrement so I'll use like

680:01

decrement d e c r e m e n t decrement so

680:06

we're going to be returning the count

680:08

and let's just get there from the state.

680:10

count and let's just write a minus one

680:12

because we're going to be decrementing

680:14

there after that let's just remove there

680:16

after that we're going to be also

680:18

providing a default state to it so for

680:20

the default we are going to be only

680:21

returning our state now that's totally

680:23

done but we also have to provide a type

680:25

for the state and also for the action

680:27

and we're going to be doing that totally

680:29

separately I'll write a type with the

680:31

name of counter State and here we're

680:33

going to be only writing like count and

680:35

count will be set to a number we can

680:37

also make that as a one liner we don't

680:39

have to split the in multiple line we

680:41

can also write a type for the increment

680:44

action which will also take the type and

680:46

the type will be set to increment so let

680:48

me just write an increment or you know

680:50

what let me just copy that from here in

680:52

a lot of time I misspell things so now

680:54

let me just duplicate there and I'm

680:56

going to change that to the decrement so

680:58

I'm going to copy and place there and

681:00

also inste of writing an increment

681:01

counter I'm going to change that to De

681:03

come on e e c r e m n decrement action

681:07

now let me make the as a one type so

681:09

I'll use like type and make that as a

681:12

counter action and that's going to be

681:13

equals to the increment action or the

681:16

decrement action like so and finally I'm

681:19

going to also export this so that we can

681:21

use that in other file two I'm going to

681:23

also export this counter so I'll just

681:25

use like export right here and finally

681:27

we're going to be also exporting the

681:28

first one so now let me just use export

681:30

for this one as well now it's time to

681:32

annotate our state with our counter

681:35

State and also our action with our

681:38

counter action like so so now that's to

681:41

done now let me go ahead and create my

681:43

counter. jsx or TSX component I'll use

681:46

like counter. TSX inside there I'm going

681:48

to use my RFC sem my file go to my app

681:52

and register that component right here

681:54

inside my app the first thing that I

681:56

want to do is that I want to grab my use

681:58

reducer so I'll use like use reducer

682:00

from the reactjs you would also need to

682:02

grab our counter reducer and also the

682:05

counter start from where from our

682:08

counter reducer so now underneath that

682:10

we have to Define our initial State for

682:12

the initial I in

682:15

I initial State we are going to be

682:17

annotating there with the counter State

682:20

and that counter state is coming from

682:21

this use reducer which we've already

682:23

defined like count is now set to number

682:26

that's going to be equals to the count

682:28

and count will be equals to zero then St

682:30

it done now we have to use our use

682:32

reducer to get our dispatch function and

682:34

also our initial St all use like use

682:36

reducer and here we're going to be

682:38

passing our counter reducer and then the

682:41

initial State inside there let me

682:43

destructure my state and also uh the

682:46

dispatch out of that use reducer and now

682:49

I'm going to create the UI for there

682:51

like not a magical UI but a very simple

682:54

UI like count and here we are going to

682:56

be only using our st. count to see our

683:00

counter we're going to be also creating

683:01

a button the first one will just

683:03

increment our counter and the second one

683:05

will be decrementing our counter so I'm

683:08

going to provide the on click and

683:10

Handler on both of them so the first one

683:12

will increment our count not interface

683:14

but

683:16

increment i n c r e m n t and the second

683:20

one will be decrementing our counter

683:23

okay so now let me just go ahead and

683:24

create the increment and also the

683:26

decrement counters increment and that's

683:28

going to be an aror function and this

683:30

aror function will just dispatch and

683:32

here we have to specify that

684:04

now the final thing that we are going to

684:06

be learning in this section is that how

684:07

we are going to be providing a type for

684:09

the use effect okay so to do that I'm

684:11

going to first of all create my

684:12

components folder and I'll just with the

684:14

name of like my component. TSX inside

684:18

there let's just use our rafc sa my file

684:21

go to my app and use that my component

684:25

right here I'm going to call this semi

684:27

file and check this out so here you can

684:28

see we have our my component which is

684:30

looking amazing so the first thing that

684:32

we have to do is that we have to grab

684:34

our use St because we would need some

684:36

sort of a state to store our data and we

684:38

would also need the use effect as well

684:41

okay so now we going to be using the

684:43

inside our component so this is how

684:44

we're going to be doing there first of

684:46

all we're going to be creating our data

684:47

and then set data and that's going to be

684:49

equals to the use St and we are going to

684:51

be providing the initial value of null

684:53

to it I will also annotate as a null

684:56

value now that we have to fetch our data

684:58

so to fetch our data you already know

685:00

how we are going to be fetching our data

685:02

so we are going to be using the use

685:03

effect Right Here and Now inside that

685:05

we're going to be passing the call back

685:06

function and also our empty dependency

685:08

array now the first thing that I want to

685:10

do is that I want to use my fet data

685:11

function that's going to be coming from

685:13

this as syn function like so and inside

685:17

there we're going to be using our try

685:18

and catch block and if we have some sort

685:20

of error so in that situation we're

685:22

going to be using like console. error

685:24

and let's just use like error fetching

685:27

data okay and we will also specify our

685:29

error right here and if that's not the

685:31

case so for the tri block we are going

685:33

to be getting our data by using the

685:34

fetch method and we are going to be

685:36

getting our data from this API which is

685:39

Json

685:43

placeholder.png first product okay so we

685:45

have to also change there or convert our

685:48

response to Json and we have to store

685:50

there in some sort of variable like so

685:52

and I'm going to also set the data to I

685:55

mean like set the result to our set data

685:57

so this is how we going to be fetching

685:58

our data and now let's just execute this

686:00

function so that we can successfully

686:02

fish this data so if I save my file and

686:05

now if I click on this it's going to

686:07

show us all of their stuff right here

686:08

like it's going to give us the ID the

686:10

title and also the description and we

686:13

have a few more things like discount

686:15

percentage and so on and so forth so for

686:18

all of that data we going to be creating

686:20

a product type okay so to do there I'm

686:22

going to be using like first of all we

686:24

have to go ahead and create our type

686:26

right here so I'm not going to waste a

686:28

lot of your time but we will just create

686:30

this type right here so first of all we

686:32

have a product type it's going to have

686:33

the ID title description price discount

686:36

percentage rating stock brand category

686:39

thumbnail and images okay so these are

686:41

all of the data that we are going to be

686:43

using in inside your app so that's why

686:45

we now successfully created a type for

686:47

there so we can now annotate our St by

686:49

using that type so I'll just put a type

686:51

or null and now that's done the next

686:54

thing that I want to do is that I wanted

686:55

to render all of the data right here

686:56

inside my UI so to render that first of

686:59

all we are going to be checking like if

687:00

you already have the data or not so if

687:02

you have the data in this situation we

687:04

are going to be rendering our data but

687:06

if you don't have the data we going to

687:08

be using a paragraph come on let's just

687:10

use our paragraph and inside this

687:12

paragraph you will select dot dot dot

687:15

okay and I'm going to also close my

687:16

paragraph right here okay so if we have

687:19

the data so in this situation what do I

687:21

have to do I'm going to create here

687:22

another div and now inside this div

687:24

we're going to be rendering all of our

687:26

content so I'll just use like paragraph

687:28

and this paragraph will have the ID and

687:30

we will use like data. ID basically you

687:33

can also render your data or destructure

687:35

your data right here if you wanted to

687:37

but I'm not going to I'm going to fast

687:39

forward the video because this is just a

687:40

UI stuff and we can totally do that a

687:43

bit quickly so I'll just use like data.

688:11

title now if I save my file and check

688:14

this out so here you can see we have our

688:15

ID we have the title price the discount

688:18

and so on and so forth and we also have

688:20

our thumbnail right here so which I can

688:22

copy and place it here it's going to

688:24

gives us the thumbnail of our product so

688:26

if you want to go into like another

688:28

product so we can just choose like

688:30

second one s file and refresh this so

688:32

now it's going to give us the updated

688:34

data I can totally copy that I can

688:36

totally render there if I wanted to but

688:38

you know what I guess that's going to

688:39

look better so yeah this is how we're

688:41

going to be providing a type or this is

688:43

how we going to be creating a type for

688:46

or use effect so now we are going to be

688:48

using a TN CSS inside your reactjs

688:51

project so if you guys don't know what a

688:53

TN CSS is I have a complete course on

688:56

there which is about like almost 4 Hour

688:58

of content plus you're going to be also

689:00

building three amazing responsive

689:02

projects so if you care about learning T

689:04

in CSS I promise this is going to be the

689:07

best course for you so now let's get

689:09

into it like how we going to be using T

689:11

and CSS inside our reactjs project so to

689:13

do that first of all I'm going to just

689:15

click on this getting started button

689:16

then I'm going to go into the framework

689:18

guides now we going to be choosing we

689:20

and if you want to choose some other

689:21

framework you more than welcome to use

689:23

that I'm going to just choose whe right

689:25

here so the first thing that we have to

689:26

do is that we have to create our we

689:28

project so I'm going to copy there from

689:30

here and I'm going to open my terminal

689:32

right here I'll just right click on this

689:33

so it's going to place my command right

689:35

here first of all we are going to be

689:36

using like npx create we project and I'm

689:39

going to just give it the name of like

689:40

my project and we're going to be using

689:42

the reactjs template so now want to go

689:44

into their project by using a CD command

689:46

now I'm inside their project I'm going

689:48

to use like npmi let's just use npmi

689:51

it's going to install all of their

689:52

packages by which your reactjs is

689:54

depends on right here while it's doing

689:56

its thing I'm going to also copy there

689:58

so it's going to install a few things

690:00

like T CSS post CSS and also Auto

690:03

prefixer it's going to also initialize

690:05

our tailin CSS inside our project okay

690:08

so now that's successfully done I'm

690:09

going to just copy that once again and

690:11

now let me place it right here and find

690:14

we have to initialize our tman CSS

690:15

inside their project by just using npx

690:18

tman CSS in it D piece so I'm going to

690:20

just hit so it's going to initialize my

690:21

tailin CSS right here and I'm going to

690:23

open that by using my vs code so now

690:26

inside there we have to go into our

690:28

tailin config.js file so I'll just copy

690:31

it and place it right here so now we are

690:32

inside this Stalin config.js file so we

690:35

have to replace this content with this

690:38

one word here okay so we only want to

690:40

provide our index.html file which is

690:42

inside SRC file file and we want to

690:44

select like all of these extension right

690:46

here okay we just have to replace and

690:48

also we have to go into our index.css

690:50

file I'm going to copy that from here

690:53

and now let me just go into my index.

690:54

CSS file I'm going to select every

690:56

single thing and replace that with this

690:59

these three directives right here now

691:00

finally I'm going to copy this H1 and

691:02

I'm going to go into my app not app. CSS

691:06

but app.jsx and I'm going to remove

691:08

every single thing from there I'll just

691:09

use my RFC and replace their D with this

691:13

H1 so I'm going to sem file now let me

691:15

use my npm run Dev so to start my server

691:18

so here you can see we now getting the

691:19

styling so now what I'm going to do is

691:21

that I'm going to go into the components

691:22

then I'm going to go to the browse

691:24

component and now I'm going to just

691:26

choose this component right here okay so

691:28

we can totally copy the HTML code I'm

691:30

going to just select a few things like

691:32

maybe I'm going to just select this D

691:34

right here and copy there because I just

691:36

want to test my code so I'll just remove

691:38

that from here place this DS right here

691:41

save my file check this out refresh

691:43

there

691:44

and we're not getting anything oh that's

691:46

because we are using a class instead of

691:48

class name so we have to select all of

691:49

them and change that to the class name

691:52

instead so if I save my file and now

691:54

refresh that and it has the class of

691:56

headden so I'm going to just remove

691:58

there save my file and here you can see

692:00

we now getting these kind of a component

692:03

they are not looking that great but yeah

692:05

trust me you can do a lot of crazy stuff

692:07

with tman cses and I have a complete

692:09

course on there and if you want to check

692:10

that out here it is okay so yeah this is

692:14

how we going to be using a tan CSS

692:16

inside our projects okay so time for

692:18

another challenge and I guess that's

692:20

going to be the final challenge for our

692:21

react jsn typescript Series so what you

692:24

have to do is that you have to F your

692:26

data from this Json placeholder type a

692:28

code and this endpoint will give you a

692:31

lot of users so it's going to give you

692:33

the user data structure like this you're

692:35

going to have the ID an ID will be a

692:37

number then we will have a name name

692:39

will be a string username will be a

692:40

string email will be a string and phone

692:42

will be also a string so use the use

692:44

effect to fish the data use the use

692:46

state to store that data and then

692:48

finally just renter in some sort of a

692:50

table or something like that so give it

692:52

your best shot if you can do it that's

692:54

completely okay then come back and watch

692:55

the solution and here is my solution so

692:58

I'm going to just create my what the

693:00

hell user list. TSX and I'm going to use

693:04

my rafc S my file go to my app and

693:08

render there right here like user list

693:11

like so okay so the first thing that I

693:13

want to do is that I want to create a

693:15

few stats so we are going to be creating

693:17

a state for the users like so and also

693:20

the set users it's going to be equals to

693:22

the use State and the initial value will

693:24

be set to empty array okay so let's just

693:26

create an interface for this array I'm

693:28

going to place this interface right here

693:30

so we have our user and we have the ID

693:32

which will be set to number and the rest

693:34

of the stuff will be set to string so

693:36

we're going to be annotating our state

693:37

by using this user and we have to

693:40

provide our array inside there like so

693:42

and we have to close there now

693:44

underneath that we have to use our

693:46

lowering and then set lowering and it's

693:48

going to be equals to the use State and

693:49

the initial value will be set to true

693:51

and we also have to annotate there as a

693:53

Boolean because we are storing the value

693:56

of Boolean inside there now finally we

693:58

also have to create one for the error

694:00

and that's going to be set to the set

694:01

error and we have to use our use St one

694:04

more time and the initial value will be

694:06

set to no okay so I'll annotate there

694:08

like it's going to be either a string or

694:09

null okay and we have to close this so

694:12

then it's going to be at forward state

694:13

now we have to fetch our data by using

694:15

the use effect so I'm going to be using

694:17

like use effect and here we have to

694:19

specify our callback function and for

694:21

this callback function we're going to be

694:22

providing our empty dependency array and

694:25

we're going to be also creating a

694:26

function which allows us to fish the

694:28

users like so and this going to be an as

694:30

synchronous function and inside this

694:32

function we're going to be using our try

694:34

and catch blocks for the catch we'll be

694:35

using like set error and we have to

694:37

provide where error and instance of come

694:40

on that error will be the instance of of

694:44

error if that's the case we're going to

694:46

be getting like error do message out of

694:48

there but if that's not the case we're

694:50

going to be just saying like an error

694:52

occurred like so we're going to be also

694:54

providing the final St finally and for

694:58

the finally we're going to be setting

694:59

the loading to false okay and now let me

695:02

take care of the tri block so for the

695:04

tri block first of all we're going to be

695:05

fetching our data by using the fetch API

695:09

and I'm going to specify this URL inside

695:11

there and let me just thr in some sort

695:13

of VAR varable like response response

695:15

like so and I'm going to also check if

695:17

we don't have the response if the

695:20

response is not okay so in this

695:22

situation we are going to be throwing a

695:25

new error which will say like Network

695:28

response was not okay and if that's not

695:31

the case we're going to be getting our

695:33

data so I'll use like con data and we're

695:35

going to be annotating there by using

695:37

our user like so and it's going to be

695:41

coming from the AIT and then response.

695:43

Json and we have to convert our data to

695:45

the Json response we also have to push

695:48

our data to our user so we're going to

695:49

be using like set users and let's just

695:52

push our data inside there so now that's

695:54

to done so I'm going to hide or you know

695:56

what we also have to call this function

695:58

inside there like so and now we have to

696:01

hide this use effect now I'm going to be

696:03

checking so if loading so in this

696:06

situation we're going to be returning or

696:09

lower so I'll just write like da or I

696:11

can also write H1 which will say like

696:13

low dot do Dot and we can also duplicate

696:16

that and change that to the error so

696:19

I'll just change that to the error like

696:21

so so I'm going to also render my error

696:23

inside there and here we have to just

696:25

write error so if you have some sort of

696:26

an error we're going to be displaying

696:28

there now for the UI I'm going to remove

696:30

this user list from here and I'm going

696:32

to have to change that to the table and

696:34

also change this div to the table and

696:37

inside this table we're going to be

696:38

defining our T head okay and inside this

696:41

T head we have to Define our TR ins

696:43

inside this TR we're going to be

696:44

defining our th with the name let me

696:47

just duplicate there a few time we also

696:49

have to write a username and we also

696:51

have to write the email and finally we

696:53

have to write the phone come on phone

696:56

like so and underneath this D head we

696:59

have to write our T body and inside this

697:01

T body we are going to be itating over

697:03

through all of the users by using this

697:04

map it's going to take the user as a

697:07

yeah as a perimeter and here we have to

697:09

specify our TR and for this TR we're

697:12

going to be also providing a key which

697:13

will be a user. ID and here we also have

697:16

to use our TD to render our element so

697:18

use like user.name and also I'm going to

697:21

just duplicate that a few times change

697:23

that to the name yeah you know what that

697:27

was the user ID and this is going to be

697:30

the name and we also have to change

697:32

there to the username and change this

697:34

one to the email and finally change this

697:36

one to the phone now let me S my file

697:39

and check this out so here you can see

697:40

we are now getting the name it should be

697:43

the name we also have to provide the ID

697:46

so let's just duplicate that change that

697:48

to ID now we are

698:01

get so now let's talk about the da UI so

698:04

what is a DA UI and how are we going to

698:06

be using there with reactjs as you can

698:08

see right here on their landing page

698:10

they are saying like Desi is the most

698:12

popular component Library for tman CSS

698:15

if you guys already know what a tman CSS

698:17

is you will love thisi so you can choose

698:20

different themes if you want it to like

698:22

dark and we have a cupcake and so on and

698:24

so forth theme okay so in my case I'm

698:26

going to only choose this dark theme

698:28

right here and inside their landing page

698:30

you can learn more about there like

698:32

instead of writing all of these tman CSS

698:34

classes you no longer have to write all

698:36

of these tman CSS classes now you can

698:38

use D UI to only write a few classes it

698:41

will give you the same result right here

698:44

okay so you can choose different kind of

698:46

themes you can choose a lot of things

698:48

inside the D UI and if you guys want me

698:50

to make a separate course on deui I can

698:52

totally do that or maybe a crash course

698:54

and I want you to notice this animation

698:57

these are the themes that you can choose

698:58

from the dayi and if you want to learn

699:01

there as I said you can either learn it

699:03

from their documentation or if you want

699:05

me to make a separate course on there I

699:07

can totally make a course on there but

699:09

now let's talk about how we are going to

699:10

be using them to use the we only have to

699:13

run this Command right here and also

699:15

just right there but first of all we

699:17

have to make a tailan CSS setup so I'm

699:19

going to go into the tailan CSS right

699:21

here and I'm going to go to my framework

699:23

guides one more time then I'll choose

699:24

the weat and I'm going to copy them then

699:27

I will open my terminal right here I'm

699:29

going to place this command but I'm

699:30

going to also change the name of that to

699:32

like something else DUI would be fine

699:35

and I'm going to hit enter right now

699:37

then I'm going to go into my DUI

699:38

component and now I'm going to just use

699:41

npmi to install all of the packages now

699:43

I'm going to open that in my vs code and

699:45

then I'm going to install all of that

699:47

other packages and stuffs so now it's

699:48

time to install Desi inside our project

699:51

so I'm going to copy that and now let me

699:53

just open my terminal right here and let

699:54

me just place this command which is npmi

699:57

and then da UI at L so it's going to

699:59

install dii inside our project so now

700:01

that's successfully done now I'm going

700:03

to select the esm and I'm going to copy

700:05

this Command right here first of all you

700:07

know let me just copy the import and

700:09

then we will go into the tailin

700:10

config.js file which is this tailin come

700:14

on where in the what is okay so I'll

700:16

just use oh I forgot to install my

700:19

tailin CSS I install this one but I

700:21

forgot to install my tailin CSS so I'm

700:23

going to copy there and now let me run

700:24

this Command right here so it's going to

700:26

install and configure my T CSS inside my

700:29

project let me just hit enter so it's

700:30

going to initialize my tailin CSS right

700:32

here now that's successfully done and we

700:35

also have to copy there we have to go

700:37

into our tailin config place it right

700:40

here save my file and we also have to

700:42

copy this these go to our index. CSS

700:45

file and replace it with this component

700:48

and yeah we are totally done with the TN

700:50

CSS but we also have to copy there now

700:52

we have to go into our tailin config.js

700:54

file which is this file and I'm going to

700:56

just place it right here and also let me

700:59

just copy this T UI we have to go inside

701:02

the plugins and just place it right here

701:04

and now we have to use some sort of a

701:05

component so I'll just go ahead and go

701:07

to the components and in this case I'm

701:09

going to go to the buttons and I'll just

701:11

copy the code for there so maybe I'm

701:15

going to go to this one and copy the GSX

701:18

code from there let's just copy there

701:20

I'm going to go into my SRC folder then

701:24

my app component folder so I'll just

701:25

replace it with my RFC and remove this

701:28

div or you know what we're going to be

701:30

just removing the app and I'm going to

701:32

just place all of my code right here so

701:33

if I save my file now let me run my npm

701:36

run Dev so it's going to run that right

701:38

here and here you can see we are now

701:39

getting all of these buttons like just a

701:41

simple button and we have a neutral

701:43

primary secondary asent and ghost and so

701:46

on and so forth but right here we can go

701:48

ahead and do lots of stuff right here

701:49

like we can get the model if you wanted

701:51

to we can get the accordians if you

701:53

wanted to we can do all lot sort of

701:55

stuff like if I click on there we can

701:56

get this model so I'm going to just copy

701:58

all of these code and now let me just

702:00

replace that with this code right here

702:03

so if I save my file now if I go there

702:06

click on there we are now getting our

702:08

model so yeah this is how we going to be

702:10

using a d UI inside our reactjs projects

702:14

now let's use another component Library

702:16

which is called redex inside our reactjs

702:19

project so here you can see redex is an

702:21

open source component Library optimize

702:23

for fast development easy maintenance

702:25

and accessibility just import and go on

702:28

so here are the live demos so these are

702:30

the amount of things that you can do by

702:32

using the RX uh component Library so

702:35

these are just the themes we can also go

702:37

to The Primitives we can check out the

702:39

icons we can also go to the colors and

702:41

there are a lot of stuff going on so I'm

702:44

going to go into my redex one more time

702:45

and now to install there the first thing

702:47

that we have to do is that we have to

702:48

make a reactjs setup and now let me show

702:50

you how we're going to be doing this so

702:52

I'll just open my terminal word here and

702:54

I'm going to write npm create weed and

702:57

latest and if I hit enter so it's going

702:59

to ask me for the name I'm going to give

703:00

it the name of like

703:02

redex um project or demo would be fine

703:05

I'll just give it the name of like redex

703:07

demo I'm going to choose reactjs as a

703:08

framework and JavaScript I'm going to go

703:11

into the redex and I'm going to open the

703:13

my vs code let me open my integrated

703:15

terminal and I'm going to use npmi to

703:17

install all of my packages so now while

703:19

it's doing there I'm going to click on

703:21

this getting start button and here you

703:22

can see this how we going to be

703:24

installing there so we just have to copy

703:26

this command I'm going to copy this

703:27

Command right here and now they

703:29

successfully done so I'm going to just

703:30

past this command here and hit enter

703:33

okay so while it's doing that I'm going

703:34

to go into my Global main component and

703:37

I'm going to just place this Command

703:38

right here so I'm going to copy there

703:40

now it is doing its thing and now they

703:42

successfully so I'll go into my main

703:44

component and inside this main component

703:46

I'm going to also import the Red X right

703:48

here so I'll just save there next we

703:50

have to go into our main component and

703:52

we have to use our theme context so I'm

703:54

going to copy that from here and now I'm

703:56

going to also import that right here

703:58

okay so let's just import that I'm going

704:00

to wrap my entire application by using

704:02

this theme context like so okay so let's

704:05

just close there hit enter and wrap my

704:07

entire application by using this context

704:10

if I just remove there next we have to

704:12

use the in sort of a component so I'll

704:14

just copy this component from here and

704:16

I'm going to go into my app component

704:18

and I'll just remove every single thing

704:19

from there and I'm going to use my RFC

704:22

or you know what let me just place this

704:23

component right here cut that from here

704:25

use that right here I'm going to use my

704:27

app copy them and just change the name

704:30

of my function to app so if I save my

704:32

file and now I'm going to use npm run

704:34

Dev to start my server and here you can

704:36

see we are getting this result right

704:38

here which is saying like hello from the

704:39

RX theme and I guess we are not getting

704:42

that much cool result this because we

704:44

are now getting these stuff right here

704:46

so I'm going to remove every single

704:47

thing from the app.css and now let me

704:49

just refresh them I'm going to also riew

704:51

every single thing from the index.css as

704:53

well and now if I just refresh this

704:55

hello from the redx themes and let's go

704:58

okay so this is how we going to be using

705:00

a redex inside your reactjs project now

705:03

let's talk about the copy pasta

705:05

component Library which is called the

705:06

shars and UI and shars and UI is by far

705:10

the most popular and the most our full

705:13

front end UI Library so to install them

705:16

and I'm thinking about making a course

705:18

on there but anyways there other story

705:20

so to install them I'm going to just

705:21

click on this getting started button

705:22

right here then I'm going to go into

705:23

this installation and I'm going to just

705:25

choose we right here and first of all we

705:27

have to make a setup so I'm going to

705:28

copy that from here open my terminal one

705:30

more time now inside this terminal I'm

705:32

going to place this command and hit

705:34

enter I'm going to give it the name of

705:36

like uh Shar CN demos and now I'm going

705:40

to just choose reactjs and typescript

705:42

now I'm going to go into my Shar and

705:44

demos and come on CD and then Shar CN

705:49

demos and now let me just open there

705:50

right here and I'm going to open my

705:52

terminal one more time and use npmi to

705:55

install every single package the next

705:57

thing that we have to do is that we have

705:58

to install tailin CSS inside our project

706:00

so I'm going to copy that and now we

706:02

have to use that right here okay so

706:04

that's done now let me place this

706:06

Command right here so it's going to take

706:07

a bit of time to install tmin CSS post

706:10

CSS and an auto prefixer and also so

706:12

it's going to initialize my T CSS right

706:14

here which is amazing so next thing that

706:16

we have to do is that we have to go into

706:18

the TS config file and I'm going to copy

706:20

there let's just go ahead and go to the

706:22

TS config so I'll just provide a comma

706:24

here now let me just place my compiler

706:26

options and now let me just save there

706:28

and close there next we have to go into

706:30

our TS config.js file so I'll just write

706:34

there hit enter and now inside there we

706:36

only have to provide this base URI and

706:39

also this path so I'm going to copy that

706:41

from there and nor need this skip l

706:43

check I'm going to just place my command

706:45

word here and now finally we have to

706:47

install the typescript type so I'm going

706:49

to copy there and we also have to

706:50

install them right here inside uh our

706:53

project the next thing that we have to

706:55

do is that we have to place all of them

706:57

into our we.

707:06

config.ini where sh and UI so I'm going

707:09

to copy there now let me open my

707:11

terminal and place this command which is

707:13

Shar send UI and initialize there and we

707:15

are getting some sort of error no till

707:18

CSS configuration found at this location

707:20

it is likely you don't have t CSS

707:22

installed or have a invalid

707:24

configuration so how is that even

707:26

possible we set up every single oh there

707:29

we go so we have to go into the not

707:32

Sharon but tail wi CSS tailwind css.com

707:37

and here I'm going to have to copy this

707:39

content and place it right here sa my

707:42

file and we also have to copy these

707:44

components and we have to go into the

707:45

index. CSS file and place the here semi

707:49

file and now it will work okay so if I

707:51

just rerun there and now it's going to

707:53

initialize my tment CSS right here I'm

707:55

going to just choose this New York

707:56

neutral will be fine for the color and

707:59

we are not going to be using CSS

708:01

variables but I'm going to just set that

708:02

to yes everything will work just

708:04

fine okay so now that successfully done

708:07

finally we have to install something

708:09

from the shets and UI so I'm going to go

708:11

ahead and install some sort of a

708:14

component I'm going to go

708:16

into maybe button so this is how the

708:18

shet and UI works it will give you a lot

708:20

of component to choose from and let's

708:23

suppose you choose like button first of

708:24

all you have to install that in your

708:26

project and then you will be able to use

708:28

this so in this case I'm going to

708:30

install my button right here so I'm

708:31

going to copy there and first of all we

708:33

have to install there and here you will

708:35

see a components folder right here and

708:37

here you can see we have a components

708:38

folder inside this component folder we

708:40

have a UI folder and inside there we

708:42

have our button right here we're not

708:44

going to be playing around with these

708:45

buttons but we are going to be just

708:47

using them and how are we going to be

708:49

using them let me show you how we can

708:50

use there I'm going to go into my app.

708:53

TSX and I'm going to remove every single

708:55

thing from there and I'm going to just

708:57

use my RFC and now I want to use that

708:59

button okaye so I'll just use like

709:01

button right here and here you can see

709:02

we have this location like component UI

709:04

and button now if I hit any right here

709:07

and now we can just write like whatever

709:09

I want to write like uh learn more and

709:11

now if I say my file run our server by

709:14

using npm run Dev copy that place it

709:17

right here and here you can see we are

709:18

now getting our button right here which

709:20

is amazing but that was a huge setup to

709:23

make okay so we can get like the card we

709:26

can get like uh come on a cordan we can

709:29

get like a lot of stuff so what I'm

709:31

going to do is that I'm going to just

709:32

create my card right here so I'm going

709:33

to copy them and run that first of all

709:36

let me just terminate there and install

709:38

my card inside my project so it's going

709:40

to install that card right here then

709:42

successfully done now I'm going to go in

709:44

there and copy all of that content and

709:46

I'm going to just copy all of that code

709:48

right here now inside there we just have

709:50

to use there okay so if I just place

709:52

this coding right here you're now

709:54

getting a lot of stuff but in this

709:56

situation I only want to get there so I

709:59

will cut that from here and remove all

710:01

of that stuff from here and we need all

710:03

of these Imports so instead of providing

710:05

this button I'm going to only provide

710:07

all of their stuff so if I sem my file

710:09

we getting an input and also the labels

710:11

we also have to inst install there okay

710:14

so we're getting a button twice we don't

710:17

need reactjs and we're now getting this

710:19

ER like we have to install the input

710:21

label and also the select so I'm going

710:23

to go ahead and add there so to add

710:25

there we are going to be using that same

710:27

command but we only have to change the

710:29

component name like instead of providing

710:31

a card I'm going to write like input I'm

710:33

going to also provide the label and also

710:36

finally we have to add the select okay

710:40

if I hit ENT right here so it's can

710:41

install the inside my project and now

710:43

that successfully installed and if I cut

710:46

this file and open there once again here

710:49

you can see those errors are now

710:50

successfully gone okay so this is how it

710:53

will look like but now I'm going to use

710:55

my npm run Dev and if I just refresh

710:57

there and here you can see we are now

710:58

getting our form so we have our input

711:00

field we have also a select statement

711:02

right here so yeah this is how we're

711:04

going to be using a shetsen UI inside

711:06

your react GS project so now let's learn

711:08

about the react hook form Library which

711:10

will allows us to provide easy to use

711:12

validation forward form okay so I'm

711:15

going to click on this getting started

711:16

button and here you can see this is how

711:18

we going to be installing there and this

711:20

is how we are going to be using there so

711:22

what I'm going to do is that first of

711:23

all I'm going to make a setup so I'm

711:24

going to open my terminal right here and

711:26

I'm going to be using npm Create weed

711:29

and latest and I'm going to give it the

711:31

name of like react hook

711:35

form um demo would be fine and I'll

711:38

choose reactjs and also typescript let

711:40

me go into my react Hub form and I'm

711:43

going to use npmi to install all of the

711:44

packages so that's successfully done I'm

711:47

going to open there in my vs code by

711:48

using a code dot so it's going to open

711:50

there right here I'm going to open my

711:52

terminal and install the react hook form

711:54

package from here so we just have to

711:57

write npm install or I and then we have

711:59

for react hook form and I'm going to hit

712:01

enter so it's can install that in my

712:03

project so here you can see that's done

712:05

now let me just close there and I'm

712:06

going to be using npm rund to run our

712:09

server I also made a cleanup so now it's

712:11

time to focus on the re hook form so I'm

712:13

going to create a folder with the name

712:15

of components and inside there I'm going

712:17

to create my form. TSX component right

712:19

here I'm going to use my RFC and

712:21

registered that in my app okay so first

712:24

of all we have to just use like form and

712:27

we have to import that from the

712:28

components folder so now I'm going to

712:30

save that and this is how it looks like

712:32

right here which is looking amazing so

712:34

now the next thing that we have to do is

712:35

that we have to grab or use form from

712:39

where we're going to be grabbing there

712:40

from the react hook form going to be

712:42

getting all of our magic like form

712:44

validation form handling and also the

712:46

errors from this hook that is why we

712:48

call it as a react hook form okay so we

712:51

have to also execute there right here

712:53

and now from this use form hook we are

712:55

going to be restructuring a few things

712:57

first of all we are going to be

712:58

destructuring the register we would also

713:00

need to destructure the handle submit

713:02

and also the form State and from this

713:05

form State we're going to be also Ned D

713:08

structuring the errors and also the is

713:10

submitting uh is submit there we go so

713:13

I'm going to save my file and now let me

713:15

explain all of that stuff right here so

713:17

the first thing that we are

713:17

restructuring is a register and register

713:20

is used to connect input field to the

713:21

form then we have a handle submit and

713:24

this is a function which allows us to

713:25

handle the form submission then we have

713:27

a errors which contains the validation

713:29

error for the form and then we also have

713:31

a is submitting so this is basically

713:33

just a flag which I'm going to show you

713:35

in a few seconds okay so yeah that was

713:37

just a bit of explanation about the

713:39

register handle submit and errors so I'm

713:41

going to remove that from here here now

713:43

we are getting this error so we have to

713:44

also resolve this error so which is a

713:46

typescript error so I'm going to create

713:48

my interface right here with the name of

713:50

form data and inside there we are going

713:53

to be first of all defining my name

713:54

which will be a string and also the

713:56

email which will be a string and also

713:59

the password which will be a string as

714:01

well okay so I'm going to take this form

714:03

data right here and we have to put the

714:06

or annotate or use hook with this form

714:08

data so here you can see that's now

714:10

successfully done we are now getting

714:12

these errors because we have to use

714:14

these okay so now to use them the first

714:16

thing that I want to do is that I want

714:17

to remove this form from here and

714:19

instead of pring this D I'm going to

714:20

change that to form and I'm going to

714:22

also provide the on submit Handler today

714:25

and for this on submit Handler we are

714:27

going to be calling this function which

714:28

is a handle submit which we now

714:30

importing from this hook okay so we have

714:32

to provide there now inside there we are

714:34

going to be providing our own custom

714:36

function which will be the on submit

714:38

function and now let me create this on

714:40

submit function right here okay so

714:41

basically we we're not going to be doing

714:43

anything crazy but we're going to be

714:44

just loging to the console or data okay

714:46

so we have our own submit and it's going

714:48

to take the data and now inside there

714:51

we're going to be just logging that data

714:52

to the console that's everything that we

714:54

have to do but I'm going to also provide

714:56

my uh typescript Magic right here so

714:58

we're going to be using like submit

714:59

Handler okay so now let me just grab

715:01

that from the reog form and we are going

715:03

to be annotating there with this form

715:05

data which we' have already defined

715:07

right here so the form submission is now

715:09

totally done the next thing that we have

715:11

to do is that we have to create our

715:12

input field so that we can type

715:14

something inside there so I'll just

715:16

create a div and inside this div I will

715:18

provide like a label and for this HTML

715:20

for I'll just provide like a name and

715:22

I'm going to also provide a name as a

715:23

label now underneath that we're going to

715:25

be defining what input field right here

715:27

it's going to take the type of text and

715:29

we're going to be also providing the ID

715:31

of name to the here now we are going to

715:33

be using our register function okay so

715:35

I'm going to use dot dot dot and here we

715:37

have to call this register function

715:39

which is now coming from this uh use

715:42

form hook right here so we are now

715:43

calling there right here so the first

715:46

argumented text is a name as you can see

715:49

right here like argument name was not

715:51

provided like you can provide the name

715:53

of name or email or password or anything

715:56

that you prefer then you have to also

715:58

specify like you don't have to but if

716:00

you wanted to you can provide a

716:01

validation data there so instead of

716:03

talking about the theory let me just

716:05

provide a name right here okay and I'm

716:07

going to provide a comma and then we're

716:09

going to be providing some sort of

716:10

validation rules okay so I'll just use

716:12

like required this should be required

716:14

but if somebody did not specify the name

716:16

so we are going to be throwing this

716:18

error which will say like name is

716:19

required okay so I'm going to save my

716:21

file so this is how we are going to be

716:22

making a set of for our input field this

716:25

is how we are going to be telling our

716:26

react hook form that you have to take

716:28

care of this input field if somebody did

716:30

not specify anything inside this input

716:32

field so we're going to be providing

716:34

this error which will say like name is

716:36

required okay so this is going to be our

716:38

constraint or our Rule and this is how

716:41

we are going to be registering for re

716:43

hog form now what if somebody did not

716:45

provide something inside this input

716:46

field so we are going to be just

716:48

throwing some sort of error right here

716:50

case I'm going to use like my curly

716:51

braces and inside then we're going to be

716:53

going into our errors which we are also

716:55

importing from or use form right here

716:58

we're going to be grabbing them and here

717:01

we have to use the dot notation and from

717:03

where is our error coming from our error

717:05

is coming from this name so I'm going to

717:07

select that so if you got some sort of

717:08

error we're going to be using this end

717:10

operator okay so then we have to specify

717:13

or show that error right here we're

717:15

going to be using like error. name and

717:18

we are going to be getting the message

717:19

out of there okay and now here for this

717:21

paragraph I'm going to also provide a

717:23

bit of styling to that so I'll just use

717:24

like the color will be now set to

717:26

totally red I'm going to sa my file and

717:28

now let me just test this out here you

717:30

can see we have our input field but so

717:32

you know what let me also create some

717:33

sort of a button which will just allows

717:36

us to submit I'll just write like type

717:38

of submit to the save my file and now if

717:41

I didn't specify anything today and

717:43

click on the submit so it's going to

717:44

gives us like name is required if I just

717:47

write like I don't know maybe a b c s my

717:51

file and now let me click on this submit

717:52

button one more time so it's going to

717:54

give us that ABC right here this is how

717:56

we are going to be registering our input

717:57

field this is how we're going to be

717:58

providing a constraint for there and

718:00

this is how we are going to be rendering

718:02

that specific error right here okay so

718:05

that's done I'm going to also remove

718:06

this button from here now let me take

718:08

care of the email and also so I'm going

718:10

to create yet another div and inside

718:12

this D first of all we have to provide

718:14

our label which will take a email and

718:16

also we have to Define our input field

718:18

and it's going to take the input or the

718:21

type of email now that we have to tell

718:23

your re hope form that you have to keep

718:25

track of this input field so we're going

718:27

to be using the register function and we

718:29

are going to be providing an email right

718:30

here and I'm going to also provide a bit

718:32

of rule today like this will be required

718:35

if somebody provide invalid email so

718:37

we're going to be writing like email is

718:39

required that's going to be the first

718:40

thing and now we're going to be

718:42

supporting our pattern like what will be

718:44

the pattern of our email okay so for the

718:47

value if you know what a jsx is cool but

718:50

if you don't know what a jsx is but so

718:52

this is how it looks like to be honest I

718:54

also don't know what a jsx is I just

718:56

copy this sniffer from a CH GPT so yeah

718:59

I'm using there right here and we also

719:01

have to specify some sort of a message

719:03

right here which will say like invalid

719:04

email address like so now I'm going to

719:07

sve my file so now that we successfully

719:09

tell or re hook form that you have to

719:12

keep track of this input field and also

719:14

we are telling it if somebody did not

719:16

specify nothing inside there we're going

719:18

to be showing like email is required and

719:20

also if the email is invalid so we're

719:22

going to be showing like email is

719:24

invalid now underneath that I'm going to

719:26

also provide the ID of email and the

719:28

placeholder will also say email right

719:30

here I'm going to save my file but we

719:32

also have to show those errors okay so

719:35

to show those errors we're going to be

719:36

using like errors. email in this case

719:39

and if that is the case so come on if

719:42

that is the case so we're going to be

719:44

just creating a div and now inside this

719:45

div we're going to be rendering our

719:47

error right here like error email.

719:49

message and we also have to change the

719:51

color of that to like uh color will be

719:53

now set to totally red like so I'm going

719:56

to save my file but we cannot see there

719:58

because we have to create our button

720:00

which will allows us to submit this form

720:01

so I'll just use like submit and the

720:03

type will be also set to submit if I

720:05

didn't specify nothing to that and if I

720:07

click on this submit it's going to give

720:09

us two errors right here so it's going

720:10

to give us like name is requ Reed and

720:12

email is also required so if I just

720:14

specify some sort of a name and for the

720:16

email I'm going to write like uh I don't

720:18

know or you know what test yeah test

720:21

would be fine so here you can see we now

720:22

getting our invalid email address so if

720:25

I use like test at gmail.com that eror

720:28

is now successfully gone and now if I

720:29

click on that we are no longer getting

720:31

that error this is how we are going to

720:33

be keeping track of that now outside

720:35

from this div we are going to be

720:37

creating yet another div okay so just

720:39

created a div 4 uh what we call for the

720:42

password so I'll just create a input

720:44

field with the type of password and here

720:47

we have to specify first of all our

720:48

register function so that we have to

720:50

tell our Rea hook form that you also

720:52

have to keep track of this input field

720:54

and we're going to be providing our

720:56

password today and also the minimum

720:58

length will be um value let's just

721:01

provide a value and the minimum length

721:03

will be add characters if the password

721:05

length is less than add character so we

721:07

are going to be showing this error like

721:09

password must be at least add characters

721:13

and now outside from there we are going

721:14

to be also providing our placeholder and

721:17

the placeholder will be just a password

721:20

like so so if I save my file and now

721:22

underneath I'm going to also render my

721:23

errors right here so if you have some

721:25

sort of error inside the password so we

721:27

going to be showing that error and we're

721:28

going to be also providing a color of

721:30

red to that so here you can see we have

721:32

our name email and also the password and

721:35

we can also provide a label for there

721:37

but I guess like we don't have to and

721:39

now we're going to be creating our

721:40

button which will just say submit and

721:43

now we are going to be also providing a

721:44

type of submit to there so if I save my

721:46

file now let me just spill this form so

721:48

I'm going to just provide like the name

721:50

of Huzan and test at gmail.com and I'm

721:54

going to only provide like one two three

721:56

and now if I click on submit so it's

721:58

going to gives us that ER like password

721:59

must be at least eight characters if I

722:02

write like 4 five still 7 8 99 10 and

722:06

here you can see that it is now

722:07

successfully gone so yeah this is how

722:09

we're going to be working with the

722:10

validation or the the re hook form

722:12

library but I'm going to also show you

722:14

the disable state if you want to disable

722:16

this button on the form submitting state

722:18

so for that we can use the disable come

722:20

on not this one the disable and here we

722:23

have to specify the is submitting so

722:26

it's going to gives us a Boolean value

722:28

so if our form is submitting so the

722:30

button will be disabled but if our form

722:32

is not submitting it's going to giv us a

722:34

false and our button will no longer be

722:36

disabled okay so just keep that in mind

722:39

and I'm going to also change the text of

722:40

there to like uh if it is submitting let

722:43

me just use like if it is submitting so

722:45

in this situation we're going to be

722:46

using like lading dot dot dot and if

722:48

that's not the case we're going to be

722:50

using submit now let me just save my

722:52

file and now I'm going to just write

722:54

like hosan and this email and also I'll

722:57

just proide some sort of a random

722:59

password and here you can see if I click

723:01

on that you cannot see that because

723:03

that's super quick so you cannot see

723:05

that in the production you will see that

723:07

so yeah that was just the basics of

723:09

react hook form Library now let me give

723:12

you one more example of the react hook

723:14

form so if you care about that you can

723:16

totally watch there or if you don't so

723:18

you can go ahead and jump to the next

723:19

section and now let's just create

723:21

another form which will be a bit of

723:23

advanced form it's not that much

723:26

Advanced to be honest like we're not

723:27

going to be learning anything new but

723:29

this form is only for the practice okay

723:31

so let's just save that and go ahead and

723:32

go to our app Advance form right here

723:35

registered then save my file and I'm

723:37

going to also go ahead and go to my SRC

723:40

folder and use my St CSS right here and

723:43

I'm going to provide all of the CSS

723:45

which you can find on my giab repository

723:47

so what I'm going to do is that I'm

723:48

going to just create a bit of advanced

723:50

form not that much advanc to be honest

723:53

but the first thing that we have to do

723:54

is that we have to grab or use form from

723:57

where from the react hook form we would

724:00

also need to grab the submit Handler

724:02

from this react hook form and we also

724:05

have to import our styling so we are

724:06

going to be using like style. CSS say my

724:09

file and this is how it looks like for

724:11

here which is looking amazing now let me

724:13

provide interface of the form data so we

724:16

are going to be providing like first

724:17

name last name email city state ZIP code

724:19

country and complete location okay so

724:22

I'm going to use that inside my

724:23

component so what I'm going to do is

724:25

that I'm going to use my use form once

724:27

again from this use form we going to be

724:29

destructuring a few things we would just

724:31

destructure our register which will

724:33

allows us to register our input field we

724:35

would also need our handle submit

724:36

whenever we are submitting our data and

724:38

we will also need a few St from this

724:41

component so we will just need like the

724:42

errors that's going to be it now let me

724:44

just annotate my form data right here so

724:48

that we don't get those errors so that's

724:50

cool I'm going to just remove that from

724:52

here and change this one to the form so

724:55

I'll use like or you know what we're not

724:56

going to do that we are not going to do

724:58

that okay let's just put a class name of

725:00

form container and inside this Dev we're

725:04

going to be creating our H2 which will

725:05

say like registration form and now

725:07

underneath there we're going to be

725:09

creating our form it's not going to take

725:11

any action but we are going to be

725:12

providing our own submit Handler and

725:14

whenever we are submitting this we going

725:16

to be using the handle submit from the

725:18

react hook form and let's just provide

725:20

our own submit function to there so I'll

725:22

use like on submit and let's just create

725:25

our own submit right here so basically

725:27

we're not going to be doing anything

725:28

crazy but we are going to be just

725:30

logging all of that data to the console

725:32

so I'll just use like onsubmit and

725:34

whenever we are submitting there we're

725:36

going to be using our submit Handler and

725:38

let's just provide our form data today

725:40

and that's going to be to this data we

725:42

are going to be taking that data as a

725:44

perimeter and then we are going to be

725:45

logging that data to the console and now

725:47

inside this form what I want to do I

725:49

want to create a d inside this D Pro a

725:52

label which will say like uh first name

725:55

and it's going to take like a first name

725:57

as a label we're going to be also

725:58

providing our input field and the ID

726:01

will be set to first name first name

726:04

like so and we're going to be also

726:06

providing our register so I'll use like

726:08

register and here we have to use our

726:10

first name and now for the next

726:13

parameter we have to provide our pattern

726:15

so I'll use or not a pattern but or

726:17

constraints so I'll use like required

726:19

and that should be required we have to

726:21

provide like first name is required

726:24

there we go save my file let's just go

726:26

back and this is how it looks like and

726:29

now underneath there we are going to be

726:30

also rendering our errors so if you have

726:32

some sort of Errors inside our first

726:34

name so in then situation we're going to

726:36

be rendering our paragraph which will

726:38

say like uh errors first name do message

726:41

so we going to be just basically

726:43

grabbing the message from there so

726:45

that's done now underneath this div we

726:47

are going to be defining yet another div

726:49

okay so inside that D we're going to be

726:50

defining our label which will say like

726:52

last name and inside there let's just

726:54

provide our last name right here we're

726:57

going to be also providing our input

726:58

field with the type of text and the ID

727:00

of last name to that and now we have to

727:03

register that so we're going to be using

727:04

our register function let's just provide

727:06

a last name inside there and here there

727:09

going to be required so we also have to

727:11

provide or required okay so I'll use

727:13

like last name is required there we go

727:17

and finally we have to render those

727:18

errors we're going to be using like

727:20

errors. last name and uh let's just

727:24

render our paragraph right here and

727:26

inside this paragraph you're going to be

727:28

using like errors. last name. message

727:31

there we go next we also have to take

727:33

care of the email so let's just create

727:35

our label for the email in lowercase

727:38

email like so and we are going to be

727:40

providing what input field and for this

727:42

input field we're going to be providing

727:44

a type of email the ID of email and also

727:47

let's just registered there right here

727:50

okay so I'm going to be using like email

727:52

and inside there let's just required

727:54

there by providing a email address is

727:58

required and this should be double D I'm

728:00

going to also provide my pattern and for

728:03

the value of this pattern we are going

728:04

to be passing this pattern which I copy

728:07

from the chat gbt to be honest okay and

728:09

we are going to be also providing a

728:11

message message which will say like

728:12

invalid email a r e s we also have to

728:16

render our errors so I'm going to be

728:17

using like errors. email and we have to

728:20

render our errors by using our

728:22

paragraphs so I'm going to be using like

728:24

errors. email and then do message now

728:28

outside from there we're going to be

728:29

creating a d one more time and inside

728:32

there let's just create a label for the

728:33

City come on City and let's just also

728:36

provide our city here and also the ID

728:38

will be set to city and let's just

728:41

register there by using dot dot dot

728:43

register function we have to provide our

728:45

city and also that's going to be

728:48

required okay so if that is required so

728:51

we going to be using like city is

728:53

required there we go and also let's just

728:56

render our errors by using errors uh

728:59

errors. City God damn it why the hell am

729:02

I not getting there errors. City and if

729:05

we have some sort of error coming from

729:07

the city we're going to be rendering our

729:10

errors. c t. message there we go that's

729:14

going to be a lot of typing we have to

729:17

create another div and also provide you

729:19

a level and level will say State and

729:21

also provide your state here for the

729:24

input field we're going to be providing

729:26

uh text obviously and ID will be set to

729:29

State then it's going to be required and

729:32

we going to be providing what state

729:34

inside not required but that's going to

729:37

be register we have registered the here

729:39

okay so it's going to take the state and

729:41

that is going to be required required

729:45

there we go so stad is required now

729:48

underne this input field we have to use

729:50

our errors. St one more time and I'm

729:52

going to use my end operator and provide

729:54

my paragraph and change that to uh

729:58

errors. state. message and now outside

730:02

from there I guess I have to just

730:03

duplicate it like a few times so I'm

730:05

going to create for the ZIP code next

730:07

for the country and also one for the

730:10

complete location okay so now here

730:12

that's going to be it for the state we

730:14

also have to create one more for the zip

730:15

so I'll just change that to a zip like

730:17

so change this one to zip or in

730:20

uppercase zip the ID will be set to zip

730:23

and the state will also be zip and zip

730:27

is required next we have to create a

730:29

country Sol provide like country and

730:32

here we have to provide a country as a

730:34

label and uh ID will be set to Country

730:38

the register we're going to be

730:39

registering our country and country is

730:42

required like so and the final one that

730:45

we have is a complete location so I'll

730:47

just write like uh complete location l c

730:51

a t o n and here we also have to provide

730:54

our complete location and for this text

730:56

I'm going to also copy them place it

730:58

here and place it here as well and

731:00

complete location is required so I'll

731:02

use like complete location is required

731:05

and we did not change the state so

731:07

instead of providing a state for all of

731:09

them I'm going to change there to zip

731:11

change this one to Country and also this

731:14

one to the complete complete location

731:17

right here so now if I hit enter oh I

731:19

also have to change this value right

731:21

here so I'm going to copy that place it

731:24

here I'm going to also copy the country

731:27

place that to the stand and the complete

731:29

location will also be here okay so now

731:32

finally if I sa my file and now let's

731:35

just test this out so here you can see

731:36

we are now getting our form button which

731:39

will just say submit and we are going to

731:41

be also providing a type of submit to

731:44

the sa my file and we are now getting

731:46

our button right here so if I didn't

731:47

specify nothing today and click on

731:49

submit so it's going to give us These

731:50

Warnings it's going to say like first

731:52

name is required last name is required

731:54

email address is required city and state

731:56

is required zip country and complete

731:58

complete is required complete location

732:00

is required what the hell complete

732:03

location is required so it's going to

732:06

give us like a complete location is

732:08

required so I'll provide like my own

732:10

name H

732:11

last name is set to webd and provide a

732:14

email as a test

732:16

gmail.com and also the city will be uh

732:20

something state will be I don't know the

732:22

ZIP code will be uh

732:25

4312 and Country will be uh uh uh uh and

732:30

complete location will be uh God damn it

732:33

uh I'm going to copy this uh something

732:36

then I don't know then the ZIP code will

732:39

be 5 31 to and also the country is

732:46

yeah and now if I click on the submit

732:48

button we not getting anything but we

732:50

can also go ahead and go to the inspect

732:51

element we can see all of that content

732:54

right here so we are getting these

732:55

errors and now if I you know let me just

732:57

refresh there we're going to submit one

732:59

more time now we are getting all of that

733:01

data like City complete location country

733:03

email first name last name State and zip

733:05

so yeah that was a lot about the react

733:09

hook form that we've learned so if you

733:11

have a spare time you can definitely go

733:13

ahead and do some other stuff with them

733:15

but yeah I am done with the react H form

733:17

welcome to the react 19 master class so

733:19

in this section we're going to be

733:20

covering every single thing that there

733:22

is to learn about the react 19 and keep

733:25

in mind I'm going to be also making a

733:26

separate video about the react 19

733:28

because I know there are a lot more

733:31

feature coming in the react 19 and I

733:33

cannot cover there right now because

733:35

they are not even released yet I've met

733:37

with a lot of meta developer and they

733:39

tell me about a certain feature which

733:41

are coming into the react 19 but not

733:44

right now but I promise they are coming

733:47

so yeah now let's talk about the biggest

733:49

feature about the react 19 which is

733:52

their own compilers react 19 now

733:54

includes its own compiler which will not

733:56

only speed up the performance but also

733:58

automate a certain terious task reducing

734:00

the overload for developers so yeah we

734:03

have a new compiler

734:05

hooray next we no longer have to care

734:08

about the memorization and the

734:09

memorization and stuff like that with

734:11

react 19 new compiler there is no need

734:14

for the memorization or memorization the

734:17

process of optimizing a component to

734:19

prevent unnecessary renders previously

734:21

we relied on the used memo and also on

734:24

the used call back hook for these

734:26

purposes but now thankfully they are

734:28

totally obsolete because of the react 19

734:31

compiler we also have another feature in

734:33

react 19 which is called the metad DAT

734:35

so we no longer need to install third

734:37

party packages for SE and metadata

734:40

because react 19 now offers built-in

734:42

support for these features we can place

734:44

the text anywhere within our component

734:47

and that will work totally fine in the

734:49

client component and also on the server

734:51

component so yeah that's also a big

734:54

thing now let's talk about everyone's

734:57

favorite topic which is called the

734:58

directives so react 19 now includes

735:00

built-in support for the used client and

735:03

also the used server directives we are

735:05

not going to be covering the use server

735:06

one because it involves some sort of a

735:08

backend functionality but we are not

735:10

going to be covering that not right now

735:11

but I will make a separate video about

735:13

this allow component to be rendered on

735:15

the server resulting in improve SEO

735:17

faster page load time and more

735:19

straightforward data fetching so yeah

735:21

that was a few things but now let's talk

735:23

about what are the things which are now

735:26

completely obsolete in the react 19 so

735:29

we no longer have to worry about the

735:30

forward ref we also have to don't care

735:32

about the react lazy loading and also

735:35

the use context I mean like yeah we

735:37

totally can use the use context like

735:39

Nothing is Stopping Us but we are not

735:41

going to be using the use context we are

735:43

going to be only using use that's it

735:46

which is something I'm going to be

735:47

showing you in a few seconds we no

735:49

longer have to care about the memo the

735:51

use effect and also the use callback we

735:53

are going to be using the use effect for

735:55

the side effects but not for the data

735:58

fetching so yeah that was a few things

736:01

but now let's talk about the use so now

736:03

let's talk about the use hook in react

736:05

19 so the use hooklets you read in low

736:07

resources asynchronously such as

736:10

promises or context so unlike any other

736:12

hook we can use the use hook inside the

736:15

loops and we can also use that inside

736:17

the conditional statement in certain

736:19

situation it can serve as a replacement

736:21

for the use effect when fetching the

736:23

data something which I'm going to be

736:24

showing you in a few seconds and it also

736:26

streamlines a context usage by allowing

736:29

you to use the use context like just use

736:31

the use and then provide your context

736:33

inside there instead of using the use

736:36

context hook and then providing your

736:37

context so yeah this just a theory about

736:40

the use hook and now let's write some

736:41

code and then you will get to know what

736:43

I'm talking about so now let's talk

736:44

about the actions in react 19 react 19

736:47

introduces actions which are

736:49

asynchronous function designed to

736:51

simplify form submissions actions can be

736:53

utilized on both client and also on the

736:56

server side so yeah this just a basic

736:58

theory about the actions now let's get

737:00

into the cording part and then you'll

737:01

get to know what I'm talking about now

737:03

let's talk about the use form status

737:05

hook in react 19 so use form status is a

737:07

hook that give you a status information

737:09

about the last form submission

737:11

and this is how the syntax will look

737:13

like first of all we're going to be

737:14

using the use form status like we're

737:15

going to be executing our hook and then

737:18

we're going to be D structuring the

737:19

pending data method and also the action

737:22

totally self-explanatory so now let me

737:24

just write some code then you'll get to

737:26

know what a use form status is now let's

737:28

talk about the use action hook in react

737:30

19 so when I was recording this video

737:33

this hook used to be a use form stat

737:35

hook but this is no longer a use form

737:37

stat hook this is a use action stat hook

737:40

so that's the only reason I'm going to

737:42

be making a separate video about the

737:44

react 19 features because I know there

737:47

will be a lot of changes and I can

737:50

totally guarantee there so now let's

737:52

talk about it so what is a use action

737:53

state so use action state is a hook that

737:56

allow you to update the state based on

737:58

the result of a form action and this is

738:00

how the syntax will look like first of

738:02

all we're going to be calling our use

738:04

action State we can provide the function

738:06

we can also provide the initial value

738:08

and now it's going to give us the return

738:09

value of array and now inside this array

738:12

we can totally restructure the state and

738:14

also the form action which we can

738:16

provide for our form so this is the

738:18

theory and now let's get into the coding

738:20

then you will get to know what I'm

738:21

talking about I know what you're

738:22

thinking you're thinking where in the

738:25

word is hosan getting these amazing

738:28

wallpapers I'm going to show you from

738:30

where but first we have to make a setup

738:32

forward course let's just make a setup

738:35

for this course I'm going to zoom in a

738:37

bit and the first thing that we have to

738:38

do is that we have to install react I'll

738:40

use like npm create we at latest and

738:45

then I'll get the name of like react 19

738:48

uh features or something like that I'm

738:50

going to choose reactjs and also

738:53

typescript so now let's get into the

738:54

reactjs and now we going to be using

738:57

npmi to install every single thing

738:59

inside there that's done now reactjs by

739:02

the time of this recording react 19

739:04

version is not available so we're going

739:06

to be using the experimentals so you

739:08

just have to provide this command so now

739:10

just place there so first of all you

739:12

have to use npmi then react at

739:15

experimental and also react Dum at

739:17

experimental so I'm going to hit enter

739:19

so it's going to also install the inside

739:21

their project so now let me just open

739:22

that in my vs code and this is how it

739:24

looks like so I'm going to remove the

739:25

public folder I'm going to also go into

739:28

the SRC and remove this assets folder

739:30

remove the app. CSS file and let's just

739:33

empty out this f. TSX and I'm going to

739:35

only write my RFC inside there save my

739:37

file and also I'm going to remove every

739:39

single thing from this index start CSS

739:41

file and now I'm going to go into the

739:43

tment CSS T css.com click on the getting

739:48

started go to the framework and guides

739:50

choose we and copy this command open my

739:54

terminal place that here and it's going

739:56

to install 10in CSS inside my project

739:58

I'm going to also hit enter so it's

740:00

going to initialize T CSS inside my

740:02

project so I'm going to copy there and

740:04

let's just go into our T config and

740:06

replace that with this new content okay

740:09

and finally we also have to copy this

740:10

this index. CSS stuff and place that

740:13

here and we have to run there by using

740:15

npm run Dev check this out all used like

740:17

Local Host and yep everything is working

740:20

the way I expect them to work I fast

740:22

forward the video and created a

740:23

component folder and inside there we

740:25

have our fish too. TSX file and now

740:28

inside this file we are now fishing our

740:30

data so now let me just show you every

740:31

single thing first of all we importing

740:33

the use St and also the use effect then

740:35

we are creating an interface for or

740:36

to-do which will only hold the title and

740:39

title will be a string then we have our

740:41

component with the name of fetch to-do

740:43

and inside there we have a to-do state

740:45

which allows us to store our to-dos

740:47

inside this St next we also have a

740:49

loading ST which allows us to either

740:51

show the loading or hide the loading

740:53

then for the side effect we are now

740:54

using the use effect and inside this use

740:56

effect we are now fetching our data okay

740:58

so we are now creating a function with

740:59

the name of fetch data which is going to

741:01

be an asynchronous function and inside

741:03

this function we are now providing a TR

741:05

and catch block so first of all we're

741:07

going to be fetching our data from this

741:08

URL if we don't have the data so we're

741:10

going to be throwing this response but

741:12

if we do have the data so we're going to

741:14

be converting that to Json finally we

741:16

have to send that to or to do so that we

741:18

can render there if that's not the case

741:20

we are going to be getting some sort of

741:22

error which we are logging to the

741:23

console and if that's also not the case

741:25

we are going to be providing our lader

741:27

finally we are just calling our function

741:29

to get all of the data so now let me

741:31

just collapse them we are also checking

741:33

if we have the loading so we're going to

741:35

be showing this lower and if that's not

741:37

the case so finally we have to just

741:38

render our title from this studio

741:41

so yeah that was our entire component

741:44

and now if you want to execute or call

741:45

that component inside our app so this is

741:48

how we are going to be doing there and

741:49

now I'm going to render this component

741:50

right here so I'll use like fish to do

741:53

and let's just close there like so I'm

741:56

going to try to import there so this is

741:58

how we're going to be importing this so

742:00

let's just save our file and here you

742:02

can see we're now getting our title

742:04

right here which is a random to-do title

742:07

which means like everything is working

742:08

the way we expect him to work but we no

742:10

longer have to write like all of that

742:12

code like using the use effect and using

742:15

the if andl statement and all of that

742:17

crap we have to just remove them and the

742:19

first thing that we have to do is that

742:20

we have to just use our component right

742:22

here which is a fch to-do component and

742:24

inside this fch to-do first of all we're

742:26

going to be creating a variable with the

742:28

name of data and inside this data we're

742:31

going to be using the use and where in

742:33

the word is use coming from use will be

742:35

coming from the reactjs so I'll just

742:37

import the use from the reactjs okay so

742:40

this how we're going to be importing the

742:41

use function or the use Hook from the

742:43

reactjs and now inside this use we have

742:46

to specify our promise so I'll just

742:48

provide a function which will be a fetch

742:50

data function and now we have to create

742:52

this function separately we can also

742:54

provide our function right here if you

742:55

wanted to so I'll just create my

742:57

function separately with the name of

742:59

like P data and inside this function

743:02

what do you want to do let's just write

743:03

our as synness function and inside this

743:06

function we're going to be making a

743:07

request to this URL which is H HTTP

743:11

https and then Json placeholder do type

743:16

io.com and then todos and one okay we're

743:20

going to be storing that in the res

743:22

variable and now we have to just return

743:24

the res. Json okay like so now that we

743:28

successfully fetch our data now we are

743:30

providing that to our use function next

743:32

we have to render the data to the Dom so

743:34

I'll just remove this fch to do from

743:36

here and I'm going to only use data Dot

743:38

and then title so if I use this save my

743:40

file this also is going to gives us an

743:42

error and why is that because whenever

743:44

we want to use the use function or the

743:46

hook we have to wrap that inside the

743:48

suspense so I'm going to just select

743:50

this div and we have to convert that to

743:52

suspense like so suspense is a huge

743:55

topic which we are going to be covering

743:56

in this course but not right now okay

743:59

and here you can see we're now getting

744:00

our title which is looking cool so yeah

744:02

this is how we're going to be fetching

744:04

our data by using the use hog so now let

744:06

me just show you that once again first

744:08

of all we're going to be importing the

744:09

use hog and inside this use hook we're

744:11

going to be providing our promise okay

744:13

so here we're now providing our fetch

744:15

data function and now we're creating

744:17

that fetch data function and inside this

744:19

fetch data function we're now fetching

744:21

our data from this URL and then we are

744:23

converting the data to our Json okay so

744:26

this how can allows us to fish the data

744:28

and this how we're going to be showing

744:30

the data to the do now let me show you

744:32

how we're going to be using the use hook

744:34

with context so first of all I have my

744:36

app component and inside this app

744:38

component I'm now rendering my theme

744:40

comp component so now let me go ahead

744:42

and go to my theme and wo that's a lot

744:45

of coding H that's a lot of coding so

744:48

now let me just explain all of them one

744:49

by one first of all we are defining a

744:51

typ forward theme it's going to be

744:53

either a light or a dark theme and then

744:55

we are creating an interface and then

744:57

inside this interface we have a theme

744:59

which will be coming from that theme

745:00

like either the light or the Dark theme

745:03

then we have a toggle function which

745:04

will only return the white then we are

745:06

creating our context and this context

745:08

will either take the theme cont text

745:10

type or undefined so for the initial

745:12

value we are now specifying undefined to

745:14

there now we're creating our provider

745:17

and inside this provider is going to

745:18

take a children so we're now just

745:19

annotating there right here and now

745:21

inside there we're now creating our

745:23

theme which will be sharable for all of

745:25

our components so we now just creating a

745:27

stare for or theme and the initial value

745:29

will be set to light we also creating a

745:32

toggle theme function which will allows

745:33

us to either provide the light or dark

745:36

or toggle that to either light or dark

745:39

theme then we're just spacing the theme

745:41

and also the toggle theme function to

745:43

our context provider like theme context

745:46

provider to be precise and here you can

745:48

see we have our theme component and now

745:50

inside this theme component we are now

745:51

wrapping our card component by using our

745:54

theme provider okay and finally we're

745:56

just creating a custom hook which is a

745:59

used theme and we are checking if we

746:01

have the context so cool get the context

746:03

but if you don't have the context then

746:06

show this error like us theme must be

746:08

within the theme provider component so

746:10

that's everything for this component now

746:12

let me go ahead and go to my card

746:14

component and we are not doing anything

746:16

crazy but we are first of all importing

746:17

our context from theme context and we're

746:20

now passing them to the use context and

746:22

if we don't have the context so then

746:24

we're going to be rendering this error

746:26

so if we have the context so we're going

746:28

to be restructuring the theme and also

746:30

the toggle theme function from there

746:32

we're providing a bit of styling today

746:34

and we are now rendering our theme

746:35

totally dynamically so if our theme is

746:37

equal to light then we're going to be

746:39

changing the background color to totally

746:41

white but if that's not the case we're

746:42

going to be changing the background

746:44

color to kind of a tealish color okay

746:46

and we are also providing our H1

746:48

providing our our styling totally

746:50

dynamically and also we are creating

746:52

some sort of a paragraph and providing

746:54

our style to them and and finally we

746:56

have our button which allows us to

746:58

toggle our theme so this is how the UI

747:00

will look like as you can see I have

747:02

this UI I have this theme card and also

747:05

some sort of a lum Epsom if I click on

747:07

this switch to dark mode it's going to

747:09

make it as a dark mode if I click on

747:10

there once again so it's going to make

747:12

it totally light mode so yeah this is

747:14

what's going on now using the react 19

747:17

version we no longer have to use what do

747:20

we call it uh this use context so now we

747:23

can totally replace that with the use

747:25

function so how are we going to be doing

747:27

there I'm going to comment this line out

747:28

and I'm going to be importing the use

747:30

function or Hook from where from the

747:32

reactjs and now we no longer have to use

747:35

the use context we're going to be only

747:37

using the use okay so now if I sa my

747:40

file test this out and click on the

747:42

still it works exactly the same so yeah

747:46

that's the only change that we have to

747:48

do for the react 19 now let's talk about

747:50

actions in react 19 but first of all I

747:53

want to say that we're going to be only

747:54

covering actions on the client side

747:57

we're not going to be covering that on

747:58

the server side because we did not learn

748:00

about the back end so that's why we not

748:02

going to be covering that not right now

748:04

but we will cover there very soon so

748:05

what I'm going to do is that I'm going

748:07

to create my components sper and inside

748:09

there we're going to be defining our

748:10

form. jsx file or you know what this

748:14

should be a TSX rather so now let me

748:15

just change that to TSX I'm going to use

748:17

my RFC component and go into my app and

748:20

register my component right here so

748:22

let's just scate to our form and

748:24

register this component and here you can

748:26

see we now getting our form so first of

748:27

all I'm going to provide my UI today and

748:30

then we will provide the rest of the

748:32

stuff so I'll change this St to a form

748:34

and now inside this form we're going to

748:36

be creating a label and this label will

748:39

be a name label I'll just write like

748:41

label for the name and we're going to be

748:43

also providing an input field with the

748:44

type of text and we're going to be also

748:46

providing an ID and the ID will be set

748:48

to name and please do not forget this

748:51

one you have to specify a name if you

748:54

want to work with a form okay so you

748:55

have to specify some sort of a name for

748:57

your input field so I'll just write like

748:59

name for this one and now I'm going to

749:00

save them so now underneath this one

749:02

we're going to be also creating let me

749:04

just write a v right here so we're going

749:05

to be also creating a label for the

749:06

email I'll write like label and I'm

749:08

going to just write like email and also

749:10

email there now let me just provide my

749:12

input field with the type of you know

749:14

what email would be fine so I'll just

749:15

change that to email I'll also provide

749:17

my ID of email and once again I can

749:20

stress that enough you have to specify

749:22

the name if you are working with the

749:23

action so we have to specify some sort

749:25

of name for there and yeah now

749:27

underneath this one we're going to be

749:28

creating our BR once again and let's

749:30

just create one more label and also

749:32

input field for the password so I'll

749:34

just write like password and then

749:35

password inside there so I'll just use

749:38

my input feeld with a type of password

749:39

in this case and we're going to be also

749:41

providing an ID and the ID will take a

749:43

password and once again we going to be

749:46

providing a name and the name will be

749:48

password so now underneath there let's

749:50

just create our button which allows us

749:52

to submit our form so I'll just write a

749:53

br and now we're going to be creating a

749:56

button for the submit so I'll just put a

749:58

type and the type will be submit okay

750:00

and yeah I'm going to just save this

750:02

file this is how my form looks like I

750:04

know it is looking super ugly so now let

750:06

me just provide a bit of styling today

750:08

so what I'm going to do is that I'm

750:09

going to provide The Styling to this

750:10

input field to this input field and also

750:14

to this input field we're going to be

750:15

also providing a different styling for

750:17

this submit button so now let me just

750:19

place this so now if I save my file and

750:21

check this out so here you can see this

750:23

is how my UI looks like I know super

750:25

amazing right yeah it is amazing so

750:29

let's talk about the forms so as I said

750:32

that forms are just an asynchronous

750:33

function which we are going to be

750:35

attaching forward form so what we have

750:37

to do I mean like action or asynchronous

750:39

function which we going to be attaching

750:40

forward form I don't know what the hell

750:42

I just said in the first place so I'll

750:44

just use like action we just have to

750:46

specify our action and change it to the

750:49

PHP code if you guys are aware of a PHP

750:52

code you guys already know all of that

750:53

stuff but if you don't you don't have to

750:55

worry about there so here we have to

750:57

specify some sort of a arrow function or

750:59

some sort of a function so I'll use like

751:01

form action function and this should be

751:04

action form action function and now I'm

751:06

going to copy them and now let me just

751:08

crate that right here so I'll use like

751:10

con form action and it's going to take a

751:12

special perimeter which will be a form

751:14

data okay so now inside then what we

751:17

have to do we have to create some sort

751:18

of a user data so I'll use like cons

751:20

user data it's going to be equals to

751:23

this object and I'm going to provide the

751:24

property of name to there and that data

751:27

will be coming from this form data we

751:29

now attaching this uh function to this

751:32

form by using our action then we are

751:34

providing this perimeter which is a form

751:36

data so now we are going to be copying

751:38

and pasting there then we have a

751:40

property inside this so if I just use

751:42

the do get and here we can now get our

751:44

data so where in the world is this name

751:46

coming from this name is coming from

751:50

this name which we are now providing

751:51

right here okay so it's going to select

751:53

that name form or that name input to be

751:55

precise now I'm going to provide a comma

751:57

I'm going to also provide an email and

751:58

for the email we're going to be

751:59

providing our form data. getet method

752:02

once again and now we're going to be

752:03

providing our email and finally we have

752:05

to also create the for the password so

752:07

I'll use like form data and then get

752:09

method and provide our password in this

752:11

case password there we go now I'm going

752:14

to sve my file and now underneath them

752:16

we have to just log to the console this

752:17

uh user data and now let me just save

752:20

there it is giving us an error and you

752:21

know what let me just proide like any

752:24

type to there so yeah we are now getting

752:26

all of the data so you know what let's

752:28

just go ahead and check this out and now

752:30

if I open my console let's just go ahead

752:32

and go to our console and I am going to

752:35

provide my name like husan and then

752:37

something or test atgmailcom

752:40

and some random password now if I click

752:44

on the submit button it's going to give

752:45

us that data right here as you can see I

752:48

have my name data I have my email data

752:50

and I also have my password data so now

752:53

you are totally free to do whatever you

752:55

want to do with that data you can

752:57

totally modify that you can send that to

752:59

a server you can do whatever you want to

753:01

do with that data so now let me just

753:02

explain that once again first of all

753:04

we're going to be creating some sort of

753:05

a form and then we have to specify some

753:07

sort of a name for our input field so

753:10

that we can select that specific input

753:11

field by that specific name we also have

753:14

to use our action and for this action

753:16

we're going to be providing some sort of

753:17

a function so you can pass your function

753:19

right here or you can create this

753:21

separately as I did right here okay so

753:23

now inside this function it's going to

753:25

take this form data as a perimeter and

753:28

you can totally get your data by using

753:29

this form data. getet method and here

753:32

you have to specify your name okay and

753:34

then you can do whatever you want to do

753:35

with that data so yeah that was just the

753:37

basics of actions in reactjs on the

753:40

client side we not going to be covering

753:42

the server side because we are not there

753:44

yet so now let's talk about the most

753:46

easy a bit weird and also not that much

753:50

useful hook in react 19 which is called

753:52

the use form hook so what I'm going to

753:54

do is that I'm going to create my

753:55

components folder and I'm going to

753:56

create my form. TSX inside there and

753:59

let's just use our RFC sem my file and

754:01

register this component right here this

754:04

I'll use like P and here in is going to

754:07

gives us their home right in here which

754:09

is looking cool so let's just remove

754:12

them and first thing first I'm going to

754:14

just remove that and change it to a form

754:16

and inside this form we're going to be

754:18

creating our div and inside this div we

754:19

have to provide our label and for this

754:21

label we have to provide some sort of a

754:23

label like name or something and

754:24

underneath that we're going to be also

754:26

creating an input field with a type of

754:27

PEX we're going to be also providing a

754:29

class of Border all around will be or

754:32

yeah all around will be set to two and

754:34

the ID will be set to name and we're

754:35

going to be also providing a specific

754:37

name because we're going to be using our

754:39

ction inside the and this should be

754:41

required and now underneath this div

754:43

we're going to be defining yet another

754:45

Dev so let's just use our Dev and

754:47

provide my label inside there and we

754:49

have to specify the email and email like

754:52

so so inside there we have to specify

754:54

our input with a type of email and we

754:57

are going to be also providing a ID and

754:59

the ID will be an email we also have to

755:01

specify the name and the name will be an

755:03

email and this should be required to and

755:07

finally we're going to be creating a

755:09

button but we are going to be creating

755:10

that in a separate component which will

755:12

be a form button okay so that's why I

755:15

said that form status Hook is a bit

755:17

weird one because whenever we have to

755:19

use that function we have to create a

755:21

separate component or use that hook we

755:23

have to create a separate component for

755:25

that so what I'm going to do is that I'm

755:26

going to go ahead and Define or create

755:28

my component right here with the name of

755:30

form button. TSX I'm going to only use

755:33

my RFC inside there and just call this

755:36

function s my file import this component

755:39

right here now I'm going to also create

755:41

an action for my form so I'll use like

755:44

uh action and here we have to specify

755:46

some sort of action so I'll give it the

755:48

name of like my action I'm going to copy

755:50

that and let's just create this action

755:52

right here okay so what I'm going to do

755:53

is I'm going to just create my action

755:55

and this should be an asynchronous

755:57

action here we have to specify our form

755:59

data and inside this form data we're

756:01

going to be using like a and then new

756:03

promise promise and and that's the only

756:05

reason we marked it as an asness

756:07

component or action to be precise and

756:09

inside this promise we have to provide a

756:11

resolve and when this is resolve we are

756:13

going to be firing this function which

756:15

is a set timeout and here we have to

756:17

specify the resolve function today and

756:19

also we have to provide the delay of

756:21

2,000 now underneath here we're going to

756:23

be getting our data Sol use like new

756:24

post or post rather and inside there

756:27

we're going to be first of all getting

756:28

the name and name will be coming from

756:30

the form data and then we have to use

756:33

the get method to get the data by using

756:35

one name I'm going to also duplicate and

756:37

change it to email and also change this

756:39

want to email as well and now I'm going

756:41

to be using like console.log of new post

756:44

and now let me just save my file we are

756:45

now getting this error so I'll just

756:47

annotate with the any flag now this

756:49

component is done I'm going to go ahead

756:51

and go to my form button component and

756:53

now let's just use our form status hook

756:55

inside there so the first thing that I

756:57

want to do is that I want to grab my use

756:59

P status we have to grab them manually

757:02

from where from the react D not from the

757:05

react J but from the react D like so now

757:08

that we successfully get there so now

757:10

I'm going to be using this all use like

757:11

use form status and execute there I'm

757:13

going to store there in some sort of

757:14

variable like form or something now let

757:16

me just log this form to the console so

757:18

if I save my file and now I'm going to

757:20

go ahead and go to my console and here

757:23

you can see we're now getting an object

757:24

SOI just refresh that so we have a

757:27

action which we can provide for our form

757:29

we are not interested in there we can

757:31

also have a data which we can also

757:32

render inside our component we're not

757:35

interested in there we also have a

757:36

different methods I'm not quite sure

757:38

what in the word is a method thir but

757:40

yeah we have this black which is a

757:42

pending so now it is giving us a status

757:45

of our form okay so we are now only

757:47

interested in this pending so I'm going

757:48

to just destructure there so to

757:50

destructure there I'm going to only use

757:52

this bracket and I'm going to use like

757:54

pending inside there okay so now if I

757:57

just use like pending save my file once

757:59

again and refresh there and now it's

758:01

going to give us a false right here so

758:02

now what I'm going to do is that I'm

758:03

going to just remove there and change

758:05

there with a button component or just a

758:07

simple button and we also want to

758:09

provide a type and the type will be set

758:10

to submit and here we have to specify

758:13

our flag so I'll just use like if that

758:15

is pending then make this component

758:17

disabled but if that's not pending so

758:19

then we can just do whatever we want to

758:21

do with that and I'm going to also

758:22

provide like if we have a pending state

758:24

so in this situation we can just use

758:26

like submitting dot dot dot but if

758:28

that's not the case we can just write

758:30

like submit like so submit there we go

758:33

so now if I save my file and test this

758:35

out so now let me just refresh there and

758:37

yeah you know what let me just go ahead

758:39

and provide a provide a style to this

758:41

one I'll copy this style and place there

758:44

right here inside this input field so

758:46

now both of them are looking cool so

758:48

what I'm going to do is I'm going to

758:49

specify hus test at gmail.com and now if

758:54

I click on this submit and watch what

758:55

happened is now giving us a submitting

758:58

and then it will submit that data it's

758:59

going to give us all of that data right

759:01

here and then it will give us St submit

759:04

let me just try that once again case

759:05

I'll use like something then something

759:08

at G

759:10

mail.com come there we go so now if I

759:12

click on there once again let me just

759:14

clear this out if I click on there once

759:16

again here you can see it is now giving

759:17

us a submitting and then it's going to

759:19

giv us that data and then it's going to

759:21

gives us that submit I don't know why we

759:22

are getting this error but we are

759:24

getting that so this H will only gives

759:26

us the status about our form so now in

759:29

this case we are now only interested in

759:31

the pending state so we can totally use

759:33

that so now let's talk about the use

759:34

action St hook in react 19 so what I'm

759:37

going to do is I'm going to create my

759:39

components holder and inside there we're

759:42

going to be providing our count. TSX and

759:45

now inside there let's just use our RFC

759:47

and register this component right in

759:50

here like my counter or just account and

759:53

execute and here you can see we're now

759:55

getting our count which is looking cool

759:57

so the first thing that I want to do is

759:59

that I want to call my use action stad

760:01

hook so I'll use like use action and

760:03

then come on use action St hook and now

760:07

we are going to be grabbing that from

760:08

the re yes so I'll import that by using

760:11

import and then use action come on

760:13

action St it is still not giving me a

760:15

suggestion so we're going to be graving

760:17

that from the react J okay import there

760:21

we go so now if I sell my file still we

760:23

are getting this error I don't know why

760:25

but we are getting this error and what

760:27

I'm going to do is that I'm going to try

760:29

to explain that but I want you to give

760:30

me a few seconds because it takes a lot

760:34

of things we going to be restructuring

760:36

the chat and also the form action which

760:38

we can proide forward form okaye we're

760:41

going to be destructuring the state and

760:42

also the form action and for the initial

760:44

value we're going to be specifying first

760:46

of all the increment function which will

760:47

allows us to change our form and we can

760:50

also specify initial value and the

760:52

initial value will be like basically

760:54

anything you want to WR I'm going to

760:56

only provide zero for the initial value

760:59

so let me just explain that once again

761:01

first of all we're going to be providing

761:02

some sort of a function which will

761:04

allows us to change our data or our

761:06

initial state or just our state then we

761:08

can provide initial value forward State

761:11

and it can be anything you can provide a

761:12

string you can provide object you can

761:14

provide array you can provide anything

761:16

that you prefer but now in this case I'm

761:18

now creating a counter so I'm now

761:20

specifying a zero value inside the okay

761:23

and we're going to be restructuring the

761:24

state we'll be holding the value of zero

761:26

inside there which means like we're now

761:28

destructuring there so that we can use

761:30

the inside our UI then we have an action

761:33

and you already learned like what in the

761:35

word is an action so I'm going to also

761:37

show you that in a few seconds which

761:38

means like we're going to be using the

761:40

inside our form so now let me just save

761:42

them and I'm going to change that to a

761:43

form once again and also change this one

761:46

to a form so now let's just remove this

761:47

count from here and I'm going to be

761:49

using my H1 come on this H1 and I'll

761:52

just say like uh I'll just render my

761:54

state inside there but it will give me

761:56

an error and you guessed it why it will

761:58

gives us an error so I'll just provide a

762:00

styling of like text 3XL it's going to

762:02

gives us an error because we have to

762:04

create this function right here or this

762:06

action whatever you want to call it so

762:08

I'll just use like s flag and create my

762:10

function inside there like so and the

762:12

name will be increment so it's going to

762:14

take a few perimeter now let me provide

762:16

like previous state and it's going to

762:18

also get the form data if you don't want

762:21

to provide this previous state you don't

762:22

have to but if you want to get the data

762:24

you have to specify the form data to

762:27

there okay so I want to use my previous

762:29

St so it's going to also gives us a

762:30

previous St right here so now if I want

762:32

to loog to the console my data so I'm

762:34

going to be using like uh form come on

762:36

form data. getet method and here we have

762:39

to specify the name inside there and why

762:42

is there oh we did not create our uh

762:45

what do we call it we did not create our

762:46

input field but yeah we going to be

762:48

getting our data by using this name and

762:50

also let's just use our return statement

762:52

and here we have to specify our previous

762:54

state plus one okay so now I'm going to

762:56

save my file I know it is giving us a

762:58

lot of errors but we don't have to worry

762:59

about the errors right now we only have

763:01

to care about this use form actions so

763:04

this is how we are going to be rendering

763:05

our data and now let me show you so here

763:07

you can see we're now getting the

763:08

initial value of zero because we are

763:10

providing a zero to there but if I

763:12

change that to this number and save my

763:14

file and now let me just refresh there

763:16

and here you can see it's going to gives

763:17

us that number right here so I'm going

763:18

to make that as a zero right here once

763:21

again and now we have to create our

763:23

button which allows us to increment or

763:25

change your St so I'll use like button

763:28

and inside this button I'll provide my

763:30

increment flag right here and also I'm

763:32

going to provide a bit of styling like

763:33

background will be set to tot T of 300

763:35

300 and also ping will be set to two and

763:38

I'm going to be using my form action

763:39

inside there and here we have to specify

763:41

our form action okay which we are

763:44

providing right here I'm going to

763:45

provide my BR so I'll use like BR and

763:48

now underneath you have to create what

763:49

input field and the type will be set to

763:51

text we're going to be also providing a

763:53

placeholder and I'll just say like

763:55

please enter your name enter God damn it

763:58

enter your name like so and also I'm

764:00

going to provide a bit of classes to it

764:02

so like border will be set to two pixel

764:04

all around and now let me just use that

764:06

name and what did I provide right here

764:09

we are now getting our data by using

764:10

this name so we have to specify that

764:13

name come on name right here so now if I

764:15

sa my file test this out and here you

764:17

can see we're now getting a lot of

764:18

weirdness but now let me just refresh

764:20

there and yeah if I click on this

764:23

increment function so it's going allows

764:24

us to increment or counter and if I type

764:27

something inside there and click on this

764:29

increment it's going to also gives us

764:31

the data inside there so yeah that was

764:33

our use action State let me just explain

764:35

that once again this function will take

764:37

increment function or some sort of a

764:39

function which allows us to change our

764:41

initial value and this is how we going

764:43

to be providing initial value to there

764:45

it's going to gives us a state which we

764:46

can render inside our UI it's going to

764:48

also gives us a form action which we can

764:50

execute on our specific button or on our

764:53

specific action okay so this is how

764:55

we're going to be creating our increment

764:56

function it's going to take a previous

764:58

St and it's going to also take a form

765:00

data and now we are logging that data to

765:03

our console and we're also just

765:04

incrementing our counter by one and yeah

765:07

that was just it about the use action

765:09

state in react 19 okay so now let's talk

765:11

about the used transition hook in

765:13

reactjs so what I'm going to do is that

765:16

I'm going to create my components folder

765:18

and inside there we're going to be

765:19

creating a lot of components I'll use

765:21

like home. TSX I'm going to also use the

765:24

contact. TSX and also um the post. TSX

765:29

so I'll use my RFC inside this component

765:33

rafc

765:35

rafc rafc e rafc C give me a pepc or

765:41

what what the am I saying so let's

765:44

just create our states I'll use like

765:46

active Tab and then set active tab it's

765:50

going to be equals to this function

765:51

which is a used St function and the

765:53

initial value will be set to home and

765:55

now we have to create a function which

765:57

allows us to render our content so I'll

765:59

use like uh render content and here

766:02

we're going to be just creating a

766:03

function and here we just have to use

766:05

our switch and cases baby so I'll use

766:08

like X active Tab and for the active Tab

766:11

case we're going to be providing a home

766:12

and now we're going to be returning the

766:14

home component from there so let's just

766:16

import there remove this bread from here

766:19

and also provide a case for the Post

766:22

like so and return the post post there

766:26

we go and I'm going to also close that

766:28

now we also have to use the cas and the

766:30

case will be set for the contact and if

766:32

that's the case so we're going to be

766:33

returning the contact component and

766:36

first I want to give you the example

766:37

without using the use transition hook

766:40

and then we're going to be refactoring

766:41

that hook I like then we going to be

766:43

refactoring that code to use the use

766:45

transition hook so now use like home and

766:48

import there right here okay everything

766:50

is working the way we expect him to work

766:52

and now we have to create our UI so I'm

766:54

going to go ahead and create my UI right

766:56

here I'll use first of all my dat with

766:58

the class of tabs and inside there we

767:01

have to create our button and I'll just

767:03

use like home and then change that to

767:05

post and then change that to contact and

767:08

I'm going to be calling my function on

767:09

there so when somebody try to click on

767:11

this function we are going to be firing

767:13

these function so like set active Tab

767:16

and let's just provide our tabs inside

767:18

there so I'll use like home I'm going to

767:19

also provide a post inside there and I'm

767:22

going to also provide a context now if I

767:23

save my file and underneath that we are

767:26

going to be rendering our content so

767:28

I'll just create a d with the class of

767:30

content content God damn it content

767:34

there we go and now we have to render or

767:37

what do we call it render content

767:39

function inside there now let me just

767:41

save my file but here is a bit of catch

767:44

if I go ahead and I'm going to also put

767:46

AIT of styling to these buttons so I'll

767:48

just select it and provide a class name

767:51

of Border two and sa my file yep that's

767:54

cool so I'll use like pairing for all

767:56

around will be set to four and I guess

767:58

that's looking better so if I click on

768:00

the home so it's going to gives us a

768:01

home if I click on a post so it's going

768:02

to give us post if I click on the

768:04

contact it's going to gives us a contact

768:06

but what I'm going to do is that I'm

768:07

going to go ahead and go to the Post and

768:09

I want to just render a lot of post so

768:12

so I'll just generate come on generate a

768:15

lot of post okay so to do that we're

768:18

going to be using our

768:20

post and inside there we're going to be

768:22

using array. from method and let's just

768:25

provide our length and how many you want

768:28

so I'll just provide like 1 2 3 4 5 6

768:33

okay and then uh we don't need the data

768:36

we only need the index and I'm going to

768:38

just write like post inside there or

768:39

just a simple post and render my data

768:42

inside the like index + one there we go

768:45

so now it's going to give us a lot of

768:46

post and now we have to iterate over

768:48

through all of that post by using the

768:50

map method and render there so I'll use

768:52

like post. map and here I'm going to

768:54

only provide a post inside this as aror

768:56

function and I'm going to also create a

768:58

div and inside this div we have to

769:00

specify our key and the key will be set

769:02

to post and provide a class name of post

769:05

and inside this div we have to render

769:07

our post okay so now if I sa my file and

769:10

now if I click on this post and watch

769:12

what happened everything is now freezed

769:15

out I cannot click on the home I cannot

769:17

click on the contact you know what let

769:19

me just uh say that once again if I go

769:22

ahead and click on this post once again

769:25

now I can't click on the home I can go

769:28

to the contact page until I render all

769:31

of that data it will not let me to go to

769:34

any other component and everything is

769:35

now totally freeze up so if you want to

769:37

try this code by your you can totally go

769:39

ahead and try there by yourself but I

769:41

think I'm demonstrating that a bit cool

769:43

if I click on this post I cannot go to

769:45

any other component until all of their

769:48

data is rendered okay so it is taking a

769:50

lot of time and now for this kind of

769:53

situation we're going to be using the

769:54

used transition hook we are not going to

769:57

be using a used transition hook in the

769:59

day-to-day life that's just a thing you

770:01

have to keep in mind but whenever you

770:03

want to render a lot of data like I mean

770:06

this amount of data so for this

770:08

situation you may use the use transition

770:11

hook and yeah let me just show you how

770:13

we can refactor our code to use the use

770:15

transition hook so to do that first of

770:17

all I'm going to go into my app

770:18

component and I am going to import the

770:20

used transition Hook from the reactjs so

770:23

I'll just use like uh use transition so

770:27

I'll just create first of all or you

770:29

know what let me just call this use

770:30

transition uh function and I am going to

770:33

store there in some sort of a something

770:35

or something like I'm going to store the

770:37

inside the something and log that

770:40

something to the console so now if I

770:41

save my file and I'm going to go ahead

770:43

and go to my inspect element go to my

770:45

console and now let me just refresh

770:47

there so it's going to gives us a few

770:48

things it's going to gives us first of

770:50

all the false it's going to also gives

770:51

us a function okay so that false will be

770:54

the state like is it pending or not okay

770:57

so if it is pending it's going to giv us

770:59

true but if it is not pending it's going

771:02

to gives us false no so now in this case

771:04

it is not pending so it is now giving us

771:06

a false and yeah we have a function

771:09

which we can provide for loaded data so

771:12

what I'm going to do is that I'm going

771:13

to restructure my uh what do we call it

771:15

is pending and I'm going to also

771:17

destructure the start trans come on

771:20

start transition function from there now

771:23

I'm going to delete this line of code

771:24

next we only have to refactor this code

771:26

so I'm going to also collapse there and

771:29

I'm going to go ahead and just change

771:30

the instead of using this set active tab

771:32

I'm going to change that to like uh

771:34

handle tab change or something and I'm

771:37

going to copy the name of there and put

771:39

there here and also I'm going to just

771:42

replace there with this handle change

771:44

now I'm going to go ahead and just

771:46

create that handle change function I'll

771:47

use like con handle change it's going to

771:49

take a tab as a perimeter and now inside

771:52

this function we're going to be using

771:53

our start transition function which is

771:55

coming from this use transition so we

771:57

have to just it's going to giv us an

771:58

asynchronous function which causes a

772:00

state update that can be deferred I know

772:03

this is a bit mouthful to say but yeah I

772:05

am going to provide my arrow function

772:08

inside there and now inside this Arrow

772:10

function I'm going to be using a set

772:11

active Tab and provide my tab inside

772:14

there I'll basically call this set

772:16

active Tab and we have to specify this

772:18

tab inside there which we are providing

772:21

right here like we're now providing a

772:22

home we are also providing a post and we

772:24

are also providing this contact word

772:26

here okay so I'm going to also use my

772:28

flag word here so if it is pending so

772:30

I'll use like if it is pending in that

772:33

situation we only want to show some sort

772:35

of a loader so I'll use like paragraph

772:37

and I'm going to say like loading dot

772:38

dot dot and let's just say our file and

772:41

that's the refactor that we have to do

772:42

so now I'm inside the Home tab if I

772:45

click on this post so it's going to give

772:46

us that loading and that loading is

772:48

coming from this is pending flag okay so

772:51

it's going to give us that P I mean like

772:52

that loading and then it's going to

772:53

render all of our content right here let

772:55

me just refresh there I'm now inside the

772:57

home component if I click on the post

773:00

then I can also click on the contact and

773:02

it's going to brings us to the contact

773:03

so yeah that was just the basics of what

773:06

do we call it the use transition

773:08

function or hook to be precise in react

773:10

19 time for our tabs project setup so

773:12

I'm going to use npm create we at latest

773:16

and the name will be tabs I'm going to

773:19

choose reactj and typescript and now let

773:21

me go into the tabs project and install

773:24

every single thing for there then done

773:26

I'm going to also install the react

773:28

icons Library I don't even know if

773:30

you're going to be using react icons or

773:32

not so I guess that's going to be here

773:33

so I'm going to open there in my vs code

773:35

right here so close there now let me

773:37

make a cleanup so I'm going to remove

773:38

this public folder and I'll also remove

773:41

this assets app. CSS and also we will

773:43

remove every single thing from the app.

773:45

TSX and replace it with our own custom

773:48

component I'm going to also REM every

773:50

single thing from there and the rest of

773:52

them is fine so now let me just click on

773:54

the getting started and go to the

773:55

Frameworks and guides choose we and copy

773:59

this command and now let me open my

774:01

terminal and place there right here so

774:03

it's going to install table CSS in my

774:05

machine so I'm going to go back now let

774:06

me hit enter while doing there I'm going

774:09

to copy there and let's just go into my

774:12

tailing config.js file and replace it

774:15

with this content like so I'm going to

774:17

also go ahead and copy there and go to

774:19

my index.css and place my styling there

774:23

and let me just test this out so I'm

774:25

going to copy this line out go to my app

774:27

and replace it with this new H1 right

774:30

here save my file and now let me use my

774:32

npm run Dev so it's going to start my

774:34

server and let's just refresh there we

774:37

now getting our hello the word with the

774:39

styling which means like everything is

774:40

working the way we expect him to work

774:42

the first thing that I want to do is

774:43

that I want to remove this H1 from here

774:46

and we are going to be rendering our

774:47

sidebar and also our profile but first

774:50

of all let me just create a div and

774:52

inside this div we're going to be

774:53

rendering both of that components so

774:55

I'll just create a component with the

774:56

name of or you want a folder with the

774:58

name of components and inside there

775:00

we're going to be defining our sidebar.

775:01

TSX and also our profile. TSX I'm going

775:05

to go into the sidebar use my rafc

775:07

inside them go to my profile and use my

775:10

RFC rafc inside there as well and now

775:13

let me render both of these components

775:15

so I'm going to use like uh sidebar and

775:18

render them I'm going to also use the

775:20

profile and also render this component

775:22

and this is how both of them looks like

775:24

so I'm going to start working on the

775:26

sidebar so I'm going to go into the

775:27

sidebar component and we're not going to

775:29

be doing anything crazy inside the

775:31

sidebar but we're going to be providing

775:32

a lot of styling so what I'm going to do

775:34

is that I'm going to remove this div and

775:36

I'm going to replace it with the assign

775:38

side a s i d e there we go okay and I'm

775:42

going to also put the class name of

775:44

sidebar fixed and top will be set to

775:47

zero left will be set to zero let me go

775:50

back for a few times and and height will

775:52

be set to screen which means like

775:53

totally full with will be set to 20 I'm

775:55

going to also provide a background color

775:57

of uh 1 A 1 C and 1 e that's going to be

776:02

the background color I'm going to also

776:03

change the text to totally white and

776:05

inside this sidebar let me just zoom in

776:07

a bit we going to be creating our UL

776:09

which will have the classes of pairing

776:11

for all around will be set to four flex

776:13

and flex will be set to column and let's

776:15

just write what justify like so justify

776:18

will be set to between and items will be

776:21

set to Center for the height fa could be

776:23

setting there totally full let me just

776:25

save my file I'm going to create a d

776:27

with a class of top and inside there

776:29

we're going to be creating our Ali with

776:30

a class of margin for the bottom will be

776:32

now set to two and create a d with the

776:34

class of flex and also items will be set

776:36

to Center inside there

776:38

we're going to be just creating our fa

776:40

home and that's going to be our icon and

776:42

I'm going to also style this icon so

776:45

I'll just write like class name of

776:46

margin for the right will be set to two

776:48

margin for the bottom will be set to

776:49

three and the size I'm going to increase

776:51

that to 18 save my file and this is how

776:54

everything looks like right here we only

776:56

have our uh home icon and which is

776:59

looking cool now underneath this Li you

777:01

know let me just duplicate this li4 like

777:04

a few times let's just duplicate there

777:06

one time and I'm going to change the fa

777:08

user fa user and grab that from the

777:11

react icons let me just save that and

777:14

yeah we are getting the user which is

777:15

looking cool and I'm going to also

777:17

duplicate there for the final time so

777:19

let's just duplicate there and change

777:21

this icon to fa search like so and yeah

777:26

we are now getting our search which is

777:27

looking cool and now underneath this div

777:30

we're going to be defining our bottom

777:31

div like that was for the top UI let me

777:35

just collapse there that was for the top

777:37

UI which you can see see right here now

777:39

we are going to be pushing our icons to

777:40

the bottom so for that we're going to be

777:42

creating our bottom uh dep right here so

777:44

let me just give it the class of bottom

777:46

and you can basically give it in any

777:47

class that you prefer I'm going to write

777:49

Ali inside the Ali we're going to be

777:51

using our iomd settings s e t NS and I'm

777:56

going to also provide the size of 18 to

777:59

them and now underne them we're going to

778:00

be also rendering our fa user from or

778:04

react icons and provide a class name of

778:06

margin for the top will be set to five

778:08

and the size will be set to 18 semi file

778:11

and now we are also getting these icons

778:13

right here basically you can change that

778:15

anything that you like but in my case

778:17

that's that's looking better so that was

778:20

it about for the sidebar next we're

778:22

going to be working with the profile

778:23

component now let me just zoom in a bit

778:25

and the first thing that I want to do is

778:27

that I want to create a state for the

778:28

banner URL and also for the profile URL

778:31

so I'll just create a banner URL uh in

778:34

lower case and then set Banner URL and

778:37

that's be equals to the used and for the

778:40

initial value I'm going to specify this

778:41

string okay so which is going to be

778:43

basically just a prototype or a simple

778:46

image you know let me just show you

778:48

there if I go to a new screen and we're

778:50

going to be getting like 1500 x400 so

778:53

this is going to be basically our Banner

778:54

image and just for Prototype and we will

778:57

be able to change that in a few seconds

778:59

okay so that's going to be for the

779:01

banner we're going to be also creating a

779:03

profile URL so I'll just create like

779:05

profile URL and also set Prof profile

779:08

URL and this going to be equals to the

779:11

US T and this us will have this link

779:15

right here is just a placeholder image

779:17

with 100 so now let me also show you

779:19

that one so this is how God damn it uh

779:23

I'm going to have to copy only the image

779:25

link and let me just place that here and

779:28

yeah this is what we are going to be

779:29

getting for the profile now let me go

779:32

into the UI so I'll just remove this

779:33

profile and provide my class name to

779:35

there so it's going to be relative

779:38

relative and width will be set to

779:41

94% 94% just like that and the margin

779:44

for the left will be set to five rims

779:47

inside this div we're going to be

779:49

creating a div with the class of

779:50

relative and inside this div we're going

779:53

to be defining our image and I'm going

779:54

to remove them now we're going to be

779:56

providing our Banner image so I'm going

779:58

to copy them and place it right here and

780:01

for the alternative text I'll just

780:03

provide like some sort of a you know

780:04

what background image or something like

780:07

that would be

780:08

and for the classes I proide like withth

780:10

will be set to totally full and height

780:12

will be set to 60 and also the object

780:15

will be set to cover so it's going to

780:16

take the entire de so now let me show

780:18

you there and here you can see we now

780:19

getting our Banner which is looking cool

780:22

now let me also take care of the profile

780:24

but now underneath there we're going to

780:25

have to create our button so this button

780:27

will include a lot of classes so now let

780:29

me just put all of them the first thing

780:31

that I want to do is that I want to make

780:33

it so that this is going to be absolute

780:36

this is now Rel relative so this button

780:39

will be absolute for this relative top

780:41

will be set to two and the right side

780:43

will be set to two background will be

780:46

gray of um 800 you know what 800 and

780:51

text will be set to totally white

780:52

pairing for all will be set to two

780:54

rounded totally full and whenever

780:57

somebody H over there we want to change

780:59

the background color to gray of 600 like

781:02

so and inside there let me just save my

781:05

file inside this button we're going to

781:07

be creating our label

781:08

and you know what we're not going to be

781:10

providing any HTML 4 today but or yeah

781:13

we will provide HTML 4 so I'll just

781:15

write like Banner upload or something

781:17

like that

781:18

upload and we're going to be also

781:20

providing a class name of cursor to

781:23

pointer uh label we're going to be

781:25

creating a fa camera icon let's just get

781:28

that from the react icons and I'm going

781:30

to increase the size of there to 24 now

781:32

let me just save there and yeah this is

781:34

how we are going to be getting our icon

781:36

now underneath this level we're going to

781:37

be defining what input field so I'll

781:39

just write input type will be set to

781:41

file in this case because we're going to

781:43

be uploading some sort of image okay so

781:45

I'm going to also provide the IDE of

781:46

banner upload to this one because we've

781:48

already specified this Banner upload for

781:50

the HTML 4 okay and I'm going to also

781:53

provide the accept flag so it's going to

781:55

accept every single image and also we're

781:58

going to be providing a class name of

782:00

herden today so it's going to hide there

782:01

and when somebody try to change

782:03

something we are going to be firing this

782:04

function which is a handle Banner change

782:07

is so now let me save there it's going

782:09

to obviously gives us an error because

782:10

we have to create this function okay so

782:13

you know let me just create this

782:14

function right away so I'm going to go

782:15

to the top and here I'm going to Define

782:17

my banner image so I'll use like const

782:20

Banner or handle excuse me handle Banner

782:22

image or handle Banner change it's going

782:24

to take the event we're going to be

782:26

first of all creating our file so I'll

782:28

just use a file and it's going to be

782:30

coming from the event. target. files and

782:33

we only want to get the first element

782:35

out of there okay I'm going to explicit

782:38

Define there as any because this is just

782:39

a file so it doesn't really matter the

782:41

type and we're not going to be doing

782:43

anything crazy and now let me just check

782:45

if we got the file if we have the file

782:48

so in this situation we're going to be

782:50

running this set Banner URL and we want

782:53

to change that to the url. create object

782:56

URL and here we're going to be

782:58

specifying our file so now what in the

783:00

word is this URL and then. create object

783:02

URL this line of code is used to create

783:05

a temporary URL that point to the blob

783:08

or file object in JavaScript so yeah

783:11

this is what we are going to be doing

783:12

right now and we are totally done with

783:14

this one so now let me just test this

783:15

out first of all I'm going to go to my

783:17

YouTube channel and then I'm going to

783:19

download my own Banner I'm going to save

783:21

there to my desktop and now I'm going to

783:23

click on this icon and here I'm going to

783:26

just choose my banner right here so

783:27

whenever I click on there it's going to

783:29

add my banner from my YouTube channel

783:31

and it's going to add there right here

783:33

so which is looking cool but we also

783:35

have to take care of our uh profile

783:37

image as as well so now underneath there

783:39

we going to be also creating a logo or a

783:42

profile image whatever you want to call

783:43

there so now underneath this T here

783:46

we're going to be defining our come on

783:50

ah Channel logo there we go and here

783:52

let's just take care of our Channel logo

783:54

I'm going to create a with the class of

783:56

flex and items will be set to Center

783:58

margin for the left will be set to four

784:00

and margin for the top will be set to

784:02

arbitrary value like two rims and now

784:05

inside this Dev we're going to be

784:06

defining our IM and for the image text

784:09

we're going to be providing our profile

784:10

URL which we've already set up up above

784:13

and now for this alternative text I'm

784:15

going to write like Channel logo or

784:17

something like that and for the class

784:19

name I'm going to provide a width of 40

784:21

and the height will be also set to 40

784:23

and object will be set to totally cover

784:25

okay and I'm going to also make it

784:27

totally rounded full so that we get our

784:29

Perfect Circle I'm going to also change

784:31

that to border totally white and

784:33

relative r e l a t i v e there we go so

784:35

now I'm going to save my file and yeah

784:37

we are getting our profile kind of a

784:39

logo but we also need a camera icon

784:42

there so now let me just put a camera

784:44

icon there okay so I'm going to first of

784:46

all create my button button with the

784:49

class of absolute and inside there I'm

784:52

going to also provide the margin for the

784:53

left of 3.6 rim and margin for the top

784:57

will be set to 10 rim and background

785:00

will be set to totally gray of 8 100 and

785:04

text will be set to totally white ping

785:06

for all around will be set to two

785:08

rounded will be set to four and whenever

785:11

somebody H over there we're going to be

785:13

changing the background color to gray of

785:15

600 and inside this button we are going

785:17

to be rendering our fa camera icon and

785:20

I'm going to also provide a class name

785:21

or you know not class name but the size

785:23

of 24 so if i s my file and check this

785:27

out

785:29

so okay we are getting something this is

785:32

not what we want so I'm going to cut

785:33

there and create my label first of all

785:36

and for the label I'm going to provide

785:37

like uh profile upload and we're going

785:40

to be also providing a class name of

785:41

cursor and which will be set to pointer

785:44

and inside this level we're going to be

785:46

providing our camera and I just specify

785:49

these two classes and I remove the other

785:51

ones so here you can see we are

785:52

providing a margin for the left but we

785:55

are now reverting there by using the

785:56

minus and I just specify six RM and we

785:58

are also providing a z index so that we

786:01

can see our icon so if I remove this we

786:03

are not able to see there if I do

786:05

provide my Z index we are now able to

786:07

see or icon there I'm going to also

786:09

provide the margin for the top of two

786:11

rims so that we can see that or you know

786:13

what six Rim would be fine God damn it

786:16

eight or nine rims nine Rim is looking

786:19

cool yeah nine Rim is looking cool now

786:21

underneath this label what do you want

786:23

to do we just want to create our input

786:25

field so I'll use like input and the

786:27

type will be set to file here we also

786:29

have to specify the ID which will be set

786:31

to profile upload okay like so we're

786:34

going to be also providing the except

786:36

flag which will be set to image in every

786:39

single image okay and class name will be

786:42

set to Hidden so we just want to hide

786:43

there and when somebody try to change

786:45

there we're going to be firing this

786:47

function which will handle which will be

786:49

handle profile change I'm going to copy

786:52

the name of there go to the top and

786:54

create this function underneath that

786:55

I'll just use like con handle profile

786:58

change it's going to take the event and

787:00

that's going to be set to any and here

787:02

I'm going to write like file not files

787:05

but just a file which will be coming

787:07

from the event. target. file or God damn

787:11

it files and the first file now to need

787:13

that we just have to check if we have

787:15

the file so in this situation we are

787:17

going to be using like set profile URL

787:19

and we are going to be providing a URL

787:21

API and then inside there we have our

787:24

create object URL and then just P our

787:26

file inside there okay so here you can

787:28

see if I click on there but before I do

787:30

I'm going to have to save my profile

787:32

image and also save there now let me

787:34

click on this icon I can choose my image

787:36

and who is this amazing guy

787:39

awesome so yeah I can change the

787:42

background color and I mean like

787:43

background image and I can also change

787:45

the profile image now underneath this

787:47

button we're going to be providing our

787:49

Channel details details there we go and

787:53

now need the let crate over D with the

787:55

class of margin for the left will be set

787:56

to four margin for the top will be also

787:59

set to four okay so H1 with the class of

788:01

text to Excel and font will be set to

788:04

bold which will take my own name you can

788:06

specify your own name name if you wanted

788:08

to Sol right like hosan web dev baby see

788:11

if I save there we're now getting there

788:13

but that's not looking that cool set

788:16

just provide a margin for the left of

788:18

four would be fine and now underneath

788:21

them we're going to be creating our

788:22

paragraph with the level of 1 million

788:24

views did I even get a 1 million views

788:27

not quite sure about that but create a

788:29

paragraph with the class of margin for

788:31

the top of two and which will have a bit

788:33

of description I'm going to just place

788:34

this description right here like this is

788:36

a short description for the YouTube

788:37

channel it gives the overview of the

788:39

content and what viewer can expect or

788:42

yeah expect so I'll also provide the

788:46

margin for the left of four to this one

788:49

for REM copy there and create a class

788:52

name for the paragraph and place that

788:54

there still amazing finally I'm going to

788:57

create a subscribe button and you guys

788:59

should subscribe to my YouTube channel

789:01

so margin phot top will be set to four

789:04

and background color will be set to Red

789:06

of 600 and I'm going to also provide a

789:08

text of totally white ping for the Y AIS

789:10

will be two ping for the xaxis will be

789:12

four and totally rounded and whenever

789:15

somebody H over there we are going to be

789:18

doing that arbitrarily so I'll just

789:20

write like background totally red and

789:23

500 inside the and inside this BT I'll

789:25

just say like

789:27

subscribe subscribe baby sem my file now

789:31

we are getting our subscribe button but

789:32

we also have to specify the margin for

789:35

the left or for Rim like so and yeah

789:39

this is looking better now that we have

789:41

to create our tabs component so I'm

789:42

going to create a component with the

789:43

name of tab. TSX or tabs rather and I'm

789:47

going to be using my rafc inside there

789:49

now let me just save this file and here

789:51

we have to call our tabs component right

789:54

here okay so I'm going to save my file

789:56

right now check this out so here you can

789:58

see we have our TS component which is

790:00

looking cool so what I'm going to do is

790:02

that first of all let me just zoom in a

790:03

bit I'm going to place the tabs data

790:06

right here okay so here you can see we

790:07

have our tabs array and inside this tab

790:10

array we have a few objects so each

790:11

object will have the ID icon label and

790:14

content so this is how our content will

790:16

look like first of all we are going to

790:17

be creating array with the six item and

790:20

then we're going to be iterating over

790:21

through each of that item then we're

790:23

creating a card component and that card

790:26

component will accept the key prop title

790:28

description and also the image okay so

790:31

yeah here you can see we have there like

790:32

a few times and we are going to be

790:34

trading over through there so what I'm

790:36

going to do is that I'm going to just

790:37

import all of that icons like first of

790:39

all we're going to be importing the fa

790:41

home and we are going to be also

790:43

creating this card or you know let me

790:44

just create this card right away so I'm

790:46

going to just create a component with

790:47

the name of card. TSX and let's just use

790:50

our rafc inside there and I'm going to

790:52

also import that right in here I'm going

790:55

to remove this D and rewrite that and

790:57

hit enter so it's going to import there

790:58

right here okay so let's just import

791:02

this icon and we are going to be also

791:04

creating the about component so I'm

791:06

going to also do that right now now okay

791:08

let's SC we about TSX and use the RFC

791:12

inside there save this file and go to

791:15

this steps component and import my about

791:18

right here okay and we're going to be

791:20

also importing this this icon let's just

791:23

import this icon I'm going to also

791:26

import this phone icon and I guess

791:28

that's going to be the last one we also

791:30

have to create this contact component so

791:31

I'm going to create a component with the

791:32

name of contact. TSX and I'll just use

791:35

the RFC inside there and now let me

791:37

import there right here so if I save my

791:40

file so that's going to be like all of

791:41

the data so I'm going to collapse that

791:43

and yeah that's done next thing that we

791:45

have to do is that we have to create our

791:48

state forward tab so I'll just write

791:50

like uh active Tab and then set active

791:55

tab it's going to be equals to the use

791:57

St and for the initial value we're going

791:58

to be providing all of the tabs data and

792:01

we are going to be getting the first

792:03

stab out of there and from that first

792:05

step we going to be getting the IDE

792:07

okay so that's done now let's get into

792:09

the UI so I'm going to remove this tab

792:11

from here I'm going to provide a class

792:13

name and pairing all around will be set

792:14

to four margin for the top will be set

792:16

to three R and inside this D we're going

792:19

to be creating a d with a class of flex

792:21

and Border for the bottom and also

792:23

border gray of 200 let me just go back

792:26

and inside this div now we going to be

792:28

iterating over through all of their tab

792:31

okay so what I'm going to do is that I'm

792:32

going to write like tabs and then it

792:34

right over through all of their Tab and

792:36

let me just spr it tab like so inside

792:38

there we're going to be creating our

792:40

button and this button will have a lot

792:42

of styling but you know what yeah I'm

792:45

going to just do that right now for the

792:46

key we're going to be getting the key by

792:48

using the tab. ID I'll also provide the

792:51

class names today but they will be

792:52

dynamic so I'm going to have to use the

792:54

template leral for the so I'll use like

792:56

Flex one text will be set to totally

792:58

Center pairing for the y axis will be

793:00

set to two pairing for the xaxis will be

793:02

set to four and font will be set to

793:05

medium like so text Will to totally

793:07

small and we have to render our active

793:10

tab right here so if our tab is active

793:13

and let me just write like triple equals

793:14

to tab. ID so if that's the case so in

793:18

this situation we're going to be

793:19

changing the border to border bottom of

793:21

two but if that's not the case we're

793:23

going to be setting there to Tex gray of

793:26

600 right here let me just write a 600

793:29

God damn it 600 and when somebody clicks

793:32

on there they're going to be fing this

793:33

function so I'll just use like this aror

793:35

function which will say like said active

793:37

Tab and here we have to specify the tab.

793:40

ID inside there inside this button we're

793:43

going to be creating a d with the class

793:44

of Le and then items me just write items

793:47

and Center we're going to be also

793:49

providing a justify of Center space will

793:51

be set to the xaxis of two inside this

793:53

de I'll just use like uh what do we call

793:55

it tab. icon and also underneath there

793:59

I'm going to create a span which will

794:00

tag the tab. label I'm going to save

794:03

this file so we are now getting these

794:05

tabs if I click on the about it's going

794:07

to gives us the about section if I click

794:09

on the project so it's going to gives us

794:10

the project courses and also the contact

794:13

so that's looking cool now underneath

794:15

this div what I'm going to do is that

794:17

I'm going to create a div with a class

794:18

of margin for the top will be set to

794:20

four pairing will be set to four and

794:22

also totally rounded large and inside

794:25

this one we're going to be using tabs.

794:27

find and here we have to specify the tab

794:30

and now we just have to use a tab. ID

794:32

that's going to be triple equals to the

794:34

active tab let's just WR our active Tab

794:36

and if that is the case we only want to

794:39

get the content out of there now let me

794:40

just save my file and here you can see

794:42

it's going of gives us like card card

794:43

card that much time so what I'm going to

794:46

do is that I'm going to go into my card

794:47

component and now let me just take care

794:49

of that time to create the card

794:51

component so we first of all need the

794:54

title description the image and also the

794:58

link from our props and for them we are

795:01

going to be also creating an interface

795:03

so I'll just create interface with the

795:04

name of card props and inside there

795:06

let's just Prov our title and that's

795:08

going to be a string and

795:10

description will be also a string and

795:12

the image will be string and finally we

795:15

have to provide the link everything is a

795:17

string okay and we have to also inate

795:20

the with our card prop right here sa my

795:23

file next we have to use there so what

795:26

I'm going to do is that I'm going to

795:27

just remove this card go back and inside

795:29

there we will first of all Define our

795:32

card by providing a Max come on let's

795:34

just provide our Max with of small and

795:36

also provide the MX like margin for the

795:38

x-axis will be set to Auto and margin

795:40

all around will be set to one ram and

795:42

let's just put the background color and

795:44

background color will be set to uh 1 A 1

795:47

C and 1 E like so and we're going to be

795:51

also providing a rounded large Shadow

795:53

will be set to medium and overflow will

795:57

be set to Hidden in this case now let me

795:59

just use my image and for the image

796:01

we're going to be rendering our image

796:03

totally dynamically so I'll just use the

796:04

image I'll just write like right here

796:08

and I'm going to also provide the class

796:09

name withd will be set to totally full

796:11

and also height will be set to 48 like

796:14

so and object will be set to totally

796:17

cover so that we can see all of this now

796:20

let me just save my file and here you

796:21

can see we are now getting all of their

796:23

images which are looking great now

796:25

underneath we're going to be defining

796:26

our D with the class of pairing all

796:29

around will be set to six and now inside

796:31

there let's just use our H2 with the

796:33

class of text 2 Excel and the font will

796:36

be to totally Bard margin for the bottom

796:38

will be set to two and here let's just

796:40

render our title like so we're going to

796:43

be also using a paragraph with a class

796:45

of text totally set to gray of 700

796:48

margin for the bottom will be set to

796:50

four and let's just render or

796:52

description right here so I'll just use

796:54

a description and now to need that we

796:57

have to create our anchor tag which will

796:59

not take anything but we are just going

797:01

to be providing our link right here so

797:03

I'll just use a link and I'm going to

797:05

provide a lot of class names to it so

797:06

I'll just use like inline block and also

797:09

pairing for the xaxis will be set to

797:10

four pairing for the y- axis will be set

797:12

to two background color will be set to

797:14

totally white text color will be set to

797:16

totally black font will be semi bold

797:19

like so and totally rounded large and

797:24

Shadow whenever somebody H over there so

797:26

we just want to change the background

797:28

color to gray of 600 and also on the

797:31

hour text will be set to totally white

797:33

we going to also specify the Transitions

797:35

and duration will be set to 200 inside

797:38

this anchor tag we will just select

797:39

learn more if I save my file and this is

797:42

how it looks like but they are looking

797:45

off they are looking super awful to fix

797:47

that I'm going to go into my CSS and

797:50

provide this line of CSS so we only want

797:52

to change the background color to this

797:53

one and provide a text color to that one

797:56

okay so now if we change that and that's

797:59

not looking that cool yeah it is not

798:02

looking that cool remove that once again

798:05

also remove the text color and and yeah

798:07

it is looking cool yeah it is looking

798:10

great so we can do a lot sort of stuff

798:13

with them but you know I don't have a

798:14

lot of time for this UI you can change

798:16

the UI to like however you want but I

798:18

only want to focus on the logic so let's

798:21

get into the about section the about

798:23

section will be super straightforward so

798:25

I'll just go ahead and remove the about

798:26

right here and change that to section

798:29

and also change that one to section as

798:31

well and let's just provide our class

798:33

name of background gray of 100 and

798:36

pairing for for the y axis will be set

798:37

to 12 pairing for the xaxis will be set

798:40

to four and for the smaller screen size

798:42

we're going to be setting the pairing

798:43

for the xaxis of six and for the largest

798:46

screen paing for the xaxis will be set

798:48

to add Okay add and inside this section

798:51

we're going to be creating a d with the

798:53

class of Max with which will be set to

798:55

for Excel and also margin for the xaxis

798:58

will be set to Auto inside this D let's

799:01

just create our H2 with the class of

799:02

text two 3 XEL to be precise and font

799:05

will be set to extra Bol okay and the

799:09

text will be also set to gray of 900 and

799:12

margin for the bottom will be set to

799:14

four God damn it six there we go and I'm

799:18

going to write like about husan and you

799:20

can specify your own name and here you

799:22

can see we now getting our about H which

799:24

is looking great but now underneath this

799:26

H2 what do you want to do you just want

799:28

to create our paragraph in which will

799:30

select text of totally large and text

799:32

will be set to gray of 700 now let me

799:34

just place all of this stuff about

799:36

myself

799:37

you don't even have to worry about any

799:38

of that and you can also copy and place

799:41

there or you can just ask CH gbt to

799:42

write there for you and now underneath

799:44

then I'm going to also create a

799:46

paragraph once again with the class of

799:48

margin for the top will be set to four

799:50

text will be set to um extra not extra

799:54

large but just large text will be set to

799:56

gray of 700 so I'll just write a 700 and

799:59

hit enter and inside then I'm going to

800:01

place my more content so these are just

800:03

the videos if you want to watch them and

800:06

this this is just about section about me

800:09

now let me just go ahead and go to the

800:11

projects and that's also done we also

800:13

have to go into the courses that's also

800:15

done but finally we have to take care of

800:17

this contact Section and we are done now

800:19

let me go ahead and go to my contact and

800:22

let's just provide my contact Section

800:24

right here as you can see I have a links

800:26

array and inside this array I have a few

800:28

object each object will have the

800:30

reference the label and also the icons

800:32

so what I'm going to do is that I'm

800:34

going to also place all of that icons

800:36

right here here so that errors are now

800:38

successfully gone if you want to provide

800:39

your own links you are more than welcome

800:41

to do there but if you want to provide

800:43

mine so you can also go ahead and copy

800:45

that from my gab repository so let me

800:47

just close there and now we are going to

800:49

beating over through there and then we

800:51

are going to be rendering there so what

800:53

I'm going to do is that I'm going to

800:54

just remove this contact from here and

800:56

select this div and change there to a

800:58

section I'm going to provide the class

800:59

name of background gray of 100 pairing

801:03

for the y-axis will be set to 12 pairing

801:04

for the xaxis will be set to four and

801:06

for the smaller screen size we're going

801:08

to be providing pairing for the xaxis of

801:10

six and for the large screen size we are

801:12

going to be providing pairing for the

801:13

xais of add inside this section we're

801:16

going to be creating our H2 with the

801:17

classes of text 3 XEL and font will be

801:20

set to extra bold and text will be gray

801:25

900 and margin for the bottom will be

801:27

set to six so contact me and sa my file

801:31

now here you can see we're now getting

801:32

our contact me section right here and

801:35

now to need the let's just create or div

801:37

with a class of links and items is now

801:39

set to Center and here we're going to be

801:41

iterating over through all of that links

801:43

from here like as you can see we have

801:44

all of that links now you want to over

801:46

through all of them and provide each of

801:48

the link inside the links we're going to

801:50

be rendering our anchor tag and I'm

801:52

going to remove this HF and change that

801:55

to uh link. HF I'll also provide the key

801:59

and for this key I'll just rer like

802:01

link. label we also have to provide the

802:03

Target and Target will be set to- lank

802:07

WR the relation and also the classes so

802:09

for the classes flex and items will be

802:13

set to Center space will be set to X XIs

802:15

of two and text will be set to gray of

802:17

900 and somebody how over there so text

802:20

will be set to gray 600 margin for the

802:24

right will be set to two RS like so r

802:28

two r r m there we go and now inside

802:32

this one what do you want to do you just

802:33

want to write over uh link. icon save my

802:37

file and now underneath this link icon

802:40

let's just create our span the classes

802:42

will be text large this going be it and

802:45

here we have to render our link. Lael

802:47

like so and that's going to be it for

802:49

the contact Section so let's just check

802:51

this out here you can see we have a

802:52

Twitter or X nowadays we have a YouTube

802:56

GitHub and Instagram okay so there a

802:58

contact Section we have a courses

803:00

projects about and home we can also

803:02

provide our own profile image we can

803:04

also provide the banner image from our

803:07

computer and this is just our basic

803:09

project time to make a set of four or

803:11

third projects so let's just write npm

803:13

create we at latest the project name is

803:16

blogs and I'm going to choose reactjs

803:19

with typescript go into the blogs and

803:21

now let's just install every single

803:23

thing now I'm going to go into the

803:24

tailin CSS click on the getting started

803:27

go to the framework and guide now let me

803:29

copy this command and place a right here

803:32

inside my integrated terminal hit enter

803:34

to configure tment CSS and also I'm

803:37

going to copy this content let's just

803:39

copy there and go into my tailing config

803:42

and replace it with this content so

803:44

let's just do there I'm going to also go

803:46

ahead and copy every single thing from

803:48

there go to the index. CSS file and

803:50

replace it with this new one okay and I

803:53

guess that's going to be it but I'm

803:54

going to copy there let's just go into

803:56

the F do not CSS but f. TSX and remove

804:00

every single thing from there and I'll

804:02

just write RFC and let's just write this

804:05

H1 word here okay so I'm going to open

804:07

my terminal once again and use npm run

804:09

Dev and let's just check this out yep we

804:12

are getting a hello world but I'm going

804:13

to also make a bit of cleanup so I'll

804:15

just remove this assets folder the

804:17

public folder the app. CSS folder and

804:20

yeah I guess the rest of them will be

804:22

fine next we're going to be defining our

804:24

navigation so I'll just create a div and

804:26

inside this div we're going to be

804:27

rendering our navigation but first of

804:29

all let me just create a folder with the

804:30

name of components and inside there we

804:33

going to be creating our navigation. TSX

804:36

I'll use the RFC and register there

804:39

right here inside the app component like

804:42

navigation this component semi file and

804:45

here you can see we're now getting our

804:47

navigation which is looking cool so

804:48

let's just style our navigation then

804:50

we're going to be jumping into the next

804:51

stuff so I'll change this div to nav

804:54

because we are creating our navigation

804:57

and I'll provide a class name of Border

804:58

2 and text will be set to totally black

805:02

border will be gray of 200 pairing will

805:05

be set to four and it's going to be a

805:07

flex justify will be set to between and

805:10

items will be set to Center inside this

805:12

navigation we're going to be creating a

805:14

d with the class of legs and then items

805:16

will be set to Center border will be set

805:18

to two and totally rounded four paing

805:21

for the xaxis will be set to four ping

805:23

for the y- AIS will be set to two Max

805:25

width will be set to medium and margin

805:28

for the left will be set to arbitrary

805:30

value so I'll just use like uh five R

805:33

inside this we're going to be rendering

805:35

our icon but first of all we have to

805:37

install that so I'll use npmi and then

805:39

react icons so it's going to install the

805:42

in my machine now that's done let me use

805:44

my npm rund once again and I'll just use

805:47

like fa search from where from the react

805:50

icons so let's just render them now

805:52

underneath them we're going to be using

805:54

our input Fe with the type of text I'm

805:56

going to also provide the placeholder

805:58

which will say like search dot dot dot

806:00

and I will also provide the class name

806:02

background will be set to totally

806:04

transparent and also I'll outline will

806:06

be set to none and width will be set to

806:09

totally full okay I'm going to go back

806:12

so you guys can see everything a bit

806:13

better and this is how it looks like

806:16

right here I know it is looking awful

806:18

but yeah it is looking still a bit

806:21

better now underneath this day we're

806:22

going to be creating a section with the

806:24

class of flex and then items come on

806:27

items will be set to Center and I'm

806:29

going to also provide margin for the

806:31

right of five Rim like so and inside

806:35

this section let's just render our fa

806:37

user Circle okay render them and I'm

806:41

going to provide the class name of text

806:43

will be set to 3 XEL margin for the

806:45

right will be set to two if I sell my

806:47

file and check this out so here you can

806:49

see we now getting our icon we are also

806:51

getting this search field word here now

806:53

I'll go to my f. TSX once again and here

806:56

inside there I'll create with a class of

806:58

flex and justify Center and inside this

807:01

D we're going to be creating our main

807:04

area right here but not right now now

807:06

now underneath we're going to be

807:07

creating our div with the class of width

807:10

and the width will be arbitrary value

807:12

like

807:12

30% and let's just close there inside

807:15

this div we're going to be defining a

807:17

few component let's just start from a

807:19

people to follow component so I'll just

807:20

create a component with the name of

807:22

people to follow. DSX and I'm going to

807:25

use my rafc inside there and render

807:28

people to follow right here semi file

807:32

and here you can see we now getting more

807:33

people to follow component which is

807:36

looking great so the first thing that I

807:37

want to do is that I want to place these

807:39

people to follow and we have a few

807:40

people names and also the following list

807:43

so what I'm going to do is that I'm

807:45

going to iterate over through there and

807:46

render there into this component okay so

807:49

I'll just remove this people to follow

807:51

I'm going to provide a bit of classing

807:52

to it so background will be set to

807:54

totally white and padding will be set to

807:56

four and round it totally large Shadow

808:00

and now underneath there create H3 with

808:02

the class of font semibold text will be

808:05

Lar mer and merger for the bottom will

808:07

be set to four which will select people

808:11

uh or who to follow whatever you want to

808:13

call them then create a with a class of

808:15

space y inside the list is itate or

808:18

through all of that people to follow so

808:20

I'll just put that right here and I'm

808:22

going to use the map method it's going

808:23

to take the person and also the index

808:26

and inside this Arrow function we're

808:28

going to be creating our user card which

808:30

will take a key as a prop and inside the

808:32

key we're going to be providing our

808:34

index and then it's going to also take

808:35

the person is the main value okay so I'm

808:38

going to close there and create my card

808:40

component right here I'll just use a or

808:43

user card. TSX inside there let's just

808:47

use our RFC sem my file and render that

808:50

right here so we have to render our user

808:53

card component and here you can see

808:55

we're now getting user card user card a

808:57

lot of time now let me go into this user

808:59

card and create there so it takes the

809:02

index and it also takes the person okay

809:05

so let me just create

809:06

uh interface for this so like user

809:08

interface user card props or something

809:12

like that I'll provide index which will

809:14

be set to a number and I'm going to also

809:16

provide a person which will be set to a

809:18

string and I'll annotate there with the

809:20

user card prop and now let's get into

809:23

the UI I'm going to remove this user

809:25

card from here and I'm going to put the

809:27

class name to this so let's just put a

809:30

flex and items will be set to Center and

809:32

justify will be set to between in this

809:34

case inside this

809:36

let's we're going to be creating a

809:38

section with a class of legs and items

809:40

will be set to Center inside there let's

809:41

just render our icon which is fa user

809:44

Circle and render there right here with

809:47

also these classes like text will be set

809:49

to 3 XEL margin for the right will be

809:51

set to three and text will be set to

809:53

totally gray of

809:54

500 500 like so now let me just save my

809:58

file and here you can see we're now

810:00

getting that icons right here which is

810:02

looking cool but now underneath that

810:03

we're going to be also creating a spin

810:05

and let's just render our person. name

810:08

inside there and yeah this is how it

810:10

looks like and they are looking cool now

810:12

underneath this Dev uh or this section

810:14

to be precise we're going to be creating

810:16

our button and inside this button we

810:18

will just say like person f o l o w iing

810:23

if that's the case we are going to be

810:24

saying like following but if that's not

810:27

the case so we will just say like follow

810:29

and here you can see we now getting the

810:31

follow button and also the following

810:33

button right here now let me just style

810:34

that a bit but that St triling with

811:21

now let me go ahead and create another

811:23

component with the name of uh Trends

811:26

list. TSX and I'm going to use the RFC

811:29

inside come on RFC inside there once

811:32

again and go to my f. TSX and render

811:35

this comp component right here like

811:36

Trends list yeah and render there this

811:40

is how it looks like is there I'm going

811:42

to render all of their Trends right here

811:44

so you can also copy that from my giab

811:46

repository if you wanted to so basically

811:48

we have array with the name of Trends

811:50

inside there we have a few objects which

811:51

will have a title and also the author

811:54

okay so you can also create that by

811:55

yourself if you wanted to but if you

811:57

want to copy that from my gab repository

811:59

you can totally do that so I'll just

812:01

remove this Trends list from here and

812:03

I'm going to provide the class name

812:04

background will be set to totally white

812:06

pairing will be on around set to four

812:08

and rounded large Shadow will be also

812:11

provided and margin for the top will be

812:12

set to eight and inside this da we're

812:14

going to be creating our H3 with a class

812:16

of font semi Bold and the text will be

812:20

set to totally large margin for the

812:21

bottom will be set to four and I'll just

812:23

say like today's uh top trends or

812:27

something like that now if I save my fil

812:29

so this how it looks like they are

812:31

looking great and now let's just use our

812:33

UL with the class of uh space on the y-

812:36

AIS will be set to four and I'm going to

812:38

itate all through all of their Trends by

812:40

using the map method it's going to take

812:42

the trend and also the index so inside

812:45

this function what do you want to do we

812:47

just want to get our Ali and inside that

812:49

lii first of all let me just provide a

812:50

key and the key will be that index and

812:52

I'm going to also provide the class name

812:54

let's just write a class name class name

812:56

will be set to flex and flex will be set

812:58

to column inside that Ali we're going to

813:00

be using our span spin like so and

813:03

proide the font of medium turn so in

813:06

this case we're going to be using trend.

813:09

title and now need this span we're going

813:11

to be creating our span once again with

813:14

the class of text small and also the

813:16

text will be set to gray of 500 okay and

813:20

by who by the trend and then do author

813:25

come on go to the top remove that icon

813:28

from there and change this one to trend.

813:33

author now that's done let me check this

813:36

out so yeah there other component which

813:37

is also looking cool now I'm going to go

813:39

to the ab. TSX file once again and

813:42

create my topic list component so I'll

813:44

use like topics list. TSX and create my

813:48

component right here and register that

813:51

topics uh list component here I'm going

813:54

to sa my file go there once again and

813:57

the first thing that I want to do is

813:58

that don't want to just place these

813:59

topics like we have technology and

814:01

design and thinking and so on and so

814:03

forth I'm going to place that here now

814:05

I'm going to go into my UI so I'll

814:07

change the background to totally wide

814:09

pairing will be set to four totally

814:10

rounded large and Shadow margin for the

814:13

top will be set to eight and inside this

814:15

D we're going to be creating our H3 with

814:17

a class name of font semi bold and also

814:20

the text will be set to totally large

814:22

margin for the BM will be set to four

814:24

which will say like topics uh for you sa

814:28

my file once again and we are now

814:29

getting our topics for you right here

814:31

now underneath the I'll create with a

814:34

class of flex and also Flex will be set

814:35

to W and WP like so and GAP will be set

814:40

to two inside this D we're going to

814:42

beating over through all of their Topics

814:44

by using the map method and provide my

814:46

topic let's just write a topic and also

814:49

the index inside there and this pen will

814:51

have pairing for the xaxis of three and

814:53

piring for the y- axis of one background

814:55

will be set to gray of 200 and the text

814:58

will be set to gray of 700 like so if I

815:02

hit Tab and I'm going to also provide a

815:04

text of totally small

815:06

and rounded full cursor will be also set

815:09

to pointer and when somebody how over

815:11

there change the background to gray of

815:14

300 and I'll also specify the key and

815:17

the key will be our index inside this

815:19

pen what do you want to do we just want

815:20

to render their specific topic and now

815:23

let me just save my file and check this

815:25

out so here you can see we are now

815:26

getting all of the Technologies and

815:27

stuff uh topics right here now let me

815:30

create my context so the first thing

815:31

that I want to do is I want to create a

815:33

folder with the name of shared and

815:34

inside there we going to be creating our

815:36

block context. TSX and here we will need

815:40

a few thing like create context we would

815:42

also need the user and also they use

815:45

context as well okay and now underneath

815:48

there let's just Define our context I'll

815:49

just use like create context and the

815:51

initial value will be undefined and I'm

815:54

going to store there some sort of a

815:55

variable like block context and it's

815:57

going to be equals to this context so

815:59

now let me also create an interface for

816:00

there so let's just create our interface

816:03

and here it's going to take like block

816:05

context type and inside this one first

816:08

of all we are going to be creating our

816:09

blocks this will be a huge block so I'm

816:11

going to separate that into a separate

816:14

file so I'm going to go ahead and create

816:15

my file right here with the name of

816:17

types. TS and I'm going to just place

816:19

these types right here so we have ID

816:21

which will be a number the title will be

816:23

string description will be string the

816:25

image will be string and the time will

816:26

also be string okay so what I'm going to

816:29

do is that I'm going to grab that right

816:31

here and underneath that we're going to

816:33

be also defining our add block that's

816:35

going to be a function which will take a

816:36

Blog as a perimeter we're going to be

816:38

also providing the blogs as a type and

816:40

it's going to return the wide and now

816:42

also let's just provide our update blog

816:44

it's going to be set to the blog once

816:47

again and here we have to annotate the

816:49

with the blog and inside there we're

816:51

going to be only returning the white and

816:52

also we have to delete the blog so let's

816:54

just put to our ID and ID will be set to

816:56

a number and it's going to return the

816:59

white okay so now that's St done I'm

817:01

going to annotate my context by using

817:04

this block cont context type or

817:07

undefined so initially we're providing

817:09

the value of undefined today so that's

817:11

great now that we have to create our

817:12

provider so I'll use a cons and then

817:15

block provider and here we're going to

817:18

be annotating there by using react J and

817:20

then functional component okay so if you

817:22

want to annotate them we're going to be

817:24

providing a children and for this

817:25

children we're going to be using react.

817:27

react node which will be coming from the

817:30

reactjs and now let's just create our

817:33

context right here so what I'm going to

817:35

do is that I'm going to only provide my

817:36

children now let me just save there the

817:39

first thing that I want to do is that I

817:40

want to just use my use St and the

817:42

initial value will be set to this empty

817:44

array and I'm going to also inate with

817:47

the block and here we have to just write

817:49

a block of array I'm going to

817:51

restructure the blogs and also the set

817:53

blogs out of there now we are going to

817:55

be also creating a function which allows

817:57

us to add a Blog so I'll use like add

817:59

blog and it's going to be equals to the

818:01

blog and I'm going to also annotate the

818:03

with that blog okay and inside we're not

818:05

going to be doing anything crazy but

818:07

I'll just write like set blocks and

818:08

first of all we have to clone our

818:10

existing blocks and then we have to add

818:12

our new one now underneath there we're

818:14

going to be also creating one for the

818:16

updating a Blog so I'll just use update

818:18

blog and here we have to write like

818:20

update blog and annotate the with or

818:23

blogs type inside there I'm going to use

818:25

my set blocks because we are going to be

818:27

mutating them and here we have to itate

818:29

over through all of the blogs I'll use

818:30

like blogs. map and let's just provide

818:32

our block to them and here we're be

818:35

checking if block bog blog. ID is triple

818:39

equals to the updated blog. ID in this

818:42

situation we going to be rendering our

818:44

updated blog come on uh updated blog but

818:48

if that's not the case we're going to be

818:50

rendering our blog just like there I'm

818:52

going to copy this updated blog and now

818:54

let me just put that here and finally

818:56

let me create one more function for the

818:58

delete block I'll write a delete Block

819:00

it's going to take the ID and ID will be

819:02

a number and inside there we're going to

819:04

be using our set blogs here we have to

819:07

provide our blogs and use a filter

819:09

method and it's going to take the

819:10

perimeters we're going to be providing

819:11

the blog as a perimeter we are going to

819:13

be removing that specific block whose ID

819:16

is not equal to the ID which we are

819:18

providing for the perimeter okay so now

819:20

that we successfully created or stad the

819:22

add function update function and also

819:24

the delete function now let me provide

819:26

there by using my provider or context

819:29

provider so what I'm going to do is that

819:30

I'm going to just return and inside I'm

819:32

going to be using my block context which

819:34

we've created it up above and here it

819:36

has a provider property so I'm going to

819:38

call them and now for the value I'll

819:41

just provide my value right here like

819:43

blogs and then add blog and update blog

819:47

and also delete blog like so now inside

819:50

there we're going to be also rendering

819:51

our children that's going to be it for

819:54

the blog I also create a hook for myself

819:56

I can totally create in the separate

819:58

file but I guess I don't have to so I'm

820:00

going to export that because we're going

820:01

to be using the into multiple file so

820:03

I'll use like use blogs and inside there

820:06

we're going to be first of all consuming

820:08

our context so for that we're going to

820:09

be using our use context and provide my

820:12

block context inside there and I'm going

820:14

to also store there in the context uh

820:16

variable so I'll just use like context

820:18

and now underneath there I'm going to be

820:20

checking if you don't have the context

820:22

so in this situation we're going to be

820:24

throwing new error which will say like

820:26

use blocks must be used within a Blog

820:31

provider and now underne this check we

820:33

are going to be just returning or

820:35

context and that's going to be fine okay

820:37

so now we are totally done with this

820:38

provider but we also have to export them

820:41

so we can use them so I'll just use like

820:43

export and then we will be able to use

820:46

there now I'll use my provider to

820:49

provide all of that Valu so I'll just

820:50

use like block provider and then I'm

820:53

going to close that right here like so

820:57

now here inside this main area what I'm

820:59

going to do is that I'm going to create

821:01

a section with the class of margin for

821:03

the xaxis will be set to Auto and and

821:05

pairing will be set to six and inside

821:07

this section we're going to be creating

821:08

our div and then create a button and

821:11

which will have a few classes like uh

821:13

you know let me just put a bit of

821:14

classes to it like margin for the left

821:16

will be set to seven R background will

821:18

be set to totally black flex and justify

821:21

will be set to Center and items will

821:23

also be set to Center text will be set

821:25

to totally white and pairing for the

821:27

x-axis will be set to four pairing for

821:29

the y axis will be set to two totally

821:31

rounded margin for the bottom will be

821:33

set to four inside therefore the I'll

821:35

just use like add new block and here

821:37

we're going to be adding a new block so

821:40

I'll just use like IO MD add Circle and

821:43

hit enter so it's going to add there

821:44

right here and for the class name I'm

821:46

going to provide the margin for the left

821:48

of zero of5 rims case now if I save my

821:52

file check this out so here you can see

821:54

we are now getting our button which is

821:55

looking cool but we're going to be also

821:57

attaching a event handler on there so

821:59

when somebody clicks there we're going

822:01

to be fing this function which will be

822:03

open model for new block

822:05

okay so we're going to be creating this

822:06

function in a few second but first of

822:08

all we have to create our stat so I'm

822:10

going to go to the top and create my

822:11

stat right here I'm going to Define

822:13

these two State like is model open and

822:15

then set is model open and inside there

822:18

we're going to be also getting or Us St

822:21

and also editing block and set editing

822:23

blog and we're going to be getting our

822:25

block types from this types file as now

822:28

underneath we also have to Define two

822:30

functions so for the first function we

822:32

going to be defining like open model for

822:35

new block inside this function what do

822:37

you want to do set editing block you

822:39

want to set that to now and then set

822:41

model open and you want to set there to

822:43

true now underneath this function we're

822:45

going to be defining one more function

822:47

for the open model 4 edit and here

822:52

inside this function we going to be

822:53

saying like set editing blog and the

822:55

initial value will be set to blog and

822:57

also set model open here we're going to

823:00

be setting that to true now that's

823:02

successfully done I'm going to go to my

823:04

UI once again again now underne this

823:06

button what do you want to do here we're

823:08

going to be also rendering our article

823:10

list component which we're going to be

823:12

creating in a few second but now I'm

823:14

going to check if our model is open then

823:18

show this UI but if our model is not

823:20

open then don't show anything at all and

823:22

I'm going to first of all create my

823:24

model component which I am going to do

823:26

in a few seconds so I'm going to close

823:28

there and it's going to take a lot of

823:30

things and it should be a model like so

823:32

I'm going to copy there and place it

823:34

right here and now let me just go ahead

823:36

and create this model component inside

823:38

my components folder so I'll use like

823:40

model. TSX and Define my model component

823:43

right here so I'll use my RFC inside

823:46

there and here what I want to do I want

823:48

to use my react and then functional

823:51

component from the reactjs and here it's

823:53

going to take a children so I'll just

823:54

write like children and that children

823:57

will be react. react node just a react

824:00

node like so and I'll also close them

824:03

and now the next thing that we have to

824:04

do is that we we also have to specify

824:06

the own close prop it's going to be a

824:08

function it's going to just return the

824:09

wide okay so that's already done I'm

824:12

going to close there like so now for the

824:14

actual props we're going to be only

824:16

returning the children and then the on

824:18

close right here so now if I save my

824:20

file so this is how it looks like and

824:22

now for this UI I'm going to first of

824:24

all provide a lot of classes like fixed

824:27

and then insert will be set to zero and

824:29

background will be set to totally black

824:31

background opacity will be set to 50 in

824:34

this case and also Flex items will be

824:37

Center justify will be Center and inside

824:40

this div we going to be creating yet

824:42

another div with a class of background

824:43

totally wide pairing will be set to four

824:45

totally rounded large and also shadow in

824:48

this D will be relative like so and

824:51

provide my children inside there and now

824:53

underneath there we're going to be also

824:55

creating a button and which will just

824:57

say x like cross and we're going to be

824:59

also providing a classes for this one as

825:01

well like absolute top will be set to

825:03

two right will be set to two and text

825:06

will be set to gray of 500 100 lik God

825:10

damn 500 there we go and when somebody

825:13

clicks on this button so we're going to

825:14

be firing the on close on close function

825:18

which it is taking as a prop now our

825:20

model is totally done we have to import

825:22

that model right here and I'm going to

825:24

just hit enter so it's going to import

825:25

that here for this model I'm going to

825:27

pass my own close function on close and

825:31

that function will be just an arrow

825:33

function which will just say like set

825:34

model open and here we have to specify

825:37

the false value inside there and inside

825:39

this one we're going to be also

825:40

providing our blog form which we are

825:43

going to be creating in a few seconds so

825:44

now let me just save my file and create

825:46

this blog form component so I'm going to

825:48

just use like blog

825:50

form. TSX and I'm going to use my RFC

825:54

inside there and import my blog form

825:56

component right here check this out so

825:58

if I click on there it's going to gives

826:00

us that block form it's going to also

826:02

gives us that X symbol so if I click on

826:03

this it's going to make it up here now

826:05

let's start work on this block form

826:07

component so it's going to take two

826:08

props so the first prop it will take is

826:10

the existing block this going to be set

826:12

to the editing blog which we' have

826:13

defined up above and I'm going to also

826:15

provide the on close so on close and

826:18

it's going to take the arrow function so

826:20

I'll just use like Arrow function by

826:22

providing a set model open and I'm going

826:23

to change their two fils okay so now let

826:25

me just save my file and let's just go

826:27

into this blog form component and the

826:30

first thing that we have to do is that

826:31

we have to grab our custom hook which is

826:34

the US blog okay we already find the in

826:37

the cont and what I want to do is that I

826:39

want to just destructure uh the add blog

826:42

and also the update blog from where from

826:45

the used blog okay and now underneath

826:48

that we're going to be also defining our

826:50

title and then set title and this going

826:52

be equals to the use State and for the

826:54

initial value we going to be first of

826:56

all destructuring our existing blog uh

826:59

you know what let me just go ahead and

827:01

grab the name of them so I'll just copy

827:03

the name of that put the right here and

827:05

I'm going to also get this on close and

827:07

put there right here so now it's going

827:09

to gives us a lot of Errors so I'm going

827:11

to use my react functional component and

827:14

annotate there with the blog form props

827:17

and now let me just create their types

827:18

right here so we're not going to be

827:19

doing anything crazy but we're going to

827:21

be creating our interface with the name

827:23

of blog form props it's going to take

827:25

the existing blog and we have to

827:26

annotate them with our blog which we're

827:29

going to be getting from these types and

827:31

now we also have to provide the on close

827:34

and it's going to be just a function

827:35

which will just return the wi that's

827:37

really done and we now successfully

827:39

annotating there and now we have to use

827:41

the inside our component so what I'm

827:43

going to do is that I'm going to also

827:44

create a state for the description

827:46

description and then set description

827:49

it's going to be equals to the US and

827:52

here I also forgot the initial value for

827:55

this one so if we have the existing

827:57

block and then we're going to be getting

827:59

a description out of there so if you

828:01

already have there so then use there but

828:03

if you don't have there then we're going

828:05

to be Shing there to empty string and

828:07

now for this description we're going to

828:08

be also providing the uh existing

828:11

existing blog and from this existing

828:14

blog we're going to be getting a

828:15

description and for this one we going to

828:17

be getting a title there we go okay so

828:20

if you already have the existing

828:21

description then use them but if you

828:23

don't then just provide the empty string

828:26

Right Here and Now underneath that we're

828:28

going to also creating a state for the

828:30

image and then set image this going to

828:31

be equals to the U State and we're going

828:33

to be using the existing data exis s t

828:37

iing existing block if you have this we

828:40

want to get an image out of there but if

828:42

you don't so we just want to set that to

828:43

empty string now let me just provide one

828:45

for the time and then set time it's

828:48

going to be equals to the used St and we

828:50

are going to be getting our data from

828:51

this existing block if we have that data

828:54

then use that data but if we don't then

828:56

we're going to be setting that to empty

828:58

string now we are going to be using a

829:00

side effect so like whenever our

829:02

component first renders so we just want

829:04

to f all of that field I'm going to be

829:06

providing my existing blog okay so

829:09

whenever our component first rendered so

829:11

it's going to take all of that data it's

829:13

going to fill that inside their input

829:15

field so I'm going to just write like

829:16

first of all if we have the existing

829:18

block come on existing block so in this

829:21

situation we are going to be getting the

829:23

set title and we have to provide our

829:25

existing block data to this I'll use

829:27

like existing L you know I'm going to

829:30

have to copy there and I'm going to use

829:31

my title and now we are going to be

829:33

doing exactly the same thing for the

829:35

description so existing block.

829:37

description and also the set image

829:41

whenever our component rendered so we

829:42

are going to be also providing the image

829:44

and finally for the time okay so I'll

829:46

just write like existing block. time and

829:48

that's going to be fine okay so then

829:50

said now let me just go back and now

829:52

let's get into this UI I'm going to

829:54

remove that from here and provide my

829:56

class name so for this class names the

829:58

background will be set to totally wide

830:00

pairing for all around will be set to

830:02

six rounded large and also with will be

830:04

set to 30 rim and also margin for the

830:07

xais will be set to Auto and here we

830:10

have to use our H3 with the classes of

830:12

font semi bold and text will be set to

830:14

extra large and the margin for the

830:16

bottom will be set to two text will be

830:18

set to totally gray of 800 okay inside

830:22

this one we're going to be checking if

830:23

we have the existing blogs so then we

830:25

will say like edit blog but if we don't

830:28

have there then we're going to be

830:29

changing there to add block okay so now

830:32

let me just save my file and test this

830:33

out so here you can see we have like add

830:35

new block so if I click on there now

830:37

it's going to use us like add block

830:39

because we don't have any data inside

830:41

there so that's why we are now getting

830:42

like a block so that's cool now

830:45

underneath this H3 we are going to be

830:47

defining our dat with the class of space

830:49

on the y- axis of four and then inside

830:52

the we're going to be defining our input

830:53

field with a type of text and also the

830:56

placeholder will be set to title and

830:59

here we're going to be also providing

831:00

the value and the value will be coming

831:02

from this St so I'll just get the title

831:05

and put the right here inside this title

831:09

okay and then we are going to be also

831:11

providing the own change even hand

831:13

whenever somebody types something inside

831:15

this input field we're going to be

831:16

firing this set not time but set set

831:19

title there we go and we're going to be

831:22

providing that value which we are

831:23

getting from this input field now what

831:25

I'm going to do is that I'm going to

831:27

just specify these classes and that's

831:28

going to be done now if I click on that

831:31

so here you can see we now getting our

831:32

input field with the placeholder off

831:34

title so that's looking great next we

831:36

have to Define our text area so I'll use

831:39

like text area and we're not going to be

831:41

providing any IDs and names I'm going to

831:43

remove that from here and for the

831:45

placeholder I will just say like

831:47

description and we don't want to close

831:49

this separately we want to close there

831:51

as a on liner and for the value we going

831:54

to be passing our description which

831:55

we've already created up above and when

831:58

somebody types something inside this we

832:00

are going to be fing this function and

832:02

we will say like set description to e do

832:04

target. value and also I'm going to be

832:07

placing these classes for The Styling so

832:10

let's just check this out if I click on

832:12

there and this is going to be my text

832:14

area now underneath this text area we're

832:16

going to be defining our input field

832:18

once again and now what I'm going to do

832:20

is that I'm going to just provide my

832:21

placeholder image URL and also provide

832:25

the value and the value will be that

832:27

image value and somebody types something

832:29

inside there so we're going to be firing

832:31

this function which is a set image and

832:33

provide my event. target. value inside

832:36

there and also for the classes we're

832:38

going to be placing these classes right

832:40

here now underneath this input field

832:42

we're going to be defining or you know

832:43

what underneath even this uh div we're

832:46

going to be creating a section with the

832:48

class of flex and justify will be set to

832:51

end and margin for the top will be set

832:54

set to six space on the xaxis will be

832:56

set to four and inside this section

832:58

we're going to be creating our button

833:00

and for this button you will first of

833:03

all check if if we have the existing

833:06

block then we will just say like update

833:08

but if we don't have the existing block

833:10

we will just say add now for this button

833:13

we're going to be attaching the own

833:14

click event handler which allows us to

833:16

submit our forms so we're going to be

833:17

providing like handle submit and we're

833:19

going to be also creating this function

833:21

in a few seconds now let me just Place

833:22

The Styling and that's going to be it

833:24

for this button now underneath this

833:26

button we going to be defining one more

833:28

button with the class of you know what

833:31

we're not going to be providing any

833:32

classes today we are but I'm going to

833:34

just copy and place there and when

833:35

somebody clicks on there we're going to

833:37

be fing this on close function okay and

833:40

it's going to just say like cancel and

833:42

now let me just style that a b that's

833:45

going to be fine now we have to copy

833:47

there and create the up above so what

833:50

I'm going to do is that I'm going to

833:51

Define my handle submit function and

833:53

inside this handle submit first of all

833:55

we're going to be creating a Blog and

833:58

I'm going to also annotate the with my

834:00

blog and here it's going to be equals to

834:02

the ID and the ID will be the existing

834:05

come on existing blog if that's the case

834:07

we are going to be fing the existing

834:09

blog. ID but if that's not the case so

834:11

we're going to be using that. now for

834:13

that new second or for that new time

834:16

okay we're going to be also putting the

834:18

title

834:20

description d e s c r i p t i o n and

834:24

also the image and the time so that's

834:26

going to be basically my blog now we

834:28

have to check the if you already have

834:30

the existing blog so in this situation

834:33

we are going to be using the update blog

834:35

and we're going to be also providing the

834:37

blog inside like all of the existing

834:39

data but if we don't have the existing

834:41

data then we're going to be creating a

834:42

new blog and providing that newly

834:45

created data which we've already created

834:47

and all of that data is coming from

834:48

their appropriate stat so you know let

834:50

me just show you there this title is

834:52

coming from this title come on this

834:54

title and then description then image

834:56

and also the time and we're now

834:58

providing the inside this blog now for

835:00

this blog we're going to be providing

835:01

our blog and also we have to close them

835:04

by using the own close function okay

835:07

that was a lot of talking so now let me

835:09

just test this out so what I'm going to

835:11

do is that I'm going to click on there

835:12

and now it's going to give us like the

835:13

title description image and so on and so

835:16

forth and I'm going to just write like

835:18

um I don't know oh my

835:21

God

835:23

Vlogs Wikipedia blogs top 50 blogs I'm

835:27

going to choose that first one and I

835:30

need some sort of a block so I'm going

835:31

to go into that first one yep I'll go to

835:34

the Reddit and copy some stuff from

835:37

there okay so 3 months of whatever this

835:40

is I'm going to copy there and place

835:42

there and for the description I'm going

835:43

to only place this first portion and for

835:46

the image I'll just copy the image from

835:48

somewhere so I'll just go to the

835:49

unsplash.com go to the unsplash and copy

835:53

some sort of image so I guess no that's

835:56

bad one I'm going to have to choose some

835:58

sort of a free image like this one now

836:00

let me right click on there and copy the

836:02

image address place it here and click on

836:04

the add so it's going to add there right

836:06

here but we cannot see there and the

836:08

reason we cannot see there is because we

836:10

have to create our article component so

836:12

that we can render our articles inside

836:15

there and we're going to be rendering

836:16

our articles right here there we go so

836:20

what I'm going to do is that I'm going

836:21

to create my article list. TSX component

836:25

and I'll just provide my RFC inside the

836:28

sa my file and render that article list

836:31

component right here article list and

836:35

hit Ander is going to render there right

836:37

here yep we are getting our article list

836:40

which means like we are providing some

836:41

sort of a data inside there it's going

836:43

to also take one PR which will be the on

836:46

edit and we're going to be providing the

836:48

open open model for edit right here now

836:52

let me go into that article component

836:54

and let's just create the right here the

836:56

first thing that we want to do is that

836:57

we want to grab my use blogs and we want

837:00

to use it right here but first of all we

837:02

have to destructure the block

837:04

and also the delete block so I'm going

837:06

to save there next we're going to be

837:09

also annotating this component so I'll

837:10

just create an interface for there with

837:12

the name of article a r t e a r t e list

837:18

props and inside there we going to be

837:21

also returning the own edit and this is

837:23

going to be a function which will take a

837:25

Blog and we are going to be annotating

837:27

there with our blogs type and let's just

837:29

return the white out of there and I'm

837:31

going to copy there and annotate my

837:33

component component by using react. FC

837:37

for functional component and annotate my

837:39

component like so it's going to also

837:41

take the on edit as a prop that's done

837:45

now for this UI what I'm going to do is

837:47

that I'm going to just remove that from

837:49

here and I'm going to Prov the class

837:50

name of margin for the left will be set

837:52

to fire frames and inside this D we're

837:54

going to be iterating over through all

837:56

of that blocks and I'm going to provide

837:58

a block as a perimeter and inside there

838:00

we're going to be rendering one more

838:02

component which will be article card

838:04

component and we're going to be creating

838:06

this article card component in a few

838:08

second just going to take the key and

838:10

we're going to be providing a blog. ID

838:12

as a key we're going to be also

838:14

providing an article and that article

838:16

will be that entire blog we're going to

838:18

be also providing the on delete so that

838:20

we can totally delete there if you

838:23

wanted to so in this situation we're

838:25

going to be finding this function like

838:26

delete blog and here we have to specify

838:29

our block ID and also the on edit it

838:32

allows us to edit the block so we're

838:34

going to be firing this function which

838:36

allows us to edit our blocks all used

838:38

like on edit and we have to specify our

838:40

block inside there now let me go ahead

838:42

and create this article card component

838:44

so we just create my article card. TSX

838:47

and inside there I'm going to be using

838:48

my RFC s my file and grab this component

838:51

right here this is s file and now let me

838:54

test this out so if I click on that I

838:56

can just write some sort of a gibberish

838:58

like so and now if I click on the add

839:00

button so it's going to use us a article

839:02

card which means like everything is

839:04

working the way we expect him to work

839:06

now what I want to do is that I want to

839:07

first of all create my interface for all

839:09

of that prop so I'll use like

839:13

rtal card props inside this one first of

839:16

all we going to be providing our article

839:18

a r t i CLE and that's going to be our

839:21

entire blogs we're going to be also

839:23

providing the on delete so we can also

839:25

delete the and for this one we're going

839:27

to be returning the wi function and on

839:29

edit you would be also able to edit our

839:32

um card so let's just proide the right

839:34

inside there okay so what I'm going to

839:36

do is that I'm going to annotate there

839:39

with the re functional component like so

839:42

and I'll just provide My article card

839:44

prop inside there and from this one

839:46

we're going to be restructuring all the

839:47

four props so I'll provide My article

839:50

the on delete and also the on edit like

839:53

like so okay so that's cool now for this

839:56

de I'm going to provide a lot of styling

839:58

Place The Styling and for this label I'm

840:01

going to remove there and render my

840:02

image and for this image I'll just say

840:05

like article dot not this one but a r t

840:09

i e article. image and we also have to

840:11

specify some sort of alternative text

840:13

for there so I'll use like article do

840:16

title and we also have to specify some

840:18

sort of classes for this so now let me

840:20

just go back with will be set to 36 36

840:23

like so height will be six to 24 and

840:26

object will be set to totally cover and

840:28

totally rounded large Shadow will be

840:31

medium and that's going to be it and

840:33

here you can see see we're not getting

840:34

any image that's because we are

840:36

providing some sort of a Gib to there

840:38

let me just refresh there and add a new

840:40

block I'm going to copy this image from

840:42

there and put that image and if I C and

840:44

if I hit on this add now it's going to

840:46

gives us that image right here which is

840:48

cool now underneath there we're going to

840:50

be also creating a d with the class of

840:52

margin for the left will be set to six

840:54

and flex will be set to One Flex and

840:56

then Flex will be also set to column and

840:58

H3 and let's just put our text of

841:01

totally extra large and font will be set

841:03

to semi come on semi bold and text will

841:06

be set to gray of 800 and margin for the

841:09

bottom will be set to two cool and we

841:11

also have to render our

841:14

article. title inside the so now if I

841:17

save my file and here you can see we're

841:19

now getting our article title which is

841:21

also looking awful because we did not

841:23

specify nothing inside there and let's

841:25

just take care of the paragraph so I'll

841:27

just write like uh article do God damn

841:31

it r t i e article description and

841:35

provide a styling to this I'll just use

841:36

like Tex of to is small and text will be

841:39

cray 700 and flex will be set to one

841:43

save my file and yeah this is how my

841:45

description looks like underneath this

841:46

paragraph we going to be defining where

841:48

div with the class of flex and items

841:50

will be set to Center justify will be

841:52

set to between margin for the top will

841:54

be set to four text will be set

841:57

to of 600 and inside this D we're going

842:00

to be creating our spin with a class of

842:02

text small and and inside this one we're

842:05

going to be using article. time save my

842:08

file and we cannot see the time I don't

842:11

know why let me go ahead and go to my

842:14

blog

842:15

form God damn go to the blog form so we

842:19

have a title then we have description

842:21

then we have the image we oh yep we

842:26

forgot to include the time so let's just

842:28

render the time as well so I'm going to

842:30

create input with a type of date and

842:32

placeholder will say time and also

842:35

provide the value which we've already

842:36

specified as a time or did we even

842:39

specify the time or not I forgot yep we

842:43

did yeah we totally did so here what I'm

842:47

going to do is that I'm going to proide

842:48

the on change EV hander and when

842:50

somebody try to change there we're going

842:52

to be firing this function which will

842:53

take like event. target. value and we're

842:56

going to be also providing a bit of

842:57

classes today so I'll just go ahead and

843:00

place these classes and now if I just

843:02

refresh there here you can see we have

843:04

our timer can write whatever I want to

843:06

write copy the image of that place it

843:09

right here and I'm going to set there to

843:11

today now if I add there and here you

843:13

can see we are also getting their time

843:14

now let me go to My article card and

843:17

underneath this span uh I'm going to be

843:19

creating yet another day with the class

843:21

of flex and space on the xais will be

843:23

set to three and inside there this is

843:26

render or fa book Mark Mark like so and

843:31

I'm going to be providing a classes to

843:32

it so all we just place these classes

843:35

and now underneath this bookmark we're

843:37

going to be also providing the fa edit

843:40

and also import there and provide a

843:42

classes to this one as well like so when

843:45

somebody tried to edit there so we're

843:46

going to be firing this function and

843:48

provide our own edit inside there and

843:50

also let's just render our final icon

843:52

which will be fa a trash and hit enter

843:56

and here we have to specify the final

843:59

icon like so and we're going to be

844:01

providing the on click event handler

844:03

when somebody to click on there we're

844:05

going to be removing that uh that

844:07

specific article and we are totally done

844:09

with that let's just test this out so if

844:11

I click on this edit okay that's not

844:13

working if I click on the delete that is

844:16

working so what's up with that edit let

844:19

me just test this out so I'll just

844:21

provide some dat enter there and click

844:24

on the edit go to my inspect element

844:27

we're getting some sort of error blog is

844:29

not defined and that is coming from 23

844:34

let me go into the app go into the

844:38

23 block is not defined what do you mean

844:41

by there oh here we have to specify that

844:43

blog so I'll just write a blog in here

844:45

now it is defined so we are going to be

844:48

also annotating there with the blog like

844:51

so now it is defined so now let me just

844:53

refresh there add a random blog here

844:58

like so enter there and now if I click

845:00

on the edit so it's going to gives us

845:01

all of their data okay that's working if

845:05

I change that to my own name like Huzan

845:07

webdev and change this description to

845:10

hello I am hen webd

845:15

amazing

845:17

YouTuber and for the image I'm going to

845:20

go into my github.com

845:23

and search for my own image which is

845:26

hosan webd go there copy the image and

845:31

place it here and now I'm going to just

845:34

update there to 14 click on the update

845:37

okay the update spelling is incorrect up

845:41

okay let me just fix that I'm going to

845:42

go into the card and where is my update

845:46

where in the world is that update button

845:48

I'm going to search for you

845:50

dtl

845:53

dtl up DTE updte search for that and

845:59

here we have to change that to update

846:01

like so now this looking better okay so

846:05

this is how we're going to be adding our

846:07

block this is how we're going to be

846:08

editing there like let me just edit it

846:10

with some random uh gibberish and click

846:14

on the update so it's can also update

846:16

there and I can also totally delete

846:18

there that was a lot of talking and that

846:21

was our blogs project so now let's make

846:23

a set of forward projects so the first

846:25

thing that I want to do is that I want

846:26

to install reactjs inward machine so I'm

846:28

going to be using like npm weed or npm

846:30

create weed at latest I'm going to give

846:33

the name of like projects and I'm going

846:34

to choose a reactjs and typescript so

846:37

now let me go into my projects folder

846:40

and I'm going to install every single

846:41

thing inside there now that successfully

846:44

done I'm going to open that in my vs

846:46

code like so and first of all we have to

846:48

remove this public folder because we

846:50

don't need that we're going to be also

846:52

removing this assets and app. CSS and

846:54

index. CSS but we have to remove every

846:57

single thing from there and also remove

846:59

every single thing from the app and just

847:01

provide like RFC inside there go to the

847:03

main and that's going to be fine okay so

847:05

now let me install 10in CSS in my

847:07

project so I'm going to copy there open

847:09

my terminal and place this command here

847:12

hit enter to initialize my tailin CSS

847:15

and now I'm going to copy this content

847:17

go to my tailin config file remove there

847:20

and replace it with this new one okay so

847:22

that's to done and we also have to

847:24

provide these directives inside our

847:26

index.css so now let me go ahead and

847:29

provide the save my file and then St it

847:31

done so you know what let me just check

847:33

this out I'm going to be using npm run

847:34

Dev to run my project so here you can

847:36

see we now getting an app but I'm going

847:38

to copy this H1 and go to my m. TS one

847:42

more time and place it right here and we

847:45

are now getting our hello word with the

847:47

styling so which means like everything

847:48

is now successfully working next I'm

847:50

going to create my utl folder and inside

847:52

there I'm going to Define my data. ts

847:55

file okay so now I'm going to place a

847:56

lot of data and you can find all of

847:58

their data in my giab repositories so

848:00

here you can see first of all we have a

848:02

data and we are now exporting there so

848:04

that we can use the in other file okay

848:06

so we have array inside this array we

848:08

have a object and inside this object we

848:10

have a client country email project

848:13

progress status date and also different

848:15

images for each of the client right here

848:18

okay so yeah we have a lot of data and

848:20

if you interested in all of that data

848:22

you can totally go ahead and go to my

848:23

gab repository and grab all of their

848:25

data from there but if you want to just

848:27

proide like your own you can totally do

848:28

that by yourself okay so that's done now

848:31

let me just go ahead and create my

848:32

component folder and inside there first

848:35

of all I'm going to be defining my

848:36

dashboard. TSX and I'm going to use my

848:39

RAF come on rafc sa my file go to my app

848:43

and registered there right here so I'll

848:45

just remove there and I'm going to

848:46

replace there with Dev and inside this D

848:48

let me just render my dashboard

848:50

component okay so let's just save our

848:52

file and here you can see we now getting

848:54

our dashboard which is looking amazing

848:56

next let me just go to this dashboard

848:58

and the first thing that I want to do is

848:59

that I want to just make a bit of UI so

849:01

I'll just write like class of FX and

849:04

also the height will be set to screen

849:06

and inside there we're going to be

849:07

rendering first of all the Side Bar

849:09

which we're going to be creating in a

849:10

few second and we are going to be also

849:12

providing a d with the class of Flex one

849:14

and background of totally gray of 900

849:17

and inside this one we are going to be

849:19

rendering our project table like the

849:21

main table in which we're going to be

849:23

rendering all of our content so now then

849:25

toally done so I'm going to go ahead and

849:27

work with the sidebar so what I'm going

849:29

to do is that I'm going to create my

849:31

sidebar. TSX file file right here and

849:34

I'll just use the RFC inside there and

849:37

I'm going to go ahead and go to my

849:38

dashboard and remove this sidebar and

849:40

replace it with this actual sidebar

849:43

component now let me go ahead and just

849:45

style the sidebar right here so I'm

849:46

going to remove that and provide a lot

849:48

of styling to it so first of all we're

849:50

going to be providing the width of 16 to

849:52

it and we're going to be also providing

849:53

a border and Border color will be this

849:55

color like uh 24 24 24 this is prob a

849:59

bit of pairing of four pixel and also

850:02

Flex Flex will be set to column and

850:04

items will be set to Center and space on

850:06

the y- axis will be set to add and

850:08

that's going to be it and now inside

850:10

this div we're going to be defining

850:11

first of all our text of totally white

850:13

logo so I'll just write a logo Right

850:15

Here and Now underneath that I'm going

850:17

to just create like text of totally come

850:20

on text of toally gray of 400 it's going

850:23

to take this icon like folder icon or

850:26

something so I'm going to just place

850:27

this folder icon and now let me just

850:29

duplicate there and change the icon to

850:31

like a person like basically here here

850:33

you can just specify any kind of icon

850:35

that you prefer but this is just a

850:37

sidebar and we're not going to be

850:38

providing any functionality to it so

850:40

that's why I'm just providing this icon

850:41

so I'll just write like settings

850:43

settings or gear Gear would be fine now

850:46

let me just save there and check this

850:48

out so here you can see we now getting

850:50

our sidebar and which is looking amazing

850:52

so that was there about four our sidebar

850:54

and now let's get into the main table

850:56

now let me take care of this table

850:58

temporarily so I'm going to go ahead and

851:00

hide there and it right over through all

851:02

of my data so for the T body I'm going

851:05

to just like cut every single thing from

851:08

there and I'm going to be using a

851:09

projects which is that state in which we

851:12

are defining all of the data okay so

851:14

we're going to be iterating over through

851:15

them by using our map method it's all

851:17

used like map it's going to take the

851:19

project and also it's going to take the

851:21

index as a perimeter and now inside

851:24

there we're going to be defining all of

851:25

our data like we have our TR and also

851:28

our TDS I'm going to select these

851:30

projects and just select all of them by

851:32

hitting control D and remove this s out

851:35

of there so now it's going to give us

851:36

their project and now inside their

851:38

project we have our image client country

851:40

email and project and now if I save my

851:42

file and test this out so here you can

851:44

see we are now getting all of our data

851:45

which is looking cool but we have to

851:47

take care of this uh image and also this

851:49

UI so now let's just do that so what I'm

851:51

going to do is that I'm going to take

851:53

care of the image first of all I'll

851:54

provide a class name of with will be set

851:56

to three rim and also uh we're going to

851:59

be providing a height which will be also

852:01

set to three rims okay and for the

852:04

object which will be set to totally

852:05

cover so that our image will contain all

852:07

of the DAT okay so we're going to be

852:09

also providing a rounded for sem my file

852:12

and now we are getting this amazing UI

852:15

which is looking cool and you know what

852:17

underneath this TD we're going to be

852:19

also providing our project so for that

852:20

we are going to be creating our TD with

852:22

the class of pairing for the xaxis will

852:24

be set to two four and also pairing for

852:26

the y axis will be set to two inside

852:28

then we're going to be defining our

852:30

width with the class of uh 20 I mean

852:32

like d with the the class of width 24

852:34

and height will be set to totally two

852:37

just height will be set to two and we're

852:39

going to be also providing a background

852:40

color of totally gray of 700 and totally

852:44

rounded okay so now inside this div what

852:47

do you want to do we just want to create

852:48

our div once again and it's going to

852:50

take the height of two and we're going

852:53

to be also providing the background of

852:54

totally green 500 and totally rounded so

852:58

now if I go ahead and save my file and

853:00

check this out so here you can see we're

853:02

now getting our progress which is

853:03

looking cool now underneath this TD

853:05

we're going to be defining yet another

853:07

TD with the class of pairing for the

853:09

xaxis of four and uh come on pairing for

853:12

the xaxis of four and pairing for the y

853:14

axis of two with will be set to this

853:17

arbitrary radio so I'll just write a

853:19

width and that's going to be equals to

853:21

10 rims inside this 3D we're going to be

853:23

defining our Spin and here we just have

853:26

to write our project. status and now we

853:28

are getting like all of that project

853:30

statuses I'm going to also render my

853:32

date so I'll just use like TD pairing

853:35

for the xaxis of four pairing for the y

853:37

axis of two and render my project. dead

853:41

project. de like so and we are getting

853:43

the date and finally we have to take

853:45

care of that action button and this can

853:47

be it okay so what I'm going to do is

853:49

that I'm going to Define my TD with the

853:51

class of pairing for the xaxis of four

853:53

and pairing for the Y AIS of two inside

853:55

there we're going to be defining what D

853:57

with the class of relative so I'll use

853:59

like relative I'm going to provide my

854:01

three dots icon so I'll use like bs3

854:04

dots we're going to be rendering them

854:06

I'm going to also put the class name of

854:08

cursor and we are now getting these

854:10

three dots which is not doing anything

854:12

but we are not toly done with this UI I

854:15

know this is not looking that great UI

854:17

but we will take care of the rest of

854:18

these stuff now let me just remove the

854:20

sidebar from here and we're going to be

854:22

defining our table component right here

854:24

so I'll just use RFC inside there let's

854:27

just register that inside our dashboard

854:29

so instead of providing this comment so

854:31

I'm going to write like uh uh table

854:34

component like so so if I save my file

854:37

here you can see we are now getting our

854:38

table but which is not looking that

854:41

great so we are going to be taking care

854:43

of the styling right now I'm going to go

854:45

ahead and provide a bit of state and

854:47

also the styling to it so I'll just

854:48

remove there the first thing that I want

854:50

to do is that I want to grab my data

854:52

like this entire data that we've

854:54

specified right here okay so we're going

854:56

to be grabbing them inside our table

854:59

components I'll use like import uh data

855:02

from where uh we want to get that data

855:05

from let's just go ahead and go to uh

855:08

the UTS folder and we want to select

855:10

this data that's all done now we have to

855:12

store that data inside our state so I'm

855:14

going to be using like H state for there

855:16

and here we want to provide all of that

855:18

data okay and here we just have to

855:20

restructure the projects and also set

855:22

projects from where from this Us St now

855:25

let me go back because we're going to be

855:27

writing a lot of GSX and a lot of

855:29

classes so I'm going to just uh select

855:31

this one and provide a classes to this

855:32

so so paing for all around will be set

855:34

to four with will be set to

855:37

93

855:39

93% and also margin for the left will be

855:42

set to five RS okay and now inside this

855:45

Dev we're going to be first of all

855:46

defining or sorting and then we're going

855:49

to be defining our main table and after

855:52

that we're going to be defining our

855:53

pagination so let's start from the

855:55

Sorting so what I'm going to do is that

855:58

I'm going to create a with a class of F

856:00

and also the items will be set to

856:01

totally Center and for the bottom will

856:03

be set to five inside there we're going

856:05

to be creating our button with a class

856:07

of border and Border will be set to gray

856:11

of 700 this is right or 700 and we're

856:15

going to be also providing a flex and

856:16

items will be set to Center justify

856:19

justify will be set to Center and text

856:22

will be set to totally wide pedding for

856:24

all around will be set to two and

856:26

rounded and inside there we're going to

856:28

be rendering our icon which will be bi

856:31

sord and that's going to become from the

856:33

react icons so we have to also install

856:35

this so I'm going to be using npmi and

856:37

then react icons now then successfully

856:39

done so I'm going to use the npm Run Dev

856:41

to start my server and now we have to

856:43

grab this icon from that react icons

856:46

okay like so and I'm going to also

856:47

provide the class name of margin for the

856:50

right will be set to 0.3 RM okay now let

856:53

me just save my and we're going to be

856:55

also providing a sort as a label to it

856:57

and now let me also renter my AI outline

857:00

AI outline down we also have to get this

857:03

icon and I'm going to provide a class

857:05

name of margin for the left will be now

857:07

set to two let me remove this empty

857:09

space from here and this is how my icon

857:11

looks like right here of course we're

857:13

not providing any functionality to it

857:15

but this is just for the UI now let me

857:17

go ahead and take care of this main

857:19

table so what I'm going to do is that

857:20

I'm going to create my table with a

857:22

class of minimum width of totally full

857:24

and also the table will be set to Auto

857:26

like all around and we're going to be

857:28

providing around it and also border

857:30

border gray of 7 100 text will be set to

857:34

totally white inside there we're going

857:36

to be defining our T head not fed but T

857:38

head like so and then let's just Define

857:41

our TR and inside each of these TR we

857:44

are going to be defining our th with the

857:45

class of pairing for the xaxis of five

857:48

and pairing for the Y AIS of three and

857:50

text will be set to left and let's just

857:52

proide an image right here for the first

857:54

level and I'm going to duplicate that

857:55

like a lot of time okay I'm going to

857:57

remove this image and replace that with

857:59

name and also replace this one with

858:01

country e y but c n TR r y there we go

858:06

and email then we have a project name we

858:10

also have our task

858:16

progress status date and finally we have

858:20

our actions okay so I'm going to remove

858:23

the last one sa my file and this is how

858:25

it looks like right here so that's going

858:26

to wa for the basic header now we are

858:28

going to be also providing a filtration

858:30

for this one but we're going to be

858:32

taking care of the in a few seconds okay

858:34

so what I'm going to do is that

858:35

underneath this T head we're going to be

858:38

also defining our t b so it's going

858:40

allows us to give this all of that b so

858:42

I'm going to write like t b and inside

858:45

this T Bor we're going to be using our

858:46

TR and that's going to have the border

858:49

and also border will be set to to gray

858:50

of 700 like so and inside this T we're

858:54

going to be defining our TD with the

858:56

class name of pairing for the x-axis of

858:58

four and pairing for the y axis of two

859:00

I'm going to also render my image but

859:03

you know what yeah I'm going to just

859:04

render some sort of image right here and

859:07

that image will have the value of

859:09

project and then image I im a g and we

859:13

are going to be also providing our

859:14

alternative text so I'll use like

859:17

project. client so now you might be

859:19

wondering like where in the world is

859:20

this image coming from and where in the

859:22

world is this client coming from so if I

859:24

hold control and click on this projects

859:26

so it's going to brings us to this state

859:28

and now if I hold control and click on

859:29

this data so it's going to brings us to

859:31

this data Okay so so we are now grabbing

859:33

this image and also this name of the

859:36

client and we are now putting that

859:39

inside this image right here so it's

859:41

going to giv us the image of that

859:42

specific person it's going to also gives

859:44

us the client right here it's not going

859:46

to gives us any data because we're not

859:48

iterating over through our client so

859:50

that's why or our array to be precise

859:52

our client but you know what I'm going

859:54

to just complete the UI and then we will

859:56

take care of the functionality so

859:57

underneath this TD we're going to be

859:59

defining yet another TD with the class

860:01

of pairing for the x-axis

860:03

uh of four and pairing for the y axis

860:05

will be set to two and here we have to

860:08

Define our project. client as a name and

860:11

I'm going to just duplicate there a few

860:12

times I know we are getting a lot of

860:14

errors but this just a typescript error

860:16

so now let me just Define a country and

860:18

also the email and finally we have to

860:20

just write um the project right here

860:23

like so now if I sell my file and check

860:25

this out still we are not getting any

860:27

data because we are not iterating over

860:29

through nothing okay so you know what

860:31

I'm going to take care of the rest of

860:32

the UI in a few seconds because you are

860:34

not able to see anything but yeah I'm

860:37

going to take care of there in a few

860:38

seconds so you know what I'm going to

860:39

just hide this entire main body and

860:42

we're going to be also taking care of

860:43

the page ination so let me just create a

860:45

UI for this page ination right here so

860:47

I'm going to create a different the

860:48

class of flex and justify will be set to

860:51

end and also pairing for the top not

860:54

pairing but margin for the top will be

860:55

set to four and inside they we're going

860:57

to be defining our button with the class

860:59

of pairing for the xaxis will be four

861:01

and pairing for the Y AIS will be set to

861:03

two background color will be set to gray

861:05

of 700 and we're going to be also

861:08

providing the text of totally white t

861:10

totally arounded and margin for the

861:12

right will be set to two and disable d i

861:15

s a b l e d will be set to opacity when

861:18

it is disabled so we're going to be

861:19

changing the opacity to 50 there we go

861:23

okay so now inside this BT what do you

861:24

want to do we just want to write a

861:26

previous p r e v i o u s there we go and

861:29

yeah that's going to be fine so now

861:31

underneath this button you know let me

861:33

just go back so you guys can see

861:34

everything a bit better and we're going

861:36

to be also creating a spin with the

861:38

class of piring for the xxs we be set to

861:40

four and pairing for the Y AIS will be

861:43

set to two text will be set to totally

861:45

white and inside there let's just start

861:46

our page okay so it's going to basically

861:48

gives us like page one out of two or

861:51

page two out of three or something like

861:53

that so in this case I'm going to only

861:55

provide like page one of uh four would

861:59

be fine let's just check this out so

862:01

here you can see we are now getting what

862:02

previous button and we are also getting

862:04

this shouldn't be a project it should be

862:06

a page okay so yeah we are now getting a

862:10

page 1 hour four now let me just copy

862:12

this entire button and let me just place

862:14

there right here instead of writing a

862:17

previous I'm going to change that to

862:18

next save my file and now we are getting

862:21

this next button which is looking cool

862:22

so now let me take care of these drop-

862:24

down menus so I'll just Define a St with

862:26

the name of drop down visible and then

862:29

set drop down visible or you know what

862:33

it set drop down v i s i b e that's

862:37

going to be equals to the user and

862:39

initial value will be set to false f a

862:42

LS e there we go now let me go ahead and

862:44

go to my UI which is the Sorting so I'm

862:47

going to go ahead and go there and when

862:48

somebody clicks on this button so what

862:50

do you want to do we just want to fire

862:52

this function so let's just write like

862:53

on click event handler and we want to

862:55

fire this function which will just set

862:56

the drop down menu to not false okay so

863:00

I'll just use like drop down menu like

863:02

so so so if our drop down menu is set to

863:04

true this will make it false so if our

863:07

drop down menu is set to false it's

863:09

going to make it true so which means

863:11

like if it is hidden it's going to

863:12

unhide there and if it's not hidden so

863:14

it's going to just hide there okay so

863:16

now that's all done next we have to show

863:18

our content based on our true or false

863:21

state so what I'm going to do is that

863:23

here we're going to be defining like if

863:25

our drop down menu is visible then we're

863:28

going to be showing this UI but if our

863:30

drop down menu is set to f then we are

863:33

not going to be showing anything at all

863:35

okay I'll just created with a class of

863:36

absolute and also top will be set to

863:39

totally full and the left side come on

863:42

the left side will be set to totally

863:43

zero margin for the top come on margin

863:46

for the top will be set to two and

863:49

background will be set to totally gray

863:51

of 800 and border border gray of 700

863:55

totally rounded and Shadow will be set

863:58

to large and inside this D we're going

864:00

to be defining our button and here we're

864:03

going to be just writing a name I'm

864:05

going to duplicate or you know we are

864:06

going to be duplicating there in a few

864:08

seconds but I'm going to also provide

864:10

bit of classes to it so like block and

864:12

pairing for the xaxis will be set to

864:14

four pairing for the y axis will be set

864:15

to two text will be set to totally white

864:17

with will be set to totally full and

864:19

when somebody H over there we're going

864:21

to be changing the background color to

864:23

700 off totally gray and also when

864:26

somebody clicks on this buttons we're

864:27

going to be finding this function which

864:29

will be handle sort sort off

864:32

option click and here we're going to be

864:35

also providing a client today we're

864:37

going to be creating this function in a

864:39

few second but now let me just save my

864:40

file and also I'm going to have to

864:42

duplicate this button a few times so I'm

864:44

going to just uh duplicate the one for

864:46

the country and one more time for the

864:48

DAT I'm going to change the values of

864:50

them instead of providing a click I

864:52

should have to provide like client not

864:54

click okay and here we also have to

864:57

specify the country and also country

865:00

here change this one to dat and this

865:02

label to dat as well so it's going to

865:04

gives us an error obviously because we

865:06

have to create this function so I'm

865:08

going to go ahead and go to the top and

865:09

create this function so what I'm going

865:12

to do is that I'm going to just write

865:13

like cons handle option click and it's

865:16

going to take a key and that key will be

865:18

a string and inside this function we're

865:20

going to be defining our set drop down

865:22

visible and we have to set there to

865:24

false we also have to do a lot more

865:26

things inside there but you know what

865:28

let's just check this out so if I click

865:29

on there we are not getting anything so

865:32

you know what let me just take care of

865:33

the set sort project so we are going to

865:35

be using like uh sort projects and here

865:38

we have to Define our key and now let me

865:40

just create the sort projects up above

865:43

right here the first thing that I want

865:44

to do is that I want to just write like

865:46

sort project it's going to take a key

865:48

and that key will be the type of string

865:50

and here what I'm going to do is that

865:52

first of all I'm going to just make a

865:54

clone of all of that projects right here

865:56

not this one but this one to make a

865:58

clone of all of their projects so

866:00

basically what we are going to be doing

866:01

is that that we're going to be using the

866:03

spread operator so I'm going to use like

866:05

dot dot dot and clone all of the

866:07

projects right here and we also have to

866:09

store them some sort of variable so I'll

866:10

use like let sorted projects and that's

866:13

going to be equals to this clone of this

866:15

data now outside from there we also have

866:18

to Define one more State for the sort

866:20

configuration so I'll just write like

866:22

sort config and also we have to write

866:25

like set sort config that's going to be

866:27

equals to the US state and the initial

866:29

value will be set to now but I'm going

866:31

to also annotate there with this object

866:33

and this object will have the key and

866:35

key will be set to string and we're

866:37

going to be also providing a Direction

866:38

so I'll use like Direction and direction

866:41

will be set to string otherwise if

866:42

that's not the case we're going to be

866:44

only providing a now which this is right

866:46

here like initially the value is now set

866:48

to know and now we have to use this sord

866:50

configuration inside this functions so

866:53

we already made a copy of this projects

866:55

the next thing that we have to do is

866:56

that we have to provide our checks I'm

866:58

going to provide a check right here so

867:00

if our sort config like if we have some

867:03

sort of A Sort config in this situation

867:05

we're going to be defining yet another

867:07

check so if our sort configuration do

867:10

key is triple equals to the key which we

867:12

are now taking as a perimeter so if that

867:15

sort. key is equal to that key so in

867:17

that situation we are going to be

867:19

providing the sort config Direction and

867:22

that's going to be set to ascending a c

867:25

n d i NG like so and I'm going to have

867:27

to use triple equality operator right

867:30

here if this expression is true so in

867:32

this situation we're going to be sorting

867:34

our item by using like sort projects

867:37

which is going to be the clone of our

867:38

projects and then we're going to be

867:40

using the JavaScript sort method on

867:42

there here it takes two perimeter like a

867:44

comma B and what do you want to do with

867:46

there we just want to fire a function

867:48

and here I'm going to be doing a bit of

867:49

magic and then I'm going to explain that

867:52

magic so I'll use like a and key and

867:54

also if that is greater than b do B not

867:57

do key but just a key so in this

867:59

situation we're going to be returning

868:01

minus one but if that's not the case

868:03

we're going to be returning only one so

868:05

now let me explain like what in the word

868:07

is this line even mean you already know

868:09

like this is going to be the clone of

868:10

our project and then we can use the sort

868:12

method on them because this is array

868:14

inside the array we have a lot of

868:16

objects which means like we can use the

868:17

sort method on there this is an arrow

868:19

function that takes two parameters Like

868:21

A and B which represent two elements

868:24

inside the projects array to be compared

868:26

like it will first of all compare you

868:27

know let me just show you there it's

868:29

going to first of all compare this

868:30

element with this another one like the

868:33

second one so this is what's going to

868:35

happen for the first step and now let me

868:36

explain this line of code so this is a

868:39

expression that compare the values of A

868:41

and B at the property of key which we've

868:44

already specified right here so if the a

868:46

key is greater than the b key then the

868:49

function will return one which means

868:51

like a should compare with B in the

868:53

sorted order so if the a key is not

868:56

greater than the b key for example like

868:58

if it is less than or equal to or

869:00

something like that will return one

869:02

meaning the B should come before a okay

869:05

so I hope it makes sense but if it

869:07

didn't so you can just quick Google

869:09

search or something like there we're

869:10

going to be also using our set sort

869:12

config and here we have to Define our

869:15

key first of all and also we have to

869:17

give it the direction so I'll just write

869:18

like Direction come on what the hell d i

869:21

r e c t i o n and the direction will be

869:23

set to descending d e s e b e s c e n d

869:27

i n g like so so that's going to be it

869:29

for the first case and what about the

869:31

next case like for the else class like

869:33

if that is not the case then we're going

869:35

to be jumping into this else class and

869:37

for this else class we're going to be

869:39

copying and placing both of these code

869:42

and here we only have to change that

869:44

minus one to one and also we have to

869:47

provide a minus for this second one

869:49

right here like basically we're just

869:50

reverting our expression that's it and

869:53

we also have to change this one from

869:54

descending to ascending a a s c n d i n

869:58

like so and finally we have to push then

870:00

to our projects we're going to be using

870:02

like set projects and we have to push

870:04

our sorted projects in there okay like

870:06

so it should be a sorted okay so I'm

870:09

going to copy there and place it right

870:10

here and now that are is successfully

870:12

gone let me just refresh there and check

870:14

out the UI so if I click on there I

870:16

don't know why we're not getting there

870:18

drop down menu so let me just take care

870:19

of there and I forgot to include the

870:21

relative div right here so I'll just

870:22

create a with the class of relative and

870:25

I'm going to cut that div and we have to

870:28

close that right here so now if I save

870:31

my file and now if I I click on this

870:32

drop down menu so it's going to give us

870:34

that name country and dat so if I click

870:36

on the name it's going to sort my data

870:38

but I cannot see that sort data we will

870:41

see that in a few second but we also

870:42

have to take care of the filters so what

870:44

I'm going to do is that I'm going to

870:46

Define my filters right here underneath

870:48

this div we're going to be defining our

870:50

filters so I'll just create a with a

870:52

class of like relative and also margin

870:54

for the left will be set to four with

870:56

will be set to totally full and inside

870:58

there we're going to be once again

870:59

defining our button with the class of

871:01

border and Border will be set to toally

871:03

gray of 700 and also we going to be

871:06

providing a flex class to it and items

871:09

will be set to Center justify will be

871:11

also set to Center and text will be set

871:13

to totally white pairing for all around

871:15

will be set to two and totally rounded

871:18

inside this Buton we're going to be

871:19

defining what MD sort as icon so let's

871:22

just grab there and also I'm going to

871:24

provide a class name of margin for the

871:26

right that's going to be equals to 0.3

871:29

rims outside from there I'll just Define

871:31

my filters and also provide my AI

871:34

outline and down there we go a class

871:37

name of margin for the left will be set

871:38

to two so it's going to gives us that

871:40

button right here and this is not

871:42

something that we want so we have to cut

871:45

this div and we have to put that inside

871:47

that D and now let me test this out so

871:49

here you can see we're now getting our

871:51

filters and also our sorts now let me

871:53

also take care of this drop down menu

871:55

here so what I'm going to do is that I'm

871:58

going to just Define my drop down menu

872:00

and when somebody clicks on this button

872:02

so we going to be firing this function

872:04

okay so this function will have like set

872:06

filters come on set filters not filter

872:10

visible like so so we're going to be

872:12

defining this filter visible and also

872:14

set not filter visible right here as a

872:16

St so now underneath there I'm going to

872:19

just create my filter visible and also

872:22

set filter visible like so that's going

872:26

to be equals to the US and the initial

872:29

value will be set to false and this

872:31

should be set filters visible now let me

872:34

just save my file and go ahead and take

872:36

care of the rest of these stuff okay so

872:39

now our filter will show up our UI but

872:41

we also have to create our UI to see

872:43

there so to see our UI first of all

872:45

we're going to be rendering our UI

872:47

totally conditionally so I'll just use

872:49

like filter visible if that is the case

872:52

we're going to be rendering this UI but

872:54

if that's not the case so if which means

872:56

like if this is not set to true so we

872:58

not going to be showing nothing and if

873:00

it is true so we're going to be creating

873:02

a d with a class of absolute and top

873:04

will be set to four and left will be set

873:07

to zero and I'm going to also provide

873:09

the margin for the top will be set to

873:11

two and background color will be set to

873:14

800 like so border and also border will

873:17

be set to totally gray of 700 and I'm

873:20

going to provide the rounded border and

873:23

Shadow will be set to totally large and

873:25

pairing for the y axis will be or you

873:27

know what piring all around will be set

873:29

to four inside then we're going to be

873:31

creating with the class of margin for

873:33

the bottom will be set to two and label

873:35

will be just like uh you know we're not

873:37

going to put any HTML 4 but I am going

873:40

to provide some sort of a class name to

873:41

it so block and text will be set to

873:43

totally white and here we have to Define

873:46

our filter by and then name like so okay

873:49

so now underneath that we're going to be

873:51

creating our input field with a type of

873:53

text and also the name will be set to

873:55

name and I'm going to also you know

873:57

we're not going to be providing any IDE

873:58

today so for the value our value will be

874:01

coming from the filters. name come on or

874:04

filters and then the dot name and we're

874:07

going to be also providing the own

874:08

change event handler so you know what

874:11

we're going to be taking care of all of

874:12

that stuff in a few second but you only

874:14

want to see the UI so I'm going to put a

874:15

class name and background color will be

874:17

set to totally 900 and text will be set

874:20

to toally White and I'm going to proide

874:23

the rounded pairing come on pairing for

874:25

the Y AIS or ping for all around will be

874:28

set to two and width will be set to four

874:31

now if I my file and check this out so

874:33

if I click on there we are not getting

874:35

anything I don't know why and it is not

874:37

working because we have to cut this code

874:40

and we have to put that underneath this

874:42

button right here so now if I put that

874:44

here and now we are getting our filter

874:46

by name and we can just prob we filter

874:48

like some sort of a name right here okay

874:50

so now you can click on this so it's

874:52

going to unhide there and now if I click

874:53

on there once again so it's going to

874:55

hide there or the other way around I

874:58

just said they wrong uh yeah now

875:00

underneath this t what do we have to do

875:02

we have to Define yet another div so I

875:04

guess I'm going to have to copy and

875:06

place this one so I'm going to just copy

875:09

therefore the filter by country filter

875:12

by email filter by project and filter by

875:15

status okay so now let me just change

875:17

these video so we have like filters I'm

875:19

going to just remove that from here we

875:21

have a filter by name we also have a

875:23

filter by email or you know what let me

875:25

just change that to filter by country

875:28

name will be set to Country and also we

875:31

have a filtered by email so I'll write

875:33

like email and the name will be set to

875:36

email like so I'm going to make the

875:39

uppercase E filter by project so I'll

875:41

just use like project and also provide a

875:44

project right here for the name okay

875:47

then we have a status so I'll just

875:49

change that to status and finally we

875:52

also have to change this name to status

875:54

right here now let me just s my file and

875:56

check this out so we have a filter by

875:58

name by country email project and Status

876:01

so which is looking cool now let me go

876:03

ahead and take care of the filtration so

876:04

I'm going to go to the top and first of

876:06

all I'm going to Define my filtration

876:09

state right here so I'm going to just

876:10

create a filters or yeah filters will be

876:14

fine then we have a set filters that's

876:16

going to be equals to the US and the

876:17

initial value will be set to this object

876:19

object will have the name and here we

876:21

just have to provide this empty array or

876:24

not array but string and Country c u n t

876:27

r y will be also set to empty string we

876:30

also have to proide the email will be

876:31

set to empty string the project will be

876:34

empty string and also the status will be

876:36

empty string so now we have to use the

876:39

inside or project so I'm going to go

876:40

ahead and go to my filtration and use

876:43

that right here first of all I'm going

876:45

to provide a value to this so I'll use

876:47

like value value will be coming from the

876:49

filters. name we are only interested in

876:51

the name in this case and when somebody

876:53

types something inside this we are going

876:55

to be firing this function which will be

876:56

a handle filter or yeah filter change

877:00

okay so now let's just Pro there for

877:02

this one so for the value we are going

877:04

to be providing like filters. country

877:07

and also when somebody clicks on there

877:09

we're going to be fing this function

877:10

which is a handle filter change filter

877:14

change like

877:15

so next we also have to provide the

877:17

value for this one and this one will

877:20

take the value of filters. email and

877:24

when somebody try to type something

877:26

inside there we're going to be firing

877:27

this function then we have a value and

877:30

for this value we're going to be

877:32

providing our filters and when somebody

877:34

types something inside there we're going

877:35

to be firing this function and finally

877:38

we have a status so we just have to

877:39

write a value and value will be set to

877:41

filters. status right here and when

877:44

somebody types something inside there

877:46

we're going to be firing this function

877:48

okay that was a lot of talking so now

877:50

let me just create this function I'm

877:52

going to go to the top and Define my

877:54

function right here underneath that one

877:57

so we're going to be using like cons and

877:58

then handle filter change it's going to

878:00

take the event object and we are going

878:02

to be using this event object on the

878:05

react. change event and we are going to

878:07

be using that on the HTML input element

878:11

so we have to explicitly Define okay so

878:13

now inside there we're going to be using

878:15

our set filters and inside that set

878:17

filters we're going to be first of all

878:19

making a clown of all of the filters

878:20

that we currently have and then we're

878:22

going to be using like e. target. name

878:25

and we have to set that to e. target.

878:28

value that's all that we have to do but

878:31

now we also have to take care of all of

878:33

that filtration logic so what I'm going

878:35

to do is that I'm going to just write

878:37

like filtered projects and that's going

878:39

to be equals to our entire projects

878:41

which means like our entire data which

878:43

is now set to this entire data right

878:45

here we're going to be defining our

878:47

filter method on there project and here

878:50

inside there what I want to do I want to

878:53

just create my UI but first of all we

878:54

also have to create yet another state

878:57

which will be for the search query okay

878:59

so I'm going to go ahead and go to the

879:00

top and now underneath there I'm going

879:02

to Define yet another state for the

879:04

search query so I'll use like search

879:06

query and then set search query that's

879:10

going to be equals to basically like the

879:12

use and empty string inside there and so

879:14

now let me just go ahead and use there

879:16

inside this project but you know what we

879:19

don't have to specify this curly braces

879:21

I can use my parenthesis and inside

879:23

these parenthesis I'm going to be first

879:25

of all providing this condition if

879:26

search query is triple equals to like if

879:30

search query is equal to m string we

879:32

have object. values and we are going to

879:34

be just providing our object inside

879:36

there and inside this object. values and

879:39

project we have to find the sum method

879:41

on there and then we have to provide a

879:42

call back function to the sum method so

879:44

we're going to be passing a value for

879:46

the sum method and we're going to be

879:47

making the as a lower case so I'll use

879:49

like value. to lower case and here uh we

879:54

going to be also using the includes

879:56

method on there okay so here we have to

879:58

just specify our search query and we

880:00

also have to make that to lower case

880:02

like so I'm going to save my file so

880:04

this is how my currently code looks like

880:07

and that's going to be it for the first

880:09

condition so now let's just put more

880:10

conditions okay so I'm going to just

880:12

write like my parenthesis right here

880:14

first of all we have to just write the

880:16

end symbol so if that is the case then

880:18

we're going to be using like filters.

880:21

name and if that is equal to empty

880:23

string so in that situation we're going

880:25

to be getting like all of the data and

880:27

we only want to get the project out of

880:29

there then we have to make the as low

880:31

case because we don't want to get like

880:33

the casing conflict so we just want to

880:35

change that to two lower case like so

880:39

and we have to uh use the dot method and

880:42

check if it is including filters.

880:45

country and then to lower case like so

880:49

so in this situation we're going to be

880:51

getting our data so that was it for the

880:53

name and now let me just Prov for the

880:55

email so let's just write the end symbol

880:57

and use our filters. email and if that

881:00

is triple equal to empty string or

881:03

project. email. to lower I'm going to

881:07

also have to change that to lower case

881:10

and then use the included method on

881:12

there and here we have to specify our

881:14

filters. email and change this one to

881:17

lower case as well so that's going to be

881:19

it for the email and now we have to use

881:21

that for the project so I'll use like

881:23

filters. project is triple equals to

881:25

empty string uh come on or we have to

881:28

write our project and then the project

881:30

inside there we also have to change that

881:32

to uh lower case come on what the hell

881:36

to lower case like so and we have to

881:39

check the includes method on there so if

881:41

you have the filters. project. to lower

881:45

case so you know let me just semi file

881:47

so we get we have to file this function

881:50

right here and now for the final one we

881:52

are going to be using that once again so

881:53

we going to be using like filters.

881:55

status is triple equals to empty string

881:58

so in that situation what we have to do

881:59

we have to just get like project status

882:02

and then we have to make there two lower

882:04

case like so I'm going to execute this

882:06

function and check out the includes

882:08

method on there and use the filter.

882:11

status. to lower case right here so now

882:14

if I sa my file and that's toally done

882:16

and now we have to use that inside your

882:18

UI so this should be filters there we go

882:22

I just pause the recording and set back

882:24

and enjoy the code and it turns out that

882:27

I made two mistake the first mistake

882:30

that I made is this one so you know let

882:32

me just go to the top and here you can

882:35

see inside the sort we are not going to

882:37

be using a sort projects we are going to

882:39

be using a sorted project so sorted

882:43

project right here okay which is that

882:45

sorted project array so I'm going to

882:46

copy there and now let me just place

882:48

there right here for this one as well so

882:51

now if I save my file and now if I try

882:53

to sort something by either the name or

882:55

country so this is how we going to be

882:57

doing there if I click on there and if I

882:59

click on this name and it's going to

883:00

sort the by name if I want to sort the

883:03

by country so here you can see we have

883:04

first of all the Canada then we have a

883:06

South Korea so if I click on the countes

883:09

so now it's going to giv us Argentina

883:11

and Australia and Canada and so on and

883:13

so forth I can also sort the by dat so

883:15

here you can see we have like 279 2023

883:19

and now if I click on there it's going

883:20

to sort there from one so now that error

883:22

is now successfully gone and I made a

883:26

lot of errors in this uh function right

883:28

here so I want you to take a look at

883:30

that and this then I'm going to remove

883:32

this entire function and I'm going to

883:34

replace it with this function and as you

883:36

can see right here on the other function

883:38

I did not specify these parentheses

883:40

right here like this is going to be my

883:42

opening parenthesis and this is going to

883:44

be the closing one and here you can see

883:46

I just provided this parenthesis and

883:48

that says I want you to pause the video

883:51

and I don't want to like retype all of

883:52

the entire function so this is how

883:54

you're going to be doing there so I want

883:56

you to pause the video and type all of

883:58

that code or if you don't want to type

884:00

there you can totally get there from my

884:01

gab repository right here so everything

884:03

else is exactly the same like I did not

884:05

change any code but I have to specify

884:08

these parenthesis right here on the

884:10

exact same places pause the video and if

884:12

you want to type there so feel free to

884:14

type there and you know what I'm going

884:16

to hide there from here and now let me

884:18

just copy this filtered project and

884:29

now

884:59

e e

885:40

now to take care of the pagination I'm

885:41

going to go to the top and underneath

885:43

this filtered project I'm going to start

885:45

work on pagination okay so now

885:48

underneath this comment I'm going to

885:50

first of all create a state which will

885:51

allows us to take care of the current

885:53

page so I'll write like current page and

885:55

then Set current uh page it's going to

885:58

be equals to the use State and the

885:59

initial value will be set to one like we

886:01

want to basically start from the first

886:03

page so that's why we specified one in

886:05

there now let me just write items per

886:07

page so per page you want to set the

886:09

items so let's just write per page on

886:11

per page we want to set the items to

886:13

only five elements like here you can see

886:15

we have like Petra of a lot of people

886:18

but we only want to set the five people

886:20

on per page nothing else than there so

886:22

that's going to be for the second one

886:24

and now let's just write a start index

886:26

I'll write like start index and that's

886:27

going to be equals to uh let's just

886:29

write the current page and then minus

886:32

one from there it's going to gives us

886:34

basically the last index and now we want

886:35

to multiply there by items per page okay

886:40

so here you can see we have the items

886:41

per page which simply means that we're

886:43

now multiplying all of them by five let

886:46

me just undo there and now underneath

886:47

there we're going to be getting the

886:49

current projects I'll use like current

886:51

projects and it's going to be equals to

886:53

the filter data uh or filter projects to

886:56

be precise which is that filter project

886:59

so in which in this filter project we

887:00

have all of that logic about the search

887:02

query and the filter name country email

887:05

and so on and so forth you get the idea

887:07

and we're going to be using there right

887:09

here and then inside there we're going

887:11

to be using the slice method and then

887:13

first of all we have to specify the

887:14

start index which is this variable right

887:16

here and then we have to specify the

887:19

start index plus the items per page and

887:22

that's it for the current projects now

887:25

the next thing that we have to do is

887:26

that we have to get the total pages so

887:27

I'll just write like total pages and

887:29

that's going to be equals to to the

887:31

math.co and here we have to specify the

887:34

filtered projects right here come on

887:38

filtered projects. LIF and we have to

887:42

divide them by items per page okay so

887:45

that's going to be it for the total

887:47

pages and finally we have to take care

887:48

of the handle submit but we're going to

887:50

be doing that in a few seconds so I'm

887:52

going to go to the very bottom and here

887:54

we have to specify all of that values

887:56

right here so what I'm going to do is

887:58

that first of all I'm going to provide a

888:00

disable start on there and it's going to

888:02

be disabled if the current page is

888:04

triple equals to one like if you are on

888:06

the first page so we going to be setting

888:08

the previous button to disable and when

888:10

somebody clicks on this button we're

888:12

going to be firing this function which

888:13

we're going to be creating in a few

888:14

second which will be a handle page um

888:17

yeah handle page change and here we're

888:19

going to be specifying the current page

888:21

and then minus one now for the next

888:24

button we're going to be also taking

888:25

care of there but instead of providing

888:27

this one I'm going to just replace that

888:29

with Dynamic value which will be the

888:31

current page and also how many pages we

888:34

have so I'll just write like total pages

888:37

okay so it's going to give us like the

888:38

current page and also how many pages

888:40

that we have now let me also provide

888:43

there for the button so I'll just write

888:44

like uh disable and this button will be

888:47

disabled if we have the current page

888:49

triple equals to the total Pages like if

888:51

you have the last page then we're going

888:53

to be disabling this next button okay so

888:56

if that's not the case we're not going

888:57

to be disabling there so when somebody

888:59

clicks on this button we're going to be

889:01

firing this function which is the handle

889:03

page change okay so let's just write our

889:06

handle and here we have to specify the

889:07

current Page Plus one and now I'm going

889:09

to save them now let me create this

889:11

handle page change on the top so I'm

889:13

going to go to the very top and

889:16

underneath all of them we're going to be

889:18

defining our function you're not going

889:19

to be doing anything crazy but I'll just

889:21

write like const this

889:23

should what the hell am I doing let's

889:26

just remove the and con handle page

889:28

change and this can be equals to the

889:30

page number and that's going to take a

889:32

number as a perimeter and we are going

889:35

to be using the Set current page and we

889:37

only have to specify the page number

889:39

inside there and that ladies and

889:41

gentlemen was the entire thing but now

889:44

I'm going to copy this current project

889:46

and instead of providing all of that

889:48

filter data we are going to be using

889:51

this current page right here so now if I

889:53

save my file and now let me just test

889:55

this out so here you can see on the

889:56

current page we only have five people I

889:59

can also increase the size of that if I

890:01

wanted to so I'm going to go to the top

890:02

and change that to like I don't know

890:03

maybe seven or something now it's going

890:06

to gives us that seven people right here

890:08

I can also make there like 10 and I

890:11

guess 10 would be fine you know what let

890:13

me just change that to nine or8 would be

890:16

fine rather and now that's looking

890:18

better I can also click on the next page

890:20

so it's going to brings us to the next

890:21

page right here and now we are getting

890:23

like page and we're now in this page

890:25

like the second page so now here you can

890:27

see this button is disabled like I

890:29

cannot click on there and now if I want

890:31

to go back I can click on this previous

890:33

one so it's going to brings us to this

890:34

previous right here now I can also sort

890:36

anything by name I can also sort it by

890:39

country and I can also sort the by dat

890:41

we can also provide a filtration like I

890:43

don't know let's suppose if I want to

890:44

get like Lucas uh LCS so it's going to

890:48

give us that Lucas right here and

890:49

everything is working the way we expect

890:51

him to work anyways so that was it about

890:53

for this entire project so here you can

890:55

see we are now getting the images we are

890:57

getting the sidebar we can sort our data

890:59

we can filter our data by using name

891:01

country email we also implemented the

891:03

page ination so we can go to the next

891:05

screen and if you have like a lot of

891:07

data we're going to be getting like a

891:09

lot of pagination right here so yeah

891:11

that was the simple project for the

891:13

typescript this is what we're going to

891:14

be building in this project by using

891:16

reactjs typescript and tman CSS so now

891:19

let me show you the functionalities that

891:20

we are going to be implementing in this

891:22

project the first thing that we have is

891:24

a filter so we can select the cheap

891:26

products as you can see this one is the

891:27

cheapest one we can also select the

891:29

expensive one one here you can see we

891:31

have a expensive product we can also

891:33

select the popular one and this one is

891:35

the popular one right here we can also

891:37

search by the product name suppose if I

891:39

want to search for a Rolex so I'll just

891:41

write like Rolex and here you can see

891:43

it's going to give me all of their

891:44

products which have the name of Rolex so

891:46

I'm going to remove that from here we

891:48

can reset our filter so I'm going to

891:49

click on there you can also search by a

891:51

minimum price and also the maximum price

891:53

so suppose if I just write like the

891:55

minimum price of 20 and then I'm going

891:57

to also put the maximum price of like

891:59

200 200 so here you can see it's going

892:01

to only give me that two products right

892:03

here and we can also select by a

892:05

category so if I just select like Beauty

892:07

so it's going to only give me the beauty

892:09

products you can also select by

892:10

different kind of things let's suppose

892:12

if I click on the furniture it's going

892:13

to only give me that furniture right

892:15

here and so on and so forth okay so now

892:17

let me just refresh there one more time

892:18

we can also select by a keyword so let's

892:21

suppose if I click on the Apple it's

892:23

going to give me all of that Apple

892:24

product right here we can also search

892:26

for the watches

892:28

fashion trend shoes shirt and so much

892:33

more okay so that was the first thing so

892:35

now let me just reset there and we also

892:37

implemented the pagination so if I click

892:39

on the second one and here you can see

892:41

it's going to brings us to the second

892:42

page and I can choose like different

892:44

kind of pagination and so on and so

892:46

forth so I can click on the next button

892:48

going to show me the next page I can

892:50

also click on the previous one so it's

892:51

going to brings us to the previous page

892:53

and now if I click on a specific product

892:55

so I'm going to just choose like watches

892:57

and now if I click on a specific product

893:00

and is as you can see right here is

893:01

going to brings us to that specific

893:03

product page so we have the product

893:04

image we have the product name

893:06

description price and also the rating as

893:09

well okay so we can go back to see all

893:11

of the products once again we can also

893:13

follow someone and unfollow someone if

893:15

you wanted to and these are totally

893:17

Dynamic people like we're going to be

893:19

sending a request to the random users

893:20

API if I refresh there so anytime I

893:23

refresh there it's going to give me all

893:25

of that random people right here and

893:27

finally we have these blogs and they

893:29

don't do nothing

893:31

so now let's get into the setup of this

893:32

project and I'm going to see you there

893:34

let's talk about the requirements for

893:35

this video so for this video you will

893:38

have to know the JavaScript so if you

893:39

don't know what a JavaScript is so I

893:41

have a complete course on there you also

893:43

would need to know a tellin CSS so I

893:45

have a complete course on there you also

893:47

have to know a typescript and reactjs

893:49

and also you have to take this course

893:52

which is Advanced typescript types for

893:54

nextjs but this course is not only for

893:56

the next JS uh develop I made this

893:58

course for both rejs developers and also

894:00

for the next year developers if you

894:02

complete these courses I can totally

894:04

guarantee that you're going to be

894:05

calling yourself as a typescript and

894:08

reactjs monsters now let's get into the

894:10

setup of this video now let me make a

894:12

setup for my coding Journey so I'm going

894:13

to open my terminal right here on my

894:15

desktop and I'm going to just P this

894:16

command which is create a new project by

894:18

using the weed and I'm going to just

894:20

give it the name of like R Ecom you can

894:22

give it any name that you like and I'm

894:23

going to just hit enter right now I'm

894:25

going to write Y and hit enter and now

894:27

I'm going to choose the react I'm going

894:29

to also choose the the typescript

894:31

because in this video we're going to be

894:32

also using a typescript as well so I'm

894:34

going to go ahead and go to that folder

894:36

which is react

894:37

Ecom and now let me use npmi to install

894:41

every single thing now then successfully

894:43

done so I'm going to clear this out and

894:44

now we have to install more packages

894:46

which is AOS Lucid icon and also react

894:49

router Dom I'm going to hit enter so

894:51

it's going to install that in my machine

894:53

now then successfully done the next

894:54

thing that we have to do is that we have

894:56

to go ahead and go to the tman css.com

894:58

then dogs guides and we so once we are

895:01

there so this step is now successfully

895:02

done the next thing that we have to do

895:04

is we have to copy this command and I'm

895:05

going to place that right here paste it

895:07

anyways and I'm going to also hit enter

895:09

so it's going to initialize my tman CSS

895:11

inside my project now thenly done so I'm

895:13

going to open my vs code right here

895:15

inside that specific folder next we have

895:17

to copy this configuration and we have

895:19

to go to the tailin config.js file and

895:21

we have to place that right here so I'm

895:23

going to sell my file and now let me

895:25

just scroll down so we also have to go

895:26

to the index.css file so I'll just write

895:29

index.css and let me just place that

895:31

right here okay so now let's just remove

895:33

that from here and finally I'm going to

895:35

go ahead and go to my app app. TSX and

895:37

I'm going to just replace that with this

895:39

code okay and finally now let me just

895:41

run there I'm going to be using npm run

895:43

Dev and it's going to run there right

895:44

here so and we are now getting what

895:46

hello word right here which is amazing

895:48

so now let me just do a bit of cleanup

895:49

so I'm going to just remove This Ss from

895:51

here I'm going to also remove this f.

895:53

CSS and I'm going to go into my main and

895:56

yeah I guess that's going to be it so

895:58

you know what let me just check this out

895:59

let's just refresh fres there and yeah

896:01

that's going to be it for the setup and

896:03

you know what we also don't need the

896:04

public so I'm going to also remove the

896:05

public from here so that was it about

896:07

for the setup next we have to create our

896:09

components folder and I'll just give it

896:11

the name of like components and now

896:13

inside there we're going to be creating

896:15

first of all our sidebar. TSX and I'm

896:17

going to just create my component by

896:19

using our FC now inside this component

896:21

first of all we have to create our state

896:23

for the categories so I'll just write

896:25

categories and then set categories just

896:28

like that and it's going to be equals to

896:29

the used St and not transition but the

896:32

use St I'm going to set that to empty

896:34

array because here we are going to be

896:36

storing all of our categories and now

896:38

I'll just annotate there with the string

896:41

of array just like that okay so that's

896:43

going to be our first state now I'm

896:44

going to also create a state for the

896:45

keywords but now in this case we are not

896:48

going to be changing our keyword so I'll

896:49

just write like keywords and I'm not

896:51

going to just write like set keywords or

896:53

something like that because we are not

896:54

changing our um state so I'll just write

896:57

like UST St and all of these item I'll

896:59

just place that right here here and I'm

897:00

going to also annotate there with the

897:02

string okay so string of array

897:05

underneath that we are going to be

897:07

fetching our data by using the use

897:08

effect and now inside there first of all

897:11

let me provide my empty dependency array

897:12

now inside there we are going to be

897:14

creating our fetch categories it's going

897:16

to allows us to fetch our categories by

897:18

using this function that's going to be

897:20

an asynchronous function because we

897:21

going to be calling some API okay so

897:23

I'll just write a try in catch block and

897:25

for the catch block I'll just write like

897:27

um console. error and then error

897:30

pitching products okay and I'll just

897:33

pass my error right here and if that's

897:35

not the case so first of all we are

897:36

going to be getting the response by

897:38

using the aware we're going to be

897:39

fetching our data from https and then

897:42

the dumy jon.com and for/ products and

897:47

now let me get a data adjacent data from

897:49

that response I'll just write data and

897:52

then it's going to be equals to uh you

897:54

know is going to be equals to the aware

897:56

and then we're going to be using

897:57

response. Json but you know I'm going to

897:59

also create interface for there so I'll

898:01

just give it the name of like uh uh

898:04

fetch response and now let me just

898:06

create the right here up above and first

898:08

of all we're going to be creating an

898:10

interface for the product itself and

898:13

I'll just write like category and it's

898:14

going to be equals to the string and now

898:16

underneath that we're going to be

898:17

creating an interface for that fetch

898:19

response and it's going to be set to the

898:21

products and then that products

898:22

interface which we' have created up

898:24

above okay and it's going to be set to

898:25

this empty array so that's there and now

898:28

let me just log my data to the console

898:30

so I'll just write like cons. log of

898:31

data and also let me just call this

898:34

function right here okay so I'll just

898:36

use like fetch categories and now let me

898:38

just execute this function I'm going to

898:40

save my file and nothing will happen

898:42

right here why is there because we did

898:44

not register this component anywhere so

898:46

now let's just do that I'm going to go

898:47

ahead and go to my app and here now let

898:50

me just register my component so first

898:52

of all you know what you need a few

898:54

things so I'll just import first of all

898:55

my browser router so I'll just write

898:57

like browser router is router I'm going

899:00

to rename that to the router and also

899:02

let's just import our component which is

899:04

a sidebar component so I'm going to copy

899:06

that From Here and Now inside there

899:08

let's just remove that from here I'm

899:10

going to write my router first of all

899:12

like the opening and closing off router

899:15

inside there we are going to be creating

899:16

our D with the class of flex and also

899:18

the home of screen and I'm going to hit

899:20

enter Right Here and Now inside there we

899:23

just have to call our sidebar I'm going

899:25

to sve my file and now let me test this

899:26

out and now let's just refresh there and

899:28

here you can see we are now getting all

899:30

of that data right here so we have a

899:31

products here you can see each of that

899:33

product will gives us the category of

899:35

beauty but we want only the unique ones

899:37

right here we don't want to get like

899:39

Beauty again and again we only want to

899:41

get the beauty one time okay and then we

899:43

want to get like I don't know maybe uh

899:46

something else like this one I can't

899:47

even pronounce this word but yeah we

899:49

only want to get the unique categories

899:51

we don't want to get all of them so how

899:53

in the world we're going to be getting

899:54

our unique categories so we're going to

899:55

be using like array. from and now inside

899:58

there we're going to be passing a new

900:00

set to there and that set takes an

900:02

itable and it will only gives us the

900:04

unique value out of there so I'll just

900:06

use like data and then we are going to

900:08

be iterating over through that products

900:10

and now we have to use like map method

900:12

for this so I'm going to just write like

900:13

product and then I'm going to be using

900:15

like product. categories now it's going

900:16

to give us only the unique ones so I can

900:18

totally store them the variable like uh

900:21

unique categories and it's going to be

900:23

equals to that code and now let me just

900:24

Lo to the console my unique category so

900:26

if I save my file and now let me just

900:28

run that and here you can can see we are

900:30

now only getting these four categories

900:32

right here okay so we have a beauty and

900:34

so on and so forth so yeah this how we

900:36

going to be getting a unique values from

900:38

our data so I'll just remove that from

900:40

here and I'm going to just set that to

900:43

my categories so I'll just write like

900:45

set categories and we are going to be

900:46

only passing a unique categories to

900:48

there okay so this is how we going to be

900:50

fetching our category and now it's time

900:52

to render this so I'll just remove that

900:53

from here I don't know what's happening

900:55

with this GSX maybe I'm going to have to

900:57

restart my vs code okay now it's better

900:59

so first of all you know what I'm going

901:00

to have to just provide a few classes to

901:02

it so I'll just write like width of 64

901:04

and pairing all around will be set to

901:06

five and height will be set to screen

901:08

that's going to be our first D now

901:10

inside there we're going to be creating

901:11

our H1 with a class of text 2 Xcel font

901:14

of totally Bard margin for a bottom will

901:16

be set to 10 and margin for the top will

901:18

be set to four and I'll just give the

901:19

name of like react store you can give it

901:21

any name that you like I'm going to sell

901:22

my file and here you can see we are now

901:24

getting our react store right in here

901:26

which is looking amazing I'm going to

901:28

also hide this sidebar from here now

901:30

it's looking better underneath that we

901:31

are going to be creating our section and

901:33

now inside this section we are going to

901:34

be first of all creating our input Forex

901:37

and I'll just write like uh the class

901:39

name of Border 2 pixel and also totally

901:42

round it ping for the xaxis will be set

901:44

to two on the small screen size we're

901:46

going to be providing margin for the

901:48

bottom of zero okay and I'll also

901:50

provide the placeholder of search come

901:53

on search product okay and in this case

901:56

I'm not going to be providing any values

901:58

to that so I'm going to save my file

901:59

okay so that's going to be it for the

902:01

first one now I'm going to also create a

902:03

d with the class of flex and also the

902:05

justify come on justify of Center and we

902:08

are going to be providing the items of

902:09

Center as well and now inside that we

902:11

going to be creating our input with a

902:13

with a type of text and I'll also

902:15

provide a class name of Border two

902:18

margin for the right will be set to two

902:19

ping for the x-axis will be set to five

902:22

ping for the y- axis will be set to

902:23

three and also margin for bottom will be

902:25

set to three and width will be set to

902:27

totally four and you know I'm going to

902:29

also the placeholder of Min I'm going to

902:31

duplicate this line of code and I'm

902:33

going to also provide a Max right here

902:34

okay so now let me just save my file and

902:36

this is how it looks like right here I

902:38

know it's looking awful but yeah we will

902:40

change the next we have to take care of

902:41

our categor so I'm going to come

902:43

underneath this div and I'll just write

902:45

like categories section first of all we

902:48

have to create our D with a class of

902:49

margin for the bottom of five and we

902:52

have to create our H2 with the text of

902:54

extra large extra large and the font

902:57

will be semi B margin for the bottom

902:59

will be set to three and now let's just

903:01

write our categories inside there and

903:04

this is how it looks like right here so

903:06

that's amazing now underneath there we

903:07

are going to be iterating over through

903:09

all of that categories which we've

903:11

proved right here so we are going to be

903:12

itating over through all of them and

903:14

then we are going to be rendering like

903:15

only the unique ones so I'll just write

903:18

like categories and now let's just use

903:20

our map and here I'm going to provide my

903:21

category and also the index and now

903:24

inside there first of all let me provide

903:26

my label and for each label I'm not

903:29

going to be providing in HTML 4 I'm

903:30

going to provide my key of Index right

903:33

here and also let me just provide a

903:34

class name of block and margin for the

903:36

bottom will be set to only two okay so

903:38

now let's just go inside there and I'm

903:41

going to be creating my input first of

903:42

all and for this input we're not going

903:44

to be using text but instead we're going

903:45

to be using a radio I'll just provide a

903:48

name of like category and I'm going to

903:51

also provide the value of category as

903:53

well and you know I'm not going to be

903:55

providing any on change or anything like

903:57

that so I guess that's going to be fine

903:59

but but I'm going to also provide a bit

904:00

of styling to it so like uh margin for

904:03

the right will be set to two width will

904:05

be now set to 16 pixel and height will

904:07

be also set to 16 pixel so now let me

904:09

just save my file and this is how my

904:12

categories looks like right here but now

904:14

we have to render our categories and to

904:15

do that we are going to be using my

904:17

category uh yeah category just like that

904:21

and I'm going to be using two upper case

904:22

if you don't like the upper case you can

904:24

totally change that but yeah in my case

904:26

that's looking better so yeah we are

904:28

totally good here so that's looking

904:30

amazing now you know what I'm going to

904:32

also take care of the keywords as well

904:34

so and I just realized that I'm going to

904:36

have to wrap in some sort of a section

904:38

so I'll just cut that from here and now

904:41

let me just put that right underneath

904:42

there and now let's just take care of

904:44

the keyword so I'll just write like

904:45

keywords and section okay so now let's

904:48

just take care of this so first of all

904:49

we're going to be creating margin for

904:51

the bottom of five H2 with a class of

904:53

text extra large and also the font will

904:55

be set to semi Bol margin for bottom

904:57

will be set to three and let's just

904:59

right to our keywords right here so I'm

905:01

going to sell my file and this is how it

905:02

looks like right here you can also

905:04

provide like some sort of margin for the

905:06

top of four or something I guess that's

905:08

looking pretty good underneath that

905:09

let's just create another div and now

905:11

inside this div we're going to be

905:12

iterating over through all of the

905:13

keywords and let's just use a map right

905:16

here and I'm going to pass my keyword

905:18

and also the index as well okay so now

905:20

inside them we going to be creating a

905:22

button you can create like any kind of

905:24

UI if you wanted to and I'll just past

905:27

like the key of my index and also let

905:29

sty I'll just write block margin for the

905:31

bottom will be set to two pairing for

905:33

the xaxis will be set to four pairing

905:35

for the Y AIS will be set to two and

905:37

width will be set to totally full text

905:39

will be set to the left and let's just

905:41

provide a border and also rounded once

905:43

we have our over it we want to change

905:45

the background color of gray to 200 okay

905:47

so that's going to be it and now inside

905:49

this BT we want to use like keyword dot

905:52

to uppercase if you want to change there

905:54

you are more than welcome to change

905:55

there okay so here you can see I have my

905:57

buttons right here the keyword buttons

905:59

right here which is also looking amazing

906:01

and now finally we have to take care of

906:03

that one button okay so I'll just go

906:06

down here and now let me just create a

906:08

button right here and let's just style

906:10

there a bit so I'll just put the width

906:11

of totally full MB margin for the bottom

906:14

will be set to four rim and pairing for

906:16

the Y AIS will be set to two background

906:18

will be set to totally black and text

906:20

will be set to totally white and round

906:22

it margin for the top will be set to

906:24

five and I'll just put the level of like

906:26

reset filters I'll just save my file and

906:29

here you can see this is how my reset

906:31

filter will look like so we are now

906:33

totally done with this UI stuff but now

906:35

the next thing that we have to do is

906:37

that we have to take care of the

906:38

functionality we are going to be making

906:40

some sort of a changes inside this

906:41

sidebar. TX file and we want to render

906:44

that change data inside the main

906:47

content. TSX file which we are going to

906:49

be creating very soon so how in the

906:50

world we are going to be doing there

906:52

well the first way is to use a Redux

906:54

toolkit or Redux whatever you want to

906:57

call them and the next way is to use the

906:59

context so this project is not the big

907:01

project so we're going to be using only

907:02

the context so I'll go ahead and create

907:04

my context right here so I'll just give

907:05

it the name of like filter context. TSX

907:09

not text but TSX just like that and

907:12

inside this context first of all we

907:14

going to be importing a lot of things

907:15

like uh we have to import our create

907:17

context we also have to import our use

907:20

context and also we have to import our

907:23

use St and also we have to import our

907:25

react now so we are going to be

907:27

importing all of that from the react CH

907:30

next we have to create our big interface

907:32

so I'll just write like interface and

907:33

I'm going to give it the name of like

907:34

filter context type and I'm going to

907:37

just make the as uppercase and now

907:39

inside there first of all we have to

907:40

write our search query and you know let

907:42

me just zoom in a bit right here and

907:44

it's going to be set to string we

907:45

already know that we also have to write

907:47

our set search query and it's going to

907:49

be set to a function which will take

907:51

some sort of a perimeter of query and

907:53

that's going to be a string and now we

907:54

have to provide our white right here and

907:56

also we have to write our selected

907:58

category and it's going to be set to a

908:00

string we already know that and then

908:02

select set selected category will be now

908:06

equals to this function which will also

908:08

take a category as a perimeter and

908:10

that's going to be a string okay so we

908:12

also have to set that to the white let

908:14

me provide my minimum price and that

908:16

minimum price we already know that it's

908:17

going to be either a number or it's

908:19

going to be totally undefined we don't

908:21

want to accept anything else in the case

908:23

so either a number or undefined then we

908:25

have to provide our set minimum price

908:27

and it's going to be set to this price

908:29

and that's going to be totally a number

908:31

okay or maybe undefined okay so let's

908:34

just provide our wide right here because

908:36

that's going to be a function and let's

908:37

just provide for the max price and Max

908:40

price will be either a number or

908:41

undefined and also the set max price

908:45

will be now set to this function which

908:47

will be a price and now let's just

908:49

provide either a price or the undefined

908:51

and now we also have to return the white

908:53

because this is going to be a function

908:55

or a method rather and now let's just

908:57

provide our keywords or keyword singular

909:00

and it's going to be set to a string and

909:01

then we have to WR our set keyword and

909:03

that's going to be a function which will

909:05

take the keyword as a perimeter and

909:07

that's going to be a string and now we

909:09

have to just return the Y inside this so

909:11

let's just go back and this is how we

909:13

going to be creating our filter context

909:15

types that's going to be only the types

909:17

okay so let's just create our uh filter

909:19

context right here so I'll just write

909:21

like create context and now here inside

909:24

there we're going to be providing only

909:25

the undefined right here but for the

909:27

type we're going to be providing first

909:29

of for the filter context type or

909:31

undefined and now let me just close them

909:33

I'll just write like const filter and

909:37

then context and now we have to store

909:38

them in this variable right here okay so

909:41

everything is looking good but we have

909:42

to just use these unused variables the

909:44

next thing that we have to do is that we

909:45

have to create our provider so I'll just

909:47

write like export cons filter provider

909:51

and you can give it like any name that

909:52

you like and I'm going to be using like

909:54

react. functional component right here

909:56

in this case and we're going to be

909:57

providing uh our children so that's why

909:59

I'm using the so we're going to set the

910:01

children come on children to the react

910:05

node and now we have to just set that to

910:07

equal to this children right here okay

910:10

and now finally we have to go to the bod

910:12

now let me just send my file it will

910:14

gives us that error but I want you to

910:15

just ignore that for a few seconds

910:17

because it will fix

910:19

itself this is just a typescript error

910:21

so first of all we have to define a lot

910:23

of stats so we are going to be defining

910:25

like the search query State and also set

910:28

um search query it's going to be equals

910:31

to the used St and now inside there we

910:34

are going to be setting there to empty

910:35

string so I'll just set there to only a

910:37

string okay so yeah that's going to be

910:40

the first one now the next thing that we

910:41

have to do is that we have to create our

910:43

uh selected category and then set

910:47

selected category as well it's going to

910:49

be equals to the use St now inside there

910:52

we're going to be also setting there to

910:53

the empty string just like that and also

910:56

we have to set the minimum price and

910:58

also set Min price is going to be equals

911:01

to the Ed St and we have to set that to

911:05

undefined initially because we don't

911:06

want to set the initial value to

911:07

anything and you will see that why I'm

911:09

providing the undefined right here okay

911:11

in a few seconds so now let me just uh

911:13

annotate with the undefined and you know

911:15

I'm going to just you know I'm not going

911:16

to duplicate that so I'll just write

911:18

like the max price and then the set max

911:21

price it's going to be equals to the use

911:24

St use St and we're going to be

911:27

providing the undefined as initial value

911:30

okay so let's just provide either the

911:31

string or undefined and why am I

911:34

providing a string these are the prices

911:37

so we have to set there to number

911:39

underneath that we have to create our

911:40

keyword and let's just write our keyword

911:43

and then the set keyword K going to be

911:45

equals to the US St and we have to just

911:47

set that to the empty string just like

911:51

that now we are totally done with that

911:52

so I'll just write like return provide

911:54

my filter

911:56

context. provider case now inside there

911:59

uh we are going to be also providing our

912:01

children right here so I'll just write

912:02

like uh

912:04

children and I'm going to also provide

912:06

my values right here so I'll just write

912:08

like value and I'm going to destructure

912:10

there so I'll first of all provide my

912:12

search query and I'm going to also

912:14

provide my set search query and selected

912:17

category and also the set selected

912:19

category minimum price and also the max

912:23

or you know set minimum price as well

912:25

set Min price and also the maximum price

912:29

and set max price and also the keyword

912:33

and set keyword just like that so I'm

912:35

going to sell my file and then finally

912:37

we have to just create our use filter

912:40

okay so let's just use our export cons

912:42

use uh filter it's going to be equals to

912:45

this function right here and now let me

912:47

just provide first of all my context you

912:49

can give any name that you like and I'm

912:50

going to just use my use context right

912:53

here and we're going to be providing our

912:55

filter context to there okay and now we

912:57

have to check if we don't have have that

912:59

context so what do you want to do in

913:01

that situation we just want to throw the

913:03

new error and you want to say that use

913:06

filter must be used with within a filter

913:11

provider provider just like that and if

913:14

that's not the case we just only want to

913:16

return our context just like this so I'm

913:17

going to sve my file and that was a lot

913:20

of talking I don't know where in the

913:22

world this used transition came from but

913:24

yeah that's everything that you have to

913:26

do for the filter context now that we

913:28

successfully cre our context so now the

913:30

next thing that we have to do is that we

913:31

have to go ahead and go to our main and

913:33

we have to register that right here so

913:35

first of all we have to import our

913:36

filter provider and now we have to wrap

913:38

every single thing inside this so I'll

913:40

just write like filter provider and I'm

913:42

going to close that and let me just put

913:44

my app inside this filter provider so

913:46

that's to done next we have to use this

913:49

filter context inside this sidebar

913:51

component so how are we going to be

913:52

doing there first of all we have to

913:54

destructure every single thing from

913:56

there so we going to be using like use

913:57

filter now inside this use filter we are

914:00

going to be restructuring all of that

914:01

properties so I'll just put that right

914:03

here and yeah we did not use that so

914:05

that's why we are now all declare

914:07

element are unused so that's why we are

914:08

now getting this error like we have

914:11

these variable but we did not use this

914:12

so now let's just use them first of all

914:14

we have to take care of the first input

914:16

field which is this input field right

914:19

here so I'm going to provide the initial

914:20

value of the search query and I'm going

914:23

to also provide the on change and once

914:26

we change something inside there so

914:28

we're going to be using like set search

914:30

query and we're going to be providing e

914:32

target. value like what did we type

914:34

inside their input okay so that's going

914:36

to be the first one and next we have to

914:38

take care of this input field right here

914:40

like the minimum and also the maximum

914:42

okay so for the minimum we're going to

914:44

be providing the value right here and

914:46

the value will be either the minimum

914:47

price which we are now getting from the

914:49

top and now if that's not the case we

914:51

are going to be only setting there to

914:53

empty string okay so once we change

914:55

something inside this we are going to be

914:57

calling this function which is handled

914:59

uh price change this is not big function

915:01

to create it separately but you know

915:04

what I don't want to clutter my UI so

915:05

I'm going to go to the top and now let's

915:07

just create that right here so I'll just

915:08

use like const and handle Min price

915:11

change and it's going to be taking that

915:13

event object and now inside then we're

915:15

going to be first of all getting the

915:17

value from this we can use like e.

915:19

target. value and we can also just set

915:21

that to the minimum price right here so

915:24

value if we have some sort of a value

915:26

and convert our value to that floating

915:28

Point number and if we don't have the

915:30

value so we just want to set there to

915:31

undefined and now let me take care of

915:33

this event error right here just use

915:35

like fre dot change event and now we

915:38

have to just pass our HTML input element

915:41

right here inside there so this how it's

915:43

going to resolve their error right here

915:45

okay so that's going to be the first one

915:46

now let's take care of that maximum one

915:49

right here okay so we're going to be

915:50

providing the value today so let's just

915:52

write our value and the initial value

915:54

we're going to be setting there to the

915:56

maximum price and if we don't have the

915:58

maximum price so for that we are going

915:59

to be using the empty array not empty

916:01

array but just empty string okay so then

916:04

we have to use our own change when we

916:05

want to change something inside there so

916:07

for that we are going to be using like

916:08

handle Max price change kind of a Long

916:11

Function name so we just have to create

916:13

that right here so I'm going to be using

916:15

there it's going to also tag that event

916:17

so you know I'm going to have to copy

916:18

this entire thing from here now let me

916:20

just place that right here and let me

916:22

close them and we're going to be doing

916:24

the same thing like we have to get the

916:26

value by by using the e. target.

916:29

and we also have to change the set

916:31

maximum price and then we have to

916:33

provide our value if we have the value

916:35

so we have to change that to the parts

916:36

float and if we don't have the value so

916:38

we just want to change there to

916:40

undefined okay so I'm going to save this

916:41

file and that's going to be it for the

916:43

handle Max price change okay so let's

916:45

just see what else is left and here you

916:47

can see we also have to take care of

916:49

this input field right here which is not

916:50

going to be that much of a problem so

916:52

what I want to do is that I want to

916:54

provide my what do you call it um I'm

916:58

going to provide my my own change and

917:00

it's going to be taking this function as

917:02

input Handler so I'll just use like

917:03

handle radio change Kor just like that

917:08

and we're going to be passing our

917:10

category category inside there and I'm

917:13

going to copy there from here and let's

917:15

just go to the top and I'm going to just

917:17

create that right here we not going to

917:19

be doing anything crazy but we are going

917:20

to be just creating this function and

917:22

it's going to be taking the category as

917:23

a perimeter and that's going to be a

917:25

string and now inside there we have to

917:27

just write like set s category let's

917:30

just provide our category inside there

917:32

underneath this class name what do we

917:34

have to do we have to just provide our

917:35

check and we are going to be setting

917:37

there to the selected category and if

917:39

that's equals to the category so only

917:42

just check that and if that's not equal

917:44

to the category and make it disable Okay

917:47

so that's going to be for the checked

917:49

and now let's just take care of these

917:52

keywords right here when somebody clicks

917:54

on this button right here so what do we

917:56

have to do in that situation we want to

917:58

change the hand keyword click okay and

918:01

we're going to be only passing the

918:02

keyword inside this so I'm going to copy

918:04

that from here and we have to just

918:05

create that right here inside underneath

918:08

this handle radio change category so

918:10

I'll just create there right here it's

918:12

going to be taking a keyword and let's

918:14

just for a string to there now let's

918:16

just change our set keyword and we're

918:18

going to be only passing our keyword

918:19

inside there okay so I'm going to sve my

918:21

file and I guess that's going to be it

918:23

for the functionality if I am not wrong

918:25

yeah I am wrong because we have to take

918:27

care of this filters as well okay so how

918:31

we are going to be doing that to do that

918:32

first of all we have to provide our

918:34

Handler right here so we're going to be

918:36

just writing like on click Handler so

918:38

we're going to be passing like handle

918:39

reset okay so I'm going to copy that

918:41

from here and let's just go to the top

918:43

and set everything to the empty string

918:46

okay so I'll just write like const

918:47

handle reset filters and now inside then

918:51

what do you have to do first of all we

918:52

have to ride our search query and we

918:54

have to set there to empty string we

918:56

have to get our search selected category

918:58

we have to set to empty string we have

918:59

to get our set minimum price we have to

919:01

provide the undefined inside there we

919:04

have to get our set maximum price we

919:06

have to set there to undefine and also

919:08

the set keyword to empty array to empty

919:12

string so I'm going to sell my file and

919:14

I guess that's going to be it so you

919:16

know what the functionality is not toly

919:17

done but now the next thing that we have

919:19

to do is that we have to render our

919:21

content right here the sidebar is now

919:23

totally done okay so that's going to be

919:25

it for the sidebar and now let's just

919:27

create our main content comp component

919:29

so main content con main content. ESX

919:35

and I'm going to just write like RFC and

919:37

Main content inside there so I'm going

919:39

to sve my file and now let me go ahead

919:40

and go to my app underneath this sidebar

919:43

we're going to be creating a div I'll

919:44

just provide a few classes to it like

919:46

rounded and then the width will be set

919:49

to totally full and also the flex

919:51

justify will be set to between and also

919:54

Flex will be set to totally wrap okay

919:57

just like that and inside the then we're

919:58

going to be just providing our routes

920:00

you don't have to do that but if you

920:02

want to do that so that's going to be a

920:04

better idea if you want to create a

920:05

separate page you can totally do that

920:07

but you know what I'm not going to do

920:08

that I'll just write like route and

920:11

let's just get that from the react

920:12

router and let's just close it right

920:14

here I'm going to provide a path to that

920:16

and path will be just a home and for the

920:18

home we are going to be just providing

920:19

an element of our main content component

920:22

which we just created right here so I'm

920:24

going to sve my file and here you can

920:25

see we now getting our main content

920:27

right here which is amazing so I'm going

920:29

to close there and let's just close this

920:31

filter and also this sidebar and now

920:33

let's just take care of this main

920:34

content component so what I'm going to

920:36

do is there first of all I'm going to

920:37

have to import a lot of things from uh

920:39

what do we call it from or use filter

920:43

okay so let's just execute them and now

920:45

inside that we have to destructure like

920:47

the search query and also the selected

920:50

category and also the minimum price the

920:53

maximum price and also the keyword okay

920:56

so I'm going to go back come on let me

920:58

just go back and I'm going to sell my

920:59

file and that's the thing that we have

921:01

to import right here next we have to

921:03

create a few stats like products and

921:05

then set products it's going to be now

921:07

equals to the used St and we can provide

921:10

like basically anything anything for the

921:13

array okay so let's just provide our

921:14

empty array right here and also let's

921:16

just create our filter and set filter

921:19

it's going to be equals to the use St

921:21

and for the initial not a used

921:23

transition but a used St and the initial

921:26

value we're going to be passing all to

921:27

it and also I'm going to pass my current

921:31

uh page and then Set current come on Set

921:35

current page it's going to be equals to

921:38

us St use stad and we're going to be

921:41

passing one to it like for the initial

921:43

value and then let's just also create

921:45

for the drop down menu because we're

921:47

going to be also creating a drop down

921:48

menu as well and then set drop down open

921:52

okay so it's going to be equals to the

921:54

use St use St and we're going to be

921:56

providing the initial value of false it

921:59

okay so that's really done but I'm going

922:01

to also create one one variable not a

922:03

state but one variable like items per

922:06

page and it's going to be equals to only

922:08

12 item if you want to increase that you

922:10

can totally do that but in my case only

922:13

12 will do let me take care of the UI

922:15

and then we're going to be going into

922:17

how we're going to be fetching our data

922:19

okay so first of all let me just change

922:20

this D to the section I'm going to copy

922:23

that from here and now let me just

922:24

replace that with this one I'll provide

922:26

a class name of like for the extra large

922:29

screen what you want to do you just want

922:30

to provide this the width of 55 rim for

922:33

the large screen you want to change the

922:34

width to 55 Rim as well and for the

922:38

small screen uh we want to change the

922:40

width to 40 rim and for the extra small

922:44

screen you want to change the width two

922:46

to one rim and also for the padding all

922:49

around will be set to five so that's

922:50

going to be fine and now we have to

922:52

create our D with a class of margin for

922:54

the bottom will be now set to five and

922:56

we also have to create another d uh with

922:57

a class of flex and also the flex of

923:00

column and the small will be set to for

923:02

the smaller screen size we're going to

923:04

be providing the flex of row to just

923:07

like that and you know what I'm going to

923:09

also provide the justify of between and

923:13

also the items will be set to Center

923:15

inside there we're going to be creating

923:16

yet another D with a class of relative

923:18

and also margin for the bottom will be

923:20

set to five and for the top will be also

923:22

set to five okay and we're going to be

923:24

creating only one button inside there

923:27

that button will take these classes like

923:29

border and also pairing for the xaxis

923:31

will be set to four pairing for the Y

923:32

AIS will be set to two and totally round

923:35

it full and flex will be also set to

923:37

item Center okay inside this button what

923:40

do you want to do we just want to

923:42

provide um or icon just for now we are

923:44

going to be only implementing our icon

923:46

which is

923:47

tell3 tell3 we're going to be importing

923:50

there from the Lucid icon and I'm going

923:52

to just provide a class name of margin

923:53

for the right will be set to two Okay so

923:55

I'm going to save my file and this is

923:58

how it looks like right here so we're

924:00

going to be changing all of that stuff

924:01

inside there but for now this is looking

924:03

better you know I'm not going to do that

924:05

later I'm going to do that right now so

924:07

first of all let me just check if filter

924:09

is triple equals to uh all which is

924:12

already set to all right here which we

924:14

have already set there to all so if

924:16

that's the case what you want to do we

924:17

just want to set there to filter and if

924:19

that's not the case so we just want to

924:21

get like filter. character add and you

924:23

want to provide a zero and then two

924:26

lower case inside there not local but to

924:29

lower case you also have to concatenate

924:32

the filter. slice and number one okay so

924:35

I'm going to save there for now and this

924:36

is how it looks like right here but

924:38

currently we don't have any drop down

924:39

menu so that's why we cannot see that

924:41

but you know let me just create that

924:42

drop down menu right here okay so what

924:45

do I have to do underneath this button

924:48

I'm going to just create my drop down

924:49

menu which we've already created up

924:50

above so I'll just write like drop down

924:52

menu and if that's the case so what you

924:54

want to do we just want to first of all

924:56

create a div right here Pro a few

924:58

classes to it like uh absolute we not

925:01

providing an absolute because in this

925:03

case we are now providing the relative

925:04

value so this will be the absolute value

925:06

for there okay so now inside there what

925:09

do you have to do we have to change the

925:10

background color to totally white and

925:12

also I'm going to provide a bit of

925:14

border and border of gray of 300 and

925:17

also totally rounded margin for top will

925:19

be set to two width will be set to

925:20

totally full for the smaller screen size

925:22

we're going to be setting the width to

925:23

totally 40 um yeah totally 40 just like

925:27

okay now inside then we are going to be

925:29

creating yet another button and which

925:31

will say like when somebody clicks on

925:33

there so we're going to be only firing

925:34

this function which is like set filter

925:37

and we are going to be setting there to

925:38

cheap instead of a full you know let me

925:40

just show you there right here which was

925:42

set to full now we are going to be

925:44

setting there to the cheap one right

925:45

here I'm going to also put a bit of

925:47

classes to it like totally block pairing

925:49

for the xaxis will be set to four and

925:51

pairing for the Y AIS will be set to two

925:53

withth will be set to four and text will

925:55

be set to left I'm going to provide the

925:57

how Str to it like when somebody H over

925:59

it so you want to change the background

926:00

color of that to like 200 uh of totally

926:03

gray so now I'm going to just provide

926:05

the level of cheap inside then I'm going

926:06

to sell my file and you know I'm going

926:08

to just duplicate there a few times so

926:10

I'm going to just select this button and

926:12

we have a cheap so we have expensive and

926:14

we also have popular one right here so

926:17

I'm going to just change there to like

926:18

instead of a cheap I'm going to proide

926:21

expensive and here I'm going to also put

926:24

expensive and finally I'm going to put a

926:25

popular so po o want p o l r and here

926:31

popular as well so I'm going to save my

926:32

file now if I click on there so nothing

926:34

will happen so you know I'm going to go

926:36

into my drop down menu it is now set to

926:38

false so I'm going to just set there to

926:40

like true now if i s my file and here

926:43

you can see we're now getting a cheap

926:44

expensive and also the popular one I'm

926:46

going to set that to false once again

926:48

and now we have to take care of the rest

926:49

of the UI so next we're going to be

926:51

working with the card okay so I'll just

926:53

create a d with a class of like grid and

926:55

I'm going to also write a grid of

926:57

columns and and four and I'm going to

926:59

also provide for the smaller screen size

927:01

we're going to be providing the grid of

927:02

columns for the medium one we are going

927:04

to be providing a grid columns Columns

927:07

of four and also I'm going to provide a

927:09

bit of Gap to it so like Gap will be set

927:10

to five and here we're going to be

927:12

rendering the book card very soon okay

927:15

so first of all we have to take care of

927:16

the filter product and then we are going

927:17

to be jumping into the book card so we

927:19

are going to be placing our card in a

927:21

few second but first of all we have to

927:22

fetch our data okay inside this

927:24

component so what I'm going to do is

927:26

that I'm going to be using my use effect

927:27

right here so I'll just use like use

927:29

effect and here we're going to be

927:31

passing our function inside there and

927:32

also our dependency array so for the

927:35

dependency array we are going to be

927:36

passing the current page when the

927:37

current page changes and also the

927:39

keyword so you want to just free fetch

927:41

all of our content So based on that

927:43

first of all we are going to be

927:44

declaring our URL and it's going to be

927:45

equals to you know let me just zoom in a

927:47

bit right here and we're going to be

927:48

setting that to like https and then once

927:51

again our dummy jon.com and then for/

927:54

products and then here we're going to be

927:56

providing a limit to the if you don't

927:58

want to provide the limit so you don't

928:00

have to do that but in my case I am

928:01

going to do that I'm going to be

928:02

rendering my content dynamically so I'm

928:04

going to change that to the template

928:07

literal whatever you want to call it I'm

928:09

going to provide my dollar symbol right

928:11

here and then items per page which is

928:13

now set to only 12 item right here you

928:15

can increase or decrease that if you

928:17

wanted to and in my case I'm going to

928:19

just set that to like uh 12 and 12 will

928:21

do and Skip let's just provide our skip

928:24

right here and that's going to be

928:25

dynamic so I'll just write like my

928:27

dollar symbol and let me just provide a

928:29

current page minus one and then outside

928:32

from there we just want to proide a

928:33

times items per page okay so it's going

928:36

to giv us our URL based on there now

928:38

underneath this URL we have to check for

928:40

our keyword okay so if you already have

928:42

our keyword so you have to change our

928:44

URL to this URL like HTT ttps and then

928:48

where Demi come on Demi jason.com for/

928:52

products and then search Let Me provide

928:55

a key right here and here we are going

928:56

to be rendering our keyword word right

928:58

in here okay so that's going to be the

929:00

next one and finally we have to use our

929:02

exus to fetch all of our content so you

929:04

can totally use the fetch if you want it

929:06

to but in my case I'm going to just set

929:07

that to like xuse but to do that we

929:10

already installed that but we have to

929:11

grab that right here up above so I

929:13

already imported there okay so we have

929:15

to grab our xus and now we have to just

929:17

call our get method and we have to pass

929:19

our URL inside there and then we have to

929:22

password then okay so let's just provide

929:25

our response and now for the response

929:27

what we have to do we have to set the

929:29

products to response. data and then that

929:32

product okay so if you want to check it

929:34

out let me just show you there so I'm

929:35

going to just copy that from here and

929:37

I'm going to just log there to the

929:38

console like um response. data. products

929:41

but I'm going to also provide the catch

929:42

statement so if you got some sort of a

929:44

error so you want to see that error okay

929:46

so I'll just use like um yeah this error

929:48

function will be fine and I'm going to

929:50

just come on what the hell am I doing

929:52

let's just provide our console. error

929:54

and here we're going to be passing like

929:56

error patching the data and I'm going to

929:58

just use my error right here so I'm

930:00

going to sve my file and now let me show

930:02

you all of that content okay so here you

930:04

can see oh my God we got some sort of

930:07

error right here let's just check it out

930:09

so what's going on it should be a

930:11

product not what the hell I just write

930:14

like products so I'm going to save my

930:16

file and run there and here you can see

930:17

we are now getting all of their data

930:19

right here by using our XS so yeah that

930:22

was a simple and easy stuff the next

930:23

thing that we have to do I'm going to

930:24

just remove that from here the next

930:26

thing that we have to do is that we have

930:27

to take care of of the filtration okay

930:29

so I'm going to be just creating my

930:30

function right here like get filter item

930:33

like get filter product so I'll just

930:34

write like this is going to be a huge

930:36

function by the way I'm going to go back

930:38

and now let me just put a bit of spacing

930:40

right here and let's just create our get

930:42

filtered products come on p r octs and

930:46

now inside this function what you have

930:47

to do first of all we have to set our

930:49

filter products to that filter uh not a

930:53

filter but the products which is that

930:55

which is a state which we have already

930:57

defined right here here which is now set

930:58

to the empty array right here and now

931:01

let's just change there okay so we're

931:03

going to be setting there to that filter

931:04

products and now underneath there what

931:06

do we have to do we have to check if you

931:08

already have the selected category so

931:11

what you have to do in this situation

931:12

you want to get the filter products come

931:15

on the filter products that variable

931:16

which we just created right here so I'm

931:18

going to copy that from here and now let

931:19

me just place it right here so filter

931:21

products and we have to call our filter

931:23

method on there and now here what you

931:26

have to do we have to pass our product

931:27

in side there like as a arrow function

931:30

and then we are going to be checking

931:31

like product. category come on category

931:34

is triple equals to the selected

931:36

category so I'm going to just rename

931:38

that to like the filter products which

931:40

we've already defined up above so let's

931:41

just place that right here and I'm going

931:43

to save there so if I save there and now

931:45

let me just log there to the console

931:47

like products right here so I'm going to

931:48

save my file but for that we also have

931:51

to call it somewhere so you know I'm

931:53

going to call it right here uh I'll just

931:55

create a variable I'll give the name of

931:56

like filtered products and it's going to

931:58

be equals to the get filter products and

932:01

I'm going to execute there so if I

932:03

execute there so we also have to log

932:06

there to the console oh you know I'm not

932:07

going to store in any variable not for

932:09

now so I'm going to sve my file and yeah

932:12

let me just refresh there and here you

932:14

can see here is my categories so if I

932:16

click on this first one and it's going

932:18

to gives us all of their data based on

932:19

their specific Beauty right here so this

932:21

one will have the uh this one will have

932:23

the category of beauty and all of them

932:25

will have the category of let me just

932:27

show you the beauty right here so if I

932:29

click on the furniture it's going to giv

932:31

us the data based on that furniture

932:32

right here and here you can see both of

932:34

them will have the ID why am I saying ID

932:37

but the category of furniture is right

932:39

here so now let me just refresh there

932:40

and that was the first filter now let me

932:42

just take care of the rest of them but

932:44

you know I'm going to also store the

932:45

inside this variable okay so let's just

932:47

remove that from here and that was our

932:49

first if check now underneath this if

932:51

check we also have to check for the

932:52

minimum price okay so if the minimum

932:55

price is not equals to undefined you

932:58

want to get our filtered products and

933:00

you want to set there to the filtered

933:02

products come on filtered products.

933:05

filter and now inside there we're going

933:07

to be passing our product inside there

933:09

and you have to just check like product.

933:11

price come on Price is greater than or

933:15

equals to the minimum price which we've

933:16

already defined up above okay so now let

933:18

me just go there and here you can see we

933:20

are now getting this minimum price from

933:22

the use filter we want to filter through

933:24

like if the product that price is

933:25

greater than or equals to minimum price

933:27

price so in that situation we can

933:29

totally loog that to the console like

933:30

filtered products but you know it's

933:32

going to waste a lot of your time so if

933:33

you have a free time so you can totally

933:35

go ahead and filter through there so I'm

933:37

not going to do that okay so that was

933:39

for the minimum one but now let's just

933:40

also provide for the maximum price is

933:43

not equals to come on not equals to uh

933:46

undefined so in this situation we want

933:48

to get our filtered products and we want

933:50

to set that to the filter products.

933:53

filter method now inside that we have to

933:55

pass our product product. Pro price is

933:58

less than or equals to the maximum price

934:01

which is also coming from the use filter

934:02

context okay so it's going to giv us

934:04

values based on there and next we also

934:06

have to take care of this search field

934:08

as so I'm going to do that right now and

934:10

next we also have to take care of this

934:11

input field as well if we search for

934:13

some item so we're going to be rendering

934:14

only that specific item okay so let's

934:17

just do that I'm going to provide my if

934:18

statement right here so if search query

934:22

which is also coming from the context

934:23

API so we're going to be using like

934:25

filter product and now it's going to be

934:26

equals to the fil filtered product.

934:29

filter method and we are going to be

934:30

passing our product inside there okay so

934:32

let's just use our product. title we are

934:34

only interested in the title and you

934:36

want to set that to lower case because

934:39

there can be a lot of conflicts between

934:40

the upper case and the lower case so

934:42

that's the only reason I'm changing

934:43

there to the lower case I'll also

934:45

provide the include method on there and

934:47

here we have to pass our search query

934:50

and then to lower case come on Lower

934:53

come on to lower case there we go and

934:55

I'm going to also execute there okay so

934:57

so now that's St done and you know I'm

935:00

going to also take care of uh that

935:02

filtering as well so I'm going to save

935:04

this file and now let me just show you

935:05

there let me take care of where in the

935:08

world is there that is now set to false

935:10

so I'm going to set that to true I'll

935:12

set that to true and here you can see

935:14

now let me just take care of the cheap

935:15

expensive and the popular one so let's

935:17

just go back okay so let me take care of

935:21

there and I guess that's going to be the

935:22

final filter so I'll just use my switch

935:25

right here and I'm going to be passing a

935:26

filter the entire filter inside there

935:28

and now inside there we are going to be

935:30

using the cases like if the cas is set

935:32

to expensive so what do you want to do

935:34

in that situation we only want to return

935:36

the filtered products do sort method we

935:39

are going to be using that sort method

935:41

and then we are going to be passing like

935:42

two parameters Like A and B you can pass

935:45

X and Y you can pass anything that you

935:46

want b. price minus a. price okay so

935:50

that's going to be for the first one

935:52

like for the expensive one and I'm going

935:53

to also just duplicate there for the

935:55

popular one and also for the cheap one

935:57

so I'm going to just write like cheap in

935:58

this situation and then here we are

936:01

going to be changing there from the B to

936:03

a and also this one from the A to B okay

936:06

so it's going to only gives us that

936:08

cheap ones and we're going to be also

936:09

searching for the popular one as well

936:12

and now in this case we're not going to

936:13

be working with the pricing we are going

936:15

to be working with the rating b b do

936:17

rating minus a do rating like this okay

936:21

so then it's going to give us all of the

936:23

data if that's not the case we just want

936:25

to provide a default state today and we

936:27

want to only return the filtered

936:29

products right here so I'm going to sve

936:30

my file and that's going to be it so

936:33

I'll just log that to the console and

936:34

now let me just show you all of them so

936:36

I'll just use like filter products I'm

936:38

going to save this file and now let me

936:40

just show you all of them so here you

936:41

can see it's going to give me a lot of

936:42

data let me just wipe this out and first

936:45

of all I'm going to be searching for

936:46

something like e s and here you can see

936:49

it's going to gives us that data but we

936:50

cannot see that data because we did not

936:53

render our book content which we're

936:54

going to be doing in a few seconds so if

936:56

I just expand there and here you can see

936:58

it's going to gives us e scnc and eiy

937:01

and so on and so forth so that was the

937:03

first filter which means like the first

937:05

filter is totally working if I write

937:07

like the minimum value of 19 and then

937:10

the maximum value of like 200 maybe and

937:13

here you can see it's going to give us

937:14

the minimum value and it's going to also

937:16

gives us Max you know let me just show

937:18

you the minimum ones so I'll just expand

937:21

there and check out the pricing so it is

937:23

now set to 19 because I provided the

937:25

minimum value of 19 today and now let me

937:28

just check the maximum one so let me

937:30

just check this out no that's not the

937:32

maximum one let me provide 200 right

937:35

here but first of all let's just clear

937:36

this out let me provide a 200 and now

937:39

it's going to gives us I guess 200 let

937:43

me just

937:47

see yeah it is not equals to 200 but

937:50

yeah this dat is toally coming from the

937:52

API so this is not my own API so we

937:55

cannot test that right now but anyways

937:57

both of them are now working I mean like

937:59

all of these three are working let me

938:00

check out the next one so if I check out

938:03

this beauty and here you can see it's

938:05

going to uses all of their beauty

938:06

products if I click on the Apple so it's

938:08

going to only giv us that Apple product

938:10

and yeah we got an error because we have

938:11

to bind there we did not bind this we're

938:14

going to be doing that in a few seconds

938:16

oh yeah let me J oh here you can see I

938:19

made a mistake I thought I'm going to be

938:21

binding there but no we have to change

938:24

that to instead of a ocm we have to

938:27

change that to coom I'm going to save

938:30

this out and now let me just try this

938:32

out so I'll just clean this out and here

938:34

I'm going to just choose the Apple it's

938:35

going to only gives us that Apple

938:37

product right here like apple apple

938:38

apple apple and if I click on the watch

938:40

it's going to give us all of that

938:42

watches right here like we have a brown

938:44

leather built watch and so on and so

938:46

forth and everything is working and now

938:47

let me just refresh there and now

938:49

everything is working the way we exper

938:51

work but now we have to render all of

938:53

that filtered content inside our screen

938:56

right here so how we going to be doing

938:58

there let's just do there so what I'm

939:00

going to do is that I'm going to go to

939:01

the bottom and here we're going to be

939:03

rendering our book component but before

939:05

I do that we're going to be using like

939:07

filtered products and then we are going

939:09

to be iterating over through all of the

939:10

product and we have to get the filtered

939:12

one and now inside there here we're

939:14

going to be rendering our book come on

939:16

book card okay so I'm going to just

939:18

render there right here and I'm going to

939:20

comment this out I'm going to save this

939:22

file it's going to gives us an error but

939:23

now let's just create our book card

939:24

right here card. TSX now inside there

939:28

first of all we are going to be grabbing

939:29

our link component which you will see

939:32

why I'm doing there and then we are

939:33

going to be just using our

939:35

rafc and let's just create our book

939:37

component book card component to be

939:39

precise I'm going to uncomment there and

939:41

let's just grab that right here s my

939:43

file and here you can see we are now

939:45

getting book card book card and so on

939:47

and so forth you get the idea for this

939:49

book card we are going to be passing a

939:50

few props like first of all we're going

939:52

to be passing the key like product. ID

939:55

and then we're going to be also passing

939:57

the ID itself like product. ID once

939:59

again and we're going to be passing the

940:01

title so that will be equals to the

940:03

product. title and also let's space our

940:06

image because we are going to be also

940:07

rendering the image so we can use like

940:09

product. thumbnail thumbnail come on N I

940:13

just like that and then the price and

940:16

price will be set to product. price okay

940:19

so now let me just save my file and

940:20

that's going to be everything I don't

940:22

know why I'm getting this error but we

940:24

will fix it in a few second first of all

940:26

let me just drro all of their data so

940:28

I'll just use like um ID come on let's

940:31

just get our ID title and also image

940:34

price we going to be getting all of

940:36

there but first of all let's just create

940:37

an interface for there and that will be

940:39

a bookard props and now inside this

940:42

interface we're going to be putting the

940:43

ID of string and also um not a comma and

940:48

the title will be also a string

940:50

everything will be a string so I'll just

940:51

write like image will be a string and

940:54

also the price will be a number in this

940:56

situation by using my react functional

940:58

component so react come on react. FC for

941:02

the functional component and I'm going

941:04

to just pass my book uh card there we go

941:07

book card crd and then props okay so

941:10

I'll just pass it right here and it's

941:12

going to be equals to this function it

941:13

shouldn't be equal so I'll just remove

941:15

there and I'm going to just change that

941:17

to this data okay so that's all done now

941:19

the next thing that we have to do is

941:20

that we have to use there so to use

941:22

there first of all let's just remove

941:24

this book card and I'm going to be

941:25

providing a class name or border and

941:28

ping all around will be set to four and

941:30

totally rounded okay so now inside this

941:32

D we're going to be passing first of all

941:33

our link and then that link will be

941:36

going into that link will go into the

941:39

product and also that specific ID okay

941:43

so now inside there let's just render

941:45

our image first of all and I'm going to

941:46

just remove this IMG from here and let

941:48

me just P my image inside there I'm

941:50

going to also change that that

941:52

alternative text to that title itself

941:54

and let me just put a class name of like

941:56

with will be set to four

941:57

and also height will be set to 32 object

942:00

will be also set to totally cover and be

942:02

like margin for the bottom will be set

942:04

to two Okay so I'm going to save there

942:06

and now underneath this link or you know

942:08

what instead of that link underneath

942:09

this image we're going to be using our

942:11

H2 and let's just provide a font of um

942:14

bold will be fine or semi bold will be

942:16

fine I'll just change that to title and

942:18

now underneath there let's just render

942:20

our uh paragraph right paragraph right

942:22

here so I'll just write like and I'm

942:24

going to sell my file and here you can

942:26

see we are now getting all for data

942:27

right here which is looking amazing so

942:29

we have the product image we have the

942:30

product title and also the money the

942:33

price if I change there it's going to

942:35

only gives us that first one and by the

942:37

way now let me just show you all of that

942:38

filter if I want to search for like this

942:40

Dior so I'll just write like di o r and

942:43

here you can see it's going to only give

942:44

me that and if I just write like Gucci

942:46

it's going to only give me that specific

942:48

item right here and now if I want to

942:50

search for the Apple so if I click on

942:51

there it's going to only give me Apple

942:53

product right here if I click on the

942:55

watches so it's going to only give me

942:56

the watches the fashion the trend and

942:59

it's going to give me all of their data

943:00

based on these filter which we have

943:02

already done so yeah that's looking

943:03

amazing now let's just take care of the

943:05

final thing which is called the

943:07

pagination time to take care of the

943:09

pagination so first of all we will have

943:11

our previous button then we will have

943:13

our next button and we will also have

943:15

our one two three and so on and so forth

943:17

button right here okay so first of all

943:19

let's just take care of the first button

943:22

I'm going to also have to wrap it in

943:23

some sort of a container so I'll just

943:24

use like Flex and also Flex will be set

943:26

to column and the for the smaller screen

943:29

size we are going to be using like Flex

943:30

row and also justify will be set to

943:33

between and then items will be set to

943:35

Center margin for the top will be set to

943:37

five okay so now inside there what do we

943:39

have to do first of all let's just take

943:41

care of the the previous St okay so for

943:44

the previous one we are going to be

943:45

creating first of all the button that

943:47

button will take a few styling like

943:49

border and then the pairing for the xais

943:51

will be set to four pairing for the y

943:52

axis will be set to two margin for the

943:54

xaxis will be set to two and totally

943:56

around round it full okay and yeah

943:59

that's going to be it and here we are

944:01

going to be just passing like previous

944:03

and I'm going to just duplicate there

944:05

and I'm going to also change that to

944:06

next one as well okay first of all we

944:08

have to take care of the functionality

944:09

so I'll just use like if somebody click

944:11

on the previous button so you want to

944:13

just fire this function which is the

944:15

handle page uh change we did not create

944:18

this function but we are going to be

944:19

creating there in a few seconds so it's

944:21

going to take one perimeter like current

944:23

page and then minus one so let's just do

944:25

that I'm going to copy the name of there

944:27

I'm going to go to the top let me just

944:28

create that function right here like con

944:30

handle page change and it's going to be

944:33

equals to that page and let's just

944:35

provide one number inside there so

944:37

before I do that first of all we have to

944:38

declare a few variables like con total

944:41

products like how many products do we

944:42

want we want only 100 products and then

944:45

cons total come on total Pages you would

944:48

have like

944:50

math.co and we are going to be passing

944:52

the total products and then let's just

944:54

divide that by items per page okay so

944:57

it's going to giv us the total pages

944:58

right here so we have to just check if

945:01

page is greater than zero and come on

945:03

let's just put our zero right here and

945:06

uh page is less than or equals to the

945:08

total pages so what do we want to do in

945:10

this situation we just want to write

945:11

like Set current page and we want to

945:13

password page inside there okay so now

945:15

if I sa my file but it will not do

945:17

anything because we have to first of all

945:19

take care of the next one as well okay

945:21

so it will not do anything for now okay

945:23

so that's really done but I'm going to

945:25

also provide a disabled St for there and

945:27

to disable there first of all we have to

945:29

use the disable attribute and we have to

945:31

provide the current page is triple

945:33

equals to one so if our current page is

945:35

set to one so you want to disable this

945:37

entire button if the current page is

945:39

greater than one so you want to just do

945:41

something about the you want to change

945:43

there so then inst you're done I'm going

945:44

to also cut that from here yeah you know

945:47

I'm not going to cut that from here

945:48

let's just cut there and past that right

945:51

here okay so that's going to be the next

945:52

one so now let's just take care of the

945:54

next button right now and you know I'm

945:55

going to also cut that and let's just

945:57

place it right here for a few seconds

945:59

and now let me just take care of the

946:00

previous button so what I'm going to do

946:02

is that I'm going to be passing my own

946:04

click method right here and for this on

946:06

click we're going to be using that

946:07

handle page uh change one more time and

946:10

in this situation we are going to be

946:12

ping that current patch and what the

946:14

hell am I doing let's just close that

946:17

right here and I'm going to also remove

946:19

that from here so current page in this

946:21

case will be set to plus one in this

946:23

case we we are now decrementing one in

946:25

this case we now incrementing there okay

946:28

so now that's already done and now we

946:30

also have to provide our disabled State

946:32

on there so for the disabled State we

946:34

are going to be checking if the current

946:35

page is triple equals to the total page

946:38

that was the only reason I made that as

946:39

a global variable so that we can use the

946:41

word here okay so if that is set to

946:44

Total pages so you want to disable that

946:46

now the previous button is totally done

946:48

and also the next button is done now we

946:50

have to take care of these 1 2 3 4 5 and

946:52

so on buttons right here okay so how are

946:54

we going to be doing that to do that

946:56

first of all we have to just use so I'll

946:58

just write like Flex and then Flex will

947:00

be set to W and then just come on

947:02

justify will be set to center now inside

947:05

there here we're going to be rendering

947:07

our uh P come on p a n a t o n

947:11

pagination button so how are we going to

947:13

be doing that let's just first of all

947:15

create a function for that so I'll go to

947:17

the top and we are going to be creating

947:19

a new function for the pagination button

947:21

so I'll just use like con get

947:24

pagination buttons and it's going to be

947:26

now set to the this uh Arrow function

947:28

right here and first of all we have to

947:29

get the buttons so we are going to be

947:31

using like buttons and it's going to be

947:33

a number so let's just pass one numbers

947:35

of array inside there and now it's going

947:37

to be set to totally empty array okay so

947:39

not numbers but just a singular number

947:42

there we go so now let's just also take

947:44

care of the start and this the start

947:46

page and also the end page okay so let's

947:48

just use like the start page and it's

947:50

going to be equals to math. Max and we

947:53

are going to be passing one and also the

947:55

current page minus two so it's going to

947:57

give us the starting page and now let's

947:58

just take care of the end page and end

948:01

page will be set to math. minimum and

948:03

here in this case we're going to be

948:04

passing our total pages and also current

948:06

Page Plus two not minus two but plus two

948:10

and now let me just put a bit of

948:11

conditional statement right here if our

948:13

current page minus 2 is less than one so

948:16

in that situation we want to get the end

948:18

page and we want to set that to like

948:20

math. minimum and we have to provide our

948:22

total pages and then end page right here

948:25

in this case and we have to also so

948:26

combine this two and then minus current

948:29

page and also let's just provide our

948:32

minus one right here okay in this

948:33

situation this going to give us the end

948:35

page so I'm going to also duplicate

948:37

there and let's just take care of the

948:40

what do we call it the starting page so

948:41

if current Page Plus two is greater than

948:46

the total pages so in that situation we

948:48

are going to be just changing this start

948:50

like that into the start page and I'm

948:52

going to just remove all of that stuff

948:54

from here let me provide one for the

948:56

first perimeter and then start page

948:58

minus 2 and then minus total page and

949:02

then minus current page so it's going to

949:04

giv us the starting page okay so now

949:06

let's just iterate over through all of

949:07

there so let's just use like let page is

949:09

equals to start page and then um page is

949:13

less than or equals to end page and then

949:15

finally let's just use our page Plus+

949:17

you can use I if you wanted to but in my

949:19

case page would be fine so now let's

949:21

just use a buttons. push method and we

949:24

have to provide our uh page inside not

949:27

Edge but page and finally we have to

949:29

just return our buttons okay so I'm

949:30

going to sve my file and this is how we

949:32

are going to be creating our get page

949:33

ination buttons and now let's just use

949:35

the right here inside this area so let's

949:39

just use that I'm going to execute there

949:42

but first of all we have to wrap the

949:43

inside these curly braces I'm going to

949:45

also remove this command from here and

949:47

now we have to over through all of that

949:49

pages so we have to use the map method

949:51

inside there and we're going to be only

949:52

passing the page inside there so I'll

949:55

just first of all create a button right

949:56

here here inside there and first of all

949:58

we have to paste the key and the key

950:00

will be set to page and we're going to

950:02

be also providing the on click like when

950:04

somebody clicks on there so we want to

950:05

just pass for handle page change and now

950:08

in this case we we don't want to do

950:10

nothing with there but we only want to

950:11

pass the page inside there okay and

950:13

let's just put a bit of styling to this

950:15

I'm going to be using like a few Dynamic

950:17

styling like border first of all pairing

950:19

for the xais will be four and pairing

950:21

for the y axis will be set to two margin

950:23

for the xaxis will be set to one totally

950:25

rounded and full and yeah in this casee

950:28

I'm going to be passing my page is

950:30

triple equals to the current page so in

950:32

this situation we want to change the

950:34

background color to totally black and we

950:36

also want to change the text to totally

950:38

white that's not the case what do you

950:39

want to do in that situation we just

950:41

want to set there to the empty string

950:43

just like that and here we have to just

950:45

past the page name and that's going to

950:47

do it so I'm going to save my file and

950:49

here you can see we now getting our

950:51

pages right here so if I refresh my page

950:53

and here you can see we are getting like

950:54

1 2 3 I can click on the previous I

950:57

cannot click on the previous right now

950:58

because we are now at the first page if

951:00

I click on the second one it's going to

951:02

render my content right here I can also

951:04

click on the next one and here you can

951:05

see it's going also render all of that

951:07

content I can click on the fourth I can

951:09

click on the previous one and now if I

951:11

cck click on the previous one it's going

951:12

to just gives us the previous items

951:14

right here I can go to the next one and

951:16

so on and so forth which is looking

951:18

amazing so yeah I can provide a

951:20

filtering in this situation but I forgot

951:23

to take care of this filter right here

951:25

so now let's just do that I'm going to

951:26

go to the top where I have this drop

951:29

down menu right here or button which you

951:32

can see right here so we have this

951:33

button and I'm going to be just placing

951:35

my on click Handler come on the on click

951:38

Handler when somebody clicks on there so

951:40

what do you want to do in this situation

951:42

we just want to set the drop down to not

951:45

drop down open okay so if that is

951:47

currently set to false it's going to

951:49

make it true and if that is said to true

951:51

so it's going to make it false okay so

951:53

let's just check it out if I click on

951:55

there I can go to the cheap item and I

951:57

can totally select the cheap item and I

951:59

can also select the expensive one and I

952:01

can also select the popular one as well

952:03

so yeah everything is working the way we

952:05

expect him to work and they are looking

952:08

awful so I'm going to take care of that

952:10

in a few second but yeah everything is

952:12

totally working I can click on the Apple

952:13

it's going to only give me the Apple

952:15

product and watches and so on and so

952:17

forth so now we are totally done with

952:18

the main content page but now let's just

952:20

take care of the product page like if I

952:22

click on this specific product so we

952:23

have to also take care of this product

952:25

as well okay so let's just do that I'm

952:27

going to go ahead and create a new

952:29

component I'll give it the name of like

952:31

product page. TSX let me just use my

952:34

rfca and I'm going to go into my app and

952:37

let's just register there right here

952:39

okay so I'm going to just duplicate this

952:40

lineup code and then we want to go in

952:42

come on product and we want to go into a

952:45

specific ID of that product and now let

952:47

me just render my product page right

952:49

here in this case I'm going to save my

952:51

file and now let me just take care of

952:53

there first of all there will be a few

952:54

thing that we have to take care of so so

952:56

first of all let me just go ahead and

952:58

grab my ID okay so ID will be coming

953:00

from the use per RAM and which is coming

953:03

from the react ROM and here we have to

953:05

just pass the ID right here so ID will

953:07

be totally a string it's going to be set

953:09

to this parenthesis right here okay so

953:11

it's going to give us the ID now we also

953:13

have to get our navigation so we're

953:14

going to be using like use navigate for

953:16

there which is also a function coming

953:18

from the react rou Dom and we will just

953:20

store there in the NV weate uh variable

953:24

right here n AIG G at yeah and let's

953:26

just create word state so I'll just use

953:28

like uh product and also the set product

953:31

right here and it's going to be equals

953:32

to the use State and it's going to be

953:34

set to initially now and now I'm going

953:36

to annotate there with the product which

953:39

we did not create but we will create

953:40

there in a few second and also the null

953:43

okay so either the product or the null

953:45

so now let's just create interface right

953:46

here so that interface will be that

953:48

product and now inside this product

953:50

we're going to be providing the ID which

953:52

will be set to number I'm going to also

953:54

provide the title and title will be set

953:55

to string and then we have our

953:57

description and descriptions are also a

954:00

string and the price will be set to a

954:03

number and I'm going to also provide the

954:05

rating and rating will be set to a

954:06

number as well and then finally we have

954:08

our images okay so images will be set to

954:11

a string of these Mt array okay so it's

954:13

going to take the as the so we are going

954:16

to be an trating or used by using this

954:18

product and now let's just take care of

954:20

the UI but before I do that I'm going to

954:22

have to fetch all of that content right

954:24

here so I'm going to be using us effect

954:26

in this case now inside there we have to

954:29

first of all provide the dependency

954:30

array of that ID like if that ID changes

954:33

so we want to just call this function

954:35

and first of all we have to check for

954:36

the ID if you already have the ID then

954:39

we are going to be using the Xs and then

954:40

we are going to be using the get and so

954:42

on and so forth so let's just get our

954:44

Aus and I'm going to be using the get

954:46

method on there I'm going to also

954:47

annotate as the product let's just do

954:50

there and I'm going to also provide the

954:51

https and that same dummy Json API so

954:56

let's just go to the products and we

954:58

have to render our ID dynamically okay

955:00

so if that's the case so it's going to

955:01

give us that response P okay just like

955:04

that and we have to use our uh what do

955:06

we call it set product and we have to

955:08

pass our response. data inside there

955:11

okay I'm going to sve this file and now

955:13

underneath this then we have to also

955:14

provide the catch statement as well so

955:16

if you got some sort of error so in that

955:18

situation we are going to be just using

955:20

like con. log okay so cons. error would

955:23

be fine rather so I'm going to just use

955:25

like error patching come on patching

955:29

product data and let's just render our

955:32

error right here so I'm going to save

955:34

that and this is how we going to be

955:35

fetching our products right here in this

955:37

component so yeah that's cool and you

955:40

know I'm going to also put a ler right

955:41

here so if you don't have the product so

955:43

in that case we just want to return uh

955:45

H1 off loading dot dot dot would be fine

955:49

and now let me take care of this UI so

955:51

I'm going to go ahead and first of all

955:53

provide my piring all around will be set

955:55

to five and width will be set to uh yeah

955:57

60% will be fine now inside this D we

956:00

are going to be creating our button and

956:02

let's just start our own click right

956:04

here and when somebody clicks on this so

956:06

what you want to do we just want to

956:07

navigate minus one okay and also let's

956:10

just style okay so I'm going to put a

956:11

few styling like margin for the bottom

956:13

will be set to five ping for the xaxis

956:15

will be set to four ping for the y axis

956:17

will be set to two and background will

956:19

be set to totally black and text will be

956:21

set to totally white and totally rounded

956:23

so for this SP label we will just say

956:25

back I'm going to sve my file and now

956:28

let's suppose if I click on this icon

956:30

it's going to give me the loader first

956:31

of all but something is not

956:36

right okay we are still getting a loader

956:39

let me go to the

956:41

console and we got some sort of error so

956:44

error fetching a product data exus it

956:47

should be dummy why am I keep forgetting

956:50

there let's just save our file and now

956:52

let me just refresh there and here you

956:55

can see we now getting our back button

956:57

right here which is looking amazing so

956:59

that was the first thing that we have to

957:00

create our back button now let's just

957:03

create our image so I'll just use my

957:04

image right here and I'm going to be

957:06

using like first of all my product.

957:08

images and we want to get only the first

957:10

image out of the and now for the

957:12

alternative text we're going to be

957:14

providing um the product. title and then

957:17

for the class names I'll just write like

957:19

with will be set to 50% and also uh

957:22

height will be set to Auto and margin

957:24

for the bottom will be set to five I'm

957:25

going to to save that and let's just

957:27

refresh there so it's going to gives us

957:29

that image right here I'm going to go

957:31

back and choose another one like maybe I

957:33

want to choose yeah this sofa would be

957:36

fine is there a sofa or I don't know

957:37

what the hell this is so yeah here you

957:40

can see we're now getting that image

957:41

right here and now we have to provide

957:43

our H1 and I'm going to be providing a

957:46

few classes like text will be set to 2

957:48

Xcel margin for the bottom will be set

957:50

to four and font will be set to totally

957:52

bold okay so let's just use our product.

957:55

tile and let's just sa our file and here

957:57

you can see we're now getting the

957:59

product title I'm going to also put a

958:00

paragraph with the classes of margin for

958:02

bottom will be set to four and text will

958:04

be set to totally gray 700 and also the

958:08

width will be set to uh you know the

958:11

width is arbitrary value so we are going

958:13

to have to do the manually so I'll just

958:14

use like 70% and close that and now

958:18

inside that we're going to be using

958:19

product. description I'm going to save

958:21

that and here you can see it's going to

958:22

giv us their description Right Here and

958:25

Now underneath that we're going to be

958:27

using a flex you can provide more

958:28

styling if you wanted to but in my case

958:30

that's going to be fine so let's just

958:32

provide our price right here so we are

958:34

going to be using product. price and now

958:36

underneath this paragraph we going to be

958:38

using like margin for the left will be

958:39

set to 10 and let's just provide your

958:41

rating right here in this case and then

958:44

product. rating okay so I'm going to

958:46

save my file and here you can see we're

958:48

now getting our price and also the

958:50

rating which is amazing so now I can go

958:52

to any product that I like so let's

958:55

suppose if I want to go to the next page

958:57

and I'm going to just choose cat food

958:59

it's going to giv this first of all the

959:00

image it is taking a bit of time because

959:02

of my internet connection so it is now

959:04

giving me the image the name the

959:06

description also the price and rating

959:09

you can totally change like anything

959:10

that you want so that's there and that

959:13

was it about for the product page and

959:15

next we're going to be taking care of

959:17

the top seller and also the blogs that

959:19

was it about for the product page and

959:20

now let's create our popular blogs and

959:22

also the top sellers okay so I'm going

959:24

to just create two component I'm going

959:26

to give it the name of like popular

959:28

blogs. TSX and inside there let me just

959:31

create my component and then we are

959:33

going to be also creating uh for the top

959:36

sellers. TSX as well so let's just WR

959:38

our RFC and now let's just register that

959:41

in our app component so underneath these

959:43

routes we're going to be creating one

959:45

more Dev and inside this Dev first of

959:47

all let me just render my top sellers

959:49

and then we are going to be also

959:50

rendering or popular come on popular so

959:53

I'm going to sve my file and now let me

959:55

go into the top sellers and now let's

959:57

just create there so the first thing

959:59

that I'm going to do is I'm going to

960:00

just create my authors uh state so then

960:03

set

960:04

authors and it's going to be equals to

960:06

the used St and here we're going to be

960:08

only passing array okay so now let me

960:10

just annotate there by using the author

960:12

which we going to be creating in a few

960:14

seconds and now let's just provide there

960:17

okay so now let's just create that

960:18

interface right here so I'll just write

960:20

interface and then author and name will

960:22

be a string we're going to be also

960:24

providing is following and that's going

960:26

to be a Boolean and also and also we

960:30

have to PR the image and image will be a

960:32

totally string okay so that's to done

960:35

now we have to fetch our data so we

960:36

going to be using the use effect and now

960:38

inside there for the dependency area I'm

960:40

not going to provide anything and now

960:42

inside there first of all let's just

960:44

create our function so I'll just give it

960:45

the name of like fetch data it's going

960:48

to be an asynchronous function because

960:49

we are now fetching some sort of a data

960:51

inside there so now let's just use our

960:53

try and catch block for the catch block

960:55

I'm going to be using cons. error and

960:57

I'll just say like uh error fetching

961:00

authors and list render or error as well

961:03

and for the tri block first of all we

961:05

are going to be getting the response by

961:06

using the aware and fetch method and

961:08

here we're going to be passing our https

961:11

and then the random user. me and then

961:15

API and uh question mark results equals

961:19

to five because you only want to get

961:21

five users if you want to get more you

961:23

can totally provide there like let's

961:25

suppose if you want to get 10 users you

961:26

can just write 10 right here but in my

961:28

case five will be fine case I'll just

961:30

write like data and now let me convert

961:32

my response to Json okay and now we

961:35

store the inside the data so the next

961:36

thing that we have to do is that we have

961:38

to iterate over through their data so

961:39

I'll just write like authors data and

961:43

here I'm going to be passing my author

961:44

right here and that was an array now

961:46

it's going to be equals to data.

961:48

results. map and now here we are going

961:51

to be also providing our perimeter which

961:53

will be a user and for now we are going

961:55

to be only hasing any word here cuz we

961:57

don't know what kind of data we are now

961:58

getting right now okay and now inside

962:01

that we're going to be providing first

962:02

of all the name and here let's just

962:04

provide our user.name do first and then

962:07

we're going to be also providing uh

962:09

user.name do last okay so it's going to

962:12

gives us the username and now for is

962:14

Following come on uh is following will

962:18

be set to false initially and the user

962:20

image will be user.

962:23

pictures picture. medium and here we

962:26

have to provide our commas and that

962:28

error is now successfully gone change

962:30

our set authors and provide our own

962:33

authors data to there so that's

962:35

everything that we have to do for this

962:36

fetch data and let me just call that

962:38

right here fetch data and now I'm going

962:40

to execute there let's provide our GSX

962:43

so first of all I'm going to just change

962:45

the background color to totally white

962:46

I'm going to also provide the padding

962:48

for all around will be set to five

962:50

margin for the xaxis will be set to five

962:51

margin for the top will be five as well

962:54

and uh I'm going to also provide a

962:56

border and width will be only 23 RAM and

962:59

totally rounded now inside there we're

963:01

going to be creating our H2 with the

963:03

classes of

963:05

text text Xcel and also the font will be

963:08

set to Bard margin for the bottom will

963:10

be set to five and let's just proide our

963:13

top sellers inside this so I'm going to

963:15

sell my file and this is how it looks

963:16

like right here next we have to provide

963:19

our ul and inside this U we're going to

963:21

be iterating over to all of the authors

963:23

and then inside that we are going to be

963:24

providing the author and and also the

963:26

index of the author and then inside

963:28

there I'm going to first of all write my

963:30

li and for the key I'll just provide my

963:33

Index right here you can use The UU ID

963:35

and you can use all of that stuff but

963:37

for now I'm going to only provide this

963:38

Index right here and for the class names

963:40

I'm going to provide like Flex and items

963:42

items will be now set to Center justify

963:44

will be set to between and the margin

963:47

for the bottom will be only set to four

963:49

inside them we're going to be creating

963:50

our section and section will be a flex

963:53

justify will be set to Center and also

963:55

items will be set to Center let's just

963:58

render our image and I'm going to just

964:00

remove there and replace that with the

964:01

author. image and for the alternative

964:04

text we're going to be providing like

964:06

author. name as well and now let's just

964:08

provide our classes like with will be

964:10

set to 25% and also the height will be

964:13

set to

964:15

25% let's just provide our justify

964:17

Center and totally rounded off full so

964:20

if I save my file and this is how it

964:21

looks like right here so underneath

964:23

we're going to be creating what a span

964:25

with a closes so margin for the left

964:26

will be set to four and let's just

964:28

provide your author. name if I save my

964:31

file and now they are looking amazing

964:34

okay so they are looking super amazing

964:36

right now underneath this section we're

964:38

going to be creating our button and that

964:40

button will have a few things like uh

964:42

you know what yeah I'm going to just

964:43

proide first of all my uh author so

964:46

author. is following and if it is

964:49

following so we going to be using like

964:51

unfollow and if that's not the case we

964:53

going to be only providing like follow

964:55

if if i s my file and here you can see

964:57

we are now getting the follow button if

964:58

I click on that nothing will happen and

965:01

I'm going to proide that logic in a few

965:02

seconds but first of all we have to

965:03

style there so I'll just use like uh

965:06

class names and we are going to be

965:07

rendering Dynamic content so for that we

965:09

are going to be using like Ping for the

965:11

Y AIS of one pairing for the xaxis of

965:13

three totally rounded and here let's

965:15

just render our Dynamic content like is

965:17

author dot uh come on uh author not is

965:21

following if that's the case so what do

965:23

we have to do we just want to change

965:25

like the background color to totally

965:26

black uh I mean like red and also the

965:29

text will be set to totally white and if

965:31

that's not the case we going to be

965:32

changing the background color to toally

965:34

Black and the text color to toally white

965:36

so if I save my file and let me just

965:38

check this out and here you can see we

965:40

only have like this black color and

965:42

let's just put that functionality right

965:43

here on click when somebody clicks on

965:46

that so what we have to do we have to

965:48

just fire this function which is handle

965:50

follow uh click and we also have to put

965:52

our index inside there okay so I'm going

965:54

to copy there and now let's just create

965:56

there I'm going to go to the top and

965:58

underneath this use effect we're going

966:00

to be creating this function right here

966:02

and it will take the index and index

966:04

will be a number and now inside there

966:07

we're going to be setting our authors

966:09

and here we have to provide our previous

966:11

author and let's just use our previous

966:13

author Dar map and here we're going to

966:15

be providing the author and also the

966:16

index okay so let's just wrap the like

966:19

as author and also the index and now

966:21

outside from them we're going to be

966:23

checking like index index triple equals

966:25

to the index itself if that's the case

966:28

we just want to use like all of the

966:30

author and then we want to provide like

966:32

is following and we want come on uh f o

966:35

l o o w i n g you want to set the is

966:38

following to not author is following

966:42

okay and outside from that we are going

966:43

to be only providing our author okay so

966:45

now let me just save my file and now if

966:47

I click on there and here you can see we

966:49

are now getting like unfollow and also

966:51

the color is totally changed you can

966:53

follow everyone and you can unfollow

966:55

follow that if you wanted to so that was

966:57

the top seller component next we have to

966:59

go into the popular blogs component and

967:02

here I'm going to P an array and inside

967:04

this array we have a object and inside

967:07

that object we have a title and their

967:09

title can be anything then the author

967:11

can be also anything and likes can be

967:13

anything and comments can be like

967:14

basically anything you want okay so this

967:17

is our blogs array inside this array we

967:19

have a few objects right here which I

967:21

just duplicated so this is my blogs uh

967:24

array right here and now let's just

967:25

itate over through there but first of

967:27

all let me just remove there and I'm

967:28

going to style there first of all let me

967:30

just provide the background color of

967:31

totally white ping for all around will

967:33

be set to five width will be set to 23

967:36

rim and I'm going to also provide margin

967:38

for the top of four and totally provide

967:40

a border margin for the left will be

967:42

five and rounded inside then we're going

967:45

to be providing our H2 text will be set

967:47

to totally Excel and also the font will

967:49

be set to bold margin for the bottom

967:51

will be set to five and let's just

967:53

provide our popular blogs inside this if

967:56

I save my file and here you can see we

967:58

now getting our card underneath we are

968:00

going to be providing our ul and inside

968:02

this UL we're going to be iterating over

968:03

through all of our blogs and let's just

968:05

use our blog and also provide our index

968:07

as well okay so now inside them we're

968:10

going to be using our UL I me like our

968:12

lii and here we have to provide our key

968:14

and the key will be index and also let's

968:16

just provide our class name of margin

968:17

for the bottom will be set to four and

968:19

inside this UL we're going to be also

968:21

providing first of all the day with the

968:23

class of flex and justify will be set

968:25

between and items will be set to Center

968:28

okay and inside there we're going to be

968:30

also providing our span with a class of

968:32

font Bol margin for the bottom will be

968:34

set to two and let's just render our

968:36

block title so let's just use our blog.

968:38

tile I'm going to save this file and

968:41

here you can see we now getting all of

968:42

the blocks titles right here underneath

968:44

this span and div we're going to be

968:46

creating yet another span and I'm going

968:48

to provide the classes of like text Gray

968:50

of 600 published uh by and then the

968:54

blog. author and here are the author

968:57

underneath this man we're going to be

968:58

creating yet another div with a class of

969:00

F and items items will be set to Center

969:03

margin for the top will be set to two

969:05

and here we're going to be rendering

969:07

first of all the icon like message

969:09

Circle which is now going to be coming

969:11

from the Lucid icon and I'm going to

969:13

also provide the size to this so the

969:14

size will be now set to 16 or just 16

969:18

would be fine so I'm going to save there

969:19

and this is how we are going to be

969:20

getting our icon let me provide my span

969:22

with a class of text to gr 500 margin

969:25

for the right will be set to five margin

969:27

for the left will be set to only one and

969:29

inside this pen I'm going to provide

969:31

like blog. likes come on likes like

969:34

there and I'm going to close there so

969:35

outside from this Spen and also the dev

969:37

or you know outside from just this pan

969:40

you're going to be rendering one more

969:41

like thumbs up and then let's just

969:44

provide our size to this so size will be

969:46

set to 16 and now underneath there we

969:49

going to be using a spin with a class of

969:51

text totally gray of 500 and also margin

969:54

for the right will be set to two margin

969:56

for the left will be set to two as well

969:58

so let's just provide our blog comments

970:00

and that's going to be it so if I sve my

970:02

file and here you can see we are now

970:03

getting like all of the likes and all of

970:05

the comments as well so yeah that's

970:07

everything that we have to do for now

970:09

but we have to change a few things

970:11

inside there so we have to change the

970:13

sizes of these and let's just do there

970:16

there are a few changes that I made so

970:17

the first thing that you have to do is

970:18

that you have to go into the app. TSX

970:21

and instead of providing a justify bit

970:23

you have to change that to a justify

970:24

Center and then you have to go into the

970:26

main component and just provide the

970:28

margin for the right of 10 RAM and then

970:31

you have to go to the sidebar and you

970:33

have to provide margin for the top of

970:35

three and also uh you have to provide

970:38

these stuff right here like we already

970:40

provided some of them but here you have

970:41

to provide like with or full and this is

970:43

how your UI will look like so now let me

970:45

just test that for the final time I'm

970:47

going to provide like something maybe uh

970:49

I'm going to just search for like red

970:51

now come on now so it's going to give me

970:54

that first one and then if I search for

970:57

like minimum price I'll just write like

970:59

10 or you know 19 would be fine or 20

971:02

would be fine okay and then 200 so it's

971:04

going to give me all of that products

971:06

now let me just click on the reset you

971:07

can click on the beauty so it's going to

971:09

only gives us the beauty item let me

971:11

click on the reset one more time I'm

971:12

going to click on the Apple so it's

971:14

going to only give me the apples uh

971:16

product and then if I click on the watch

971:18

so it's going to give me the watches and

971:19

so on and so forth now I can also select

971:21

the cheap one I can select the expensive

971:23

one and also the popular one and we can

971:26

also work with the paginations if I go

971:28

to the next page and so on and so forth

971:30

so it's going to give me all of that

971:31

items right here okay and we can also

971:34

follow someone and unfollow someone and

971:36

this is how our entire UI will look like

971:38

so thank you so much for watching if you

971:40

like these kind of projects so feel free

971:42

to comment there below and I'm going to

971:43

do my best to make an amazing project

971:45

like these in the future as well so I'm

971:47

going to see you in the next video thank

971:49

you so much for watching and

971:54

bye-bye e

972:50

okay so let's talk about the first

972:51

question will I get a job after

972:53

completing this entire Rea J series and

972:56

I'm not just talking about this video or

972:57

a previous one I'm talking about the

972:59

entire Series so the answer is simple

973:02

yes and no I know it sounds a bit weird

973:05

like yes and no which kind of answer is

973:07

that while completing this entire series

973:10

it will give you a lot of confidence

973:12

skills and knowledge to learn your first

973:14

job but this is not my promise like I

973:17

cannot promise you like this course will

973:19

give you a job but I can definitely give

973:21

you a guarantee about that I can totally

973:23

give you a guarantee that this course

973:25

will give you a job but I cannot make a

973:28

promise about that which also leads us

973:30

to the next question how can I even get

973:32

a job and the answer for this question

973:34

is super amazing and trust me you're

973:37

going to love this one and the answer is

973:40

you have to be unique I want you to keep

973:43

that in your mind I want to say that two

973:45

times because I want to stick that into

973:46

your mind you have to be unique and you

973:49

have to be unique if you build something

973:52

unique which value other people's they

973:55

will hire you because I've seen like I

973:57

don't know maybe 10 or 20 people who did

974:00

that same thing and I swear they weren't

974:03

even qualified enough so they just built

974:06

something amazing and totally unique if

974:08

you want me to show you a few peoples I

974:10

can definitely show you there so you can

974:12

definitely go ahead and check out my

974:13

Instagram stories and I will definitely

974:15

show those people to you they are not

974:17

even qualified enough and they just

974:19

built something unique so they got H God

974:23

damn it and here a lot of people are

974:25

asking me hus how can I even get a job

974:28

well stop asking Chad GPT or other AI

974:31

Bots to give you idea for your project

974:33

you have to build something by yourself

974:35

which has to be unique which also have

974:37

to offer some value to other people and

974:40

trust me I can totally promise you that

974:42

they will hire you let's talk about the

974:44

third question isn't this just a

974:46

tutorial hell yeah I've seen a lot of

974:49

popular YouTubers make the same videos

974:52

like stop watching videos and stop

974:55

paying for online courses and do this

974:57

and do that by yourself and stop

974:59

listening to other people's and yeah

975:01

I've seen a lot of crap like this but I

975:03

have to ask you a question if you don't

975:05

watch any tutorials if you don't watch

975:07

any videos how in the world you're going

975:09

to be even learning that specific topic

975:12

let me just give you a challenge a few

975:14

days ago ten tener Lindley or I can't

975:17

even pronounce that guy name but uh he

975:19

dropped a new framework called uh 10

975:21

Stag and I'm not talking about the 10

975:23

stag query or a 10 stag crouter I'm

975:25

talking about the 10 stack itself so I

975:28

want you to go ahead and just learn

975:30

there Cod is totally complicated and if

975:32

you try to learn that you're going to

975:34

have to watch the entire documentation

975:36

and also you're going to have to go

975:37

ahead and go through a lot of code bases

975:39

to even learn that framework and what if

975:41

I make a complete course about there and

975:44

give you all of my experience and save

975:46

you a lot of time I spend 10 years in

975:49

this indust and by the way I love 10 St

975:52

query I love tener Lindsay I can even

975:54

pronounce as name but yeah I love him I

975:56

also love Tyler meinz so yeah no hate

976:00

about them but I'm just saying go ahead

976:01

and learn that framework by yourself you

976:04

can because nobody made any tutorial

976:06

about that so I'm going to be making a

976:07

complete course about that don't worry

976:09

about that framework which will be

976:10

dropping very soon what I was trying to

976:12

say is that you have to go through this

976:14

tutorial hell then there would be a

976:16

point that you don't have to watch any

976:18

tutorials and you would be able to build

976:20

anything by yourself like imagine for a

976:22

second when you are first learning about

976:24

the HTML and CSS you had to watch a lot

976:26

of tutorials now if I ask you to watch

976:28

the HTML and CSS

976:30

tutorials you won't even watch them

976:32

because I know your experience you are

976:34

now experienced developer who is

976:36

watching this video so you don't even

976:38

have to watch the HTML and CSS tutorials

976:40

you can do every single thing by

976:42

yourself so first you have to go through

976:45

the tutorial hell and then you don't

976:47

have to watch there let's talk about the

976:49

next question will there be more parts

976:51

of this course yes there will be because

976:54

we have to cover cover the 10 stack

976:55

query 10 stack router 10 stack framework

976:58

itself react design patterns react

977:01

design system react testing and also

977:04

next year 15 so yeah there will be a few

977:07

parts now let's talk about not the most

977:09

important one but why do I laugh so much

977:12

in my

977:13

videos I know some people don't like my

977:15

laughter but to be honest I love it and

977:18

I love to love and you can't take this

977:21

away from me because this is my channel

977:23

and I will do what the I like to do

977:25

let's talk about the frame or motion so

977:27

frame or motion is a popular open-

977:29

Source library for reactjs that allows

977:32

developer to create animations and

977:33

transitions easily it provides a set of

977:36

tools and apis to animate component

977:39

enabling smooth and high performance

977:41

animation with minimal effort so this

977:43

just a basic definition of what a framer

977:45

motion is now let's talk about what's

977:46

the difference between framer and framer

977:49

motion so a framer is a design tool that

977:51

allow you to create High Fidelity

977:53

prototypes and Interactive design on the

977:56

other hand a frame or motion is a

977:57

library specifically for reactjs that

978:00

enable developer to create smooth

978:02

animation and transitions now the big

978:04

question is why should I even care about

978:07

learning frame or motion if I can do my

978:09

transition and also animation in CSS why

978:11

should I even bother learning frame or

978:13

motion and now let's talk about the CSS

978:15

animation pros and also CSS animation

978:18

cons then we're going to be also

978:19

discussing the frame or motion pros and

978:21

also the frame or motion cons CSS is

978:24

great for simple how effects transitions

978:26

between stats or animation that doesn't

978:28

require a complex logic CSS animation

978:31

are typically very performant and can

978:33

leverage GPU acceleration you also don't

978:35

need to install some sort of a third

978:37

party library for there you can totally

978:39

go ahead and just write your code it

978:41

will work totally fine so that's just a

978:42

pros of what a CSS animations and

978:44

transitions is now let's talk about the

978:47

cons they are more challenging to manage

978:49

complex animation such as coordinating

978:51

multiple elements or responding to the

978:53

user interaction be beyond the simple

978:55

events animating properties based on a

978:57

component State can be also cumbersome

978:59

in a CSS animation so that's just the

979:01

pros and cons of a CSS animation and now

979:03

let's talk about the pros and also the

979:05

cons of a frame or motion so let's just

979:07

start from the pros so framer motion

979:09

offers Advanced capabilities like drag

979:12

gesture and layout animation which can

979:14

be hard to achieve with a pure CSS and

979:16

also it allows us to integrate

979:18

seamlessly with react component model

979:20

allowing for easy management of St

979:21

driven animation it makes it easy to

979:24

Define in switch between different

979:25

animation State and now let's talk about

979:27

the cons of the frame or motion so it

979:30

might take some time to get familiar

979:32

with the apis and stuff the learning

979:34

curve can be a bit difficult sometimes

979:36

but not all the times and you would also

979:38

need to install a third party package

979:40

which is called the frame or motion

979:41

package which we're going to be seeing

979:42

in a few seconds so yeah that's just the

979:44

only cons about the frame or motion and

979:47

welcome to the word of animation and

979:49

framer motion let me show you the

979:51

difference between framer and framer

979:53

Motion in action so here you can see I

979:55

am now inside the frame.com for/ motion

979:59

right here and it's going to brings us

980:00

to the frame or motion documentation

980:02

which is something that we want and here

980:04

we're going to be spending a lot of time

980:06

but now if I only remove this motion and

980:09

if I hit enter right now it's going to

980:11

brings us to something called the framer

980:13

okay so here you can see you can learn

980:15

more about that if you wanted to which

980:16

is basically a design tool and you can

980:18

do a prototyping and all of that kind of

980:20

stuff which is something which we not

980:22

going to be doing in this course okay so

980:24

yeah this is a framer website and now if

980:26

you want to go into the framer motion

980:27

documentation you're going to have to

980:29

specify the motion right here and if you

980:31

hit enter so it's going to brings us to

980:33

this frame on motion documentation right

980:35

here okay so time to make a set of for

980:37

recording Journey so what I'm going to

980:38

do is that I'm going to open my terminal

980:41

right here and then I'm going to make it

980:44

a bit bigger so that you guys can see

980:46

everything a bit better like so now we

980:48

use npm create with at latest and here

980:52

I'll give it the name of like Prim

980:54

motion demos or something like that I'll

980:57

choose reactjs and also typescript now

980:59

I'll go into the framer motion and now

981:02

let's just install every single thing

981:03

inside there so I'll use like npmi to

981:06

install all of the packages now that's

981:08

done I'm going to also install the frame

981:09

or motion so I'll just click on the

981:11

getting started and I'm going to copy

981:13

this command from there and now let me

981:15

just place this Command right here and

981:16

hit enter so it's going to install that

981:18

while it's doing then I'm going to also

981:19

go into the T css.com click on the

981:22

getting started I'm not quite sure if

981:23

I'm going to be using T in CSS or not

981:26

but yeah I will still provide this all

981:27

choose the weat and then I'm going to

981:29

copy this command and let's just place

981:31

it right here so it's going to install

981:33

tailin CSS inside my project so I'll

981:36

also copy this command or this content

981:38

from here and I'm going to hit enter so

981:40

it's going to initialize my T in CSS

981:42

let's just open our vs code right here

981:44

and this is how it looks like so I'll

981:46

just remove there I'm going to also

981:47

remove the public folder let's just go

981:49

into the SRC remove the assets the app.

981:52

CSS and also remove every single thing

981:54

from the app and I'm going to be using

981:55

my rafc inside this sa my file let's go

981:58

into this T config file and I'm going to

982:00

replace it with this new content and I'm

982:03

going to also copy these components from

982:05

there so let's just go into the

982:06

index.css file and replace it right here

982:09

okay so finally I'm going to have to run

982:11

that but I'm going to copy this line of

982:13

code and place there right here with

982:16

this new one so let's say sa our file

982:18

and I'm going to be using npm run de so

982:20

it's going to run there inside my server

982:22

so use like Local Host and here you can

982:24

see we are now getting our hello word

982:26

which is looking cool but also I want to

982:27

provide more styling to this so I'm

982:28

going to go ahead and go to my index.

982:30

CSS file and place it right here sa my

982:33

file let's just go back and here you can

982:35

see we are now selecting every single

982:36

thing providing a pairing of zero and

982:38

margin of zero box sizing will be set to

982:40

border box then we are selecting the

982:42

body changing the background color also

982:44

changing the text color and centering

982:46

out every single thing and then we have

982:48

our box and this box have the width of

982:50

300 and also the height of 300 and we

982:53

have a border pixel or Bard radius of

982:56

100% And we are also changing the

982:57

background color of there so this is how

982:59

currently things looks like and that was

983:01

just a simple setup now let me show you

983:03

the basics of Animation I'm not going to

983:05

be writing a lot of code and you can

983:07

think about that is just like the hello

983:09

Word program in the frame or motion so

983:11

I'm going to make things side by side

983:12

like so so I'll just remove that and

983:14

also remove that one and make things

983:17

side by side remove there zoom in a bit

983:20

so you guys can see everything a bit

983:21

better the first thing that I want to do

983:23

is that I want to import something from

983:25

the frame or motion which is called the

983:27

motion from where from the frame and

983:29

motion so that's going to be the first

983:30

thing next we have to create some sort

983:32

of a div not this div but we have to

983:35

create them manually and inside there

983:37

we're going to be using something called

983:38

the motion. div and I'm going to also

983:40

close it you can close your div like

983:42

this but I'm not going to close my div

983:44

like so okay I'll just close it like a

983:47

self closing tag I'm going to also Pride

983:49

the class name of box today and remember

983:51

this box is coming from this CSS as you

983:54

can see if I go into this index. CSS so

983:57

here you can see we have this box and we

983:59

are now providing The Styling today okay

984:01

so yeah we can now totally see our

984:03

Circle and I'm going to use like animate

984:05

prop and here inside this animate prop

984:08

what I'm going to do is that I'm going

984:09

to proide the X and the X will be set to

984:10

20 okay so if I save there or you know

984:13

let me just change that to 100 and here

984:14

you can see we're now animating this

984:16

ball so what is this motion which we are

984:19

now importing from the framer motion and

984:21

what is this animated prop so now let me

984:23

just explain that in the diagrams let's

984:25

talk about that motion thing which we

984:26

just import from the framer motion so

984:28

motion is an object that provides a set

984:30

of component and hooks for creating

984:32

animation and transitions in react

984:34

applications so that's just a theory but

984:37

now let's just explore the bit more so

984:39

when we use the motion dot element and

984:41

that element can be basically any HTML

984:44

element you can specify motion do H1 H2

984:47

or U Li span image div article a side

984:52

section or text area in Imports or

984:55

anything that you prefer so you're going

984:57

to be using that like this first of all

984:58

you're going to be importing the motion

985:00

then you're going to be using motion Dot

985:03

and then you're going to be using the

985:04

element name so basically we are

985:06

indicating that we want to animate this

985:08

specific HTML element framew motion then

985:11

provides additional props and feature to

985:13

facilitate those animations such as the

985:14

initial prop animate prop and also the

985:17

exit prop allowing for more powerful and

985:19

customizable animation okay so we just

985:22

mentioned these three things like and

985:24

also the initial and also the exit prop

985:27

so I want to discuss there a bit more

985:28

let's talk about the initial prop so the

985:30

initial prop is used to define the

985:32

initial state of an animated component

985:34

before it enters the Dom it specify how

985:37

the element should appear when it first

985:38

renders so that was just the initial

985:40

prop and now let's talk about the main

985:42

part which is called the animate prop so

985:44

the animate prop is used to create an

985:46

animation for the component it lets you

985:48

set the target value for the different

985:50

CSS properties making it easy to have

985:53

smooth changes when the component State

985:54

updates that was the animate prop and

985:57

now let's talk about the final not a

985:58

final but now let's talk about uh yet

986:01

another most useful one which is called

986:03

the exit prop so the exit prop is used

986:05

to define the animation that occurs when

986:07

the component is removed from the

986:09

reactory this is particularly useful for

986:11

creating an animation when the elements

986:13

are unmounted or removed from the Dom

986:17

enhancing the user experience by

986:19

visually indicating that something has

986:21

disappeared and now we are going to be

986:23

covering the first part of for animation

986:24

which is called the Transformations so

986:26

transformation allow you to change the

986:28

shape size and position of the element

986:30

on the web page I know there was a lot

986:33

of theory but now let's get into the

986:35

code and then you will get to know what

986:36

I'm talking about okay so let's talk

986:38

about the transformation and I know

986:40

there was a lot of theory so now let's

986:41

just Implement all of the theory in

986:43

action so anytime you want to work with

986:45

a frame or motion there are a few things

986:47

that you have to keep in mind the first

986:48

thing that you have to keep in mind is

986:50

that you're going to have to import this

986:51

motion object from the frame and motion

986:53

and then you have to tell the frame or

986:55

motion that which element or which

986:57

specific HTML element you want to

986:59

animate so this is how we're going to be

987:01

telling our frame or motion that we want

987:03

to animate this specific Dev okay so now

987:05

frame or motion will gives us a super

987:07

power to animate that Dev so the first

987:09

super power it will gives us is the

987:11

animate prop so it's going to take a CSS

987:13

properties and which will allows us to

987:15

animate word div so I'll just use like

987:17

translate property right here so if I

987:19

just use like translate card

987:22

translate and now if I hit penter I can

987:24

also use like translate on the x-axis

987:27

and also on the Y axxis like 200 pixel

987:29

and as soon as I save my file here you

987:31

can see it's going to move my element I

987:33

can also write like translate on the

987:34

x-axis so if I sa my file it's going to

987:37

move my element on the x-axis I can also

987:39

push that on the y- axis so here you can

987:41

see it's going of push that from top to

987:43

bottom so we are not going to be writing

987:45

our code like this because in the frame

987:47

and motion there are a lot of shortcuts

987:51

okay so instead of using like translate

987:53

on the X axis and translate on the y

987:55

axis we are allowed to do that if you

987:58

want to do that but we don't have to do

988:00

that okay so let's suppose if you want

988:01

to use like the translate on the x-axis

988:04

we just have to write like X so as soon

988:06

as we write X then we can specify like

988:08

how much we want to move our element so

988:10

I'll just write like uh not 200 but 100

988:12

pixel and now I sem my file so it's

988:14

going to move that 100 right here I can

988:16

also change that to 200 and it's going

988:18

to push that right here on the 200 we

988:21

are also not limited to only writing a x

988:23

instead of writing a translate on the y

988:25

axis we can only use the Y okay so if I

988:28

change that to like 100 and S my file so

988:30

it's going to push it down right here I

988:32

can also write like 200 and here you can

988:35

see it's going to push a bit more and

988:37

once again we are not limited to just

988:39

provide these properties we can also use

988:41

our own custom CSS pixel rims percent

988:45

and all of that kind of good stuff so I

988:46

can use like 100 pixel sa my file so

988:49

it's going to push that right here I can

988:50

also use like 10 rims or something like

988:53

that sa my file F so it's going to push

988:54

a bit more and I can also use like uh

988:57

you know what 80 80% this is for 80%

989:02

it's going to also work exactly the same

989:05

so that was there about the translate on

989:07

the x-axis and translate on the y-axis

989:09

now let's talk about the rotation so to

989:11

work with the rotation first of all

989:12

we're going to have to go into the

989:14

index.css file and we have to comment

989:16

this Bor radius right here from this box

989:19

so now if I save my file and by the way

989:21

if you are wondering here is the index.

989:22

CSS file okay so now we can totally

989:26

rotate our element so to rotate them we

989:28

have a few properties like the first

989:30

property we have is a rotate on the

989:31

xaxis then we have to specify the values

989:34

in the degrees so I can just write like

989:36

60° let me just write a 60° right here

989:38

semi file and it's going to rotate my

989:40

element on the xaxis 60° I can also

989:44

change that to like 20° it's going to

989:46

also rotate there as a 20° and I can

989:49

also change that to like 70° and it will

989:51

work exactly the same we are not only

989:53

limited to work with x-axis we can also

989:55

use the y axis and I can just write like

989:57

60° semi file and it's going to rotate

990:00

my element on the y axis 60° I can also

990:03

change that to 20 and this is how it

990:05

will look like in some situation we

990:07

would also want to use one value for the

990:10

x-axis and also for the y- axis so for

990:12

that we can use just a short hand which

990:14

is called the rotate property so I'll

990:16

just use like 60° semi file it's going

990:18

to flip it up and also we can for 20

990:21

degree we can use any kind of value so

990:24

that was the rotation and also the

990:26

transformation or a translate value

990:28

let's talk about the scaling so we can

990:30

also scale our element you know what

990:32

first of all let me just show you

990:33

something here you can see if you go

990:35

ahead and go to our index. CSS now we

990:37

are providing the width of 300 and also

990:39

the height of 300 to our specific box

990:42

which means like we are now using the

990:44

scale of one okay so if I just write

990:47

like scale of one it will look exactly

990:50

the same but if I change there to two so

990:53

which means like like we're now

990:54

duplicating or multiplying this value

990:58

like here you can see this is a 300 it's

991:00

going to make it as a 600 and also make

991:02

the height as a 600 okay so in some

991:05

situation we would want to increase the

991:06

size of that so for that we can just use

991:08

like scale then we can just specify two

991:11

which means like we want this element to

991:13

scale up twice so now if I saell my file

991:15

and boom okay so that was the scale

991:18

property we can also just change the One

991:20

Direction like on the x-axis I say my

991:23

file so it's going to change the on the

991:24

x-axis you can also change their on the

991:26

y- axis and this is how it will look

991:29

like and we can also provide like

991:30

obviously four and five and stuff like

991:33

that bang this is looking huge so then

991:35

was it about for the X Y roted X roted Y

991:39

roted scale X scale Y and just a scale

991:42

property let's talk about the final one

991:44

which is called the skew so skew will

991:47

allows us to tilt our element okay so we

991:49

can also skew that on the x-axis let me

991:52

just write like skew on the XA is of 20

991:54

and as soon as I do the and sa my file

991:57

and here you can see it's going to tilt

991:58

my element as 20° we can also change the

992:02

direction to the y-axis like so say my

992:04

file and it's going to tilt or skew

992:06

there on the y-axis s 20 so I can also

992:09

change that to like 40 and this is how

992:11

it will look like and we can also like

992:13

obviously use the short hand which is

992:14

called the SK sa my file and this is how

992:17

it will look like we can also change the

992:19

value of that to 20 and bang okay so in

992:21

this section we learned all of that

992:23

properties let me just show you there so

992:25

we learn about the come on we learn

992:27

about the animate and we also learn

992:29

about the motion motion Dot and specific

992:31

element and we learn about the x-axis

992:34

the

992:50

one I know that you like transformation

992:53

but now I'm going to tell you about yet

992:55

another property which will make you

992:56

fall in love with itself and that

992:59

property is called the transition so

993:01

let's talk about it what are transitions

993:04

and why you should even care about them

993:05

so transitions are the effect that

993:07

control how the animation happens and

993:09

you can think about them as the rules of

993:11

how the element moves or changes so

993:14

there are a few properties about the

993:15

transitions which is called the duration

993:17

easing and the delay so let's talk about

993:19

the first one which is called the

993:20

duration so duration simply means that

993:23

how how long the animation will take and

993:25

easing simply means the speed curve of

993:27

the animation like it will start from

993:29

slow and it will go fast or it will go

993:31

fast and then it will stop slow and

993:34

something like that then we have a delay

993:36

and delay just simply means how long we

993:38

have to wait before starting the

993:39

animation so yeah that was just the

993:41

basic theory about the Transitions and

993:43

now let's just discuss the inaction so

993:46

let's talk about the transitions

993:47

inaction so what I'm going to do is that

993:50

I'm going to uncomment this line of code

993:52

and now we have to provide our initial

993:53

State and we just saw initial state in

993:56

the diagrams but this is the first time

993:58

that we are using there so basically

994:00

this is going to be the initial State or

994:02

the starting point of our animation so

994:04

we want our animation to start from zero

994:07

and then we want to animate to the xaxis

994:12

100 pixels so now if I save my file here

994:14

you can see our animation will start

994:15

from zero and then it will go to 100

994:18

pixel on the x-axis so which is cool and

994:21

everything but now you want to control

994:23

the behavior year of this animation so

994:25

how are we going to be controlling there

994:27

so to control there we have another

994:28

properties called you guessed it

994:31

transition okay so I'll use the

994:33

transitions right here and inside this

994:35

transition prop we can proide the delay

994:38

duration and also the easing so now in

994:40

this case I'll just put like the delay

994:42

I'll write like delay like so and delay

994:44

will be set to maybe 2 seconds okay so

994:47

I'm going to save my file and now let me

994:49

just refresh there so we have to wait 2

994:50

seconds like one and two then it will

994:53

start work working so you know what let

994:54

me just refresh there one two bang okay

994:58

so this is the delay like how long we

995:00

have to wait before starting the

995:02

animation okay so I'm going to duplicate

995:04

this lineup code I'm going to comment

995:05

this line out and I can also set there

995:07

to like 5 seconds or something like that

995:09

now let me just refresh this so we have

995:11

1 2 3 4 5 and bang so now it will take

995:16

like 5 seconds so that was delay but I'm

995:19

going to also duplicate that and change

995:21

that to something called the duration

995:24

and this is by far one of my favorite

995:26

property and we can provide a seconds to

995:28

that like how long our animation will

995:30

take so I'll just provide like 2 seconds

995:32

and now if I just refresh there and bang

995:35

this is super smooth you know I'm going

995:36

to change that to 200 and now let me

995:38

just refresh there and here you can see

995:40

this is how it will look like so now

995:42

what animation will take 2 seconds to

995:44

complete I can also change that to like

995:46

5 seconds and now let's just refresh

995:48

there and it will take 5 Seconds to

995:50

complete now so this is also cool but we

995:53

can also change the behavior of there a

995:55

bit more okay so now let me just

995:57

duplicate this line of code and comment

995:58

that one out so I can also provide the

996:00

easing and we have a lot of easing so we

996:03

have anticipate back in back in and out

996:06

Circle in circle in and out circle out

996:08

and EAS in ease in and out and linear

996:11

and there are a lot of them so I'm going

996:13

to only choose this ease in and out I'm

996:15

going to save my file now let me just

996:17

refresh there so it's going to start

996:19

slow and then it will go a bit fast let

996:21

me just refresh there once again okay so

996:24

it's going to start slow then it will go

996:25

a bit fast I'm going to change that to

996:27

like maybe two seconds so that you guys

996:28

can see everything a bit better and yep

996:31

we also have the ease so if I change

996:33

there to ease so everything will go as a

996:35

ease so you know what let me just change

996:37

there to uh

996:38

linear

996:40

linear now if i s my file and here you

996:43

can see it will go linearly so yeah we

996:46

have these few transition properties we

996:47

have a delay duration and also the

996:50

easing welcome to one of my favorite

996:52

Topic in this entire course which is

996:55

called the key Fram so what are key

996:57

frames and why you should even care

996:58

about that so key frames allow you to

997:00

create more complex animation by

997:02

specifying multiple points in animation

997:04

sequence instead of just animating from

997:06

one state to another we can Define

997:08

several intermediate state or you can

997:10

also say frames to control the animation

997:12

more precisely and I know that's a

997:15

complex definition to say but to put

997:17

them in more simple terms you can think

997:20

about the key frames is like splitting

997:22

or dividing any into multiple frames or

997:25

multiple parts so that's just as simple

997:28

as that so how the syntax will look like

997:31

this is how the syntax will look like so

997:33

first of all we are going to be using

997:34

the array and inside this array we're

997:36

going to be providing the starting point

997:38

and then the ending point and we can

997:40

provide as many as we want so that was

997:42

just a theory about the key frames and

997:44

now let's get into the coding then

997:45

you'll get to know what I'm talking

997:46

about okay so now let's just use the key

997:48

frames in action so I'll use the animat

997:51

prop once again and inside this animate

997:53

prop we're going to be doing a lot of

997:55

magic so first of all you want to scale

997:57

up this ball so I'll use like scale and

997:59

here once again anytime you want to use

998:02

the key Fram so the first thing that you

998:03

have to do is that you have to write the

998:05

array and inside this array you have to

998:07

specify the starting point and then the

998:10

ending point so I'll use like start from

998:12

one like the scale of one then go to two

998:15

Okay so if I just write the in semi file

998:18

here you can see it's going to start

998:19

from one then it's going to go to two

998:21

and I'm going to also provide the

998:23

transition so I'll write like

998:24

Transitions and here for the transition

998:27

I'm going to provide a duration of like

998:28

maybe 5 seconds or something like that

998:30

say my file and now let me just refresh

998:32

there it's going to start very slow from

998:34

the one scale then it will go to two

998:37

scale and now let me just refresh there

998:38

here you can see it's going to start

998:39

from the one scale and then it will go

998:41

to two scale now we can also specify and

998:44

we can also tell it that we have to

998:46

start from Two and then we have to go to

998:49

three okay and we can also provide more

998:51

than this so I'll just use like this

998:53

start from that three then start from

998:55

the four then go to three and we can

998:57

also go backward then start from the

998:59

three then go to two then start from the

999:01

two then go to one okay so I know there

999:04

was a lot of saying so let's just save

999:06

our file and refresh there so it's going

999:08

to start from one then it's going to go

999:10

to two then it's going to go to two once

999:11

again then it will eventually go to

999:13

three and four and it will start from

999:15

the four then it will go to three then

999:17

it will go to two and finally it will

999:19

reach to the one and this is how it

999:21

looks like so you know what let me just

999:22

play this animation once again I'm going

999:24

to just refresh okay bang bang bang bang

999:28

bang bang

999:31

bang so that was there about for the

999:34

scaling but we are not only limited to

999:36

provide the scaling we can also provide

999:37

the rotation if you wanted to but for

999:39

the rotation you guessed it we're going

999:41

to have to comment this line out and we

999:42

can use like rotate and here we have to

999:44

specify our key frames so we want our

999:47

rotation to start from the 0 Dee and

999:50

then it should go to the 0 Dee then it

999:52

should go to the two

999:54

270° and then 270° once again and then

999:58

finally go to the zero point okay so if

1000:01

I say my file and now let me just

1000:02

refresh there here you can see it's

1000:04

going to start from 0 0 then it will

1000:05

rotate there to 270 and then it will

1000:08

reverse it back to 20 270 and finally

1000:12

it's going to make it zero so we can

1000:14

rotate the uh what do we call we can

1000:16

also provide a key frame for the

1000:18

rotation but we can also provide the

1000:22

Border e

1001:16

so we are now at the point of the course

1001:18

where I'm going to give you the examples

1001:20

now I know a lot of people will ask me

1001:21

husin why didn't you give us this

1001:22

example in the transformation and also

1001:24

in the transition section and the answer

1001:27

is obvious because you guys already know

1001:30

what a transition and also

1001:31

transformation is from CSS but now in

1001:34

framer motion we have this new concept

1001:36

of key frame so I'm going to give you a

1001:38

few examples of there if you don't care

1001:40

about the examples you can totally go

1001:41

ahead and skip this uh example section

1001:43

so I'm going to create a components

1001:44

folder and inside there I'm going to

1001:46

create my pulsing button. TSX file let's

1001:50

just hit enter what the hell did I just

1001:52

do godam

1001:53

remove there and create a file with the

1001:55

name of pulsing b. TSX and create my RFC

1001:59

inside there sa my file and let's just

1002:01

try to animate that but before I do

1002:03

here's a question for you now I'm using

1002:05

a frame motion what's going to be the

1002:07

first step that I have to do and 3 2 1

1002:11

and the answer is we're going to have to

1002:13

import the what do we call it the motion

1002:17

object come

1002:18

on oh my God motion object from where

1002:22

from the frame motion that's going to be

1002:23

the first thing that we have to do next

1002:25

we have to tell our frame motion that we

1002:27

want to animate that specific thing let

1002:30

I'll just remove the or know let me just

1002:32

select and remove both of them and I'm

1002:34

going to use like motion. button right

1002:36

here and now let's just start working on

1002:38

our button I'll use my click me as a

1002:40

label for that and now if I sell my file

1002:42

I'm going to go ahead and go to uh and

1002:45

let's just remove my action and create

1002:48

my pulsing p l s i n g pulsing button

1002:51

and register this component right here

1002:53

remove this setion from there you're now

1002:55

getting your cute little click me b or

1002:57

something like that okay so let's just

1002:59

refresh there it's not doing anything

1003:02

but now we have to start working on

1003:03

there the first thing that we have to do

1003:05

is that we have to specify our animate

1003:07

prop or you know what let me just

1003:09

provide a bit of styling to that so that

1003:10

we can see what are we working on so

1003:12

I'll just provide like pairing for the

1003:13

xaxis of four pairing for the Y AIS of

1003:15

two text will be set toally white

1003:17

background will be blue of 500 and

1003:20

totally rounded outline will be one

1003:23

outline would be set to none I save my

1003:26

file so this is how my button looks like

1003:28

and now it's time to animate there so to

1003:30

animate there I'm going to go ahead

1003:32

provide a bit of spacing today and

1003:34

provide my animate prop right here for

1003:36

this animate prop I'm going to use my

1003:38

key frames all just try a scale and the

1003:40

scale starting from the one then go to

1003:42

1.1 and then go back to the one okay so

1003:46

that's going to be it for the scaling

1003:47

I'm going to also change the background

1003:48

color of there and the background color

1003:50

will be set to these colors so first of

1003:52

all you will have this color then it

1003:54

will go to this color and then it will

1003:55

go back to that color okay so now if I

1003:58

save my file here you can see we are now

1004:00

getting this animation it's going to

1004:01

provide just a bit of opacity to that

1004:03

then it will go back to it existing

1004:05

color so now let me just provide

1004:07

duration and duration will be set to Z

1004:09

Point Ed and also I want to provide a

1004:11

bit of easing and ease will be set to

1004:13

ease in and out and also I want to use

1004:16

my uh repeat I also forgot to tell you

1004:18

the repeat but yeah we can also repeat

1004:20

our properties and I'm going to set

1004:22

there to to infinite there we go so now

1004:25

if I save my file let's just save our

1004:27

file go back a little bit this is how

1004:29

the code will look like and this is how

1004:31

the animation will look like okay so

1004:33

here you can see we are now getting this

1004:35

amazing button and that was example

1004:37

number one and basically we only have to

1004:39

write this amount of code to create this

1004:42

amazing animation by using the framer

1004:44

motion so that was example number one

1004:46

let me give you one more example which

1004:48

is uh what do we call it bouncing

1004:51

loader. TSX yes so use my RFC inside

1004:54

there go to my app and comment this line

1004:57

out I'm going to be using my bouncing

1005:00

loader import it right here sa my fine

1005:03

and this is how it looks like right here

1005:04

obviously the first thing that we have

1005:06

to do is that we have to import the

1005:07

motion from the frame motion like so

1005:10

next we have to provide a bit of styling

1005:11

today so I'll just use like uh flex and

1005:14

justify will be set to center items will

1005:17

be set to Center and space on the xaxis

1005:19

will be set to two Okay so now inside

1005:21

this div on want to just iterate over

1005:23

through a lot of data so we can get

1005:25

overloaded so I'll just use like uh dot

1005:28

dot come on dot dot dot and then I'm

1005:30

going to use my array and here we only

1005:32

have to specify three items and then we

1005:34

have to itate over through that items

1005:36

this all use like map method and here we

1005:38

are not interested in anything and we

1005:40

are only interested in the index okay so

1005:42

now inside there let's just go back the

1005:44

first thing that we have to do is that

1005:45

we have to use our motion DOD or you

1005:47

know what I'm not going to close there

1005:49

like this way I'm going to close there

1005:51

as a self closing tag now we have to

1005:53

specify our animation right here so

1005:55

first of all we have to take care of the

1005:57

key prop and this is how we going to be

1005:59

taking care of that we also have to just

1006:01

uh put a bit of styling today so I'll

1006:03

use like width of four and also the

1006:05

height will be set to four the

1006:06

background will be set to totally till

1006:08

500 now underneath that this is how we

1006:10

are going to be animating our stuff you

1006:12

know let me just save my file so here

1006:14

you can see it's going to gives us that

1006:15

three dots and that dots are coming from

1006:17

this array right here we can also change

1006:19

that to like I don't know maybe five or

1006:21

something like that now it's going to

1006:23

gives us that five one but I only want

1006:25

to get these three so now finally we

1006:27

have to animate these balls right here

1006:29

okay so I'll use like my animated prop

1006:32

and inside this animate prop we have to

1006:33

provide the y-axis and for the y-axis we

1006:36

want to start with animation from zero

1006:37

and we want to go to minus 50 and then

1006:40

zero once again okay so as soon as I do

1006:42

that here you can see all of them are

1006:43

now bouncing but I can also PR the

1006:45

transition so I use like Transitions and

1006:48

here inside this transition what do you

1006:50

want to do I want to provide a bit of

1006:51

duration and it is going to to take like

1006:53

0.6 seconds we also want to provide the

1006:55

easing and the easing will be ease in

1006:57

and out and I also want to provide the

1006:59

repeat and it's going to repeat itself

1007:01

like infinitely so now if I save my file

1007:03

and refresh there here you can see they

1007:05

are bouncing which is cool but I only

1007:08

wanted to add one more property which is

1007:10

called the repeat delay okay so like how

1007:13

much time each of the repetition will

1007:14

take so I'll just write like index time

1007:17

uh 0.5 okay so if I just save my file

1007:20

and refresh there this one will take

1007:22

like I don't maybe. 1 second then it

1007:25

will take like. 1.5 second and it's

1007:27

going to take like 1 second completely

1007:30

okay so yeah this is how our loader

1007:32

looks like and it is looking super cool

1007:35

I don't know if that's going to be

1007:35

impressive or not but for me that's

1007:37

looking super cool let's talk about the

1007:39

variants so variants are a way to define

1007:41

different state or style for or

1007:43

animation in more organized way you can

1007:46

think of them as a predefined animation

1007:48

setup that we can switch between easily

1007:51

so that's just a definition of what a

1007:52

variant is but now let's talk about how

1007:54

we are going to be defining our variants

1007:56

so we can just create a set of names

1007:58

like hidden visible or basically you can

1008:00

give it any name that you prefer they

1008:02

describe how the element should look or

1008:04

behave in each state something which we

1008:06

are going to be seeing in a few seconds

1008:08

then we have to use the then so we can

1008:10

apply these variance to or animated

1008:12

component making it easy to switch

1008:14

between State without repeating or code

1008:17

so this just a theory of what a variants

1008:19

are but now let's get into the coding

1008:20

then you will get to know what I'm

1008:21

talking about there are a few ways to

1008:23

Define your variants the first way is to

1008:25

provide it in line the second way is to

1008:27

create a separate object and provide the

1008:29

reference of that object to the variant

1008:31

prop and the final way is to just create

1008:34

a separate file Define your variants

1008:36

there so I'm going to start from the

1008:37

first one I'll just provide my variance

1008:39

right here as a inline we're going to be

1008:41

using the variance come on v a r i NTS

1008:45

and now inside this variance prop we are

1008:47

going to be defining our different state

1008:49

I'm going to give it the name of like

1008:50

here and right here basically this this

1008:52

is going to be just a simple object

1008:54

property like uh you know let me just

1008:56

show you there this is going to be the

1008:57

object we are going to be providing some

1008:59

sort of property today and then a

1009:01

specific value for their property so

1009:03

which means like you can give it any

1009:05

name that you prefer you can give it the

1009:06

name of like banana you can give it the

1009:08

name of like orange you can give it the

1009:09

name of like my name hose you can give

1009:12

it any name that you prefer but now in

1009:14

this case I'm going to give it the name

1009:15

of hidden so which means like when my

1009:17

state is hidden in that situation I want

1009:20

to set the opacity to zero and I also

1009:22

want to scale it down to like 0.8 or

1009:25

just a zero if I wanted to so this is

1009:27

how we are going to be defining our

1009:29

variant this is how we going to be

1009:30

providing a property over a state for

1009:33

our variant and this is how we're going

1009:34

to be setting the value for the specific

1009:37

variant okay so that's our first variant

1009:39

I can also create one for the visible so

1009:41

visible come on v i s i b n e and now

1009:43

when my object or my state is visible so

1009:46

in this situation I want to set my

1009:47

opacity to one and I want to scale it up

1009:50

to one that's going to be for my visible

1009:52

State we can also provide one for the

1009:54

exit and I can like basically go on and

1009:57

on and I can specify how many I want but

1009:59

now in this case I only want to provide

1010:01

two so I'll just provide the opacity and

1010:02

opacity will be set to zero I'm going to

1010:04

also provide a scale and the scale will

1010:06

be set to 0.5 okay so now we

1010:08

successfully Define our variance but now

1010:10

the question is how in the word we are

1010:13

going to be using these State like we

1010:14

have a hiden state we also have the

1010:16

visible and we also have the exit State

1010:19

okay so now that we successfully defined

1010:20

there now let me show you how we are

1010:22

going to be using us them so now

1010:23

initially like initially I want my state

1010:27

to be hidden okay so I'm going to only

1010:29

copy the hidden name from there and now

1010:31

let me just place it right here so as

1010:32

soon as I save my file and refresh there

1010:36

Watch What Happens where in the word is

1010:38

that ball that ball is totally

1010:40

disappeared and why is there because we

1010:43

specify our hidden property inside our

1010:45

variant and now we are using there let's

1010:48

suppose if I just increase it to one now

1010:50

let me just save my file and refresh

1010:52

there it's going to give it back so this

1010:54

is how we are going to be defining our

1010:55

variant and this is how we going to be

1010:57

using this so you know what let's just

1010:59

back there two Z and now I'm going to

1011:01

also provide the animation so I'll just

1011:02

use like animate property so on the

1011:05

animate property I'm going to set there

1011:06

to visible okay not visibility but this

1011:09

specific visible uh prop or variant

1011:11

whatever you want to call them oh I'm

1011:13

getting an error because we are creating

1011:15

already this object so we don't have to

1011:17

specify double uh curly presses right

1011:19

here so I'm going to have to remove one

1011:21

so now if I just remove there and sa my

1011:23

file and here you can see it will be

1011:25

visible I can also set that to here and

1011:27

if I wanted to Sol just use like here

1011:28

and sa my file bang that's gone okay so

1011:32

we can also provide the exit so when it

1011:33

is exit we want to just use our exit

1011:37

variant which is this exit variant right

1011:39

here I'm going to also provide a bit of

1011:40

transition to this so let's just use

1011:41

like Transitions and for this transition

1011:43

I want to provide the duration of 1

1011:45

second so everything is working the way

1011:47

we expect him to work but I also want to

1011:48

Define my own state so yeah you know let

1011:51

me just Define the so I'll use like is

1011:53

it visible or not so like is visible and

1011:56

then set is v i s IBL e it's going to be

1012:00

equals to the US St and here we have to

1012:02

specify true value for there so now that

1012:04

we successfully defined there now here

1012:06

we are going to be showing our content

1012:08

based on that visible flag okay so I'm

1012:10

going to copy that and now let me just

1012:12

place it right here and here we can use

1012:14

the tary operator so if this property is

1012:16

true you want to set there to visible so

1012:18

let me just write like v i s i e but if

1012:20

that's not the case we want to just set

1012:22

that to here and like so okay so now let

1012:24

me just save my file so obviously it's

1012:26

going to give us that Circle because we

1012:28

are setting that to true but if I change

1012:30

that to FSE sem my file here you can see

1012:32

that gone let's just save there I'm

1012:34

going to also provide the on click when

1012:35

Handler on there so when somebody try to

1012:37

click on this B so we just want to make

1012:39

it disappear there I'll just use like uh

1012:41

set is visible and I'm going to provide

1012:43

like not is visible which means like if

1012:46

it is true it's going to make it false

1012:48

but if it's false it's going to make it

1012:50

true so if I click on the ball bang

1012:52

that's gone if I click on there once

1012:54

again here you can see it will make it

1012:56

visible so yeah this is how we're going

1012:58

to be defining our own custom variants

1013:00

and that's just a first way we can also

1013:02

extract all of that variance from here

1013:05

let me just extract that and we can

1013:07

create a separate object for this so

1013:08

I'll just give it the name of like uh I

1013:10

don't know variance would be fine and

1013:12

that's going to be set to all of that

1013:13

variant so as soon as I do this going to

1013:14

gives us an error obviously so I'm going

1013:17

to copy this variance from there and

1013:19

just write the reference right here and

1013:21

if I click on that

1013:22

everything is working the way we expect

1013:24

him to work so that's the second way we

1013:26

can also create a separate uh file for

1013:28

this so I'm going to copy the name up

1013:29

there and create my variance. ts or TS

1013:32

would be fine and here I can cut that

1013:35

from here and I can just place that here

1013:37

and put my export statement sa my file

1013:40

so now I can use like import variants uh

1013:43

from where let's just go ahead and go to

1013:45

our variants file now if i s my file but

1013:48

we're going to have to grab them

1013:49

manually like so now if i s my file here

1013:51

you can see we are now getting this uh

1013:53

Circle you can click on there and it's

1013:55

going to show it and it's going to hide

1013:57

it that was just the basics of variance

1013:59

welcome to the example number one in

1014:01

this one I'm going to be showing you how

1014:03

we are going to be creating the flipping

1014:04

card uh by using the variant so I'll

1014:06

just create a component with the name of

1014:08

flipping card. TSX and here I'm going to

1014:11

just Define my

1014:12

rafc like so okay so let's just Define

1014:15

the or registered there right here so we

1014:17

have our flipping card and execute this

1014:20

save there and here you can see we're

1014:21

now getting our flipping P card which is

1014:23

looking amazing so the first thing that

1014:24

we have to do is that we have to import

1014:27

something called the motion I guess you

1014:30

don't know that from the frame motion

1014:33

and now inside there let's just take

1014:34

care of the UI we'll just remove that

1014:36

from here and here I'm going to also

1014:38

provide my perspective right here like

1014:40

perspective and set there to 1,000

1014:43

inside there we're going to be defining

1014:44

yet another div so I'll just Define them

1014:47

right here and I'm going to give it a

1014:48

few classes like which will be set to 64

1014:51

and we also have to provide the height

1014:53

of 40 and background will be set to

1014:54

totally white rounded totally large and

1014:58

also Shadow will be set to totally large

1015:01

and overflow will be set to totally

1015:04

large and I'm going to Al you know

1015:06

overflow will not be set to large it's

1015:08

going to be hidden like so and we also

1015:11

have to specify the transform property

1015:13

like

1015:14

transform and we have to proide the

1015:16

transform style to preserve 3D preserve

1015:19

3D like so and let's just save our file

1015:21

so this is how looks like I'm going to

1015:23

go ahead and go to this div and inside

1015:26

this div we have to create yet another

1015:28

div so now for this div it's going to

1015:29

say like uh front side not size but

1015:32

front side like so we also have to

1015:34

provide few classes to this so I'll just

1015:36

use like absolute come on AB s o l u t e

1015:39

and then we also have to specify the

1015:41

inser inser will be set to zero

1015:43

background will be set to totally wide F

1015:45

and irems will be set to Center and

1015:47

justify will be Center come on Center

1015:49

like so text will be set to tot the

1015:51

extra Lar and font will be also set to

1015:54

totally bold okay so if I save my file

1015:57

this is how it looks like right here so

1015:58

this going to be the front side I'm

1016:00

going to also duplicate there and change

1016:02

that to the back side so let's just

1016:04

duplicate there and change that to the

1016:07

back side you know back side like so and

1016:11

change the background color to uh come

1016:13

on totally blue of 500 and this should

1016:16

also rotate so I'll just put a bit of

1016:18

rotation right here like rotate on the

1016:20

y- AIS of 100 and area degree so here

1016:23

you can see we now getting this

1016:24

different color now it's time to provide

1016:26

the animation okay so what I'm going to

1016:28

do is that first of all I'm going to be

1016:29

defining my St all use like is flip and

1016:33

then set is fli come on l i p d it's

1016:37

going to be equals to the US St and the

1016:38

initial value will be set to false okay

1016:41

so that's done we also have to make this

1016:43

div as a motion div so I'm going to

1016:45

select that and change the to motion and

1016:47

here at the bottom we are now getting

1016:48

this error so we also have to change

1016:50

that to motion do div okay like so and

1016:53

when somebody try to click on this

1016:55

button you just only want to fire this

1016:56

function which is uh just set the is FP

1017:00

property to if this is set to true we

1017:03

have to make that as a false if this is

1017:05

false we have to make that true okay so

1017:07

if I click on there anything is

1017:08

happening obviously because we have to

1017:10

change a lot of stuff inside there now

1017:12

inside this div we have yet another div

1017:14

so we also have to convert there to the

1017:16

motion div so I'm going to just convert

1017:17

it to the motion div copy the name of

1017:19

them and place it right here and and

1017:22

here for this motion div we have to

1017:23

specify our variance so I'll just use

1017:25

like variance and here inside this

1017:28

variance property what we have to do we

1017:30

have to provide the front side so I'll

1017:31

use like not font but front side and

1017:34

that's going to be set to the rotate Y

1017:36

and the Y rotation will be set to zero

1017:38

I'm going to just duplicate this line of

1017:40

code and change that to the back okay

1017:42

and on the back we have to change the

1017:44

rotation to

1017:45

180° so now let's just sa our file and

1017:48

use these variants inside our component

1017:50

so I'll just use like uh for the initial

1017:52

State we have to set there to the front

1017:54

and now for the animate we have to

1017:56

provide them as a trary operator so if

1017:59

this is flipped we want to use the back

1018:01

one but if that's not the case we want

1018:02

to use the fourth one or the front one

1018:04

you also want to provide the transition

1018:06

to it so for the transition I'm going to

1018:07

specify the duration of 0.6 seconds so

1018:10

now let me just save my file we're

1018:12

getting this UI which is not something

1018:14

that we want so I'll just uh remove this

1018:17

stying from here so now if I save my

1018:18

file here you can see when now getting

1018:20

this uh card right here here so here you

1018:22

can see we are now getting our backside

1018:24

but now if I click on there we are now

1018:26

getting that to revert okay so yeah this

1018:29

is looking amazing so this is how we're

1018:31

going to be creating our flipping card

1018:33

by using the framer motion so we don't

1018:36

have to do a lot of stuff like we using

1018:38

uh what do you call it our tailn CSS

1018:40

classes for The Styling like we're not

1018:41

doing anything with that but for the

1018:43

animation we are only creating our

1018:45

variance right here and which is just

1018:47

simply a front and also the back so

1018:50

whenever we are using the front side we

1018:52

just only want to rotate the Y AIS to

1018:54

zero and whenever we are using the back

1018:56

side so you want to rotate that on the

1018:59

180° so if I click on there here you can

1019:01

see we just flipping our card that's as

1019:04

simple as that I know this is simple but

1019:06

yeah uh that's cool uh these aren't

1019:09

looking that great so I'm going to cut

1019:11

that from here and I'll just Define my

1019:13

variance right here at the top so I'll

1019:15

give it the name of like card variants

1019:17

it's going to be equals to these

1019:19

variants right here I'm going to copy

1019:20

the name of these card variant

1019:22

and provide the reference of there right

1019:24

here so still we're getting our flipping

1019:26

card which is looking amazing let's talk

1019:28

about one of your favorite topic and I

1019:30

know you're going to love this one I can

1019:33

totally guarantee that what am I talking

1019:35

about I talking about the gesture

1019:36

animation so what are they and why you

1019:38

should even care about that gestures

1019:40

allow you to add interactive animation

1019:42

based on the user action like dragging

1019:44

or Hing or tapping makes our component

1019:47

responsive to how user interact with

1019:49

them so that's just a theory of what a

1019:51

just animations is and in this section

1019:54

we're going to be learning about the

1019:55

dragging hoing and also the tapping only

1019:58

use frame or motion but there is

1020:00

something wrong with this code and I

1020:01

want you to pause the video and answer

1020:03

me what's wrong with this code and you

1020:06

guessed it the answer is obviously we're

1020:08

going to have to import uh what do we

1020:10

call it not the create function but

1020:11

we're going to have to import the motion

1020:13

function or object from where from the

1020:15

not Z but from the frame or motion I'm

1020:18

currently working on the zeen course so

1020:20

that's why I'm like importing every

1020:21

single thing from The Zo anyways let's

1020:24

talk about the what do we call the G

1020:26

animation in the framer motion so the

1020:28

first thing we are going to be learning

1020:29

is something called the while how and

1020:31

you guys already guessed it we going to

1020:33

be working with the Hing animation so

1020:36

you know what first of all we have to

1020:37

Define our motion. div and inside this

1020:39

motion. div you know what we're going to

1020:41

have to remove there and close it like

1020:43

so okay so inside there we're going to

1020:46

be providing a class of box so it's

1020:48

going to gives us that Circle right here

1020:49

which is looking amazing and now we we

1020:51

have to provide our animation so let's

1020:53

talk about the while how animation Cas

1020:56

all used like while how in this property

1020:58

or prop allows us to provide our

1021:00

animation whenever somebody H over our

1021:03

element okay so I'll just proide like

1021:05

let's suppose if I want to increase the

1021:06

scaling of there so I'm going to

1021:07

increase the scaling of there to like

1021:09

1.2 and I'm going to also rotate this so

1021:11

for the rotation I'm going to set there

1021:13

to 10 I'm going to also go ahead and go

1021:14

to my index. CSS file and comment this

1021:17

line out and now if I H over there it's

1021:19

going to first of all increase the

1021:20

scaling to 1.5 five and it's going to

1021:22

also rotate there to 10° let me just H

1021:25

over there once again and we're not only

1021:27

limited to just proide there we can do a

1021:29

lots of crazy stuff with there but you

1021:31

know what let me just put a transition

1021:33

okay so for the transition I'm going to

1021:34

use some different uh things like the

1021:37

type will be set to Spring and also

1021:39

stiffness will be set to 300 now I know

1021:42

a lot of you will ask me bzen what the

1021:44

hell is this type and what the hell is

1021:46

this stiffness you don't have to worry

1021:48

about that let me just say that once

1021:50

again you don't have to worry about that

1021:52

if you want to go to the physics

1021:53

animation you can definitely check out

1021:55

like what is a spring animation and what

1021:57

is a stiffness and all of that but

1021:58

basically I using both of them right now

1022:01

because it's going to make my animation

1022:03

super smooth and if you want me to make

1022:06

a separate video about what do we call a

1022:08

physics animation I can totally do that

1022:10

but I guess I know a lot of people will

1022:12

not be interested in there because they

1022:14

are super difficult to work with so you

1022:17

know what let me just how over there and

1022:18

here you can see it's going to gives us

1022:20

kind of a bouncy like a spring effect

1022:22

and do you guys even know what a spring

1022:24

is I'm talking about the actual spring

1022:27

like a spring sp sp r n you know let me

1022:30

just type there right here like s SP r i

1022:32

n I'm talking about that spring so if I

1022:35

H my mouse over today it's going to just

1022:37

bounce it back if I comment this line

1022:39

out save my file and H my mouse over

1022:41

today it's not going to gives us that

1022:43

kind of a spring animation but now if I

1022:46

just uncomment there and how my mouse

1022:47

over today it's going to give this kind

1022:49

of a springy animation right here and

1022:51

then coming from this type of spring and

1022:54

also this is something called the

1022:55

physics animation so yeah this is how we

1022:57

are going to be working with the wild

1022:59

how whenever somebody H over there so we

1023:01

want to just make this styling right

1023:03

here or provide this animation so that's

1023:05

the while H I'm going to remove that

1023:07

from here and the next one is also

1023:08

totally self-explanatory so we are going

1023:10

to be using the while tab whenever

1023:12

somebody clicks on there so this this is

1023:16

also super simple and easy to work with

1023:17

so we're going to be creating our D once

1023:19

again and here we have to Define our box

1023:22

first of all so that we can see

1023:23

something and whenever somebody tap

1023:26

there so we're going to be using like

1023:27

while T okay so whenever somebody tab

1023:30

there in this situation we once again

1023:32

want to increase the scaling of there so

1023:34

I'm going to just uh convert it to like

1023:36

0.8 and I'm going to also change the

1023:38

background color to totally I don't know

1023:40

maybe uh Crimson would be fine so now if

1023:43

I save my file and now if I have my

1023:45

mouse over to there you know let me just

1023:46

refresh there if I hold my mouse over to

1023:49

there nothing will happen but if I click

1023:51

on there it's going to first of all

1023:53

decrease the scaling and it's going to

1023:54

also change the background color to

1023:56

Crimson okay and we can also provide the

1023:59

transition once again and for the

1024:01

transition I'm going to provide like the

1024:02

type of spring and I will also provide

1024:04

the stiffness and set there to 300 okay

1024:07

and you know let me just refresh there

1024:09

once again and if I click on there we

1024:11

are now getting That Bouncy effect that

1024:13

spring effect okay that's amazing yeah

1024:16

and now finally once again finally let's

1024:20

talk about one of your favorite one

1024:22

which is called the wild rag I know a

1024:24

lot of people were waiting for this one

1024:26

so I want to show you that as quickly as

1024:29

possible so let's talk about it now I'm

1024:31

going to also put the class name of box

1024:33

and now if you want to make this element

1024:35

dragable so we don't have do nothing we

1024:37

just have to provide drag that's it so

1024:40

if we just specify this drag I can

1024:42

totally drag this uh element to whatever

1024:44

I want so here you can see this is

1024:46

totally dragable and if I just leave

1024:49

there it will remove it from from the UI

1024:52

if I go ahead and check it out you know

1024:54

what that's super gone so we can just

1024:57

only R then we can leave it wherever we

1024:59

want but this is not something that we

1025:01

want we want to provide some sort of a

1025:02

boundaries today we can totally provide

1025:05

the boundaries if you wanted to but now

1025:07

we can also make it as a XX is dragable

1025:10

so if I just write like X right here sa

1025:12

my file and here you can see if I click

1025:14

on the and put the on the top I'm no

1025:17

longer able to move there or drag there

1025:19

on the Y AIS it's going to only work on

1025:22

the xaxis right here I guess you can see

1025:25

the but here you can see I'm trying to

1025:26

drag that on the top but it will not let

1025:29

me because here I'm now specifying this

1025:32

x property which means like we only want

1025:34

to drag the on the x-axis okay so let's

1025:37

just try that once

1025:39

again let's remove this it's going to

1025:41

hide it from the viewport and we're

1025:43

going to have to refresh our page to get

1025:45

it back so that was just a drag and now

1025:48

let's talk about the constraint in some

1025:50

situation but not in some situation but

1025:52

in a lot of cases we would want this

1025:54

element to only be dragable in certain

1025:56

area like maybe we only want it to be

1025:59

dragable in this area in this area not

1026:02

more than that okay or maybe we want it

1026:05

to just like be dragable on this area or

1026:08

maybe smaller one so how can we provide

1026:10

our constraint or our rules for there so

1026:12

to provide there we have yet another

1026:14

property which is called or prop which

1026:16

is called a rate constraint okay so we

1026:18

can now specify our different constraint

1026:20

today so I'll just put Pro like that on

1026:22

the top it's going to be set to 50 and

1026:24

we can also P like on the left it's

1026:26

going to be set to 50 on the right it's

1026:28

going to be set to positive 50 and on

1026:30

the bottom it's going to be also set to

1026:32

positive 50 so now if I sve my file here

1026:35

you can see it's going to gives us that

1026:36

constraint right here if I try to drag

1026:39

there here you can see it will make it

1026:40

drag but if I leave there it's going to

1026:42

put it back okay let me just try there

1026:45

once again here you can see it's not

1026:46

going to be dragable like anywhere and

1026:48

it's going to push it right here back

1026:50

okay so this is this is how we going to

1026:52

be making our element totally dragable

1026:54

and this is how we going to be providing

1026:55

a constraints for the you can definitely

1026:58

try the by yourself and it's going to be

1027:00

a lot of fun okay so time for the demo

1027:02

one I'm going to create a folder with

1027:04

the name of components and then animated

1027:07

card. TSX let's just use our rafc inside

1027:11

there and register my component right

1027:14

not animated presence God damn it

1027:17

animated card and create my component

1027:20

and remove that one here you can see we

1027:23

are now getting our animated card which

1027:24

is looking super awesome all righty so

1027:27

let's talk about it the first thing that

1027:29

I want to do is I want to remove the and

1027:31

put a bit of classes to this one like

1027:33

maximum width will be set to small

1027:35

margin on the x-axis will be set to AO

1027:38

background totally white rounded uh

1027:41

totally large and Shadow large over flow

1027:46

will be set to hiden and cursor will be

1027:48

set to pointer go back cursor will be

1027:50

set to pointer like so say our file

1027:53

inside there we're going to be rendering

1027:54

our image but first of all we have to uh

1027:58

you know let me just provide a bit of

1027:59

alternative text for like card image or

1028:01

something like that I just copy this

1028:03

image from the unsplash.com you can

1028:05

definitely go ahead and go to my beh

1028:06

have repository and only grab this image

1028:08

from there I'm going to also provide a

1028:10

bit of classes to this like with will be

1028:11

set to totally full height will be set

1028:13

to 48 and object totally cover like so

1028:18

okay so here you can see this is how my

1028:19

image looks like and now underneath this

1028:20

image what do you want to do you just

1028:22

want to create word d with the class of

1028:23

pairing for the xx6 will be set to uh

1028:26

six and also you want to proide our H2

1028:29

and text will be set to extra large P

1028:30

will be set to semi B and margin for the

1028:33

bottom will be set to two and and for

1028:36

the title I'll just put like C title or

1028:39

my you know what that's going to be fine

1028:41

I'm not going to waste your time on the

1028:42

UI let's just create our paragraph with

1028:45

the classes of T will be set to totally

1028:47

gray of 700 God 700 and also margin for

1028:50

the bottom will be set to four and here

1028:52

I'm going to just write like this is a

1028:54

simple card um with framer motion

1028:59

animations and tail come on tail CS come

1029:03

on tail CSS for styling and react

1029:09

craziness or something like that I guess

1029:11

that's going to be fine this St for The

1029:12

Styling would be fine so if I save this

1029:15

here you can see we now getting this um

1029:16

body and now underneath we're going to

1029:18

be also creating a button and which will

1029:20

select learn more I know the button is

1029:23

not looking great so we're going to have

1029:25

to provide a bit of styling to there

1029:26

like pairing for the xaxis will be set

1029:27

to four pairing for the y axis will be

1029:29

set to two background will be set to

1029:31

here 400 or you know 500 would be fine

1029:34

text will be set to Ho white and also

1029:37

rounded uh when somebody have this we

1029:39

just want to change the background color

1029:40

to like uh teal I know maybe this color

1029:44

and also provide our transitions today

1029:46

okay so let's just part our transition

1029:48

so now let me just save my file if I H

1029:50

my mouse over to there so yeah this is

1029:52

how we are getting this kind of a crazy

1029:54

card right here so now it's time to

1029:55

animate there so to animate there you

1029:57

guessed it we're going to need something

1029:59

called the motion uh from where

1030:02

from the framer motion like so next I'm

1030:06

going to convert this div to the motion.

1030:09

div I'll go to the bottom and here we

1030:12

have to change the to motion. div okay

1030:14

like so now I'm going to go ahead and go

1030:16

to the top ones again and provide my

1030:18

animations right here the first thing

1030:20

that I want to do is that to provide my

1030:22

initial State let's just zoom in a bit

1030:24

okay so for the initial state I'm going

1030:25

to provide the scaling and scale will be

1030:26

set to one and rotate will be set to

1030:29

zero okay just a zero God damn it so

1030:32

that's going to be my initial St when

1030:34

somebody how over there so in that

1030:36

situation we want to just increase the

1030:37

size of that like 1.05 and also you want

1030:40

to rotate it down to three okay and now

1030:43

underneath that when somebody try to tap

1030:46

there or try to click on there so in

1030:49

that situation we're going to be scaling

1030:51

it down so I'll just use like scale of

1030:54

0.95 now underneath that we also want to

1030:56

make it totally dragable you know let me

1030:58

just save this file and check this out

1031:00

so yeah that's totally cool I also want

1031:02

to make it dragable so I'm going to

1031:04

write like drag it's going to be

1031:06

dragable totally dynamically I'm going

1031:08

to also provide the drag constraints and

1031:10

for the drag constraints we're going to

1031:11

be providing a left and left will be set

1031:13

to minus 50 and I also want to provide

1031:16

the right and right will be set to

1031:17

positive 50 and on the top we're going

1031:20

to be providing my - 50 and on the

1031:22

bottom let's just put 50 right here okay

1031:26

and we also have yet another property

1031:28

which is called the drag elastic you

1031:29

don't have to worry about that but

1031:31

basically it's going to make just or

1031:32

dragable more elastic so if you care

1031:34

about that you don't even have to worry

1031:36

about that but yeah this property is

1031:37

also available if you care about that so

1031:39

I'm going to only specify like 0.2 and

1031:42

now if I just drag there it's going to

1031:44

make it a bit elastic right here okay as

1031:46

you can see you know I'm going to show

1031:47

you that in a few second now I'm going

1031:49

to also proide the transitions and the

1031:51

transition will be set to the type will

1031:54

be set to spring because I want my

1031:57

spring animation and the stiffness will

1031:58

be set to 300 like so so let me just

1032:01

make that a bit bigger and this is how

1032:03

my card looks like right here so if I

1032:05

hold my mouse over today it's going to

1032:07

make it a bit tilt now if I click on

1032:09

there it's going to change the scaling

1032:10

of there and yeah this is how it looks

1032:13

like right here I can totally drag it if

1032:15

I wanted to and that's going to be

1032:17

amazing card for your upcoming portfolio

1032:21

yeah yeah that was cool okay so you know

1032:23

what let me just give you one more

1032:24

example which will be the animated image

1032:27

gallery so I'll just create like image

1032:28

gallery. TSX right here and create my

1032:31

rafc go to my app comment this line out

1032:35

and render my image gallery there we go

1032:38

semi file and here you can see we're now

1032:40

getting our image gallery which is

1032:41

looking cool let's go to our image

1032:43

gallery and take care of there the first

1032:46

thing that we would need is the motion

1032:48

object so we're going to be importing

1032:49

the motion from where from the frame or

1032:51

motion like so and also we are going to

1032:54

need some sort of images so here I'm

1032:56

going to place these images right here

1032:57

so we have array with the name of images

1032:59

and inside there we have a few objects

1033:01

so each object will have the image and

1033:03

also the caption you can totally

1033:05

definitely modify there if you wanted to

1033:07

but yeah we have a few images right here

1033:09

and if you care about these images you

1033:11

can totally find them in my gab

1033:13

repository so that's done next I'm going

1033:16

to just remove that from here and I'm

1033:18

going to provide a bit of uh width to

1033:20

this so like with be set to 80% and

1033:22

that's going to be set to flex so inside

1033:24

this T I'm going to itate over through

1033:26

all of that images so I'll use like

1033:27

images uh what the hell did I just copy

1033:30

the images place it right here and let's

1033:32

just itate over through there by using

1033:34

the map method and we're going to need

1033:36

the image and also the index right here

1033:39

so now inside there we are going to be

1033:41

defining our div so what the hell let's

1033:44

just Define your div totally manually

1033:46

like so I'm going to also close there

1033:48

and for this D we going to providing the

1033:49

key and the key will be there index

1033:51

which we are now getting for each of the

1033:53

image we're going to be also providing a

1033:55

bit of classes today so I'll use like

1033:57

relative margin will be set to one Rim

1033:59

all around and overflow will be set to

1034:02

Hidden and rounded totally large Shadow

1034:05

will also be set to large and yeah

1034:08

that's going to be fine now inside this

1034:10

D what do we have to do we have to

1034:11

render our image so if I just use the

1034:13

image tag and here we only have to use

1034:16

like image and then SRC which is coming

1034:19

from this image right here and then this

1034:21

image is including all of that image and

1034:23

we are only interested in this SRC like

1034:25

the source of our image okay so it's

1034:27

going to render our image I'm going to

1034:28

also Prov a bit of caption right here so

1034:30

I'll use like uh image. captions I'm

1034:33

going to just render there like so and

1034:35

here I'll also provide a class name of

1034:37

with will be set to totally full and the

1034:39

height will be also set to Auto and here

1034:41

you can see this is how they looks like

1034:43

I know they are not looking that better

1034:45

but we are going to make it a bit better

1034:47

in a few seconds so you know what let's

1034:49

just create here another diff inside

1034:51

this div we're going to be providing a

1034:53

lot of styling so I'll just use like

1034:55

absolute come on AB b s o l t e this one

1034:59

is relative so now this div is absolute

1035:02

to this relative div which means like

1035:04

this div will be inside this div right

1035:07

here but no matter what happen this div

1035:10

will be inside this div no matter how

1035:12

much height we provide or no matter how

1035:14

much with we provide this div will be

1035:17

inside this relative div okay so that's

1035:19

why we are now providing the proper of

1035:21

absolute today let's just our insert

1035:23

will be now set to zero f and items will

1035:25

be set to Center and justify will be set

1035:28

to Center and background will be set

1035:30

black uh black like so background

1035:33

opacity

1035:34

opsy opacity will be set to 50 and

1035:39

provide a text only white opacity will

1035:42

be set to zero and somebody how over

1035:45

this we're going to be changing the

1035:46

opacity to 100 and we also have to

1035:48

provide the transition for the opacity

1035:51

and duration will be set to 300 like so

1035:54

the cursor will also be set to pointer

1035:57

and now inside there we only have to

1035:58

render or paragraph and this paragraph

1036:00

will say like we only want the image.

1036:03

caption like so okay close them import

1036:06

the class of text only l s file check

1036:09

this out so if I have my mouse over

1036:11

today it's going to gives us that

1036:12

transition and that bit animation but

1036:14

now we have to use our frame and motion

1036:16

to add there okay so I'm going to go

1036:18

ahead and uh attach my frame and motion

1036:20

right here

1036:21

okay so let's just first of all start

1036:23

from this one I'm going to make it as a

1036:24

motion. div and I'm going to also make

1036:28

this one motion. div right here and when

1036:31

somebody how over there so I'll just use

1036:33

like while how and when somebody how

1036:36

over there so we just want to change the

1036:37

scaling so I'll write like scale will be

1036:39

set to

1036:40

1.05 and so now let me just H over there

1036:43

it's going to change the scaling right

1036:45

here okay so they are looking better and

1036:47

when somebody H over this D I'm going to

1036:49

just change the opacity of this I'll use

1036:51

like while how come on while how h o r

1036:55

like so I'm going to provide the opacity

1036:58

and set there to one and I'm not getting

1037:01

suggestions because we have to convert

1037:03

this one to motion. D and also convert

1037:06

this one to motion. div like so this one

1037:10

if I save my file and here you can see

1037:12

if I H my mouse over today so it's going

1037:14

to make the opacity to one I want to

1037:16

make them on a center so I'm going to go

1037:17

ahead and go to my app and on this app

1037:19

I'm going to provide the CL class so the

1037:21

minimum height will be set to screen and

1037:24

background will be set to gray of 100

1037:27

black items uh will be set to toly

1037:29

Center just ay will be set to Center

1037:32

semi file check this out so yeah they

1037:35

are looking cool yep I can totally

1037:36

remove the background if I wanted to

1037:39

yeah they're looking cool now we are

1037:40

going to be combining variants with

1037:42

gesture animation so to do that we're

1037:45

going to be creating our animated ship.

1037:46

TSX file and I'm going to be using my

1037:48

RFC go to my not index but M component

1037:52

and Define my animated

1037:55

ship come on let's just put our animated

1037:57

ship right here and close there s our

1037:59

file and here you can see we're now

1038:01

getting our animated shape which is

1038:02

looking cool and the first thing that

1038:04

you want to do is that you want to

1038:05

import the motion from where from the

1038:08

frame or motion like so now we have to

1038:10

Define our variance I'll use like cons

1038:12

boox variance it's going to be equals to

1038:14

this object right here so we have to

1038:16

Define three states so the first state

1038:18

will be the initial State i n i t l and

1038:22

now I'm going to provide a comma and

1038:23

duplicate that three times we're going

1038:25

to be also providing the how Strate and

1038:27

also the click okay so these are going

1038:30

to be my state and now let's talk about

1038:31

the initial State for the initial State

1038:33

we're going to be providing a scale of

1038:35

one and the rotation of zero and I'm

1038:38

going to also put the SK and skew will

1038:39

be set to zero okay so when somebody try

1038:41

to H over there we're going to be

1038:43

changing the scale let's just right a

1038:45

scale to 1.2 and we're going to be also

1038:48

providing the rotation to 15° and the Q

1038:51

will be also SK will be also set to 10°

1038:55

okay and provide the transitions

1038:58

transition will be set to duration of

1039:01

0.3 seconds okay so when somebody have

1039:04

over there and now let's take care of

1039:05

the final state which is a click state

1039:07

so when somebody clicks on there we're

1039:09

going to be changing the scale to 0.9

1039:12

and also the rotation will be set to

1039:13

minus 50° and the transition the

1039:17

transition will take this duration and

1039:20

duration will be set to 0.3 and where in

1039:22

the world is this error coming from we

1039:24

have to specify there okay so this is

1039:27

how we going to be defining or variant

1039:30

box or box variant or shape variant

1039:33

whatever you want to call that I'm going

1039:34

to comment or hide there let's just go

1039:37

ahead and go to our UI and zoom in a bit

1039:39

and the first thing that we have to do

1039:40

is that we have to provide a bit of

1039:41

classes today just going to be set to

1039:43

flex and also items will be set to

1039:45

Center and justify will also be set to

1039:47

Center and height will be set to totally

1039:49

screen okay inside this div we have to

1039:52

Define our motion. div okay and I'm

1039:54

going to close that and now we have to

1039:56

provide a bit of styling to this one

1039:58

like with will be set to 40 and height

1040:00

will also be set to 40 and background

1040:02

will be set to totally blue or 500

1040:05

rounded totally large and here you can

1040:07

see we are now getting our box which is

1040:09

cool so next we have to provide our

1040:11

variants or our animations so I'll just

1040:13

use like variants and now here I'm going

1040:16

to copy the name of this box variant and

1040:18

put them as a reference right here okay

1040:20

so let's just say our file and now we

1040:22

are going to be using those variant so

1040:23

I'll just put the initial State and for

1040:25

the initial State we are going to be

1040:27

using this initial state right here

1040:29

which we already Define inside our box

1040:31

variant which means like scaling will be

1040:33

set to one the rotation will be zero and

1040:35

also the ski will be zero and next we

1040:37

also have to specify when somebody how

1040:39

over there so in this situation we want

1040:41

to use over how right here okay so we

1040:44

already defined there the scaling will

1040:46

be set to 1.2 the rotation will be 15°

1040:49

skiing will be set to 10° in transition

1040:52

t r n s i t o in transition will be set

1040:55

to duration uh 0.3 okay we also have to

1040:59

specify when somebody tap on there so

1041:02

we're going to be using this click

1041:03

animation which we' have already

1041:04

specified right here like scaling will

1041:06

be set to 0.9 rotation will be minus 50

1041:09

transition will be uh 0.3 so if I hold

1041:12

my mouse over today so it's going to

1041:14

change the shape of there but now if I

1041:16

click on there it's going to also change

1041:17

the shape of this one you can also make

1041:19

it totally drag we can do a lot sort of

1041:21

stuff with there like whenever somebody

1041:23

have over there so we can totally change

1041:25

the color or whenever we drag there so

1041:27

we can also change the color and so on

1041:29

and so forth but now the reason for this

1041:31

example is that we can totally mix the

1041:34

what do we call it the variant gesture

1041:36

animations now let's quickly talk about

1041:38

something called the Stagger animation

1041:40

in stagger animation refer to a

1041:42

technique where multiple elements

1041:43

animate in a sequence rather than all at

1041:46

once and this creates a more Dynamic and

1041:48

Visually appealing effect as each

1041:50

element appear or move slightly after

1041:53

the previous one adding a sense of

1041:54

Rhythm and Float to the animation so

1041:56

that's just a quick definition of what a

1041:57

stagger animations are and now let's get

1041:59

into the coding examples and then you'll

1042:01

get to know what I'm talking about now

1042:03

to work with the Stagger animation I'm

1042:04

going to create a folder with the name

1042:06

of components and Define my Stager

1042:08

animation. TSX file inside there okay so

1042:11

let's just our file and register my

1042:13

stagger animation component right here

1042:16

okay so here you can see we're now

1042:17

getting what ster animation which is

1042:19

looking cool okay I'm going to also go

1042:21

ahead and go to my index. CSS and remove

1042:24

this Flex from there and here you can

1042:26

see it's going to make it at a center

1042:28

the first thing that I want to do is I

1042:29

want to remove that ster animation and

1042:31

grab my motion uh from where from the

1042:35

frame or motion like so now inside there

1042:38

what do you want to do you just want to

1042:40

get like five array elements all use

1042:42

like array and here we have to specify

1042:44

five inside there and I'm going to it

1042:46

right over through all of this so I'll

1042:48

just use like map method and inside this

1042:50

this one we don't need the data we only

1042:52

need the index okay so inside there

1042:55

we're going to be creating our D once

1042:56

again so let's just create them manually

1042:58

and I'm going to duplicate there and

1043:00

close there like so okay so for this D

1043:03

I'm going to provide a class name of box

1043:04

and margin for the top will be set to to

1043:07

rim s our file and this is how it looks

1043:11

like right here and for this demo I'm

1043:13

going to go ahead and go to my index.

1043:14

CSS and remove every single thing from

1043:16

there and provide this new CSS right

1043:19

here so once again we have all of their

1043:21

previous code but now in this situation

1043:23

we are just providing a bit more styling

1043:25

to this box so width will be set to 150

1043:28

height will be set to 150 and Border

1043:29

radius will be set to 50% we changing

1043:32

the background color and and also

1043:33

providing a bit of blur filter today and

1043:36

we are also adding a box Shadow the

1043:38

background color will be set to totally

1043:40

yellow and then we are just centering

1043:41

out every single thing uh so that's just

1043:43

the styling that you have to specify for

1043:45

this box and now let's get into it now

1043:47

this is how everything looks like but

1043:48

I'm going to also provide the key and

1043:49

the key will we set to index and here we

1043:52

have to specify our variant so to do

1043:54

that first of all we have to create the

1043:56

parent variant and then we're going to

1043:58

be creating the child variant okay so

1044:00

what I'm going to do is that I'm going

1044:01

to create my parent variant and parent

1044:03

variants will have the hidden property

1044:05

and inside this here we have to specify

1044:07

the opacity and opacity will be set to

1044:09

zero we also have to provide the visible

1044:12

and visible will be set to the opacity

1044:14

on the visible opacity will be set to

1044:16

one and the transition come on let's

1044:19

just SP our transition and for this

1044:21

transition we have a stagger children

1044:23

property s a g e r and then children and

1044:27

basically this property will allows us

1044:28

to provide a delay between each element

1044:31

okay so if I just write like 0.8 okay so

1044:34

it's going to add that delay to each

1044:36

element that we now animating right here

1044:38

you're going to see that in a few

1044:39

seconds but this is going to be

1044:41

basically my parent variance now we have

1044:43

to define the child variance so I'll

1044:45

just use like uh child variance and it's

1044:47

going to be an object we have to specify

1044:49

the hidden leg and here the opacity will

1044:52

be set to zero and the y- AIS will be

1044:54

set to 20 okay so let's just duplicate

1044:56

there and change there to visible and

1044:58

the opacity will be set to one and the y

1045:01

axis will be set to just zero okay so

1045:03

now that we successfully Define the

1045:05

parent variant and also the child

1045:07

variant and now we have to use the

1045:09

inside vares so to use that the first

1045:11

thing that we have to do is that we have

1045:12

to convert that to the motion. div okay

1045:16

so I'm going to just convert that to the

1045:17

motion. div and next we have to or

1045:20

variant right here and not this one but

1045:23

the variant like so I'm going to go

1045:25

ahead and go to the top and copy the

1045:27

name of the parent variant and proide

1045:29

there right here and let's just use

1045:31

there so for the initial flag we're

1045:33

going to be using the hiden from the

1045:35

parent variant okay and whenever we want

1045:37

to animate this so for the animation

1045:39

we're going to be using this visible so

1045:41

just proide like visible like like so

1045:44

same my file so this is how it looks

1045:45

like and I'm going to also use where is

1045:48

the the child variant inside this div so

1045:52

which means like we have to convert it

1045:53

to the motion div so I'll just or you

1045:55

know I'm going to remove this one and

1045:58

close there as a self closing tag and

1046:01

make that as a motion. d like so say my

1046:04

file now here inside there we have to

1046:06

specify our variance and for the

1046:08

variance it's going to take the child

1046:10

variance so now let me just save my file

1046:12

so these are all of the codes so if I

1046:14

just refresh there nothing is happening

1046:15

and I realize the spelling is incorrect

1046:18

so we have to provide the tager children

1046:21

okay so now if I just refresh there here

1046:23

you can see it's going to gives us first

1046:24

of all the first one then the second and

1046:26

so on and so forth and it's going to

1046:28

provide their delay right here so we are

1046:29

now just delaying each element before

1046:32

the other one comes up so let's just

1046:34

refresh there once again 1 2 three and

1046:37

so on and so forth so yeah this is the

1046:39

basics oftware stagger animation we can

1046:42

achieve them by only using the Stagger

1046:44

children property okay so that was the

1046:47

demo one now let me also show you the

1046:49

demo two this one will be a bit

1046:51

complicated because we're going to be

1046:52

creating our animated Gallery so I'll

1046:54

just use like rafc inside this save my

1046:57

file comment this line out and here I'm

1047:00

going to be using my animated Gallery

1047:02

right here close my file or close my

1047:05

component to be precise and yeah

1047:07

everything is looking great now the

1047:08

first thing that I want to do is that I

1047:10

want to grab my motion so use like

1047:12

motion from where from the primer motion

1047:15

that's going to be the first thing next

1047:16

we have to Define our stair so I'll just

1047:18

create like show images and set show

1047:20

images it's going to be equals to the

1047:22

UST and here we have to set the to fals

1047:25

now let me go ahead and go to the UI and

1047:27

take care of this UI right here so first

1047:29

of all we're going to be creating a

1047:30

button which will say like uh I don't

1047:32

know show images or hide images we're

1047:35

going to be taking care of the button in

1047:36

a few seconds but yeah or you know what

1047:38

let me just take care of that right here

1047:40

this I'll just use like if we have the

1047:43

show images like this St so in this

1047:46

situation what do you want to do we just

1047:47

want to provide like uh hide image or

1047:50

images rather but if that's not the case

1047:53

we're going to be providing this level

1047:54

which is a show images right here so if

1047:56

I save that and refresh there so here

1047:58

you can see we're now getting our show

1048:00

images we cannot click on that because

1048:02

first of all we have to attach the event

1048:03

handler so I'm going to be using like on

1048:05

click Handler and when somebody click on

1048:08

that we're going to be fing this uh

1048:10

handle click function okay so let's just

1048:12

create tab right here I'm going to be

1048:13

using like con handle click event

1048:16

handler and inside there we're going to

1048:18

be firing like set show Imes come on set

1048:21

show images and provide the previous St

1048:25

and not previous St right here okay not

1048:27

just a previous St now if I save there

1048:30

and click on the show images it's going

1048:31

to change there to the High images right

1048:33

here which is cool so then done I'm

1048:36

going to also provide a bit of styling

1048:37

to this so I'll use like classes and

1048:39

margin for the bottom will be set to uh

1048:41

Two Rim I'm going to also provide ping

1048:43

all around will be set to four rounded

1048:46

toly large background yellow uh 300 will

1048:49

be fine this will be set to totally

1048:52

black and font will be set to bold so

1048:54

our file and yeah that's looking cool

1048:56

you know I'm going to make the a bit

1048:58

bigger and that's totally fine here you

1049:00

can see we are now getting our button

1049:02

and we are also getting our coding right

1049:03

here so now underneath this button what

1049:05

you want to do we just want to create

1049:07

our D in this de we'll have the class

1049:09

name of flex okay and we're going to be

1049:12

attaching a lot more stuff in there but

1049:13

now let's just it right over through all

1049:15

of our images so I'm going to go ahead

1049:16

and go to the top and provide my images

1049:19

right here okay so these are the images

1049:21

that I copied from the unsplash.com if

1049:23

you want to copy this exactly the same

1049:25

images like mine you can definitely go

1049:27

ahead and go to my gab repository and

1049:29

copy all of the images from there but if

1049:31

you want to choose your own you are more

1049:33

than welcome to do that so I'm going to

1049:34

go ahead and go back and now we have to

1049:36

R over through all of the images so I'll

1049:38

use like um Gallery images and I'm going

1049:42

to use like map method here we have to

1049:44

specify the image and also the index of

1049:46

the image and inside there what do you

1049:48

have to do we have to WR our image and

1049:51

this image will take the SRC you know

1049:53

let's just write them manually oh we

1049:55

can't we have to write there like so

1049:57

it's going to take the source and it's

1049:59

going to also take the alternative text

1050:01

and I'm going to close there like so so

1050:03

for the source what do you have to do

1050:05

you have to just provide our image and

1050:06

for the alternative text I'm going to

1050:08

write like I don't know Gallery uh image

1050:11

and let's just provide our index + one

1050:14

to there that's looking cool I'm going

1050:16

to also provide a bit of styling to this

1050:18

so I'll just use like class name what

1050:20

the hell is that I'll use like class

1050:22

name and class name will be set to

1050:23

margin for the left of Two Rim and width

1050:26

will be set to 300 pixel like so and

1050:29

totally rounded so now if I sa my file

1050:31

and here you can see we are now getting

1050:33

these images they are looking cool if I

1050:35

click on there nothing will happen now

1050:38

finally it's time to add our animation

1050:39

today so I'll just go ahead and create

1050:42

my variance right here like so so I'll

1050:45

just first of all Define my parent

1050:47

variant and then my children variant par

1050:50

R variance it's going to be an object we

1050:53

have to specify the hidden property and

1050:55

the opacity uh opacity will be set to

1050:58

zero now underneath that we also have to

1051:01

specify the visible when it's visible so

1051:04

we have to provide the opacity of one

1051:05

today and also we have to provide a

1051:08

transition and for this transition we're

1051:10

going to be using a Stager animation so

1051:13

we have to use our stagger children come

1051:15

on s d a g r stagger children and

1051:18

stagger children which means like this

1051:19

going to take 0.5 second for each

1051:22

element and now I'm going to also

1051:23

introduce another one which is a stagger

1051:25

s g stagger Direction and Stager

1051:28

direction will be set to one which

1051:29

simply means like forward the Stager

1051:31

when it's showing okay so I'll just save

1051:33

my file that's the parent variant now we

1051:36

have to define the child variant so I'll

1051:38

just go ahead and Define my child

1051:40

variant and now inside there we have to

1051:42

specify the hidden flag opacity will be

1051:44

set to zero and the y- AIS will be set

1051:46

to 20 okay so I'll just duplicate that

1051:49

change the to visible and the opacity

1051:51

will be set to one and the Y AIS will be

1051:54

set to zero and first of all I'm going

1051:55

to just change that to the motion Dev so

1051:58

I'll provide like motion. div and also

1052:01

provide my motion m o t o n motion. div

1052:05

like so and here we have to use our

1052:07

variance so I'll just write like

1052:09

variance and for the variant we're going

1052:11

to be using our parent variant and let's

1052:14

just use there like for the initial prop

1052:15

we're going to be using our hidden and

1052:18

when it is animating here we have to use

1052:20

our tary operator so I'm going using

1052:22

like if we have the show images in that

1052:24

situation we want to make the as a

1052:26

visible v s i b e but if that's not the

1052:29

case we just want to set there to Hidden

1052:31

like so okay that's to done let me show

1052:34

you there if I click on there here

1052:36

that's going to happen but that's going

1052:38

to happen very quickly let me click on

1052:40

that once again and bang it's going to

1052:42

take their time but it's going to show

1052:44

it totally instantly so to prevent that

1052:46

from happening I'm going to also convert

1052:48

this image to the motion

1052:50

div and here we also have to specify our

1052:53

variants right here I'm going to be

1052:55

using like variants and for this variant

1052:58

we're going to be providing our child

1052:59

variants now if I refresh there and

1053:01

click on the show images it's going to

1053:03

show all of them one by one now if I

1053:05

want to hide there click on there once

1053:07

again and bang there an amazing

1053:10

animation let me just click on there Yep

1053:13

this is how we are going to be getting

1053:14

our animated Gallery this is how we are

1053:16

going to be making it disappear so we

1053:19

don't have to write a lot of code but we

1053:20

only have to first of all Define or

1053:22

state or variance whatever you want to

1053:25

call them and then we have to use the

1053:27

inside word Dev okay as simple as that

1053:31

welcome to the second part of this

1053:32

course so this is going to be basically

1053:34

the intermediate part of the framewor

1053:35

motion and in this section we're going

1053:37

to be covering the hooks inside the

1053:39

frame or motion Library so let's talk

1053:41

about the first hook which is called the

1053:42

Ed motion value hook so the use motion

1053:45

value hook enable find control over the

1053:47

animation allowing us to trigger

1053:48

animation program ically based on the

1053:51

component state or events it allows for

1053:53

the integration of more complex

1053:54

animation logic that goes beyond what's

1053:56

achievable with just Pro on the motion

1053:58

component like we just saw the animate

1054:00

prop the variant prop and so on and so

1054:02

forth so now the use motion value hook

1054:05

will allows us to create something

1054:07

called the motion value I'm going to

1054:09

show you what a motion value is in a few

1054:11

seconds but yeah let's just go ahead and

1054:13

go to the cording so before we talk

1054:15

about the use motion value hook first of

1054:17

all we have to talk about something

1054:18

called the motion and value in general

1054:21

so the first thing that I want to do is

1054:22

that I want to import the motion from

1054:24

the frer motion and also I want to make

1054:27

this div as a motion div okay so I'll

1054:30

just write like motion. div and now

1054:32

let's talk about something called the

1054:33

motion values so I'll just use the

1054:35

animated prop and I want you to pay

1054:37

attention please pay attention Okay so

1054:39

if I use like X and if I write like 200

1054:42

pixel and as soon as I save this file

1054:45

why in the world am I getting there

1054:46

smooth animation so if I save it Bang

1054:50

I'm getting that smooth animation like

1054:52

why is that I'm not providing a

1054:54

transition I'm not providing any

1054:55

animation I'm just only providing like

1054:57

translate on the

1054:59

x-axis 200 why am I getting that smooth

1055:02

animation if I change that to like Y in

1055:05

case if you haven't see there so I want

1055:07

you to focus right now case so if I sell

1055:09

there why am I getting there smooth

1055:11

animation well I'm getting there because

1055:14

of the motion value and whenever I'm

1055:16

using this animate prop frame or motion

1055:18

will gives us that motion value totally

1055:20

for free and now let's talk about how we

1055:22

are going to be creating our own custom

1055:24

motion values so to do that we're going

1055:27

to need to import something called the

1055:28

use motion value okay so I'm going to

1055:31

import that go back and we have to just

1055:33

create an instance off there and you can

1055:35

specify any kind of initial value today

1055:37

but in my case I'm going to only specify

1055:39

100 right here now we have to store in

1055:41

some sort of variable so I'll just use

1055:43

like X and yeah that's fine and I want

1055:45

you to once again pay attention if I use

1055:48

the animate prop for there and if I just

1055:51

set the x value to this X and this x is

1055:53

coming from this used motion value we

1055:56

are already getting an error but now I

1055:58

want to save there and let's just watch

1056:00

what happens if I just refresh there

1056:02

here you can see nothing is happening if

1056:05

I hold my mouse over to there it's going

1056:06

to tell me like yo you cannot do that

1056:08

this is just a motion value that you're

1056:11

creating and that is not assignable to

1056:12

the Boolean value you cannot do that

1056:14

that's a big no no but now the question

1056:17

is if you are creating your own custom

1056:19

motion value so how that we're going to

1056:21

be using that inside our animation and

1056:24

to do that we're going to be using our

1056:26

inline CSS and there is that we have to

1056:29

use this style and we can just use the X

1056:32

property and that X property will be set

1056:34

to this x but we don't have to specify

1056:36

that x and x we can just write X right

1056:38

here and now if I save my file and watch

1056:41

what happens this time we are not going

1056:43

to be getting that smooth animation

1056:45

we're going to be seeing this div move

1056:47

very instantly so if I save there here

1056:49

you can see it's not going to give us

1056:50

that animation anymore so let me just

1056:52

refresh there and bang it is no longer

1056:55

giving us that animation so if I just

1056:56

change that to like 200 maybe and let's

1056:59

just refresh that Bang You're not

1057:01

getting that smooth animation and why is

1057:04

that because we are no longer using the

1057:06

framer motion motion value we are

1057:08

creating our own motion value and then

1057:11

we are using that motion value right

1057:13

here okay so we can totally change that

1057:15

programmatically if you wanted to but

1057:17

yeah there are also a few hooks that

1057:19

want to talk about narrow hooks but the

1057:21

event handlers to be precise they are

1057:23

something that you don't have to worry

1057:24

about because they are just an event

1057:26

which will help you debug your animation

1057:28

so I'm going to use like use motion uh

1057:31

event and here we have to specify your

1057:33

motion value then we have to specify

1057:36

like which kind of event that you want

1057:37

to fire so if I hold control and space

1057:40

so we have like animation cancel

1057:42

animation complete animation start

1057:44

change and so on so I'm going to only

1057:46

choose this animation start and here we

1057:48

have to specify the motion value keep in

1057:50

mind now I'm going to provide a comma

1057:52

and then we have to specify our Arrow

1057:54

function this just provide our Arrow

1057:56

function right here and I want to check

1057:58

this I'll just use like uh animation

1058:01

started on X okay so that's going to be

1058:04

the first thing that we have to do I'm

1058:06

going to basically duplicate that and

1058:08

change that to uh the animation change

1058:12

like so and we are going to be also

1058:13

providing this latest value and here we

1058:16

have to just use that latest value right

1058:18

here okay sa file you don't even have to

1058:21

worry about this stuff like yeah you

1058:23

don't have to worry about that now I'm

1058:24

going to make my component dragable so

1058:26

I'll just uh provide my drag right here

1058:29

and also the drag constraints for the

1058:31

drag constraints we're going to be

1058:32

providing the left value and left will

1058:34

be set to zero and also the right value

1058:36

will be set to 200 so now if I save my

1058:38

file you know I forgot to do something

1058:41

we also have to change that to um X

1058:45

Change two so now let me just save my

1058:47

file and now if I just refresh there

1058:50

nothing will happen but if I drag my

1058:54

component so here you can see it's going

1058:55

to give us like Xchange to this new

1058:58

value which means like we now

1059:00

successfully created our own custom

1059:02

value and we are now successfully using

1059:04

there and this is how we are going to be

1059:06

debugging there now I know a lot of you

1059:08

will ask me hose like this is not a real

1059:10

world example like we want to get some

1059:12

sort of a real world example and I'm

1059:14

going to give you that in a few seconds

1059:16

but yeah I want you to keep in mind that

1059:18

this is how we going defining our own

1059:20

custom motion value and this is how we

1059:23

are going to be using that custom motion

1059:24

value and for the example one of the

1059:26

motion value hook I'll just create a

1059:28

components folder and Define my range

1059:31

slider. TSX file inside there I'm going

1059:34

to use my RFC s my file and register

1059:37

this component right here okay so use

1059:41

the range slider hit enter so it's going

1059:43

to import that and now we are getting a

1059:45

range slider next I'm going to go ahead

1059:47

and go to the div and create my motion

1059:50

div but first of all we're going to have

1059:52

to import the motion from the framer

1059:55

motion so now inside this div what we

1059:57

have to do we have to create our motion

1060:00

do button and now we have to close there

1060:02

like so I'm going to also put the class

1060:04

name of box to there and now we are

1060:06

getting that box which is looking cool

1060:08

now underneath there we're going to also

1060:10

create a d with the class of margin for

1060:11

the top and that's going to take an

1060:13

arbitrary value like six rim and close

1060:16

them inside this div I'm going to create

1060:18

an input with a type of range because we

1060:20

want to just create a range slider and

1060:22

the minimum height will be set to 0.5

1060:25

and we also want to proide the maximum

1060:27

maximum it will take like five and let's

1060:30

just provide our step and step it will

1060:31

take like

1060:32

0.01 I'm going to also proide the

1060:34

default value not check but default

1060:37

value to them and the default value it

1060:39

will take one this is s file I'm going

1060:42

to also provide the own change when

1060:44

Handler when somebody try to change

1060:45

there we're going to be firing this

1060:47

function which is a handle uh or change

1060:50

Handler would be fine like so I'm going

1060:52

to copy the name of there and Define my

1060:54

function right here so let's just use

1060:56

our cons range slider or whatever that

1061:00

is sa my file and yeah that's looking

1061:02

cool now to provide our animation the

1061:04

first thing that we have to do is that

1061:06

we have to create our own motion value

1061:08

so to do that we're going to be using

1061:10

our motion value and provide like one to

1061:13

them for the initial value I'm going to

1061:14

store in the variable with the name of

1061:16

like scale it's going to be equals to

1061:18

this use motion value

1061:19

okay so now when somebody try to change

1061:21

them we're going to be firing this

1061:23

function but it's going to take the

1061:24

event object and let's just annotate

1061:26

there with the change event this is just

1061:29

a typescript stuff you don't even have

1061:30

to worry about that WR what HTML input

1061:33

element right here because we want to

1061:35

use the inside our HTML input element so

1061:37

now we have to use the scale and then

1061:39

inside the scale we have the get method

1061:42

we also have the set method which will

1061:43

allows us to set a new value and we also

1061:46

have a get method which allows us to get

1061:48

or return the letter this new value of

1061:50

the motion value okay so I'll just uh

1061:53

use like event. Target come on target.

1061:56

value and say my file okay so it's going

1061:59

to gives us an error because we have to

1062:01

convert there to a number so if you want

1062:03

to convert it to a number so we are

1062:04

going to be providing a plus to there

1062:06

it's going to convert that to a number

1062:07

but now in this case we're going to be

1062:09

providing our parse float because I know

1062:11

the value will be a float floating Point

1062:14

values that's why we have to specify

1062:15

this pass float to the oh here we are

1062:17

using the get method we have have to

1062:19

change that to set because we are

1062:21

changing that so we have to change that

1062:23

to set but yeah you get the idea like

1062:25

now that we successfully get the data

1062:27

but now we have to bind there right here

1062:29

guess I'll use like style and let's just

1062:32

start our style here we have to use the

1062:34

scaling which is our own custom motion

1062:37

value hook so let me just refresh there

1062:39

and now if I change the slider here you

1062:42

can see it's going to increase the size

1062:43

of there and also decrease the size of

1062:45

there but this is not smooth like you

1062:48

can also almost feel there I guess you

1062:50

cannot see that in the video but if you

1062:52

write this code by yourself you will

1062:54

totally feel there like this is not

1062:56

smooth because whenever we convert that

1062:58

to a use spring which is also something

1063:00

which you are going to be learning in

1063:01

the next section then you will feel how

1063:03

much smoother that animation can get but

1063:05

now in this case like look at this yeah

1063:08

we are getting our slider like

1063:09

everything is cool but this is not

1063:12

smooth animation and why is it not

1063:15

smooth because we are not using the

1063:16

frame or motion motion value we are

1063:19

creating our own custom motion value and

1063:22

then we are changing that motion value

1063:24

by ourself that's why it is not looking

1063:27

that great but yeah this is just a first

1063:29

use case of using the use motion hook

1063:32

inside our component let's just quickly

1063:34

talk about the use spring hook so the US

1063:36

spring hook allows us to create smooth

1063:38

spring based animation it provides a way

1063:40

to manage animated values that follow a

1063:43

spring physics model resulting in more

1063:45

natural and fluid motion compared to the

1063:47

linear animation which we just a few

1063:49

seconds ago so we are not going to be

1063:50

doing anything crazy but we only have to

1063:52

refactor this amount of code instead of

1063:55

using this used motion value let me just

1063:57

show you there if I change that here you

1063:59

can see it's not going to work that much

1064:01

smooth but if I change that to the use

1064:04

spring let just use like use spring and

1064:07

I'm going to copy the name of that and

1064:08

place that right here that's the only

1064:10

change that we have to make and KN I

1064:12

save my file and Watch What Happens so

1064:14

now if I just scroll there here we can

1064:16

see we're now getting this smooth spring

1064:18

base and animation right here like kind

1064:20

of like a bounciness and there is coming

1064:22

from the US spring okay as you can see

1064:25

you can also play around with it and

1064:26

then you will feel the animation but now

1064:28

I'm using the that's why you cannot feel

1064:31

the let me try out this once again here

1064:33

you can see this is not that much cool

1064:35

but now if you use the use spring motion

1064:38

or use spring uh hook to be precise here

1064:42

you can see we're now getting this

1064:43

smooth animation right here yeah that's

1064:45

also another hook okay so let me give

1064:48

you a quick test of what a used

1064:49

transform hook can do okay so right now

1064:51

I'm going to give you just a quick test

1064:53

of what a used transform hook can do and

1064:55

how it works and later in this course we

1064:57

are going to be covering that in a lot

1064:59

more great detail once we learn about

1065:01

the use scroll hook and so on and so

1065:02

forth so let's talk about it so one is a

1065:05

use transform hook so the use transform

1065:07

Hook is used to map one range of values

1065:09

to another it's great for smooth

1065:11

animation and effects based on the input

1065:13

values like scroll position or Mouse

1065:15

movements so this just a quick

1065:17

definition of what a use transform Hook

1065:19

is and let's get into the coding then

1065:20

you will get to know what I'm talking

1065:22

about now we are going to be working

1065:23

with the dragable box so I'm going to

1065:25

create a folder with the name of

1065:26

component and inside there we're going

1065:28

to be creating our dragable box. TSX or

1065:31

use my R fce and now I'm going to sell

1065:34

my file go into my app and register

1065:37

their dragable box component not

1065:39

dragable event but dragable box

1065:41

component right here so as soon as I do

1065:43

there here you can see we're now getting

1065:45

there which means like everything is

1065:47

working totally fine so the first thing

1065:48

that we have to do is that we have to

1065:51

import something called the use

1065:53

transform Hook from the framer motion

1065:56

going to be the first thing now I'm

1065:57

going to call that hook so I'm going to

1065:58

use like use transform and here we have

1066:01

to pass a few things first of all we

1066:03

have to specify the value and that value

1066:06

should be a motion value you can use the

1066:08

frame one motion motion value or you can

1066:11

Define your own one androide there next

1066:14

we have to specify the input range okay

1066:17

and then we have to specify the out put

1066:19

range and that's going to be it okay so

1066:21

you know what let me just first of all

1066:22

create the motion value then we're going

1066:24

to be passing that to this use transform

1066:26

so I'm going to comment this line out

1066:28

and we would also need the what do we

1066:30

call the use motion value Hook from the

1066:32

framer motion because now we are

1066:34

creating our own custom motion value so

1066:36

I'll use like cons x and x will be

1066:38

equals to the used motion value and here

1066:40

we can specify any kind of motion value

1066:42

so I'm going to just specify like one or

1066:44

you know zero would be fine okay I'll

1066:47

just specify that zero I'm going to also

1066:49

duplicate there and change the variable

1066:51

name to Y so now I'm going to sve my

1066:53

file so this is how we going to be

1066:54

defining our custom motion value now I'm

1066:57

going to uncomment there and here we

1066:59

have to specify our motion value I'll

1067:01

only provide the x and I'm going to

1067:03

provide the comma and next here you can

1067:05

see we have to specify the input values

1067:08

and next we have to specify the input

1067:10

range start and also the input range

1067:13

come on range and okay so this is how we

1067:16

are going to be providing this so our

1067:17

input range will start from minus one

1067:20

and then we want to go into the positive

1067:22

one so that's going to be the starting

1067:24

point of our range next we have to

1067:26

specify the output range start and also

1067:30

the output output range end so what are

1067:34

going to be the values we want to

1067:35

specify for the output range start and

1067:37

for the output range end I'm going to

1067:39

only specify color right here like the

1067:41

red color and also the green color so

1067:43

I'll just write like FF then four zeros

1067:46

okay so this is going to be basically my

1067:48

red color and we want to go from red

1067:50

color to the green color so I'm going to

1067:51

write like 0 0 ff0 0 and I'm going to

1067:54

store the in some sort of variable so

1067:56

I'll give it the name of like background

1067:58

color and it's going to be equals to

1067:59

this use transform value let me just say

1068:01

that once again first of all we have to

1068:03

Define our own motion value then inside

1068:05

this use transform the first value it

1068:08

will take is the motion value which we

1068:10

are providing right here next it will

1068:12

take the input range start and the input

1068:14

range end then we have to specify the

1068:17

output range start and the output range

1068:19

ER okay so that's the only thing that we

1068:21

have to do and now let's get into the UI

1068:24

so that we can use that I'm going to hit

1068:26

enter and I'm going to also zoom in a

1068:27

bit so you guys can see everything a bit

1068:29

better and I'm going to change this de

1068:31

to the motion D so I'll use like motion.

1068:33

d not the motion value but motion come

1068:37

on m o t i o n there we go oh my God I

1068:40

guess we didn't import there yep we did

1068:43

not so I'll use like motion and I'm

1068:45

going to copy them select this T and hit

1068:47

control d the motion. d That's go inside

1068:51

this motion D I'm going to specify my

1068:54

span with a class of text toally white

1068:57

uh White like so and it will say like

1068:59

drag me and here you can see we now

1069:01

getting this drag me I'm going to also

1069:03

specify a bit of classes to this one so

1069:05

I'll say like width will be set to 32

1069:08

and height will be set to 32 flex and

1069:10

items will be set to Center justify will

1069:12

be set to Center toly Round it large and

1069:15

also Shadow will be set to toly large C

1069:19

will be set to pointer and I'm going to

1069:21

also provide the background of poorly

1069:23

yellow and this is going to be the

1069:25

background color so yeah this is how it

1069:27

looks like but I'm going to remove this

1069:28

background color from here and I'm going

1069:30

to specify my animation so I want this D

1069:32

to be dragable so I'm going to just

1069:33

provide like drag and also I'm going to

1069:35

specify the drag will constraints so

1069:37

I'll use like drag constraints and for

1069:39

these drag will constraints we're going

1069:41

to be providing the left value or you

1069:43

know what let me just hit enter right

1069:44

here we're going to be providing the

1069:45

left value and the left will be set to

1069:47

minus 200 I'm going going also specify

1069:49

the right value and the right will be

1069:50

set to positive 200 I'm going to specify

1069:53

top to minus 200 and finally we also

1069:56

have to specify for the bottom of 200 so

1069:59

now if I save my file oh we cannot see

1070:01

that because we have to provide this

1070:03

background color today we cannot provide

1070:05

the as animate value because you guys

1070:07

already know that here you can see we

1070:08

are now using our custom motion value so

1070:11

so that's why we cannot use our animate

1070:12

prop so we can just use the style and

1070:15

here inside the style we can provide our

1070:17

background color and here you can see

1070:18

it's going to gives us that background

1070:20

color right here but now if I drag then

1070:22

nothing is happening and why because we

1070:24

did not specify this X and also this y

1070:27

value so let me just put there right

1070:29

here okay so I'm going to use like X

1070:31

comma y you can also specify x to the x

1070:33

value and Y to the Y value but this is

1070:36

not what we're going to be doing cuz we

1070:37

want to use our modern JavaScript and

1070:39

here we also have to specify the comma

1070:41

Now I'm going to save my file and now if

1070:43

I drag there here you can see it's going

1070:44

to change its color and that's because

1070:46

of uh this us transform hook let me just

1070:49

show you there once again here you can

1070:51

see these are just a constraints if I

1070:53

drag there to the left it's going to

1070:55

gives us like red color if I drag there

1070:56

to the right it's going to gives us a

1070:58

green color and so on and so forth you

1071:00

get the idea so yeah this just the

1071:02

basics of the use transform hook and

1071:04

we're going to be covering the use

1071:06

transform hook in a lot of great details

1071:08

I want you to prepare yourself for a lot

1071:10

of theory because in this section we are

1071:12

going to be covering the scroll

1071:13

animation so let's talk about how many

1071:15

types of scroll animation there we have

1071:17

so we only we have two types of scroll

1071:19

animations so we have a scroll trigger

1071:21

animation and we also have the scroll

1071:23

driven animation so let's start from the

1071:25

first one which is a scroll trigger

1071:27

animation so these animation are trigger

1071:29

when the user scroll to a specific point

1071:31

in the viewport and once the scroll

1071:33

reaches to the specific point the

1071:35

animation plays so what are the use

1071:37

cases for them they are great for

1071:39

revealing the elements changing the

1071:41

style or starting animation at a

1071:42

specific section of the page now let's

1071:44

talk about the scroll driven animations

1071:46

so these animation continuously change

1071:48

has the user scroll allowing for

1071:50

smoother more interactive experience the

1071:53

animation property can be mapped

1071:54

directly to the scroll position so what

1071:56

are the use cases for the scroll driven

1071:58

animation and the use cases are like

1072:00

they are ideal for the parallx effect

1072:02

transforming the element or existing

1072:04

opacity based on the scroll depth let's

1072:07

talk about how we are going to be

1072:08

achieving the scroll trigger animation

1072:10

so to achieve that there are two props

1072:12

for there so we are going to be covering

1072:14

the while in view prop and we're going

1072:16

to be also covering the viewport prop

1072:18

let's start from the first one which is

1072:19

a while in view prop so the while in

1072:21

view prop is used to trigger animation

1072:23

when the element comes into the view

1072:26

Port it allows us to Define how the

1072:28

element should animate while it is

1072:29

visible on the screen it enables us to

1072:32

create engaging animation that activates

1072:34

when the user scroll to a specific part

1072:36

of the web page okay so that's just a

1072:38

while in view prop and now let's talk

1072:40

about the viewport prop so this prop is

1072:42

used to customize how the animation are

1072:44

trigger based on the visibility of the

1072:46

element inside the viewport it allows us

1072:48

to specify the setting that effect when

1072:50

and how animation should occur is the

1072:52

element scroll into or out of the view

1072:55

okay so yeah keep that in mind and now

1072:57

let's get into the coding then you will

1072:58

get to know what I'm talking about okay

1073:00

so let's talk about the scroll trigger

1073:02

animation and we're going to be

1073:04

achieving there by using the while in

1073:06

view prop okay so first of all I'm going

1073:08

to go ahead and create my components

1073:10

folder and inside there we're going to

1073:12

be defining our animated card. TSX file

1073:15

and I'm going to be using my rafc inside

1073:17

there and let's just put there right

1073:19

here but first of all I'm going to write

1073:20

my H1 with the class of text will be set

1073:22

holy Center and text will be also set to

1073:25

3XL Mar for the bottom will be set to

1073:27

four and it's going to say like I don't

1073:29

know scroll down to see the animation

1073:34

the come on the an n i m a t o n like so

1073:38

and here you can see we're now getting

1073:39

this text which is looking cool now

1073:41

underneath this H1 what do you want to

1073:43

do we just want to create a d with the

1073:44

class of height will be set toly screen

1073:46

KN i s there here you can is going to

1073:48

gives us that scroll bar right here and

1073:50

here is our text as you can see right

1073:52

there and now what I'm going to do is

1073:54

that I'm going to Define my animated

1073:56

card component uh right here so we have

1073:59

this animated card I'm going to close

1074:01

there let's just go ahead and go to our

1074:02

component let's start working on our

1074:04

animated component so I'm going to

1074:05

remove there and change the styling of

1074:08

there first of all I'm going to be

1074:09

providing the flex justify will be set

1074:11

to Center and items will be uh not

1074:13

Center but start in this case I'm going

1074:15

to also provide margin for the top will

1074:16

be set to 30 r uh like so I'm going to

1074:19

save my file and as you can see we are

1074:21

now getting the scroll bar now inside

1074:23

this D what do you want to do we just

1074:25

want to Define our uh div in this div we

1074:28

have a few classes so just proide like

1074:30

the class name the height will be set to

1074:32

200 pH and I'm going to also provide the

1074:35

width of totally four F and justify will

1074:38

be set to Center and I'm going to also

1074:40

provide the items to be Center okay so

1074:42

if I save there now inside this div

1074:45

we're going to be defining our motion

1074:46

div so I'll use like uh motion but first

1074:49

of all we have to import this so I'm

1074:50

going to be using like import the motion

1074:52

from where from the framer motion okay

1074:55

so this is how we are going to importing

1074:56

there and now let's just create our

1074:57

motion. div and I'm going to close this

1075:00

now inside this motion div I'm going to

1075:02

also provide a bit of classes to this so

1075:04

I'll just write like background will be

1075:05

set to totally white totally rounded

1075:08

large and also pairing for all around

1075:10

will be set to six and Shadow will be

1075:13

also set to large text will be set to to

1075:15

Center say our file inside this D we

1075:17

going to be reading word H2 which will

1075:19

have the uh class of text to Excel and

1075:22

also the font will be set to totally

1075:24

bold margin for the bottom will be set

1075:26

to two Tex toally black okay like so and

1075:29

I'm going to say like amazing card this

1075:32

is sell file and here you can see we now

1075:34

getting our amazing card we did not

1075:36

specify any scrolling effect today and

1075:39

we did not do anything right now so what

1075:41

I'm going to do is that I'm going to

1075:42

also just complete this card so I'll

1075:44

just provide a paragraph let's just go

1075:46

back and this paragraph will have the

1075:47

classes of of text to gray of 600 it's

1075:50

going to say like this is or you know

1075:52

what this card animates beautifully into

1075:56

the view or something like that and here

1075:58

you can see we are now getting this text

1076:00

and also this card which is looking

1076:02

amazing so let's just provide our

1076:04

animation right here so how in the we're

1076:06

going to be providing our animation and

1076:08

how our animation will look like first

1076:10

of all we going to be providing our

1076:11

initial state so for the initial state

1076:13

I'm going to provide the scaling and

1076:15

decrease the scaling to 0.5 I'm going to

1076:17

also provide the opacity and opacity

1076:19

will be set to zero and I'm going to

1076:21

also proide the transition and the

1076:23

transition will take duration of 0.5

1076:25

seconds okay so that's cool and now here

1076:28

we are going to be defining our while in

1076:30

view okay so as long as this card is

1076:33

inside the view that animation will

1076:36

happen but if this card is not in the

1076:38

view that animation will not happen Okay

1076:40

so I'm going to use like while in view

1076:43

prop here inside there we can specify

1076:45

any kind of Animation so I can use like

1076:47

scale scale will be set to 1.1 I'm going

1076:50

to also provide the opacity and opacity

1076:52

will be set to one and the Y AIS will

1076:54

just say like Min -00 so now if I sve my

1076:57

file and Watch What Happens so if I just

1076:59

refresh there and if I try to scroll

1077:02

there did you see that so we are now

1077:04

scaling it up and we are also providing

1077:06

a opacity to there so you know let me

1077:08

just show you there and Yep this is

1077:11

looking cool this is looking cool but

1077:13

now if I comment this line out I'm going

1077:15

to just comment this line out and here

1077:17

you can see there on and now if I scroll

1077:19

down here you can see it's not even

1077:21

showing because we are providing a

1077:22

scaling of what do you call it the

1077:24

scaling of 0.5 and also the opacity will

1077:26

be set to zero so if I change that to

1077:29

from zero to one and I'm going to also

1077:31

change there to like one and here you

1077:33

can see this is how my card looks like

1077:35

right here so if I scroll down still we

1077:37

are not getting any animations but now

1077:39

if I go back and uncomment this code and

1077:42

now if I save my file here you can see

1077:44

this animation will happen so let me

1077:46

just go to the top and refresh there and

1077:49

if I scroll down so yeah that animation

1077:51

is happening and we can change the color

1077:53

we can do a lot sort of stuff with there

1077:55

so if I just write like uh I don't know

1077:57

background color come on background

1078:00

color um and I'm going to just change

1078:02

that to like maybe red color or

1078:04

something like that and if I just

1078:06

refresh that come on what the

1078:08

hell if I just refresh that and if I

1078:10

scroll down here you can see it's going

1078:12

of gives us that background color of tot

1078:14

red so yeah that was a while view I mean

1078:17

like while in viewr now let's talk about

1078:19

the use scroll hook so the use scroll

1078:21

hook help track the scroll position of

1078:23

the page it makes it easy to create

1078:25

animation or effect that respond to how

1078:27

much the user have scrolled so yeah

1078:29

that's just a definition of what a use

1078:31

scroll is and now let's get into the

1078:32

coding then you will get to know what

1078:34

I'm talking about now let me give you a

1078:35

quick test of the use scroll animation

1078:37

so what I'm going to do is that I'm

1078:38

going to create my folder with the name

1078:40

of components and inside there we're

1078:42

going to be creating the scroll

1078:44

animation. TSX file and I'm going to be

1078:46

using the rafc inside then now let's

1078:48

just go ahead and go to our app and

1078:50

register that scroll component right

1078:52

here and I'm going to close that so if I

1078:54

save this file right now and now the

1078:57

next thing that we have to do is that we

1078:58

have to use or use scroll animation and

1079:01

now we have to import that not from the

1079:03

framer but from the framer motion so

1079:05

I'll use like the framer motion and now

1079:07

we have to store in some sort of a

1079:09

variable so I'll use like scroll L going

1079:11

to be equals to this you scroll I'm

1079:12

going to log there to the console like

1079:14

scroll and now if I save my file I'm

1079:16

going to open my console and here inside

1079:19

this console now we are getting these

1079:20

two objects so if I expand there and

1079:22

these properties are a motion values and

1079:25

remember we already cover a motion

1079:27

values so we have like scroll on the

1079:29

x-axis and scroll X progress y AIS and

1079:32

also scroll YX is progress so yeah we

1079:35

can use these properties to make amazing

1079:37

animation I'm going to remove that from

1079:39

here and next I'm going to destructure

1079:42

only the scroll on the y axis not the

1079:44

x-axis but on the y axis and the next

1079:47

thing that I want to use I want to use

1079:49

event so I'm going to use like the use

1079:50

motion uh value event come on use motion

1079:54

value event like so it's going to take

1079:57

the motion value first of all so I'm

1079:58

going to copy a name up there because we

1080:00

already know that this property is a

1080:02

motion value and the next thing that we

1080:04

have to do is that we have to specify

1080:06

which kind of event you want to fire so

1080:08

here you can see we have a change we

1080:10

have the animation start the animation

1080:12

complete cancel and so much more I'm

1080:14

going to only choose the change and now

1080:16

the next thing that we have to do is

1080:17

that we have to call for call back

1080:18

function and get the latest Rue out of

1080:21

there okay so I'm going to go inside

1080:22

there and now let me just loog to the

1080:24

console this page scroll and here we're

1080:27

going to be rendering our latest value

1080:29

inside there I'm going to save my file

1080:31

right now but now we need a place to

1080:33

scroll through so I'm going to remove

1080:35

that from here and inside there I'm

1080:36

going to use my ul and Li uh I want them

1080:39

to be like 50 maybe and as soon as I hit

1080:42

enter so it's going to gives us like 50

1080:43

Li and now if I save my file let me just

1080:46

test this how I'll use like H one of

1080:48

hello something and yeah we are getting

1080:50

there but why aren't we getting that you

1080:53

know what I'm going to also proide the

1080:54

class name of um how it will be set to

1080:57

all the screen so now if I do that and

1080:59

now we are getting our scroll bar right

1081:00

here so I'm going to open my console

1081:02

once again and go to my console now we

1081:05

are getting this data but now as soon as

1081:07

I scroll here you can see we are now

1081:09

getting this different data first of all

1081:11

we are getting this data then we are

1081:12

getting the two and so on and so forth

1081:15

so as soon as I scroll there it's going

1081:17

to give us new value So based on these

1081:20

new values we can create a smooth

1081:22

animation or a scroll smooth animation

1081:25

and yeah that's just the basics of the

1081:27

use scroll hook now let me show you how

1081:29

we are going to be using the use scroll

1081:31

hook with the use transform hook so what

1081:33

I'm going to doce that I'm going to

1081:34

create a folder with the name of

1081:35

components and inside there we are going

1081:37

to be defining the scroll animation n i

1081:40

m i t o n animation. TSX and now let me

1081:43

use my rafc inside the save this file

1081:46

and call this comp component right here

1081:49

so we have a scroll animation component

1081:51

now let me just save there and now let

1081:53

me go into my component and now let's

1081:54

start working on there so the first

1081:56

thing that I would need is the use

1081:58

scroll and now we are going to be

1081:59

getting there from the framer motion

1082:02

motion like so and next we have to store

1082:05

them in some sort of a variable or we

1082:07

have to destructure the scroll ya AIS

1082:11

from the use scroll so that's done next

1082:13

we have to Define our use transform hook

1082:15

so we are going to be defining that for

1082:17

the SC SC and also for the opacity so

1082:19

I'll use like scale and scale will be

1082:21

equals to the use transform hook and for

1082:23

this use transform hook it's going to

1082:25

take the motion value and we already

1082:27

know that this scroll y AIS is a motion

1082:30

value so I'm going to pass it right here

1082:32

next we have to provide the starting

1082:33

point so when our animation start from

1082:36

zero so in this situation we wanted to

1082:38

change that to one and when our

1082:41

animation reaches to 300 so in this

1082:43

situation you want to set there to 1.5

1082:46

like the scaling to 1.5 that's done now

1082:49

let me also use the transform hook for

1082:51

the opacity so I'll use like opacity op

1082:54

s CIT T YN it's going to be equals to

1082:56

use transform hook and here once again

1082:58

we're going to be passing our scroll on

1083:00

the y- axis as a motion value today and

1083:03

then when it start from zero what do you

1083:05

want to do in that situation we want to

1083:07

set that to one and when it reaches to

1083:10

300 so in that situation we want to set

1083:12

that to zero now I'm going to save my

1083:14

file and now let me go ahead and go to

1083:16

my UI and use there so what I'm going to

1083:18

do is that first of all I'm going to be

1083:19

attaching like height of to screen and

1083:22

flex and items come on items will be set

1083:25

to toly Center and justify will be also

1083:27

set to to Center inside this div we're

1083:30

going to be defining our motion. div

1083:32

okay so first of all we have to get the

1083:34

motion and then we would be able to use

1083:36

that motion right here so I'm going to

1083:38

be using motion. value and inside there

1083:41

I'm going to be putting a bit of classes

1083:42

to it like background totally blue of

1083:44

500 and with will be set to 32 come on

1083:47

let's just set to 32 and height will

1083:50

also be set to 32 toally rounded large

1083:53

and Shadow will be set to toally large

1083:55

and now for the styling we know that we

1083:58

are going to be using the motion values

1084:00

which also means that we are going to be

1084:02

passing the scaling and also the opacity

1084:04

to this style so I'm going to past the

1084:06

scale and also the opacity let me just

1084:09

copy a name up there and place it right

1084:11

here sem my file and now underneath

1084:13

there we're going to be creating a div

1084:15

for the scrolling so I'll just use a div

1084:17

and the will be set to totally full and

1084:19

for the height we're going to be using

1084:21

150 viewport height now let me just

1084:23

close there and it should be height not

1084:26

width and here you can see we now

1084:28

getting this box and when I scroll down

1084:31

here you can see it will make it

1084:32

disappear so you know what let me just

1084:34

go ahead and provide a bit of styling to

1084:35

my body I'll just Place The Styling now

1084:38

let me just save my file and here you

1084:39

can see we're now getting this de and

1084:41

now as soon as I scroll there here you

1084:43

can see it's going to make it disappear

1084:45

and I can also make the high to like I

1084:47

don't know maybe 200 so now let me just

1084:49

change that to 200 and here you can see

1084:51

it's going to make it disappear so I

1084:53

want you to notice here you can see it's

1084:55

going to increase the scaling of there

1084:57

and also it's going to change the

1084:58

opacity and we can totally achieve that

1085:01

by using just a use scroll hook and also

1085:03

the use transform hook so yeah I know

1085:05

that's just a simple and basic animation

1085:08

but that's just example of the use

1085:10

scroll and the use transform hook now

1085:11

let me give you another example so I'm

1085:13

going to remove this coding from here

1085:15

and I'm going to create another

1085:16

component with an name of

1085:19

Animation or animation scroll. TSX will

1085:22

be fine now use the RFC inside there go

1085:25

ahead and go to my app and use the

1085:27

animation scroll right here and close

1085:30

there now let's just go ahead and go to

1085:32

our animation scroll and start working

1085:34

on there the first thing that we will

1085:36

need is the use scroll animation I mean

1085:38

like the use scroll hook to be precise

1085:40

and now we have destructure the scroll

1085:42

on the y- axis from the use scroll hook

1085:44

the next thing that we have to do is

1085:46

that we have to transform the scale and

1085:47

the board radius based on the scroll

1085:50

position so how in the what we are going

1085:51

to be doing there we going to be calling

1085:53

the used transform Hook from the framer

1085:55

motion and we would need that from the

1085:58

framer motion rather than just a motion

1086:01

and here it's going to take the motion

1086:02

value so I'm going to copy a name of

1086:04

that and place it right here and

1086:05

starting from zero you want to set it to

1086:08

one and then going through 1,000 we

1086:11

wanted to decrease the size of this all

1086:13

use like 0.5 and now we can store the

1086:16

inside the variable all use like scale

1086:18

and it's going to be equals to this use

1086:19

transform hook next we have to create

1086:21

our border radius so it's going to start

1086:23

from square and then it will make it as

1086:25

a circle so I'll use like border radius

1086:27

it's going to be equals to this use

1086:28

transform hook and for this use

1086:30

transform hook we're going to be

1086:32

specifying the scroll on the y- axis

1086:34

starting from zero and then we want to

1086:37

set there to 0% and then when it goes to

1086:40

1,000 we want to set there 2 50% that's

1086:44

also done now we have to use the inside

1086:46

our UI so what I'm going to use that I'm

1086:47

going to remove this animation scroll

1086:49

from here and now I'm going to provide a

1086:51

bit of classes to this I'll use like the

1086:52

class name will be set to relative right

1086:54

will be set to to screen and the

1086:57

overflow will be set to totally hidden

1087:00

inside this T we're going to be defining

1087:02

our motion. image and so first of all we

1087:05

want have to import the motion so I'll

1087:06

use like the motion from the framer

1087:09

motion and inside this D we going to be

1087:11

defining or motion. image or IMG like

1087:14

that I'm going to close that and here is

1087:16

going to take the source and also it's

1087:18

going to take the alternative text so

1087:19

for this alternative text I'm going to

1087:21

specify background and for this Source

1087:24

we're going to be providing this image

1087:26

so now let me just save my file I'm

1087:27

going to also provide a bit of classes

1087:29

to this so I'll use like uh it's going

1087:30

to be set to totally absolute and insert

1087:33

will be set to totally zero with will be

1087:35

set to totally full height totally full

1087:37

and object totally cover I'm going to

1087:39

save this file right now now we also

1087:41

have to attach our styling so for this

1087:43

styling we're going to be providing our

1087:45

scale so I'm going to copy a name of the

1087:47

and and provide the scale right here I'm

1087:49

going to also specify this border radius

1087:51

so I'm going to copy a name of that and

1087:52

place it right here and now underneath

1087:54

that what do we have to do we have to

1087:55

create a d with a class of sticky and

1087:58

top will be set to toally zero the

1088:00

height will be set to toally screen

1088:02

items will be set to to Center and also

1088:04

justify will be set to toly Center

1088:07

inside there we going to be creating H

1088:08

one with the class of text to White and

1088:10

text to 4 Excel and inside they will use

1088:14

like scroll to animate so now let me

1088:16

just save my file and here you can see

1088:18

we are now getting this image but now as

1088:19

soon as I scroll there okay we can even

1088:22

scroll there so you know what let's just

1088:23

go ahead and go to our app and now

1088:25

underneath we have to just provide some

1088:26

sort of a div with the class of a lot of

1088:28

classes so I'll use a div and here we're

1088:30

going to be providing the height of uh

1088:32

200% so that we can see them and also

1088:36

background po gray of 800 inlex items

1088:40

will be set to totally Center justify

1088:43

will also be set to totally Center

1088:45

inside there we're going to be creating

1088:47

H2 with the class of text only white and

1088:49

here we have to specify the scroll down

1088:51

I'm going to save this file right now

1088:53

now as soon as I scroll here you can see

1088:55

we are now getting that border radius

1088:57

and also that smooth animation on the

1089:00

scroll so if I scroll it back here you

1089:02

can see we're now getting this full

1089:03

image and that's oh what the hell is

1089:05

this guy one

1089:08

doing so that's our you scroll hook

1089:12

welcome to the first exercise of this

1089:14

course so in this one we're going to be

1089:16

building six amazing amazing animation

1089:18

but they are not going to be Advanced

1089:20

like they are going to be totally simple

1089:22

because this is the first exercise of

1089:23

this course okay so let's start from the

1089:25

first one the first thing that we have

1089:26

to do is that we have to create a box

1089:28

that moves across the screen you should

1089:30

have to create a simple Box by using the

1089:32

div or you can also create a section or

1089:34

anything that you prefer then use the

1089:36

framer motion to animate that box from

1089:38

the left side of the screen to the right

1089:40

do that then we're going to be doing the

1089:41

rest of them so let's just start working

1089:43

on there so I'm going to be creating my

1089:44

components folder and inside there is

1089:47

Define our box. TSX file and I'm going

1089:49

to be using my rafc S my file and

1089:52

register there right here so we have WR

1089:54

a box and hit enter so it's going to

1089:56

render there right here check this out

1089:58

so we now getting that box which is

1089:59

looking cool okay so the next thing that

1090:02

we have to do is that we have to Prov

1090:03

our animation so I'll just import my

1090:06

motion from where from the framer motion

1090:09

so that's done we also have to specify

1090:11

or motion. or you know what I'm going to

1090:14

remove that from here I'm going to also

1090:16

remove that box and I'm going to close

1090:18

there like a self closing tag and I'm

1090:20

going to provide my motion div I'll also

1090:22

provide a bit of classes like the

1090:23

background will be set fully blue of 200

1090:26

and the width will be set to 20 and also

1090:28

the height will be set to 20 okay and

1090:30

now let me provide my animation so I'll

1090:31

just provide my initial State and for

1090:33

this initial State we're going to be

1090:35

providing the x value and X is going to

1090:37

be set to 100 minus 100 and when we want

1090:40

to animate that so we're going to be

1090:42

setting the x value to positive 100 and

1090:45

finally we're going to be providing a

1090:46

weit of transition and also I'm going to

1090:48

put a duration of 2 seconds so now I'm

1090:50

going to save my file now if I just

1090:51

refresh there and here you can see we

1090:53

now getting our box we can also use or

1090:55

what do we call it or box simply so I'll

1090:58

just write like that box save my file

1091:00

and yo that's super big okay so if I

1091:03

just refreshed there you're now getting

1091:04

this amazing animation so that's the

1091:06

first thing that we have to do next we

1091:08

have to create a vertical moment so make

1091:09

a circle bounce up and down so create a

1091:11

circle by using a CSS or you can also

1091:14

use a TN CSS then animate that Circle to

1091:16

move vertically bouncing at the top and

1091:19

bottom of the container so this is what

1091:20

you have to do next so give it your best

1091:22

shot if you can't do it then that's

1091:25

completely okay then come back and watch

1091:27

the solution so I'm going to go ahead

1091:28

and create my component right here I'm

1091:30

going to give it the name of like

1091:31

bouncing or bouncing Circle rather. TSX

1091:36

ah spelling is incorrect b o u n c i n

1091:40

bouncing circle. TSX and I'm going to be

1091:42

using my RFC inside there and now let's

1091:45

just register this component right here

1091:47

so I'm going to be using my bouncing

1091:49

Circle and close that and now inside

1091:52

this component what do we have to do the

1091:54

first thing that we have to do is that

1091:55

we have to import the motion so I'm

1091:57

going to be using like import motion

1091:59

from where from the frame or motion and

1092:02

now we have to Define our Circle so I'll

1092:04

just remove there and close that like so

1092:07

and I'm going to make the as a motion.

1092:09

div and you can also make the as a

1092:10

motion do section or article or whatever

1092:12

you want to call there I'm going to just

1092:14

make it like there and I'm going to also

1092:16

make a circle by using the tailin CSS

1092:18

and I'll use like background totally red

1092:20

of 500 and round it totally full with

1092:24

will be set to 20 it will also be set to

1092:26

20 and now let's just provide our

1092:28

animation so I'm going to be using the

1092:29

animate prop and on this animation we

1092:31

want to set the Y AIS to 0 comma - 100

1092:35

comma 0 now underneath that we also have

1092:38

to specify the transition and for this

1092:40

transition we're going to be providing a

1092:41

duration of one and the repeat will be

1092:43

set to one and not one but and repeat

1092:46

will be set to infinity and also the

1092:48

easing will be set to ease in and out

1092:51

like so so I'm going to save my file and

1092:53

that's all the code that we have right

1092:55

and here you can see we now getting our

1092:57

bouncing ball right here which is

1092:58

looking cool okay so that's also amazing

1093:02

and that's the second exercise next we

1093:04

have to create our rotation animation so

1093:06

what we have to do we have to spin an

1093:08

icon continuously so you can either use

1093:11

the SVG tag or you can use some sort of

1093:13

a react icons if you prefer the then

1093:15

animate that icon to

1093:17

indefinitely so give it your best shot

1093:19

if you can do it you know what to do

1093:22

okay so let's just create a component

1093:23

with the name of spinning icon. TSX and

1093:28

I'm going to be using my RFC inside this

1093:30

semi file go to my app. TSX like so

1093:34

comment this line out and I'm going to

1093:35

be using my spinning s p come on SP i n

1093:40

i n g spinning icon and we're now

1093:42

getting there I'm going to go ahead and

1093:44

remove there and change that to the

1093:46

image tag I'm going to also close them

1093:49

and inside this image we're going to be

1093:50

providing this Source okay so now let me

1093:52

just provide there right here and now

1093:54

let me import the motion come on motion

1093:57

from where from the framer motion I'm

1093:59

going to sve my file and this is

1094:01

basically the logo of the frame or

1094:02

motion okay so we're going to providing

1094:04

the class name of with will be set to 20

1094:06

height will also be set to 20 and let's

1094:08

just proide our animate uh prop so let's

1094:10

just use our animate inside there we're

1094:12

going to be providing our rotation but

1094:14

first of all we have to convert that to

1094:17

the motion. image right here okay so now

1094:20

inside this animate prop we're going to

1094:22

be providing the rotation and and we

1094:23

want it to be rotate on the

1094:25

360° I'm going to also provide a

1094:27

transition and for this transition test

1094:29

is part to a duration of two and the

1094:31

repeat will be set to uh infinity and

1094:34

I'm going to also provide the easing and

1094:36

ease will be set to linear like so so

1094:38

let's say s our file and here you can

1094:40

see we are now getting the rotated logo

1094:42

of the frame and motion so yeah that's

1094:44

also done let's just go ahead and

1094:46

perform this fourth one so we have a

1094:48

skewed transition now in this case so

1094:50

animate the rectangle that skews when we

1094:53

click on it so create a rectangle using

1094:55

a telin CSS or you can also use just a

1094:57

simple CSS if you wanted to and when

1095:00

somebody clicks on that then skew that

1095:02

rectangle and return it normal when we

1095:04

clicked again so yeah once again give it

1095:06

your best shot so for this one we're

1095:08

going to be creating a component with

1095:10

the name of skew rectangle. TSX and I'm

1095:12

going to be using my RFC inside there

1095:15

let's just go in there and register our

1095:17

component right here so we have our skew

1095:20

uh skew rectangle to be precise and now

1095:23

inside there the first thing that we

1095:24

have to do is that we have to create our

1095:26

motion and let's just get that from the

1095:28

frame and motion and we already know

1095:30

that whenever we are clicking on

1095:31

something so we would need some sort of

1095:33

a state so I'll just create a state with

1095:35

the name of like is skewed and then set

1095:37

is skewed it's going to be equals to the

1095:40

U State and let's just provide a true as

1095:43

a value to that so now let's just make

1095:45

this deal as a skew de so I'm going to

1095:47

provide like motion dot there and inside

1095:50

that we have to provide a bit of styling

1095:51

today so I'm going to be using like the

1095:53

class name background will be set to

1095:54

totally yellow of 500 and also width

1095:58

will be set to 40 he will be set to 20

1096:01

and now underneath there when somebody

1096:02

try to click on there in this situation

1096:04

we want to just set the isq property to

1096:07

not isq which means like if this is true

1096:10

make that false if this is false to make

1096:12

that true so if I save my file this is

1096:14

how it looks like so if I click on then

1096:16

nothing will have

1096:17

I'm going to also provide animation to

1096:18

this so I'll just use like this animate

1096:20

prop and provide the skew on the x-axis

1096:23

and we have to provide like if this is

1096:24

sked so in that situation we want to

1096:26

provide the 20 value to that but if

1096:28

that's not the case we want to set it

1096:29

back to zero I'm going to also provide a

1096:31

transitions right here and for the

1096:33

transition we're not going to be doing

1096:34

anything crazy but just Prov a duration

1096:36

of 0.5 seconds say our file and now if I

1096:39

click on there it's going to just give

1096:40

it up as simple as that so yeah that's

1096:43

also amazing so that was our fourth

1096:46

challenge and now let's talk about the

1096:48

fifth one which is a combined

1096:49

transformation so create a complex

1096:51

animation combining multiple

1096:52

transformation so you just have to

1096:54

create some sort of a shape it doesn't

1096:55

matter if there going to be a circle or

1096:57

a square or something like that and then

1096:59

animate that shape to move diagonally

1097:01

while rotating and scaling

1097:02

simultaneously so yeah give it to your

1097:05

best shot and I'm going to just create a

1097:07

component right here the name of combine

1097:09

animation. TSX or use my RFC inside

1097:13

there copy the name of there and go

1097:15

ahead and register that comp component

1097:17

right here like so I'm going to go into

1097:20

my combine animation and here the first

1097:23

thing I do is that I'm going to be

1097:24

importing the motion from the framer

1097:26

motion like so next we have to Define

1097:29

our div and I'm going to close there

1097:31

like so and Define them as a motion D

1097:34

I'm going to also provide a bit of

1097:35

styling to them let's just use our class

1097:37

name and for this class name we are

1097:39

going to be setting the background to

1097:40

totally purple and 500 with will be set

1097:44

to 20 height will also be set to 20 so

1097:46

there you also have to provide the

1097:47

animat prop and on this animate we want

1097:49

to set the xaxis to 200 and the rotation

1097:52

to be

1097:54

360° and also for the scaling we're

1097:56

going to be setting that to 1.5

1097:58

underneath that we have to provide a

1097:59

transition and for this transition we're

1098:02

going to be providing a duration of 2

1098:03

seconds so now if I save my file and

1098:05

check this out so let me just refresh

1098:07

there and here you can see it's going of

1098:09

gives us that rotation right here and

1098:11

that's looking super amazing next we

1098:13

have to create our sequential

1098:14

transformations in this case we have to

1098:16

create animation sequence so use

1098:18

multiple animats like square or Circle

1098:21

or something like that then animate them

1098:23

in a sequence when where one moves to

1098:25

the right then the next one follows

1098:26

after the delay using different

1098:28

transformation like move rotate or

1098:30

skiing and something like that okay so

1098:32

yeah once again that's going to be the

1098:34

final one so give it your best shot if

1098:36

you can do it that's completely okay

1098:38

then come back and watch the solution

1098:39

and now I'm going to give you my

1098:41

solution so I'm going to go ahead and

1098:42

create my oh what the hell is I just do

1098:45

let's just remove there and create my

1098:47

file right here with the name of

1098:49

sequential boxes. TSX file and I'm going

1098:51

to be using my rafc inside there go

1098:54

ahead and go to our app component

1098:55

comment this line out and then I'm going

1098:57

to be providing my sequential boxes and

1099:00

this run there let me go ahead and go to

1099:02

my component and the first thing that we

1099:04

have to do is that we have to import the

1099:06

motion from where from the framer motion

1099:10

inside there you would need a few boxes

1099:12

so we can define an array like so but we

1099:15

don't have to do that we're going to

1099:16

defining our array by using these curly

1099:19

braces we're going to be using like dot

1099:21

dot dot then we want to create like five

1099:23

elements inside this array and then we

1099:25

want to it over through them by using

1099:27

the map method so we are not interested

1099:29

in anything but we want to get the index

1099:31

like so and inside there what do we have

1099:34

to do we have to Define our motion. div

1099:36

and I'm going to close there so now

1099:38

inside this div I'm going to providing

1099:40

the key and key will be set to that

1099:41

index which we are now getting from this

1099:43

array right here I'm going to also put a

1099:45

bit of classes to it so I'll just write

1099:47

BG will be set to taal of 500 with will

1099:50

be set to 20 height will also be set to

1099:52

20 and margin for like all around will

1099:54

be set to two and I'm going to be also

1099:56

providing the animate prop and on this

1099:58

animate we want to move that to the

1099:59

x-axis of 100 pixel and for the

1100:02

transition uh we going to be providing

1100:04

the duration and for the duration we're

1100:06

going to be setting that to like 0.5

1100:08

seconds I'm going to also provide a

1100:09

delay so I'll just use like delay and

1100:12

delay will be set to that index times 0

1100:15

0.5 second

1100:17

and that is it okay so let me just check

1100:20

this out so if I just refresh there it's

1100:22

going to first of all move this one then

1100:24

this one and then finally that one you

1100:25

know what let me just set that one

1100:27

second and now if I refresh that first

1100:29

of all it's going to move that one then

1100:31

this one and then the third one but if

1100:33

you have like a lot more boxes like you

1100:34

know let me just increase the size of

1100:36

that to like five boxes or maybe 10

1100:38

boxes so this is how the animation will

1100:39

look like so I'm going to go back and

1100:41

now let me just refresh there so first

1100:43

second third fourth and so on and so

1100:49

for so yeah that was the first exercise

1100:52

of this course welcome to the second

1100:54

practice module so in this one we're

1100:56

going to be creating amazing amazing

1100:58

animations so let's talk about the first

1101:01

one the first thing that we have to do

1101:02

is that we have to create a simple fade

1101:03

in and Fade Out animation so what we

1101:06

have to do we have to create a component

1101:08

with the name of fed in component or

1101:10

just a Fed component then use the

1101:12

motion. diff from the frame on motion to

1101:14

create a diff that feds in and feds out

1101:16

you can style that by using the tailin

1101:18

CSS or you can also style there by using

1101:20

just simple CSS if you wanted to then

1101:22

add a button that toggles the visibility

1101:24

of the FED component so yeah give it

1101:26

your best shot if you can't do it you

1101:28

don't have to worry about it okay so

1101:31

what I'm going to do is that I'm going

1101:32

to create my components folder so I'll

1101:34

just Define my compon oh my God comp

1101:38

components folder and inside there we're

1101:40

going to be creating our fed component.

1101:43

TSX file so I'll use my rafc inside this

1101:46

sa my file and register this component

1101:49

right here just like that I'm going to

1101:51

save my file and this is how it looks

1101:53

like right here so next thing that we

1101:55

have to do is that we have to grab

1101:56

something called the motion uh from

1102:00

where from the framer motion like so and

1102:03

inside there let's just take care of the

1102:05

toggling and untl or you can say the

1102:07

visibility or unisil so I'll just create

1102:10

a state with the name of like visible

1102:12

and then set v i i it's going to be

1102:15

equals to the US St and here we have to

1102:17

set there to false okay so now inside

1102:20

this component what do we have to do we

1102:21

have to Define our class names so I'll

1102:23

use like Flex and flex will be set to

1102:25

column and items will be set to Center

1102:27

so now inside this div the first thing

1102:29

that we have to do is that we have to

1102:30

Define our button and now I'm going to

1102:32

say like toggle fed and here we also

1102:34

have to provide a bit of styling to this

1102:36

all use like margin for the bottom will

1102:38

be set to four pairing all around will

1102:40

be set to two background will be set

1102:42

totally blue of 500 and text will be

1102:44

white totally rounded I'm going to say

1102:46

my file and when somebody clicks on this

1102:48

button we want to fire this function

1102:51

okay so which will just set the

1102:53

visibility to not visibility or not

1102:56

visible which means like if this is true

1102:58

it's going to make it false if this is

1102:59

false it's going to make it true and

1103:01

here you can see we are now getting our

1103:02

amazing button we click on there nothing

1103:05

will happen so yeah let's just take care

1103:07

of the rest of the content so I'm going

1103:08

to collapse there and here we are going

1103:11

to be defining our div and our data so

1103:13

now let me just go back and what we have

1103:15

to do we have to first of all check if

1103:17

this is visible and then based on their

1103:20

visibility we are going to be showing

1103:21

this UI but if this is not set to true

1103:24

and this is not visible you're not going

1103:26

to be showing nothing at all okay so

1103:29

let's just create our motion. div and

1103:31

here what we have to do we have to do a

1103:33

lot of things so I'll just put the class

1103:35

name pairing all around will be set to

1103:37

four background will be set to gray of

1103:39

200 and totally rounded so now

1103:42

underneath that we have to create our

1103:43

initial State and for this initial State

1103:45

we're going to starting our animation by

1103:47

providing the opacity of zero then we

1103:50

going to be providing the animate prop

1103:51

on this animate prop we're going to be

1103:53

setting the opacity to one and now we

1103:55

also have to provide the exit prop so on

1103:58

this exit you want to set the opacity to

1104:00

zero once again and then finally we have

1104:02

to provide some sort of transitions so

1104:04

I'll just say like um duration will be

1104:06

set to 0.5 I'm going to S there but this

1104:09

is not how we are going to be closing

1104:10

our D I'm going to close them manually

1104:12

and I'm going to just put some sort of a

1104:14

text right here and I will say like

1104:16

first of all let me convert there to the

1104:17

motion. D and then I'll just say like

1104:21

hello um I don't know I am a feding

1104:26

component or something like that and now

1104:28

let me test this out so here you can see

1104:30

we are now getting there but we have to

1104:32

change the text to totally black like so

1104:36

and now this is looking better if I

1104:37

click on the struggle fed it's going to

1104:39

hide there if I click on there once

1104:40

again it's going to unhide there so what

1104:43

I'm going to do is that I'm going to

1104:44

wrap that in this section you know what

1104:46

we're not going to be wrapping in the

1104:48

section but I'm going to wrap it in the

1104:49

animated presence I'm going to import

1104:51

there and close there like so so I'm

1104:53

going to cut that from here and I'm

1104:56

going to place that right here so now if

1104:58

I click on the struggle button so it's

1105:00

going to unhide there if I click on

1105:01

there once again it's going to hide

1105:03

there from the UI and that's because of

1105:05

this animate present so if I just remove

1105:07

there for a second and Watch What

1105:09

Happens so if I click on there it's

1105:11

going to unhide there but now if I click

1105:13

on there once again so it's going to

1105:15

hide there totally in instantly like as

1105:17

you can see right here but now if I

1105:19

provide this animated presence once

1105:20

again save my file and click on this so

1105:23

it's going to hide there and if I click

1105:25

on there it's going to slowly hide there

1105:28

so yeah that's just a basic animation

1105:30

and that was our basic fed in component

1105:32

or just a Fed component to be precise so

1105:35

now I'm going to go ahead and perform

1105:37

the second practice challenge or

1105:39

whatever you want to call it next we

1105:40

have to create a sidebar that will slide

1105:43

in from the left when we click on the

1105:44

button so what we have to do we we have

1105:46

to create some sort of a component and

1105:48

then we have to use the motion. div then

1105:50

we can style our sidebar by using the TN

1105:52

CSS we can use the frame or motion

1105:54

animate prop to slide the sidebar in the

1105:56

form of the left then we have to add a

1105:58

button that will toggle the visibility

1106:00

so once again if you can do that go

1106:03

ahead and do that but if you can do that

1106:05

then don't worry I'm going to show you

1106:07

the solution right now so I'm going to

1106:08

Define my sidebar component and here we

1106:11

have to use our rafc inside the semii

1106:15

comment this line out and provide my

1106:17

sidebar right here let's just go ahead

1106:19

and start working on this component so

1106:21

the first thing that we have to do is

1106:22

that we have to grab the motion from

1106:25

where from the framer motion next we

1106:27

have to create our stat so I'm going to

1106:28

be using like is open and then set is

1106:31

open it's going to be equals to the use

1106:33

St and here we have to specify the false

1106:35

value to there now I'm going to go to

1106:37

the UI and remove that from here I'm

1106:39

going to also provide the class name of

1106:41

flex today inside there we going to be

1106:43

defining our button and which will just

1106:45

say like sidebar or something like that

1106:48

okay I'm going to also a bit of styling

1106:50

to this so like margin for the bottom

1106:52

will be set to four pairing all around

1106:53

will be set to two background will be

1106:55

set to Blue of 500 you can also set the

1106:59

text to totally white totally rounded so

1107:01

if I sa my file and this is how it looks

1107:04

like right here so if I click on there

1107:06

nothing will happen but I can also

1107:07

attach my event handler on there so when

1107:09

somebody try to click on there what we

1107:11

have to do we have to just use the set

1107:13

is open and set there to not is open

1107:17

okay so which means like if this is true

1107:19

make that false if this is false make

1107:21

that true if I click on that still

1107:23

nothing will happen because we have to

1107:25

provide our UI underneath this button

1107:28

next we have to use our motion. div and

1107:31

create our sidebar so I'm going to be

1107:32

using like this motion. div and then I'm

1107:36

going to close there like so inside this

1107:38

div we're going to be defining our H2

1107:39

which will have the class of text only

1107:41

large and also the font will be set to

1107:43

bold it's going to say like a sidebar or

1107:45

something now need this H2 we can create

1107:48

a paragraph now we'll say like uh some

1107:50

random content that will goes here or

1107:54

something like that now let me provide a

1107:55

bit of classes and also a bit of styling

1107:57

to this component or to this element to

1108:00

be precise I'm going to be using the

1108:01

class name and here we are going to be

1108:03

providing our classes totally

1108:05

dynamically so I'll use like f class and

1108:07

also left will be set to zero top will

1108:09

be set to zero and height will be set to

1108:12

totally full background will be set to

1108:13

gray of 700 and I'm going to also

1108:16

provide the text and text will be set to

1108:18

totally wide pairing all around will be

1108:20

set to four and here now we have to

1108:22

render our classes dynamically so what

1108:25

we have to do is this is open then we

1108:27

have to set there to empty string but if

1108:30

this is not open then we have to set

1108:32

there to minus translate value t r NS l

1108:35

a t e on the xaxis is going to be set to

1108:38

full okay so now let me just save my

1108:40

file and now underneath that you know

1108:41

let me just show you there if I click on

1108:43

there here you can see we're now getting

1108:44

our sidebar and side sidebar and then

1108:46

some random content right here you can

1108:48

specify the input field or the check

1108:51

boxes or or whatever you want to put

1108:52

right here but yeah we are now getting

1108:54

our sidebar but we are not providing any

1108:56

animations today so to provide our

1108:58

animation the first thing that we have

1108:59

to do is that we have to use our initial

1109:01

State and for this initial State we're

1109:04

going to be setting the x value to minus

1109:06

100% And now underneath there we also

1109:09

have to provide the animat prop and on

1109:11

this animat prop you want to set the x

1109:13

value if this is open so in that

1109:15

situation we want to set there to 0% but

1109:18

if this is not OP so we want to set

1109:20

there to minus 100% and we're going to

1109:22

be also providing a bit of transitions

1109:24

so let's just provide a bit of

1109:25

Transitions and on this transition we're

1109:27

going to be setting the duration to 0.5

1109:30

seconds and now if I click on this strle

1109:32

button it's going to unhide there and

1109:34

it's going to gives us this sidebar

1109:35

totally animated if I click on there

1109:37

once again it will make it disappear so

1109:40

yeah this is also amazing practice that

1109:43

we've just work on so you can totally

1109:45

animate and you can also specify

1109:47

different styling for the button you can

1109:49

also specify different styling for the

1109:50

sidebar if you wanted to but yeah that

1109:53

was our practice number two now let's

1109:55

start working on the third one what do

1109:57

we have to do we have to create a model

1109:59

with a transition so the first thing

1110:01

that we have to do is that we have to

1110:03

create a component then we have to use

1110:04

the motion. D we can style it by using

1110:06

the tailin CSS or you can also use the

1110:09

just CSS if you want to then we have to

1110:11

use the frame and motion to animate the

1110:12

model entrance and also the exit Okay so

1110:15

we can just create a button which will

1110:17

trigger the model so yeah let's just

1110:19

start working on there I'm going to go

1110:21

ahead and create my model right here so

1110:23

I'll just use like model. TSX and use my

1110:27

rafc inside there copy the name of there

1110:30

and register that model right here just

1110:34

like that I'm going to go ahead and go

1110:36

to my model component and the first

1110:38

thing that we have to do is that we have

1110:39

to import um the motion from where from

1110:43

the framer motion now inside this model

1110:45

we're going to be creating our state

1110:47

like is uh open once again and then set

1110:50

is open and it's going to be set to the

1110:52

US St and then we have to set there two

1110:55

fils now I'm going to remove this model

1110:57

from here and I'm going to provide a bit

1110:59

of classes to this so I'll use like FX

1111:01

and also fle will be set to column and

1111:03

items will be set to tot the center and

1111:05

that's done next we have to Define our

1111:07

button and on this button it's going to

1111:10

say like open the model and now we have

1111:12

to provide the class name so I'll use

1111:14

like margin for the bottom will be set

1111:15

to four pairing all around will be set

1111:17

to two background will be set to Blue

1111:20

500 and text will be set to totally

1111:22

white rounded Cas when somebody try to

1111:24

click on this model or this button to be

1111:26

precise we're going to be firing this

1111:28

function and in this function we're

1111:30

going to be setting the is open flag to

1111:32

True okay so initially it's going to be

1111:34

set to false and we are now setting

1111:36

there to true if I click on this button

1111:38

nothing will happen so you know let me

1111:40

just the color of there to like crimsom

1111:42

500 or uh you know what change that to T

1111:46

500 or something like that yep you're

1111:48

now getting what K model button right

1111:50

here I'm going to collapse that and now

1111:52

underneath this button what we have to

1111:54

do we have to specify our model content

1111:57

so I'm going to go back and we have to

1111:58

check if we have the model like if this

1112:01

is true then we want to show this UI but

1112:03

if this is not set to true then we don't

1112:06

want to show this UI okay so I'll use

1112:08

like motion div right here so I'm going

1112:09

to use like motion and then set the to

1112:12

motion Dev okay and inside this motion

1112:16

we're going to be providing a lot of

1112:17

classes to this so I'll use like P and

1112:19

then insert will be set to zero and

1112:21

background will be set to totally black

1112:23

background opacity will be set to 50 and

1112:26

flex justify will be set to center items

1112:29

will be set to Center I'm going to say

1112:31

my file and inside there when somebody

1112:34

clicks on there so we're going to be

1112:35

fing this function once again it's going

1112:37

to say like set is open and you want to

1112:39

set the to false okay so that's going to

1112:41

be it for our model styling now inside

1112:43

there we're going to be defining our

1112:45

motion do once again and close them I'll

1112:47

also provide a bit of classes to this

1112:49

one so background will be set to totally

1112:51

white and pairing all around will be set

1112:53

to four totally rounded okay and yeah

1112:56

that's going to be it let me just save

1112:58

my file and inside this Dev what do we

1113:00

have to do we have to just write like H2

1113:02

which will say like model title and I'm

1113:04

going to also style there a bit I'll use

1113:06

like text only large font will be set to

1113:08

bold if I save there and test this out

1113:11

if I click on there here you can see

1113:13

it's going to gives us that background

1113:14

of gray and it's going to also gives us

1113:16

that model content right here but we

1113:18

have to change that to text only black I

1113:22

click on there once again we are now

1113:23

getting this model title we are not

1113:25

providing any animation to that right

1113:27

now we will do that in a few seconds I'm

1113:29

going to also provide a paragraph which

1113:30

will say like this is some random model

1113:33

content come on content here or

1113:35

something like that and now if I click

1113:38

on there once again still we have to

1113:40

change that to uh text toally black and

1113:44

s file click on there and now we are

1113:46

getting the model description as well

1113:49

now underneath this paragraph We are

1113:51

going to be creating a button which will

1113:52

just say like close the model and now

1113:55

you can also specify different classes

1113:56

today like margin for the top will be

1113:58

set to four pairing all around will be

1114:00

set to two background hold red of 500

1114:03

and text will be set to totly White

1114:05

rounded if I save there click on there

1114:08

once again and now we are getting this

1114:09

close button right here I click on this

1114:11

can also hide there now finally let's

1114:13

just Pro our animation right here okay

1114:16

so what I'm going to do is that I'm

1114:17

going to go here and provide my

1114:19

animation right here so when somebody

1114:22

clicks on that what we have to do we

1114:24

have to take this event object we have

1114:25

to use this event object and we have a

1114:27

stop propagation uh method on this so

1114:30

let's just use our stop propagation and

1114:32

execute them and also for the initial

1114:34

State what we have to do we have to use

1114:37

the y axis and on the y-axis we're going

1114:39

to be using like minus 100 VH okay and

1114:42

also we going to be providing the

1114:44

animate and when we want to animate this

1114:45

we're going to be changing the y- AIS to

1114:47

zero VP height and also on the exit prop

1114:50

we're going to be using the y axis and

1114:52

it's going to be set to 100 VH and let's

1114:55

just proide a bit of transitions today

1114:57

so I'll use like uh duration of 0.5

1115:00

seconds okay I'm going to save my file

1115:02

if I click on this it's going to show us

1115:04

this model if I click on the close oh we

1115:07

also have to attach this on click

1115:09

Handler on this one God damn it I'm

1115:12

going to use like set is open and set

1115:15

there to false uh yeah let's just set

1115:18

that to false so now if I click on there

1115:20

it's going to hide there from the UI you

1115:22

know what I'm going to wrap there in the

1115:23

animer presence component and let's just

1115:26

close there I'm going to cut there from

1115:29

there and place there right here okay so

1115:33

if I click on there it's going to show

1115:34

us this model and if I click on there

1115:36

once again so it's going to hide this so

1115:37

now that's looking better I'm going to

1115:39

click on the open model so it's going to

1115:41

open this model if I click on there once

1115:43

again it will make it disappear you can

1115:45

also click on there and click somewhere

1115:47

else it's going also hide there from the

1115:48

UI so that's our amazing model the next

1115:52

exercise will not be that much

1115:54

complicated so I'm going to zoom in a

1115:55

bit and what do we have to do we have to

1115:57

create a responsive animation so what do

1116:00

we have to do make a responsive button

1116:02

that animates on the click okay that's

1116:04

going to be very simple one write a

1116:06

button using the motion do button and

1116:08

then style it by using tman CSS or you

1116:10

can also use just a pure CSS then use

1116:13

the frame and motion while tap crop to

1116:14

animate the button when clicked so once

1116:17

we click on this we just want to scale

1116:18

it down a bit okay so we can also

1116:20

provide the how effect by using the

1116:22

while how if you want to give it a shot

1116:23

you totally can but yeah if you don't

1116:25

want to do that you don't even have to

1116:27

do that so what I'm going to do is that

1116:29

I'm going to Define my responsive

1116:30

button. TSX let's just use my RFC inside

1116:34

there and go ahead and go to my app and

1116:37

register this component right here like

1116:40

so so my file go ahead and go to our

1116:43

component and the first thing that we

1116:45

have to do is that we have to import the

1116:47

motion from where from the framer motion

1116:50

and now inside there let's just remove

1116:52

that from here and make there is a

1116:54

motion come on motion. D and inside this

1116:58

motion D I'm going to quite a bit of

1117:00

classes today so I'll use like pairing

1117:02

all around will be set to two and

1117:04

background blue will be set to 500 text

1117:06

will be set to totally white rounded and

1117:09

also we are going to be providing a

1117:10

transition transform the duration will

1117:13

be set to 300 and also so the e in and

1117:17

out inside there I'm going to save my

1117:19

file right now I'm going to say like

1117:21

click me save my file once again so if I

1117:24

click on then nothing will happen I'm

1117:26

going to also change the uh cursor to

1117:29

pointer and now let's just proide our

1117:31

animation so I'm going to be using like

1117:32

the while H when somebody H over there

1117:35

so you want to scale it up to like 1.1

1117:38

and when somebody tap on there like

1117:40

while tab so what do you want to do we

1117:42

just want to use the scale and provide

1117:46

uh

1117:47

0.9 scaling to there okay so if I H over

1117:51

there it's going to pop it up if I click

1117:53

on there it's going to pop it back okay

1117:55

so that was also our simple animation or

1117:58

responsive button whatever you want to

1118:00

call it now let's create the heart

1118:03

accordion component and I know a lot of

1118:06

you will love this one so what do we

1118:07

have to do we have to create an

1118:08

accordion component that expands and

1118:10

also collapse on the click create a

1118:12

component that renders a list of item

1118:14

each with a title and also with the

1118:16

content so you can use the motion. D to

1118:19

animate the height of the content you

1118:21

can use the tman CSS for The Styling or

1118:23

you can just use the pure CSS if you

1118:25

wanted to if you want to give it your

1118:27

best shot you totally can but if you

1118:29

don't want to do that you don't even

1118:30

have to do that so I'm going to be

1118:31

creating my accordion. TSX file and

1118:33

inside there let's just use what rafc is

1118:36

sell my file go ahead and register this

1118:39

component right here okay so I'm going

1118:41

to close there and the first thing that

1118:43

we would need is the motion from the

1118:45

frer motion okay so let's just use our

1118:48

frer motion next we would need some sort

1118:50

of items by which we can iterate over

1118:53

through so I'll use like con items or

1118:55

content whatever you want to call them

1118:57

we would need array and inside this

1118:59

array we would have a few objects I'll

1119:00

use like title and I'll say like um my

1119:04

you know what title one I'm going to

1119:07

also provide the content and content

1119:09

will say like this is content of item

1119:12

come on of item one and I'm going to put

1119:15

write a comma and duplicate there like a

1119:17

few times okay so then I'm going to

1119:20

change the two two and three and then

1119:23

four I'm going to also change the from

1119:26

the item one to two to three and four

1119:29

next we have to define or St so I'm

1119:32

going to be using like const uh open

1119:34

index and then set is or set open index

1119:38

rather it's going to be equals to the US

1119:40

St and the initial value will be set to

1119:42

now and now let me go ahead and go to

1119:43

the UI and remove from there and I'm

1119:46

going to provide a bit of classes xace

1119:48

on the xaxis or not the X but the y axis

1119:51

will be set to two inside then we have

1119:53

to iterate over through all of the items

1119:54

by using this map method we have to

1119:56

provide the item and also the index

1119:58

inside there and let's just iterate over

1120:00

through all of the items so I'm going to

1120:02

be using a div and I'm going to also

1120:03

close there like so and we also have to

1120:06

specify the key and the key will be

1120:08

coming from this index so now inside

1120:10

this div we're going to be first of all

1120:12

defining a button and this button will

1120:14

have a few class is all used like uh

1120:16

with of totally full and text will be

1120:18

set to left pairing all around will be

1120:20

set to two and background gray will be

1120:22

set to 300 fully rounded and focus it uh

1120:27

will be set to outline come on outline

1120:30

none this is say our file and inside

1120:32

this button we're going to be rendering

1120:34

our item. title when somebody clicks on

1120:36

this button we're going to be firing

1120:38

this function like when click this

1120:40

Aspire this function which is a toggle

1120:42

irm function which we are going to be

1120:43

creating in a few second it's going to

1120:45

be taking an index so now if I comment

1120:47

this line out and see so here you can

1120:48

see we are now getting a title one and

1120:50

so on and so forth so then set for the

1120:52

button I'm going to comment or hide

1120:54

there for a few seconds and now

1120:56

underneath this button we're going to be

1120:57

defining where motion. div okay so I'll

1121:00

just close there and inside this button

1121:03

we we're going to be creating our H1

1121:06

just create our H1 which will say like

1121:08

uh item do content and here we have to

1121:11

specify like pairing all around will be

1121:13

set to two backround will be set to 200

1121:16

and totally rounded yep you are also

1121:18

getting that I'm going to also change

1121:20

the text to totally black text is

1121:21

totally black and there or copy that

1121:24

from there go to my button and place

1121:27

that right here Yep this is looking cool

1121:29

I'm going to hide there for a few

1121:30

seconds and provide my animation to uh

1121:33

this H1 right here or you know what we

1121:36

not going to be providing our animation

1121:37

to this one we're going to be providing

1121:38

our animation on this motion day what

1121:40

the hell am I doing so let's just use

1121:42

our overflow first of all like overlow

1121:45

low will be set to toden and underneath

1121:48

we have to provide our initial State and

1121:49

the height will be set to zero first of

1121:52

all I'm going to also Prov the animate

1121:54

prop on this animate prop you're going

1121:56

to be setting the height two if the open

1121:58

index is triple equals to the index

1122:00

which we are now getting so in that

1122:02

situation we're going to be setting

1122:04

there to rrow if that's not the case

1122:06

we're going to be setting there to zero

1122:08

and on the transition we have to specify

1122:10

the duration of 0.3 seconds and finally

1122:13

let me just create this function

1122:15

and I'm going to uncom it there from

1122:17

here and create this function right here

1122:19

so I'll use like conle uh item and it's

1122:22

going to be equals to this function is

1122:24

going to take a index as a perimeter and

1122:26

I'm going to annotate that as a number

1122:29

like so and it set open index will be

1122:32

set to if the open index if that is

1122:35

equal to the index in that situation we

1122:36

want to set that to no but if that's not

1122:38

the case we want to set that to the

1122:40

index itself okay so you know what let

1122:43

me just inate there with any so that it

1122:45

doesn't gives us that errors and now I

1122:47

can click on there so it's going to show

1122:49

us this content I can also click on

1122:51

there so it's going to hide this content

1122:52

right here and they are looking super

1122:55

amazing you can totally modify the

1122:57

styling to whatever you want but in my

1122:59

case they are looking great now we are

1123:01

going to be creating a notification

1123:02

toaster so what we have to do we have to

1123:04

create a notification toaster that will

1123:06

slide in from the top and Trigger so

1123:09

yeah if you want to do that by yourself

1123:11

you can definitely go ahead and do that

1123:13

by yourself but now I'm going to give

1123:15

you my Solutions so I'll just create

1123:17

this component like toast notification.

1123:18

TSX file and I'm going to be using my

1123:21

rafc inside the s file and register that

1123:24

inside our app component so I'll just

1123:28

provide my tost notification and hit

1123:30

enter save my file and use my npm runev

1123:33

because I stopped the server I'm now

1123:35

re-recording this portion and here you

1123:37

can see we are now getting our tost

1123:38

notification which is looking amazing so

1123:41

I'm going to go ahead and go to my toast

1123:42

notification and the first thing that I

1123:44

want to do is that I want to grab my

1123:45

motion from where from the framer motion

1123:50

like so next we also have to create our

1123:52

visibilities all use like visible and

1123:55

also uh set v i s i b and it's going to

1123:58

be equals to what the hell it's going to

1124:00

be equals to this Us St and we have to

1124:03

specify the false as a state to there we

1124:05

already seen all of that stuff like a

1124:07

lot of time so I'm going to remove that

1124:09

from here and I'm going to style there a

1124:10

bit so I'll just provide like Flex and

1124:12

flex will be set to column and items

1124:14

will be

1124:15

set to Center like so inside there we

1124:17

have to Define our button and this

1124:19

button will have a classes like margin

1124:21

for the bottom will be set to four ping

1124:23

all around will be set to two background

1124:25

toally blue of 500 or you know what let

1124:28

me just change the two the teal of 500

1124:31

and I'm going to also put the text of

1124:32

totally white today and totally rounded

1124:35

so inside this button I'm going to say

1124:37

like show notifications I'm going to

1124:40

save this file and also when somebody

1124:42

clicks on there they're going to be

1124:43

firing this function which is a

1124:45

post right here so I'm going to copy the

1124:47

name of there and create this function

1124:50

right here so I'll use like con short

1124:52

tost and inside this function I'm going

1124:54

to say like set visible and set theory

1124:57

underneath that we're going to be also

1124:58

using a set timeout okay that was fast

1125:01

I'll just TR like 3,000 for a duration

1125:05

and inside there I'll just set the

1125:06

visibility to false yes I'm going to

1125:09

save my file and this is what we have to

1125:10

do right now I can also remove these

1125:12

curly braces from here if I wanted to

1125:14

yeah yep I can totally do that so now

1125:16

let me just save my file and this is now

1125:18

looking better now let's just go ahead

1125:19

and go to our UI and create our

1125:22

notification so I'll use like uh first

1125:25

of all or visibility so if that is

1125:27

visible then we want to show this

1125:28

content if that's not visible we don't

1125:30

want to show nothing at all so I'm going

1125:32

to be using like motion div and I'm

1125:34

going to close there like so I'll

1125:35

provide the classes like the class will

1125:37

be set to fix and also for the top will

1125:39

be set to four right will be set to four

1125:42

beiring all around will be set to four

1125:44

background p green of 500 text totally

1125:47

white and totally round it like so okay

1125:51

so I'll just say like notification an

1125:54

action

1125:55

successful or something like that if I

1125:58

save this file check this out so if I

1126:00

click on there it's going to show us

1126:02

this notification right here it will

1126:03

make it disappear like so so I'm going

1126:06

to also put a bit of Animation today so

1126:08

I'm going to be using like the frame and

1126:09

motion I'll just proide like for the

1126:11

initial State you want to change the

1126:13

opacity to zero and also the y AIS will

1126:15

be set to minus 20 I'm going to also put

1126:17

the animate prop on this animate prop

1126:20

can specify the opacity to one and also

1126:22

on the Y AIS we want to set there to

1126:24

totally zero now underneath there we can

1126:26

also provide the exit St when this is

1126:28

exiting so we want to set the opacity to

1126:30

zero and also on the Y AIS we want to

1126:32

set the bank to Z minus 20 okay and we

1126:34

also want to Prov a bit of transition to

1126:36

them so I'll just write like duration

1126:38

and duration will be set to 0.5 now let

1126:41

me save my file and click on there and

1126:43

here you can see it's going to give us

1126:44

that no ification right here it's going

1126:46

to make it disappear so what I'm going

1126:48

to do is that I'm going to wrap that

1126:50

inside the animate presence and now I'm

1126:53

going to close there like

1126:56

so I'll cut their animat present and

1126:59

I'll just put there right here oh we

1127:01

have to put the underneath there no like

1127:04

so now if I click on there so it's going

1127:06

to show this notification and then it's

1127:08

going to hide there like so you can

1127:10

totally change the UI you can totally

1127:12

change the animation and stuff like that

1127:14

but now our transformation challeng is

1127:16

totally complete welcome to the key

1127:18

frame practice so in this one we're

1127:20

going to be building amazing animation

1127:23

so yeah if you want to give it a try by

1127:25

yourself you can totally do that nobody

1127:28

is stopping you to do that but if you

1127:30

can do that here is how I would do that

1127:33

so what do we have to do first of all we

1127:34

have to create our bouncing ball so

1127:37

create a bouncing ball animation using a

1127:38

key frame so the first thing that we

1127:40

have to do is we have to create a simple

1127:42

circular div to represent a ball then we

1127:44

can use the frame on motion key frames

1127:46

to create a bouncing effect then we can

1127:48

style it by either using a tailman CSS

1127:50

or just using a CSS so you know what if

1127:53

you want to give it a try by yourself

1127:55

you can totally do that but here is how

1127:57

I would do that let's just create our

1127:59

components folder and inside there we're

1128:02

going to be creating our bouncing ball.

1128:03

TSX file and I'll use my RFC inside

1128:06

there sa that file and register there

1128:09

right here just like that I'll use this

1128:11

save my file and once again I restarted

1128:14

my computer comp because there was a

1128:15

problem in my OBS so you know what let

1128:18

me just refresh there and we are now

1128:20

getting there amazingly I'm going to

1128:21

also put a bit of stying to this one so

1128:23

I'll use like height will be set to

1128:25

screen and also Flex justify will be set

1128:27

to Center and items will also set to

1128:30

Center and background will be this

1128:32

colors all used like 0 D1 and then 017

1128:36

I'm going to save my file still we are

1128:39

getting that animation so I'll just use

1128:41

like text to I mean like not animation

1128:43

but that color so yeah that's looking

1128:45

cool now let's get into it the first

1128:47

thing that we have to do is that we oh

1128:49

my God my keyboard is getting super fast

1128:52

so you know what the first thing that we

1128:54

have to do is that we have to import the

1128:56

motion from the framer motion and now

1128:59

inside there we have to Define our div

1129:01

so I'll just remove that from here and

1129:02

now we are creating a circular box so

1129:04

I'm going to call my component like this

1129:06

or create my div like this I'm going to

1129:09

also provide the class names like the

1129:10

width will be set to 16 like so and also

1129:14

the height will be set to 16 and

1129:16

background will be set to totally yellow

1129:18

400 totally rounded and full I'll save

1129:21

this file and now let's just provide our

1129:22

animation today so I'll use like on the

1129:25

animate okay first of all you have to

1129:27

make the as a motion div so I'll use

1129:29

like motion don't D and then I'm going

1129:31

to proide the animate prop on there and

1129:33

inside this animate prop now we are

1129:35

going to be using our key frames so for

1129:37

the y axis we want to start from zero

1129:39

then we want to go to minus 100 and then

1129:42

we want to go back to the zero okay so

1129:45

this is how our key frame will look like

1129:47

now we can also specify different

1129:48

transition to there so I'll use like the

1129:50

duration will be set to 1 second we can

1129:52

also provide the repeat and it's going

1129:54

to repeat infinitely and also on the

1129:56

repeat type you want to use like Loop uh

1130:00

loop like so come on Loop and also we

1130:03

are going to be providing the easing and

1130:04

easing will be set to ease in and out

1130:07

like so now if I save my file and here

1130:09

you can see we are now getting this cute

1130:11

and amazing ball and that was our

1130:14

challenge or our practice number one

1130:16

next we're going to be creating our

1130:18

pulsing effects we have to create a

1130:19

pulsing effect on a button by using the

1130:21

key frames so we have to Define our

1130:23

motion. button then we have to use our

1130:25

key frame from the frame and motion to

1130:27

animate the scaling of our button and

1130:29

make it pulse and yeah you can also use

1130:32

the tman CSS or you can use just a pure

1130:35

CSS so you know what let's just start

1130:37

working on there I'm going to go ahead

1130:38

and Define my component right here which

1130:40

is a puling button. TSX so I'll use like

1130:43

RFC inside there and here I'm going to

1130:46

also register my component like so I'll

1130:49

just call this say my file and this is

1130:52

how it looks like and which is looking

1130:53

amazing once again the first thing that

1130:56

we have to do is that we have to import

1130:57

the motion from the framer motion and

1131:00

inside them I'm going to be refining my

1131:02

div so I'll just remove that from here

1131:04

and inside this one I'm going to make

1131:06

the as a button so I'll just select

1131:07

motion dot button and come on motion do

1131:11

button like so it's going to say like

1131:13

pulse now we we have to style there so

1131:15

for the styling we not going to be doing

1131:17

anything crazy but I'll just proide like

1131:18

pairing all around will be set to four

1131:20

and background will be set to totally

1131:22

green 500 text will be set totally white

1131:25

and rounded if I save there so this is

1131:27

how it's going to look like yep it is

1131:29

looking awful I know that now we have to

1131:32

specify our animation and also our key

1131:34

frames so inside this animate prop you

1131:37

want to scale so for the scale we want

1131:39

to start from one then we want to go

1131:40

into the 1.1 then finally we want to go

1131:43

back to the one so that's going to be

1131:45

forward animation I'm going to also

1131:46

specify the transition and for this

1131:48

transition we are going to be also

1131:50

providing that same transition like the

1131:51

duration will be set to one the repeat

1131:53

will be set to infinitely and also the

1131:56

repeat type will be set to Loop once

1131:59

again we want to Loop through them and

1132:02

then finally we have to use the easing

1132:04

so I'll use like ease and ease will be

1132:06

set to ease in and out say our file and

1132:09

yep we are now getting this dancing

1132:11

bouncing effect right here on our button

1132:14

that's cool let's go to the third one so

1132:16

what we have to do we have to create our

1132:18

color changer animation so we have to

1132:20

create a component that will change the

1132:22

color using the key frames so we have to

1132:24

Define our Square div that changes the

1132:27

color continuously and we have to use

1132:29

the key frames to Define multiple colors

1132:31

for our animation and we can style it by

1132:33

either using the tailin CSS or just a

1132:36

CSS so what I'm going to do is that I'm

1132:38

going to create my component right here

1132:40

and the name will be set to color change

1132:42

square. TSX and I'm going to be using my

1132:44

AR fce inside there go into the app and

1132:47

comment this line out and register my

1132:49

component right here this is how it

1132:51

looks like right now now the first thing

1132:53

that we have to do like always always we

1132:56

have to import the motion from where

1132:59

from the framer motion and inside there

1133:01

we have to define or D I'll remove that

1133:04

from here and I'm going to call it like

1133:06

so I'm going to provide the withd and

1133:08

width will be set to 32 height will also

1133:11

be set to 32 and inside there let's just

1133:13

s our animat

1133:15

I'm going to have to make that as a

1133:16

motion div so I'll use like motion. div

1133:19

now we can definitely use our animate

1133:21

prop on there and we have to specify the

1133:23

background color and on this background

1133:25

color we are going to be using our key

1133:27

Fram so I'll use like uh this color

1133:29

which is f f and then 0 0 or you know

1133:33

four zeros we're going to be also

1133:35

providing like hash 0 0 ff0 0 and we're

1133:39

going to be also using uh 00 0 0 0 FF

1133:43

and then we have to specify in 1 2 3 4

1133:47

zeros there going to be forward uh what

1133:50

do we call it Forward background colors

1133:52

we're going to be also providing a

1133:53

transition today so let's just provide

1133:55

our uh Transitions and on this

1133:58

transition we're going to be providing a

1133:59

duration of three and the easing will be

1134:01

set to linear and underneath we're going

1134:03

to be also providing the repeating and

1134:05

repeating will be set to infinitely

1134:07

let's just check this out and now we are

1134:09

getting their different colors so we are

1134:10

getting the teal uh crimson and also

1134:13

green yellow and sign and so on and so

1134:15

forth I'm going to go ahead and do the

1134:17

sliding text effect right now so what we

1134:19

have to do we have to create a text

1134:21

component that slides in from the left

1134:23

by using the key frames so we have to

1134:25

create our component I mean like text

1134:27

component and also we have to use the

1134:29

key frames to define the moment from

1134:30

offscreen to its final position and then

1134:33

we can style there by either using the

1134:34

telin CSS or just using a pure CSS this

1134:38

one is going to be super simple so we

1134:39

have to create our component and just

1134:42

Define our RFC inside there now we have

1134:46

to go into our app and register this

1134:48

component right here just like that just

1134:52

like that as Uncle Bob said just like

1134:55

that so we are going to be defining our

1134:58

component like so okay so let's just

1135:00

import our motion uh come on motion from

1135:03

where from our frer motion and also we

1135:06

have to create our H1 inside the so I'll

1135:08

just replace that with motion. H1 and

1135:11

this H1 will say like I don't know slide

1135:13

in text or something like that I'm going

1135:15

to change that to in and now we have to

1135:18

specify our classes all Ed like text to

1135:20

Excel and font will be set to B text

1135:22

will be set to totally white and I'm

1135:24

going to save this file this is how it

1135:26

looks like right here and now we have to

1135:28

specify our animations all use like on

1135:31

the initial State we want to start from

1135:32

the xaxis and the xaxis will be starting

1135:35

from 100% now you want to animate to uh

1135:39

the x-axis of zero and then finally we

1135:42

have to specify our Transitions and for

1135:44

for this transition we're going to be

1135:45

providing a duration of one say our file

1135:48

refresh there and here you can see our

1135:50

text will now slide in from the left to

1135:53

the right next we're going to be

1135:54

creating a zigzag animation and that's

1135:56

going to be a lot of fun so what we have

1135:58

to do we have to create a zigzag

1135:59

animation for a box moving across the

1136:02

screen so create a square box by using

1136:03

the motion DOD and then use the key

1136:06

frames to animate that box in a zigzag

1136:08

pattern then you can use a tailin CSS or

1136:10

just a CSS for The Styling and yeah you

1136:13

can give it your best sh if you wanted

1136:15

to but in my case I'm going to just

1136:16

create this component right here and

1136:18

I'll use my rafc go to my app and

1136:20

register there uh right in here oh my

1136:25

god let's just register

1136:27

there like like so okay so let's just go

1136:31

ahead and start working on that so the

1136:33

first thing that I want to do is that I

1136:34

want to import the motion from the frer

1136:38

motion inside there we are going to

1136:40

defining our D so I'll just remove there

1136:42

and I'm going to replace there as motion

1136:44

dot there like so and I'm going to close

1136:47

there next we have to specify the

1136:48

styling all used like width will be set

1136:50

to 16 and height will also be set to 16

1136:53

background will be set to totally green

1136:54

of 500 and now let's just provide our

1136:56

animation to it so for the animate class

1136:59

we're going to be providing key Fram so

1137:01

let's just start from the x-axis so you

1137:03

want to start from zero then you want to

1137:04

go to 50 then you want to start from

1137:06

zero then you want to go to the minus 50

1137:08

then you want to go to the zero once

1137:10

again on the y- axis we're going to be

1137:13

doing there once again so I'll just copy

1137:15

that and place that right here okay now

1137:18

underneath that oh I forgot to remove

1137:21

this minus From Here and Now underneath

1137:23

that we have to create our Transitions

1137:25

and for these transitions I'm going to

1137:27

proide a duration and duration will be 2

1137:29

seconds I'm going to also put the repeat

1137:31

and repeat will be uh come on let's just

1137:34

put a repeat and repeat will be set to

1137:36

infinity and I'm going to also proide

1137:38

the easing and for this easing let's

1137:40

just set that to ease in and out so save

1137:43

my file and let me just start there from

1137:45

scratch so here you can see we now

1137:46

getting this box and it is now animating

1137:49

as a zigzag animation so yeah that's

1137:52

also cool you can totally modify there

1137:54

and you can change the colors of there

1137:55

if you wanted to you can also change the

1137:57

Border radius and all of that kind of

1137:59

stuff if you wanted to but now let's get

1138:01

into the sixth one so what do we have to

1138:03

do we have to create our wave effect so

1138:05

create a wave effect using a series of

1138:07

boxes so first of all we have to define

1138:09

a series of boxes in a row then we have

1138:11

to use the key frames to animate each

1138:13

box with a slight delay to create a wave

1138:16

effect then we can use a tan CSS or just

1138:18

a CSS so what I'm going to do is that

1138:21

I'm going to Define my web effect. TSX

1138:24

file and I'm going to be using my rafc

1138:26

inside there and first of all we have to

1138:28

import the motion uh from the framer

1138:32

motion like so then we have to Define

1138:34

our boxes so I'm going to be using like

1138:35

con boxes it's going to be equals to

1138:38

array. from and here we have to specify

1138:40

the length and the length will be set to

1138:41

five now here inside the I'm going to

1138:43

remove the from here and I'm going to

1138:45

provide the class names of Le and also

1138:47

space will be set to xais of two inside

1138:50

this div we want it over through all of

1138:52

their boxes and now we want to use the

1138:53

map method on there we don't need the

1138:55

data but we do need the index and here

1138:59

I'm going to be using my motion. D and

1139:01

close there like so okay so now let's

1139:03

just start working on there the first

1139:05

thing that we want to do is we want to

1139:06

specify the index to there next we also

1139:09

want to provide a bit of styling so I'll

1139:10

use like withth will be 6 to 16 and

1139:12

height will also be set to 16 background

1139:14

will be set to purple and uh purple 500

1139:18

and now underneath this is animate so

1139:20

for the animation you want to set the Y

1139:22

value to start from zero and then go to

1139:25

minus 20 and then go to the zero so

1139:28

that's going to wait for the key frame

1139:30

and now let's just put a bit of

1139:31

transition to there so I'll use the

1139:33

transition and inside this transition

1139:35

you have to specify the duration of 0.6

1139:37

I'm going to also put the repeat value

1139:39

and set that to Infinity repeat type uh

1139:42

repeat type will be set to reverse

1139:46

because we want to reverse it out and

1139:48

also provide a delay to there so I'll

1139:50

use like index time 0.1 now that's it

1139:53

now let me just go ahead and refresh

1139:55

there I guess I didn't I you know let me

1139:58

just copy there and go ahead and go to

1139:59

my app okay we have to comment this line

1140:02

out and we have to render our component

1140:04

like so so here you can see we're now

1140:06

getting the zigzag animation so now let

1140:08

me just refresh there and now we I mean

1140:10

like not a zigzag animation but our wave

1140:13

effect so you you can also change the

1140:14

Border radius of there you can also

1140:16

change the colors of there you can also

1140:18

move the around you can do a lots sort

1140:20

of stuff with there but in my case

1140:22

that's going to be it so yeah what do we

1140:24

have to do next for the final one we

1140:26

have to create our background animation

1140:28

create a background that changes the

1140:30

color using a key frames so we have to

1140:32

create a full screen D that acts as a

1140:34

background and we can use the key frames

1140:36

to animate that background color through

1140:38

multiple colors and we can style there

1140:40

by using either ailment CSS or just a

1140:42

pure CSS to ensure covers the entire

1140:44

screen I'm going to create my component

1140:46

right here inside this components folder

1140:49

with the name of animated background.

1140:51

TSX now I'll use the rafc and go ahead

1140:54

and register there right here just like

1140:57

that as soon as I registered there we

1140:59

are now getting our animated background

1141:01

which is looking cool so now let me go

1141:03

into this component and start working on

1141:05

the so I'll use like uh import the

1141:08

motion uh from where from the framer

1141:11

motion I'm going to remove this text and

1141:13

convert it two is a motion Dev so I'll

1141:16

use like motion. D I'm going to also

1141:18

specify the class name and the width

1141:19

will be set to screen the height will

1141:21

also be set to screen and inside there

1141:24

we have to provide the animate prop and

1141:25

on this animate prop we going to be

1141:27

providing or key frames or use like the

1141:29

background color it's going to be set to

1141:31

this background color so let's start

1141:33

from this one and background colors are

1141:35

going to be set to these colors now

1141:37

underneath that we also have to specify

1141:39

the transition so I'll use like the

1141:41

Transitions and for this transition we

1141:43

have to spe specifi duration of five or

1141:45

5 Seconds rather and the easing will be

1141:47

set to linear in this case and also we

1141:50

have to provide the repeat and set there

1141:52

to Infinity I'm going to save my file

1141:55

check this out so here you can see we

1141:56

are now getting this Dev or background

1141:59

color animation or whatever you want to

1142:01

call that and that's also looking cool

1142:04

so yeah we build a lot of stuff in this

1142:06

project or not a project but a lot of

1142:08

Animation so now let me just show you

1142:10

all of them in action so we created The

1142:12

Bouncing animation the Ping button and

1142:14

also the color changer the sliding text

1142:16

and zigzag and also the web

1142:19

animations this is super amazing yeah

1142:22

that's super amazing welcome to the

1142:24

variance practice SL challenge whatever

1142:27

you want to call that so what do we have

1142:29

to do the first thing that we have to do

1142:30

is that we have to create a simple fed

1142:32

in component then we have to create our

1142:34

navigation menu with the slide animation

1142:37

then we have to create a tool tip with

1142:38

variants and also you have to create a

1142:40

Toggler switch or Toggler whatever you

1142:43

want to call it Toler switch there we go

1142:45

so then we have to create a progress bar

1142:47

animation and finally we have to create

1142:49

our Dynamic list animation so let's

1142:51

start from the first one so create a

1142:52

component that feds in when it appears

1142:55

Define a variant for the FED in effect

1142:57

create a motion. d that uses that

1142:59

variant then you can use either the

1143:00

tailin CSS or just a CSS for The Styling

1143:03

I'm going to go ahead and create my

1143:05

components uh folder right here

1143:07

components and inside them we're going

1143:09

to be defining our fed in component. TSX

1143:12

now I'll use my AR fce inside there go

1143:15

ahead and go to my app and register

1143:17

there right here so I'll use like fairin

1143:19

component and close there like so I'm

1143:23

going to save this file and now let me

1143:24

also provide a bit of styling like it

1143:26

will be set to screen legs and also

1143:29

justify will be set to Center and items

1143:31

will also be set to Center and

1143:33

background will be this color so we have

1143:35

0 d10 17 Close there and this is how it

1143:39

looks like I'm going to also provide the

1143:40

text of toly white today and that's

1143:42

looking cool first thing that we have to

1143:44

do is that we have to Define I mean like

1143:46

we have to grab the motion from where

1143:49

from the let's just grab the motion from

1143:52

the frame or motion there we go next we

1143:55

have to remove the and pride our H2

1143:57

which will also have the text off come

1143:59

on H2 with the class of text only wi

1144:03

there we go wi there we go and I'm going

1144:06

to say fed in component sa our file

1144:09

check this out so now we are getting our

1144:10

F in component I'm going to also provide

1144:12

a bit of classes to this D so I'll use

1144:14

like class name of background totally

1144:16

blue 500 and pairing all around will be

1144:19

set to four totally rounded and Shadow

1144:21

check this out so we now getting our

1144:23

kind of a button or whatever you want to

1144:25

call there now we have to Define our

1144:27

variants I'm going to create my variant

1144:29

separately and you can definitely

1144:30

provide the inside your Dev so I'll use

1144:33

like con fed in variance it's going to

1144:36

be set to this object inside then we

1144:38

have to define the hidden property and

1144:40

when it is hidden so we want to change

1144:41

the opacity to zero and when it is

1144:44

visible so in this situation we're going

1144:45

to be changing the opacity to one as

1144:48

simple as this so now let's just use

1144:49

that right here first of all we have to

1144:51

convert that to the motion. div and now

1144:54

we can definitely use that right here so

1144:56

I'll use like the variance and I'm going

1144:58

to go ahead and copy this variable name

1145:01

and place that right here which means

1145:02

like I can now use the hiden prop and

1145:04

also the visible one I'm going to

1145:06

provide the initial State and for this

1145:08

initial State we're going to be using

1145:09

our Heron which we Define right here I'm

1145:12

going to also use the animate and when

1145:14

it is on the animate we going to be

1145:16

setting that to visible I'm going to

1145:18

also provide a transition and for this

1145:20

transition we want to provide a duration

1145:21

and duration will be set to 0.5 just

1145:24

like that check this out and now let me

1145:26

just refresh there and here you can see

1145:28

we are now getting this fed in and also

1145:30

fed out okay that's amazing I can also

1145:32

change that to like 2 seconds maybe and

1145:34

now if I refresh there now this is

1145:36

looking better let's start work on the

1145:38

second one so which is create a

1145:40

navigation menu with the slide animation

1145:43

so what we have have to do we have to

1145:44

create a navigation menu that slide in

1145:46

from the side so we have to define a

1145:48

variant for the open and close St for

1145:50

the menu we can use the motion. D for

1145:53

the menu and we can also use like either

1145:55

the T CSS or just a CSS for The Styling

1145:58

so yeah if you want to give it your best

1146:00

shot you can definitely go ahead and do

1146:01

that but in my case I'm going to Define

1146:03

my slide in or sliding menu. TSX file

1146:07

I'm going to be using the RFC our file

1146:09

and registered there right here inside

1146:11

our app so I'll use like slide

1146:14

and just registered there right

1146:16

here this is how it looks like right now

1146:19

let's just go ahead and start working on

1146:20

there the first thing that we have to do

1146:22

is that we have to grab the motion from

1146:25

where from the framer motion next we

1146:27

have to Define our state so I'm going to

1146:28

be using like uh is open and then set is

1146:32

open this going to be equals to the U St

1146:34

and provide your false value for the

1146:36

initial State that's also done I'm going

1146:39

to remove that from here and inside

1146:41

there we're going to be creating our

1146:42

button and for this button we going to

1146:44

be providing like pairing all around

1146:46

will be set to two background will be

1146:47

set to gray of 500 text will be set to

1146:51

totally white and when somebody try to

1146:53

click on there we're going to be firing

1146:55

this function which is a set is open and

1146:57

set that to not set is open so I'm going

1147:00

to save this file and for the text we're

1147:02

going to be providing like toggle menu

1147:04

if I save there this is how it looks

1147:06

like right here and you know what I'm

1147:08

going to also make the bit rounded so

1147:10

use like rounded SM yep that's looking

1147:13

cool or you know what we don't have to

1147:15

do that okay so I'm going to remove that

1147:16

from here next I'm going to collapse

1147:18

that and we have to Define our

1147:20

navigation menu so I'm going to be using

1147:22

uh D and now inside this D you know what

1147:25

first of all let me just put a bit of

1147:26

styling to there so I'll use like for

1147:28

the class name I'm going to set there to

1147:30

fixed will be set to zero lift will be

1147:32

also set to zero width will be set to

1147:35

64 and the height will be set to totally

1147:38

full background will be set to totally

1147:40

blue of 600 and inside that we have to

1147:43

Define our UL with the class of pairing

1147:45

all around will be set to four text will

1147:47

be set to totally white inside the let's

1147:49

just proide our Li which will have the

1147:51

text of home then about and then finally

1147:55

the contact right here so if I save

1147:57

there here you can see we are now

1147:58

getting this amazing

1148:00

sidebar but yeah you get the idea it's

1148:03

not the most cool looking sidebar but

1148:05

you get the idea next we have to Define

1148:07

your menu variant so I'm going to go

1148:09

ahead and Define my menu v a r i a n TS

1148:13

and here we have to specify the open

1148:15

when it is open so we want to set the x

1148:17

value to zero and when it is closed so

1148:20

we want to set the x value 2 minus 100%

1148:25

that's what we have to do right now I'm

1148:27

going to go ahead and apply that on this

1148:29

Dev first of all we have to convert that

1148:31

to the motion. div also change this one

1148:34

to the motion. div like so and we are

1148:37

going to be using our variance right

1148:39

here so I'll use like not a viewport but

1148:41

a variance and variance will be set to

1148:43

this menu variant and which means like I

1148:46

can now use the initial prop and this

1148:48

can be set to the close and also I can

1148:50

animate and we're going to be using a

1148:52

JavaScript tary right here so is open if

1148:55

it is open so in there come on is open

1148:59

so if it is oh you know what we are

1149:02

providing a double quote so that's why

1149:04

okay so now if this is open in that

1149:06

situation we want to set there to open

1149:08

but if that's not the case we want to

1149:10

set there to close underneath there I'm

1149:12

going to also put a bit of transitions

1149:13

today so I'll use like

1149:16

transition and on this transition you

1149:18

want to provide the duration and

1149:19

duration will be set to 01 three check

1149:22

this out so now if I click on there it's

1149:23

going to show this sidebar if I click on

1149:25

there once again it's going to hide

1149:27

there and that's looking somewhat of

1149:30

cool maybe yeah I wouldn't call it cool

1149:33

but yeah we are getting this amazing

1149:34

animation by using our variants next we

1149:37

have to create a tool tip with variant

1149:39

so create a tool tip that appears and

1149:41

disappear with the FED effect so what we

1149:43

have to do we have to define a variant

1149:44

for the visible and here instead of the

1149:46

tool tip we can use the motion. D for

1149:49

the tool tip and we can also provide a

1149:50

styling by using either detailin CSS or

1149:53

just a pure CSS so I'm going to go ahead

1149:55

and create a component with the name of

1149:57

tool tip. TSX and let's just Define our

1150:00

tool tip inside there go ahead and

1150:02

comment this line out and Define our

1150:04

tool tip right here say our file go

1150:06

ahead and go to the tool tip and grab

1150:08

the motion from the frer motion like so

1150:13

first thing first we have to Define our

1150:15

state so I'll use like v i s i and then

1150:18

set v i s i e this going be equals to

1150:21

the UST and N scroll US state and for

1150:24

the initial value we're going to be

1150:26

setting there to false now let's take

1150:27

care of our UI so I'm going to remove

1150:29

them and provide a bit of classes today

1150:31

so the class will be set to relative and

1150:33

inline and Block B and OC the like so

1150:38

inside there we're going to be defining

1150:39

our button which will say like how over

1150:42

me or something something like that I'm

1150:44

going to also put the classes for this

1150:46

one so pairing all around will be set to

1150:47

two background totally blue of 500 text

1150:51

will be set to totally white like so now

1150:53

I'm going to attach two event handlers

1150:54

so which means like when somebody Mouse

1150:56

enter so in this situation we going to

1150:59

be firing this function which is a set

1151:00

visible and set that to true and also

1151:03

we're going to be providing like when

1151:05

somebody Mouse leaves so then we're

1151:07

going to be still firing that same

1151:09

function but we going to be changing the

1151:11

value to false okay that's set for this

1151:13

button I'm going to collapse there and

1151:15

now underneath this button we have to

1151:17

Define our data so if this is visible so

1151:20

in that situation we are going to be

1151:21

showing this data so I'll use like

1151:23

motion. div and close there and it's

1151:26

going to say like come on two two and

1151:30

then tip God damn it tool tip there we

1151:34

go tool tip content or something like

1151:36

that so if I H my mouse over to there so

1151:37

it's going to show us that tool Tab and

1151:39

if I leave it back so it's going to hide

1151:41

there now I'm going to go ahead and

1151:42

Define my variants so I'll just Define

1151:45

the right here I'll give the name of

1151:47

like tool ship variant or something like

1151:51

that and when it is hidden we're going

1151:53

to be changing the opacity to zero and

1151:55

on the y- axis is going to be set to

1151:57

minus 10 and I'm going to duplicate that

1151:59

and change that to

1152:01

SI and set there to one instead of

1152:04

providing a minus we have to set there

1152:06

to only zero I'm going to copy the name

1152:08

of that go to our tool tip Dev and here

1152:11

I'm going to be using them let's is pro

1152:13

our variant n viewport variants and set

1152:16

there to this tool tip variant now

1152:18

underneath them we have to use the

1152:20

inline why am I saying in line initial

1152:23

State and for this initial State we want

1152:25

to set that to heren and when it is

1152:27

animating so we're going to be setting

1152:28

that to v i for the visible St we're

1152:31

going to be also providing an exit prop

1152:33

and when it is exit so we want to set

1152:35

that to Hidden I will also provide a bit

1152:37

of transitions to this so for these

1152:39

transitions I'll provide a duration of

1152:42

0.2 seconds right here I'll also put a

1152:45

bit of classes like uh absolute a b s o

1152:48

l u t e background will be set to gray

1152:50

of 700 and also text will be set to

1152:54

totally white ping all around will be

1152:55

set to two totally rounded let me just

1152:57

save our file test this out so if I H my

1153:00

mouse over to there it's going to give

1153:01

us that tool tip but if I leave it back

1153:03

it's going to hide there and as you can

1153:05

see it is not looking that much cool but

1153:08

yeah we are getting this tool tip or you

1153:10

can say or animated tool tip right here

1153:13

that's also done what do we have to do

1153:15

next we have to create our toggle switch

1153:18

animation and that's going to be a lot

1153:19

of fun so create a toggle switch that

1153:22

animates between the on and also on the

1153:24

off start then we have to define a

1153:26

variant for the on and also for the off

1153:28

position on the switch so you can use

1153:30

the motion. D to represent the switch

1153:32

and you can use the tailin CSS or just a

1153:34

CSS for The Styling let's just do that

1153:37

I'm going to create a toggle switch. TSX

1153:40

file and Define my R fce inside there

1153:43

save there and go ahead and register

1153:45

there right here inside our app so I can

1153:47

use a toggle switch go ahead and go to

1153:49

this toggle switch and grab the motion

1153:53

from the framer motion like so next we

1153:56

have to Define our stat all use like is

1153:58

open and then not open but is on and

1154:01

then set is on it's going to be equals

1154:04

to this US state and the initial value

1154:06

will be set to false underneath there

1154:08

we're going to be taking care of the UI

1154:10

so I'll just remove there and provide a

1154:11

classes to there to relative and also

1154:14

inline block and width will be set to 36

1154:17

and the height will also be or you know

1154:19

what the height will be set to 16 inside

1154:22

this div we're going to be defining our

1154:23

own div and which will have the class

1154:26

name of uh you know we're going to be

1154:27

providing a dynamic classes for there so

1154:29

we can use like the WID will be set to

1154:31

totally full the height will also be set

1154:33

to full totally rounded one rounded and

1154:36

then full background will be set to tot

1154:38

gr of 300 like so and cursor will also

1154:41

be set to point now we can render over

1154:44

State totally dynamically so I can use

1154:46

like you know first of all let me just

1154:48

save there and I can make a bit of room

1154:50

and now I can use like if is open which

1154:54

is our state like if our state is set to

1154:56

open if that is set to true what do you

1154:59

want to do you want to change the

1155:00

background to totally green of 500 but

1155:03

if that's not the case you want to set

1155:04

that to empty string okay and I'm going

1155:07

to also provide the on click when

1155:08

Handler on there so when somebody try to

1155:10

click on there you're going to be firing

1155:12

this function which will say like set is

1155:13

on and set there to is on like so and

1155:16

you know what let me just show you there

1155:18

so this is how it looks like right here

1155:20

but inside there we have to create our

1155:22

ball okay not my balls but we have to

1155:25

create our ball so I'm going to be using

1155:27

like motion div and close there like so

1155:30

I'm going to put a bit of classes today

1155:32

like absolute top will be set to one

1155:34

left will be set to one withd will be

1155:36

set to 14 height will also be set to 14

1155:39

totally rounded and background will be

1155:41

set to totally white shadow like so

1155:44

inside this D we have to provide our

1155:45

animations but before I provide the

1155:47

animations I'm going to go ahead and go

1155:49

to the top and create my variance right

1155:51

here so I'll use like cons switch uh

1155:54

variance and it's going to be equals to

1155:55

this object we can put the off St and

1155:58

when it is off so we can set that to

1156:00

zero and also on the on St let me just

1156:03

change that to the on you want to set

1156:05

that to 70 now that's already done I'm

1156:08

going to copy the name of that and

1156:10

provide my animations right here so

1156:12

let's just use our variants and here we

1156:14

have to specify our switch variant and

1156:16

on the animate we want to set there

1156:18

totally dynamically so which means like

1156:20

we're going to be using only one curly

1156:22

braces if our St is set to open or on

1156:25

you want to Pride the on St if that's

1156:28

not the case so you want to set that to

1156:29

off I'm going to also put a bit of

1156:31

transitions right here and for this

1156:33

transition we're going to be setting the

1156:35

type to toly Spring one of my favorite

1156:38

animation type and the stiffness will be

1156:41

set to 300 like so so and here you can

1156:44

see we're now getting our ball now if I

1156:46

click here so it's going to move it

1156:47

right here if I click on there it's

1156:49

going to move it there so this is how we

1156:51

going to be creating our basic animated

1156:53

Toggler you can also change the

1156:55

transition of there if you don't like

1156:57

that but in my case that's looking super

1156:59

amazing so yeah that's number I don't

1157:02

know whatever number there that's number

1157:04

four there we go all right guys so

1157:06

welcome to the gesture based practice

1157:08

animation so in this one we're going to

1157:10

be building amazing gesture based

1157:12

animation so first of all we're going to

1157:13

be creating a swappable card then

1157:15

dragable box then rotate on drag also

1157:18

tap to change the color long press to

1157:20

change size and finally we're going to

1157:22

be building a gesture based image

1157:24

gallery so now let start from the first

1157:26

one which is a swappable card so how are

1157:28

we going to be doing there and what

1157:29

exactly we're going to be doing first of

1157:31

all we have to create a card that can be

1157:33

swapped to the left or to the right to

1157:35

remove it from The View first we have to

1157:37

create a motion. d to represent the card

1157:39

then we can use the frame or motion drag

1157:41

prom to detect the swap gesture finally

1157:43

we have to animate that card position

1157:45

based on a swap so if you want to give

1157:47

it your best shot you definitely go

1157:49

ahead and can do that but you know what

1157:51

here is how I would do that I'm going to

1157:53

create a component folder and inside

1157:55

there we're going to be creating

1157:57

swapable card. TSX and let's just use

1157:59

our RFC s there and go to our app and

1158:02

register there right here so we are

1158:04

going to be using a swapable card say

1158:07

our file and this is how it looks like

1158:09

right here I know it is not looking that

1158:11

great but we are going to be making it

1158:13

great right now so I'll use like heart

1158:16

will be set to to the screen flex and

1158:17

justify will be set to Center and items

1158:20

will also be set to center background

1158:22

will be set to this color which is 0 D1

1158:25

017 close this s our file this is how it

1158:28

looks like I'm going to also provide the

1158:29

Toft toally white to there and yep now

1158:32

that's looking cool so I'm going to go

1158:34

ahead and start working on there the

1158:35

first thing that we have to do is that

1158:37

we have to import the motion from where

1158:39

let's just use the motion from where

1158:41

from the framer mod motion now inside

1158:44

there we have to Define our set so I'll

1158:45

use like is removed and then set is

1158:48

removed and it's going to be equals to

1158:50

this Us St and the initial value I'm

1158:53

going to set there to false now let's

1158:55

define our div so what I'm going to do

1158:57

is that I'm going to write like swipe me

1159:00

or something like that and I'm going to

1159:01

also provide a bit of styling to this so

1159:03

I'll just say like class name and we're

1159:05

going to be also using the dynamic

1159:07

classes so I'll use like with will be

1159:09

set to 64 and the height will be set to

1159:12

32 and background will be set to Blue

1159:14

500 totally rounded come on rounded

1159:18

large and we're going to be also

1159:20

providing a shadow of totally large F

1159:22

and items will be set to totally Center

1159:25

justify come on justify oh my God

1159:27

justify will also be set to Center and

1159:30

text will be also set to totally white

1159:32

so now let me just save my file this is

1159:33

how it looks like right here now we are

1159:36

going to be also providing our state

1159:38

right here so what I'm going to do is

1159:40

that I'm going to render that only

1159:41

dynamically so I'll use like if this is

1159:43

removed so if that's the case we're

1159:45

going to be using the hidden prop but if

1159:47

that's not the case we are going to be

1159:49

setting there to empty string so now let

1159:51

me just save my file I'm going to also

1159:53

attach the event handler which will say

1159:55

like on drag and and it's going to be

1159:57

equals to this handle swipe I'm going to

1160:00

copy the name of that and create this

1160:02

function right here so I'll use the cons

1160:04

handle swipe and it's going to take two

1160:07

perimeters so it's going to take like

1160:08

the data we are not interested in there

1160:10

I'm going to also annotate there as any

1160:12

prop and I'm going to also put the info

1160:14

and info can be a string or you know I'm

1160:17

going to also set there to n What The

1160:19

Hell Or Not N but just any okay so now

1160:21

let's just check if you have the info.

1160:24

offsetx value if that is greater than

1160:27

100 so in that situation we're going to

1160:29

be using like set is removed and we're

1160:32

going to be setting there to true and

1160:33

which means like if we uh swipe there to

1160:37

the right then you want to remove there

1160:40

okay swipe right to remove but if then

1160:42

not the case we're going to be also

1160:44

providing yet another check which will

1160:45

be a info. offset dox value if there is

1160:49

less than minus 100 in that situation

1160:52

we're going to be still using like set

1160:54

is removed and we're going to be setting

1160:55

that to true in that case okay so now

1160:57

let me just save my file now let me also

1160:59

provide the drag and drag will be set to

1161:02

you know first of all we have to make

1161:03

the as a motion div so I'll use like

1161:05

motion. div and now I'm going to use my

1161:08

drag and we are going to be setting that

1161:11

to the x-axis only I'm going to also

1161:13

provide the drag constraints and for

1161:15

these drag constraints I'm going to

1161:16

provide the left value and left value

1161:18

will be set to minus 100 and the right

1161:20

value will be set to only 100 oh this

1161:23

should be

1161:24

motion. there okay so I'll just remove

1161:27

this semi file check this out so I can

1161:29

only swap it to the left and also to the

1161:31

right so if I do this it's going to

1161:33

remove that from The View and here you

1161:35

can see if I just swap it right here and

1161:37

leave my cursor bang it's gone now let

1161:40

me try there once again so if I just put

1161:42

the right here or r that right here is

1161:44

going to remove them from the Dom so

1161:46

yeah this is our simple swap component

1161:49

that we wanted to create so now let me

1161:51

just remove that and now next we're

1161:53

going to be working on the dragable box

1161:55

so what we have to do we have to create

1161:57

a box that can be draggable around the

1161:59

screen okay so we have to use like

1162:01

motion. d and we have to use the frame

1162:03

on motion drag Pro for the functionality

1162:05

and also we can either use the tailman

1162:07

CSS or we can just use a Pure CSS that's

1162:09

going to be quite simple and easy so I'm

1162:11

going to go ahead and create this

1162:12

component right here with the name of

1162:13

dragable box. TSX and let's just use our

1162:16

RFC inside there I'm going to register

1162:19

there right here inside my app so I'm

1162:20

going to comment that line out and grab

1162:22

my dragable box and close it here you

1162:24

can see we're now getting there which is

1162:26

looking cool the first thing that I want

1162:27

to do is that I want to grab the motion

1162:30

uh m o t i o n motion from where from

1162:33

the framer motion that's going to be the

1162:35

first thing next we have to remove this

1162:37

drag will box and I'm going to say like

1162:39

drag me or something like that now also

1162:42

so change that to the motion. div so

1162:44

I'll use like motion. div now we provide

1162:46

a bit of styling to this so I'll use

1162:48

like with will be set to 32 it will also

1162:50

be set to 32 background will be set to

1162:52

totally green 500 and totally rounded

1162:55

large and Shadow will be also set to

1162:58

large and this is how it looks like

1163:00

right here so you know what let me just

1163:01

provide my animation so I'll use like

1163:03

the drag and I'm going to also provide a

1163:06

drag constraints right here so for these

1163:08

drag constraints I'm going to set the

1163:09

left value to zero and the right value

1163:12

will be set to 300 not 1,000 but 300 on

1163:15

the top we going to be setting there to

1163:16

zero on the bottom we are going to be

1163:18

setting there to 300 so now let me just

1163:20

save there and we can drag that to the

1163:22

left to the right and also to the top

1163:25

and also to the

1163:26

bottom okay so yeah this is how it looks

1163:30

like and I can totally remove that also

1163:32

remove that one and provide my closing

1163:35

tag Yep this is looking better we can

1163:38

also change the color of there to like

1163:40

uh Crimson or cyan

1163:43

and come on sign there we go and yeah it

1163:46

is looking kind of cool but yeah this is

1163:48

how it looks like next we have to create

1163:51

the rotate on drag so what do we have to

1163:53

do we have to create a box that rotates

1163:55

when we drag there so we have to use

1163:57

motion. div to represent a box we have

1163:59

to use the own drag event to calculate

1164:01

the rotation angle then we have to

1164:03

animate the rotation of the Box based on

1164:05

the drag moment so you know what let's

1164:07

just start working on that I'm going to

1164:08

go ahead and create my component with

1164:10

the name of rotate on Dragon do TS6 and

1164:13

let's just use our RFC inside there go

1164:15

to the app come and this line out and

1164:17

render the right in here save this file

1164:20

and here you can see we now getting this

1164:22

text which means like everything is

1164:23

working the way we expect him to work so

1164:25

I'll just go to the top and import my

1164:27

motion from where from the framer motion

1164:31

next we have to Define our rotation so

1164:33

I'll use like uh rotation and then set

1164:36

rotation it's going to be equals to the

1164:38

UST State and the initial value will be

1164:40

set to zero and now we have to make make

1164:42

there as a rotatable box so I'll just

1164:44

change that to the motion. div and here

1164:47

we have to specify the you know let me

1164:49

just hit enter right here drag and also

1164:51

we have to use our own drag event and

1164:53

here we're going to be passing our

1164:55

handle drag which we're going to be

1164:56

creating in a few seconds so you know

1164:58

what let's just do that I'm going to

1164:59

copy the name of that and Define this

1165:01

function right here so I'll use like

1165:03

const and then handle drag it's going to

1165:05

take event as an object so I'm going to

1165:07

just inate there with any for now also

1165:09

it's going to take the info and I'm

1165:10

going to also inate there as any so

1165:12

inside there we're going to be using our

1165:14

new rotation it's going to be set to

1165:17

rotation times the info do offset do x

1165:21

value so basically these are just the

1165:23

calculation of the rotation based on our

1165:26

drag okay so I'll just provide the four

1165:28

rotation state so I'll use like new

1165:30

rotation and I'm going to save this file

1165:33

okay so we don't need the you know I'm

1165:36

going to just WR there and annotate with

1165:39

any now this looking better I'm going to

1165:41

go ahead and bit of styling today so

1165:43

I'll use like class name and width will

1165:45

be set to 32 he will also be set to 32

1165:48

background will be set to totally red of

1165:50

500 all rounded large and flex items

1165:54

will be set to Center justify will also

1165:57

be set to center it's it's going to say

1165:59

like drag me or something like that let

1166:01

me check this out so if I drag there it

1166:04

is not rotatable so we have to provide

1166:06

our style so for this style I'm going to

1166:09

be setting the root head property to the

1166:12

rotation which is coming from our St

1166:15

right here I'm going to test this out so

1166:18

if I drag there here you can see it is

1166:19

now rotating I know the rotation is a

1166:22

bit funky but yeah this is what it is

1166:24

I'm going to also provide a bit of uh

1166:26

duration to this so I'll use like

1166:28

transition and here I'm going to Define

1166:30

my duration and duration will be set to

1166:32

maybe 3 seconds okay and now let me just

1166:34

refresh there and

1166:37

still we are getting that super fast but

1166:40

yeah you get the idea so that's also

1166:42

cool so let's just remove that line of

1166:44

code and next we have to create our tab

1166:46

on change color so create a box that

1166:48

changes the color when we tap on it so

1166:51

create a motion. for the box and then

1166:53

use the own tap event to change the Box

1166:56

color you can either use a t CSS or just

1166:58

CSS for the classes I mean like for the

1167:00

styling so yeah let's just work on there

1167:03

I'm going to go ahead and Define my

1167:04

component right here with the name of T

1167:06

to change color. TSX and I'm going to be

1167:09

using my rafc inside there let's just go

1167:12

into the app comment this line out and

1167:14

register my component right here I'm

1167:17

going to go ahead and first of all we

1167:18

have to import the main thing which is

1167:21

the motion object from where from the

1167:23

framer motion next we have to Define our

1167:25

colors so this is how our color will

1167:27

look like so we have a blue green red

1167:30

and also the yellow color which are the

1167:32

TN CSS classes next we have to Define

1167:35

our color state so I'm going to be using

1167:37

like color uh index and then we have to

1167:39

set that to the set color index and it's

1167:43

going to be equals to the use St and

1167:45

here we have to annotate that or provide

1167:47

value of zero to the I'm going to remove

1167:49

that from here and change that to T me

1167:52

and pro and change that to the motion. D

1167:55

I'm going to be providing a classes so

1167:57

use like class names and we're going to

1167:59

be rendering our classes to dynamically

1168:01

so use like withth will be set to 32

1168:03

will also be set to 32 and let's just

1168:05

render our colors I'm going to be using

1168:07

like uh colors you know what we have to

1168:10

get their colors God damn it so I'll use

1168:13

like colors and then color index we're

1168:15

going to be providing there right here

1168:16

so essentially these colors are coming

1168:18

from these main colors and now we are

1168:20

providing a specific index to them so

1168:22

which means like it's going to start

1168:24

from zero and then we will increment

1168:25

there so what I'm going to do is that

1168:28

I'm going to provide like rounded large

1168:30

and flex and items come on items will be

1168:32

set to tot the center and justify will

1168:35

also be set to toly Center I'm going to

1168:37

save this file right now and when

1168:39

somebody tap on it so let's just use the

1168:41

on tap not capture but when somebody use

1168:44

the own tab then you want to F this

1168:46

function which is a handle tab function

1168:48

so I'm going to copy the name of that

1168:50

and register this function right here so

1168:51

I'm going to go back and use handle Tab

1168:54

and it's going to be equals to this

1168:55

Arrow function and inside there we have

1168:57

to use the set color index and provide

1168:59

our previous index and here we have to

1169:01

use like the previous index plus one and

1169:04

we are going to be rounding them by

1169:06

using this modular operator and then we

1169:08

have to get the colors. length so we

1169:11

want to divide both of these value and

1169:13

get the remainder of that by using this

1169:15

modular operator so that's done we don't

1169:18

need this color from the frame or motion

1169:20

and you know what let's just try this

1169:22

out here tap me if I click on there here

1169:25

you can see it's going to change the

1169:26

color to whenever I click on this it's

1169:28

going to just change the color but I'm

1169:29

going to also provide the cursor of

1169:31

pointer to this so cursor will be set to

1169:33

pointer come on let's just WR the

1169:36

pointer and now if I click on this so

1169:38

anytime I click on this it's going to

1169:39

just change the color to these different

1169:42

colors which we now specifying right

1169:43

here that's also something that I want

1169:46

to show you that we can build next we

1169:48

have to create long press to change the

1169:50

size so create a box that changes the

1169:53

size when we long press on them so you

1169:55

can use the motion. dev and on Tab and

1169:58

animate the size of there so yeah let's

1170:00

just do that the first thing that we

1170:01

have to do is that we have to create our

1170:03

component with the name of long press to

1170:05

change the size. TSX and RFC go to our

1170:09

app and register the right here here so

1170:12

long press to change the size I'm going

1170:15

to go into this component and first of

1170:17

all we have to grab the motion object

1170:19

from the frame or motion so motion from

1170:22

there from the frame or motion and next

1170:24

we have to provide the size so I'll use

1170:27

like is large and then set is large it's

1170:30

going to be equals to the use St and

1170:32

provide the initial value of false to

1170:34

them I'm going to remove them and change

1170:36

that to you know first of all change

1170:38

that to the motion. D and I'm going to

1170:40

also put a bit of classes to this all

1170:42

use like uh the class of come on with

1170:46

will be set to 32 height will be also

1170:48

set to 32 and background will be set to

1170:50

totally blue 500 rounded totally large

1170:53

and the flex items will be set to

1170:56

totally Center and justify will also be

1171:00

set to to Center and transitions

1171:03

transition will be set to all and

1171:05

duration will be set to 300 I'm going to

1171:08

also change the cursor to to pointer and

1171:11

here we have to render our data

1171:12

dynamically so if we have the large icon

1171:15

so we're going to be using like uh with

1171:17

will be set to 48 come on 48 and also

1171:20

the height will be set to 48 if that's

1171:23

not the case we are going to be setting

1171:24

that to empty string like that and for

1171:26

the label I'll just provide like uh long

1171:29

press me or something like that and if I

1171:32

save this file check this out if I click

1171:34

on there nothing will happen now I can

1171:37

provide my events so I can use like on

1171:40

Tab start and here we can specify the

1171:43

handle long press start going to be

1171:46

creating there in a few seconds now let

1171:47

me Define another event which will be

1171:49

the on Tab cancel and here we have to

1171:52

specify the handle long press end and

1171:56

now finally we have to define the on Tab

1171:58

and here we're going to be using like

1172:00

handle long press and one more time okay

1172:04

first of all we are going to be creating

1172:05

this function so what I'm going to do is

1172:07

that I'm going to Define this function

1172:09

right here and now we're not going to be

1172:11

doing anything crazy but we're going to

1172:12

be using like set is large and change

1172:15

that to true now this done we have to

1172:17

create this function so I'm going to

1172:19

copy the name of there and duplicate

1172:20

this line of code and change the name of

1172:22

there to handle long press and and I'm

1172:25

going to set there to false in this case

1172:27

so now if I sa my file test this out so

1172:29

if I click on there it's going to

1172:30

increase the size of there but if I

1172:32

leave it down it's going to bre it to

1172:34

its normal size next we have to create a

1172:36

gure based image gallery so create an

1172:38

image gallery that can be navigated

1172:40

using a vertical swipe gesture so you

1172:42

can use the motion. D for the gallery

1172:44

that contains the images implement the

1172:46

Swip gesture to navigate between images

1172:48

vertically and down and then use the

1172:50

animated presence for the smooth

1172:52

transitions between the images so let's

1172:54

just do that I'm going to go ahead and

1172:57

create my component right here with the

1172:58

name of gesture Bas image gallery. TSX

1173:01

and Define my component and go ahead and

1173:03

go to our file and register there right

1173:07

in here just like that I'm going to

1173:09

close there let's just go ahead and

1173:11

Define there remove that one you know

1173:13

I'm going to remove every single thing

1173:16

and and go to this uh just a function or

1173:19

component rather the first thing that we

1173:20

have to do is that we have to grab the

1173:22

motion object from where from the frame

1173:25

and motion that's going to be the first

1173:26

thing next we have to render these

1173:28

images you can get these images from my

1173:31

giab repository or if you want to use

1173:33

your own images you are more than

1173:34

welcome to use them now we have to

1173:36

create our current index for our image

1173:38

so I'll use like uh const current index

1173:41

and then Set current index and it's

1173:43

going to be equals to the U St and the

1173:45

initial value will be set to zero now

1173:47

I'm going to go ahead and remove that

1173:49

from here and provide my class name

1173:51

first of all we're going to be providing

1173:52

the relative class with will be set to 7

1173:54

to2 the height will be set to 7 to2 once

1173:57

again and overflow will be set to not

1173:59

overline but overflow will be set to

1174:02

totally hidden inside there what do we

1174:05

have to do we have to create our animate

1174:07

presence for the smooth transition so

1174:09

I'll use like animate presence and close

1174:11

there and inside this animate presence

1174:14

we're going to be defining our image so

1174:16

I'll use like IMG to Define my image but

1174:18

first of all we have to convert this

1174:20

image to the motion. image okay so for

1174:22

the source we going to be using the what

1174:24

do we call it the images come on this

1174:26

images you know let me just go to the

1174:28

top we're going to be

1174:30

us we're going to be using this variable

1174:33

which is now holding all of their images

1174:35

and I am going to place that right here

1174:37

and inside that we have to specify this

1174:39

current Index right here so I'm going to

1174:40

copy the name of the m place there but

1174:43

what the hell am I doing uh we have to

1174:45

convert there to the curly braces like

1174:48

so I'm going to also convert that one

1174:50

and for the alternative text I'll just

1174:52

change that to I don't know maybe slide

1174:55

and then I'm going to put that current

1174:57

Index right here so current index and

1174:59

I'm going to sve my file so this is how

1175:00

currently things looks like and I also

1175:03

forgot that I'm going to also proide the

1175:04

key and that key will be coming from the

1175:07

current index now let's just save there

1175:09

now that's looking better I can also

1175:11

make it dragable so I can use like drag

1175:14

on the y axis in this case I'm going to

1175:16

also provide a drag constraint today and

1175:18

for these drag constraints we're going

1175:19

to be using like top will be set to

1175:21

totally zero and bottom will be also set

1175:23

to zero okay and now let's just use the

1175:26

on Rag and function and here we're going

1175:29

to be creating this function like handle

1175:31

swipe I'm going to copy name of them and

1175:34

create this function right here so once

1175:36

again we're going to be defining this

1175:37

function it's not going to take any data

1175:39

we're going to be annotating there with

1175:41

any and now we have to also annotate the

1175:43

information to any and now we have to

1175:45

check if we have the info dot come on

1175:48

offet do y value greater than 100 so in

1175:52

this situation we are going to be

1175:53

setting the current value to the

1175:55

previous not yeah current value to the

1175:57

previous one and let's just remove one

1175:59

from this so I'll use like uh previous

1176:02

minus one and then times the images.

1176:05

length Okay and we also have to divide

1176:08

there so if I want to divide there first

1176:10

of all we have to wrap there in inside

1176:12

these parentheses and then I'm going to

1176:13

divide that by the images. length let's

1176:16

just use the images. length right here

1176:19

so this the formula to swipe it down now

1176:22

if that's not the case so what we have

1176:24

to do we have to use our lse if block

1176:26

and use our info. offset on the Y AIS if

1176:30

that is less than minus 100 so in this

1176:32

situation we're going to be setting the

1176:34

current index to the previous one and

1176:36

then we can multiply there so I'll use

1176:38

like previous * 1 and I'm going to also

1176:41

rep inside the parentheses and then

1176:43

let's just divide all of them by images.

1176:46

length Okay that was a lot of talking

1176:50

I'm going to save this file right now

1176:52

and now let me test this out if I drag

1176:54

there nothing is happening okay nothing

1176:57

is happening right now so I'm going to

1176:59

also provide the initial and all of that

1177:01

kind of transition so I'll use like

1177:03

initial and for the initial we're going

1177:05

to be providing the opacity and opacity

1177:07

will be set to zero so that's going to

1177:08

be the initial stage of my animation and

1177:11

when we want to animate there then we

1177:13

going to be increasing the opacity to

1177:15

one and also on the exit we want to set

1177:17

the opacity to stor zero I'm going to

1177:20

also provide the class name and the

1177:21

class name will be set to totally full

1177:23

withd it will also be set to totally

1177:25

full and totally rounded so now let me

1177:27

just save there test this out and if I

1177:30

swipe there to the top you're not

1177:32

getting a new image I don't know why

1177:34

let's just test this out oh this

1177:36

shouldn't be times this should be a plus

1177:39

symbol now let me see there and if I

1177:41

break there to the top still nothing is

1177:43

happening and this should be a plus so

1177:46

now let me write a plus and now let me

1177:49

just test this out here you can see it's

1177:50

going to remove there from the Dom and

1177:52

now if I swipe there to the top it's

1177:54

going to remove that image it's going to

1177:56

gives us the new image if I scroll there

1177:58

to the bottom it's going to remove there

1177:59

and gives us a new image like so so yeah

1178:03

that's amazing looking Gallery if you

1178:06

care about that you can Implement in

1178:07

your projects but if you don't care

1178:09

about that you don't even have to worry

1178:11

about out there so yeah that was the

1178:13

gesture practice welcome to the Stagger

1178:15

animation practice so in this one we're

1178:17

going to be building amazing animation

1178:19

so first of all we are going to be

1178:20

creating a stagger list item then the

1178:22

Stagger image gallery then the Stagger

1178:24

button press stagger grid layout and

1178:27

finally we're going to be building a

1178:28

stagger text

1178:29

review starting from the first one we to

1178:31

create a list item that animates into a

1178:33

view with a stagger effect and you guys

1178:35

already know what a Stager effect is so

1178:38

what do we have to do we have to create

1178:39

an array of items like strings or

1178:42

something like that then we can use the

1178:43

motion. D to display each item Implement

1178:45

a Stager effect so that each item

1178:47

appears one after the other when the

1178:49

component first mounts so now let's

1178:51

start working on this so I'm going to go

1178:53

ahead and create my uh components folder

1178:56

and inside there we're going to be

1178:57

defining a Stager list. TSX file I'm

1179:00

going to be using the

1179:02

rafc and now let me just save them I'm

1179:04

going to go ahead and go to my app and

1179:06

register that component right here just

1179:09

like that this is how it looks like like

1179:11

so I'm going to also provide a bit of

1179:13

classes to it so the height will be set

1179:14

to toly screen flex and justify will be

1179:17

set to toly Center and items will also

1179:20

be set to center background will be set

1179:22

to this background like 0 D1 017 I'm

1179:26

going to say my file and this is how it

1179:28

looks like I always forget this text of

1179:32

white so yeah that's looking great and

1179:34

the first thing that we have to do is

1179:36

that we have to grab the motion uh from

1179:39

where from the framer motion

1179:41

next we have to Define our item so I'm

1179:43

going to be using like items and I'll

1179:45

say like item one and then item two and

1179:48

then I don't know item three and also

1179:51

item four finally item five and I guess

1179:54

that's going to be fine next we have to

1179:56

go into the UI and remove that and

1179:58

change that to the motion. div inside

1180:01

then we have to itate over through all

1180:03

of that items so I'm going to be using

1180:04

like items. map method you want to get

1180:07

the item and also its index so now

1180:09

inside there what you we have to do we

1180:12

have to first of all create one motion.

1180:14

Ali and inside this Ali first of all

1180:17

we're going to be providing the key and

1180:18

the key will be coming from that index

1180:20

I'm going to also provide a bit of

1180:22

classes today so margin for the bottom

1180:23

will be set to two pairing all around

1180:26

will be set to five background yellow

1180:28

300 like so okay and here we're going to

1180:31

be rendering each of the items so I'll

1180:33

just save my file test this out so yeah

1180:35

we are now getting these amazing items

1180:38

yeah you get the idea next we have to

1180:40

Define our variants so I'll just Define

1180:42

like uh coner on sgr stagger variant

1180:48

it's going to be equals to this object

1180:49

and we're going to be providing the

1180:50

hiden property and opacity will be set

1180:53

to zero I'm going to also duplicate that

1180:55

and change that to visible and change

1180:57

the opacity to only one I'm going to go

1180:59

ahead and provide my variance right here

1181:02

as well we can also make this separately

1181:04

if you wanted to but you know what I

1181:05

guess that's going to be fine so I'll

1181:07

use like uh variant and inside there we

1181:10

have to Pro or visible flag so VI i s i

1181:13

b e and inside that visible we're going

1181:15

to be using the transition and for this

1181:18

transition TR a n s i t i o n for this

1181:21

transition I already explained that we

1181:23

have a stagger children property so

1181:25

we're going to be using the St stagger

1181:27

children and provide a 0.2 delay for

1181:30

each element to animate now I'm going to

1181:32

use this tagger variance I'm going to

1181:34

copy the name of them and use the inside

1181:36

your lii so I'll use like variants and

1181:39

provide the right here let's just sa our

1181:41

file test this out so now if I just

1181:43

refresh there nothing is happening I

1181:46

don't know why but now let's just test

1181:47

this out oh that's because we also have

1181:50

to use the initial state so I'll use

1181:52

like the initial State and set that two

1181:54

hereen I'm going to also use the animate

1181:56

and for this animate we're going to be

1181:58

setting there two visible and now let's

1181:59

just refresh there and now we are

1182:01

getting like each item one by one 1 2 3

1182:04

4 5 I'm going to go ahead and remove

1182:06

this item from there and also I'm going

1182:09

to change there to instead of a Eli I'm

1182:11

going to change that to div now that's

1182:13

looking better so if I just refresh that

1182:16

yep that's looking cool I can also

1182:18

change the timing of there to like 1

1182:20

second or something like that and

1182:22

refresh there one 2 3 bang

1182:26

bang that's cool what do we have to do

1182:29

next I'm going to go in there and next

1182:31

we have to Define our stagger image

1182:33

gallery so what do we have to do we have

1182:35

to create an image gallery where the

1182:37

image feds in with the Stager effect uh

1182:39

when loaded yeah create array with image

1182:42

URLs and then use the motion. image to

1182:45

display each image and then implement

1182:47

the Stagger effect for each image to Fed

1182:49

in as they loaded so let's just start

1182:51

working on there I'm going to go ahead

1182:53

and go to our component folder and

1182:55

register my stagger image gallery. TSX

1182:58

right here I'm going to be using the RFC

1183:01

go to our app and register there right

1183:03

in here just like that I'll go to my

1183:07

component and the first thing that we

1183:08

have to do is that we have to grab the

1183:10

motion from where from the frer motion

1183:13

you also have to Define these images

1183:15

which you can get from my giab

1183:16

repository or if you want to provide

1183:18

your own you are more than welcome to do

1183:20

that I'll just remove that from here

1183:22

change that to the motion. D and here we

1183:25

have to specify the class name of flex

1183:27

now we have to go into this div and I'm

1183:30

going to be itting over through all of

1183:31

that images so I'll use like images. map

1183:34

method and it's going to take the source

1183:36

and also the index and inside there I'm

1183:38

going to use the motion. image and and

1183:41

here let's just close it it's going to

1183:43

take the key so for the key we're going

1183:45

to be passing our index inside there for

1183:47

the source let's just pass our source

1183:49

for the alternative text I'll use like

1183:51

provide my index totally dynamically

1183:53

I'll use like index and here we also

1183:56

have to provide the variance and for

1183:57

this variance we're going to be passing

1183:59

our stagger variance which we're going

1184:01

to be defining in a few seconds so

1184:03

stagger variance like so and I'm going

1184:06

to also provide a bit of classes to this

1184:08

so I'll use like with will be set to 20

1184:10

rim and also will be set to Auto margin

1184:12

for the left will be set to to rim and

1184:15

totally rounded r o u n d a d like so so

1184:18

if i s my file I'm going to Define this

1184:20

variant at the top here so I'll use like

1184:23

con tagger variants and inside there we

1184:27

have to Define what hidden and when it

1184:29

is hidden so we want to change the

1184:30

opacity to zero and if that is set to

1184:33

visible we want to change the opacity 2

1184:35

one that's totally done I'm going to go

1184:37

into this Dev and provide my animation

1184:40

right here so I'll use like for the

1184:41

initial prop or initial okay so you want

1184:45

to use the hidden but if that's not the

1184:47

case so on the animate you want to use

1184:49

the animate not animate but or visible

1184:52

and also we are going to be defining our

1184:54

variants I'll use like v a r i NTS and

1184:58

we're going to be providing the visible

1185:00

State and for the visible State once

1185:02

again we're going to be using that same

1185:04

transition so let's just provide this

1185:05

transition and for this transition we

1185:08

have a special property called the

1185:09

Stagger children and I'm going to

1185:11

provide like maybe one second would be

1185:13

fine so now let me just save there test

1185:14

this out so let's just refresh there and

1185:17

here you can see we're now getting one

1185:18

two three all of that images so let me

1185:21

just refresh that once again first of

1185:23

all it's going to give us that image

1185:24

then that one and then this one I

1185:26

provided a lot of time but you can

1185:28

change there to like 0.5 or 6 or

1185:30

something like that and it will work

1185:32

totally fine so now let me just refresh

1185:34

there and I guess that's looking a bit

1185:36

cool you can also change that to like

1185:38

0.2 now let me just refresh there yep it

1185:41

is super quick yeah this one is super

1185:43

quick I can probably change that to I

1185:45

guess five would be fine definitely five

1185:47

would be great yeah that was the Stagger

1185:50

image gallery what we have to do next we

1185:53

have to Define our stagger button press

1185:55

create a set of buttons that animate

1185:57

Into The View with with the Stagger

1185:58

effect when we H over it so we have to

1186:01

create a set of buttons then we can use

1186:03

the motion. div to animate each button

1186:05

and then we can Implement a ster

1186:07

animation effect when Hing over the

1186:09

button container this going be quite

1186:11

simple and easy so I'm going to go ahead

1186:13

and go to my component folder I didit it

1186:16

again God damn it so we have to create a

1186:19

stagger button first. TSX file and I'm

1186:22

going to be using the rafc inside there

1186:24

go to the app comment this line out and

1186:26

register my uh stagger anywh come on

1186:29

stagger press button there oh my God

1186:32

stagger button press there we go I can't

1186:34

even speak no more I speak a lot today

1186:38

because I was recording this course so

1186:40

it took me way much time and energy to

1186:43

record this course but yeah let's just

1186:45

first of all create our button so I'll

1186:47

use like array and we are going to be

1186:48

using like button one button two and

1186:51

button three also button four would be

1186:55

fine okay so we're going to be going in

1186:58

there and change there to the motion. D

1187:01

and inside there let's just itate over

1187:03

through all of their buttons buttons.

1187:06

map method here we have to specify the

1187:08

label and also the index inside then

1187:11

okay so inside this one we're going to

1187:12

be using our motion. button and Define

1187:15

our buttons right here so it's going to

1187:16

take that label I'm going to render that

1187:18

level right here s file and it's going

1187:21

to gives us that uh what do we call it

1187:23

button one two 3 and fourth one so I can

1187:26

also to the style then I can proide

1187:28

first of all the key and the key will be

1187:30

set to the index I'm going to use the

1187:31

class name ping all around will be set

1187:33

to two background will be set to Blue of

1187:35

500 text only white and rounded sver

1187:39

file this is how it looks like right now

1187:40

I'm going to also put a bit of margins

1187:43

so margin two rims would be fine yeah

1187:45

they they are looking cool now

1187:47

underneath there let's just use when

1187:49

somebody how over there so I can use

1187:51

like while how so we can just increase

1187:53

the scaling of this so I'll use like

1187:55

scale 101 I mean like 1.1 and now if I H

1187:59

over there so it's going to increase the

1188:00

scaling of these buttons and they're

1188:03

looking cool next I'm going to also use

1188:05

my stagger on this button I mean like on

1188:08

this Dev so I'll use like the class name

1188:10

and the class will be set to flex and

1188:12

space on the x-axis will be set to four

1188:14

like so and when somebody H over there

1188:18

while how so we're going to be using the

1188:19

transition property and we want to use

1188:21

our stagger children and set there to

1188:24

0.2 and now if I have my mouse over

1188:27

today so yeah we are getting this kind

1188:29

of a smooth transition but I wouldn't

1188:31

call it as a stagger animation I don't

1188:33

know why I put the in this practice but

1188:36

yeah we have a little bit of practice

1188:38

about what do we call it the while how

1188:40

effect or the while how prop as well so

1188:43

you know what I'm going to either crop

1188:45

this part out or I'll just remove that

1188:47

from the giab depository anyways let's

1188:49

talk about the Stagger that was a button

1188:52

so now let's talk about the Stagger grid

1188:53

layout so what we have to do we have to

1188:55

create a grid layout of item that

1188:57

animate Into The View with the Stagger

1188:59

effect and you guys already know what a

1189:01

stagger effect is so we have to create

1189:03

an array of items that can be displayed

1189:05

into a grid format and then we can use

1189:07

the motion. D for each grid item we can

1189:09

implement the Stag effect so that each

1189:11

grid item animate with a slightly delay

1189:14

relative to its position so let's start

1189:16

working on that one so what I'm going to

1189:18

do is that I'm going to Define this uh

1189:21

stagger grid layout. TSX and I'm going

1189:23

to be using my rafc inside there go

1189:26

there comment that line out and register

1189:28

my component right here so I'll use this

1189:32

layout sem my file and let's just start

1189:34

working on there by importing first of

1189:36

all the motion from where from the

1189:39

framer motion now I'll also Define my

1189:41

item so I'll use like item 1 2 3 and so

1189:44

on and so forth until item six now we

1189:48

also have to convert that to the motion.

1189:51

D and I'm going to also put a class name

1189:53

of grid grid will be set to columns

1189:56

three and g I'm going to provide like

1189:58

four inside this div let's just iterate

1190:01

over through all of that item so I'll

1190:02

use like the map method and specify the

1190:05

item and also the index inside there is

1190:07

I'll use like the motion. D and close

1190:11

there duplicate this line of code and

1190:13

close it like so I'm going to provide

1190:15

the key and for the key which will be

1190:16

coming from the index I'm going to also

1190:18

provide the class name I'm ping whe all

1190:20

around will be set to four background

1190:22

gray will be set to 200 come on 200 and

1190:27

round it totally so I'm going to sell my

1190:29

file right now check this out so yeah

1190:31

this is our simple basic GD layout so

1190:34

now let's just provide a bit of styling

1190:36

today but first of all I'm going to also

1190:37

render the items so let's just check

1190:39

this out we have all of that items you

1190:42

want to change the color of that to text

1190:45

come on uh text totally black the color

1190:49

is now changed to tot black and you know

1190:52

what let's just provide a bit of

1190:53

Animation to that so I'm going to go to

1190:54

the top and Define my Stager right here

1190:56

not a stagger but my variance so I'll

1190:58

use like con stagger variance it's going

1191:02

to be equals to the hidden prop and the

1191:04

opacity will be set to zero initially on

1191:07

the visible the opacity will be set to

1191:09

one and we have to specify a comma in

1191:12

there copy the name of that put that

1191:14

stagger variants right here so I'll use

1191:17

like the variant not the viewport but

1191:19

the variant r i NTS and provide my

1191:22

stagger variants in there here for this

1191:24

div I'm going to also provide my

1191:26

variants and for this variant what do we

1191:29

have to do we have to provide our

1191:30

visible and I'm going to say the

1191:32

transition that's tager children and.

1191:35

0.2 as a delay to them we're going to be

1191:39

also using the initial St and for the

1191:41

initial State you want to use the hidden

1191:43

and for the animated State you want to

1191:45

use the visible VI i s IBL now let me

1191:49

just save my file test this out so if I

1191:51

just refresh there it's going to gives

1191:52

us this amazing amazing amazing uh look

1191:57

right here amazing trade so yeah and you

1191:59

know what that is looking horrible so

1192:01

I'm going to have to remove that one and

1192:03

close that manually like so now let me

1192:06

just refresh there here you can see it's

1192:08

going to gives us this layout I can also

1192:11

change the styling of that to 1 second

1192:14

and now let's just refresh there and 1 2

1192:17

3 slightly

1192:20

slow okay so that was our stagger grid

1192:23

layout the final thing that we have to

1192:24

do is that we have to Define our stagger

1192:26

text review create a title where each

1192:29

letter animate Into The View with a

1192:30

stagger effect are we going to be doing

1192:32

this split a string into array of

1192:34

characters then use the motion. spin to

1192:36

display each character Implement a

1192:38

Stager animation effect for the

1192:40

character to appear one after the other

1192:42

so let's just start working on there I'm

1192:44

going to go ahead and Define my

1192:46

component right here with the name of

1192:48

stagger text. I me like Stager text

1192:50

reveal. TSX and let's just use our RFC

1192:53

inside there go to the app come and just

1192:55

line out and Define my component right

1192:58

here just like that I'm going to go into

1193:01

that component now let's start working

1193:03

on there the first thing that we have to

1193:04

do is that we have to import the motion

1193:07

from where from the framer motion so we

1193:09

have to Define our text all use like

1193:11

cons come on cons text and it's going to

1193:13

be equals to my name like husan webd or

1193:16

you know instead of writing my name I'm

1193:17

going to write like hello I'm going to

1193:19

save that but providing a comma I'm

1193:21

going to proide a space next we have to

1193:23

remove that and change that to the

1193:25

motion. H1 and here I'm going to provide

1193:29

the class name of um text for Excel F

1193:33

will be set to bold text will be set to

1193:35

totally white and here we have to render

1193:37

our text so I cannot render my text like

1193:40

this but you know what I'm going to hit

1193:41

enter right here the first thing that I

1193:43

can do is that I can use the text. split

1193:45

method and then I can just provide empty

1193:47

string so it's going to convert my

1193:48

string to array so now let me just save

1193:51

there and here you can see it's going to

1193:52

gives us that string but basically this

1193:54

is array right now because we are now

1193:56

using the split method on there so it's

1193:58

going to convert there to array so which

1194:00

means like I can also iterate over

1194:02

through there so I'll use like the map

1194:03

method I'm going to get the character

1194:05

and also its index like for each

1194:07

character you're going to be also

1194:09

getting its index now I can use like

1194:11

motion. span and I'm going to close them

1194:13

and here we also have to specify the key

1194:15

and for the key we're going to be

1194:16

passing the index and yeah now let me

1194:19

just past that character right here the

1194:21

character name to be precise we can

1194:23

totally see there right now but now we

1194:25

have to animate there so if you want to

1194:27

animate there first of all we have to

1194:29

animate this H1 then we are going to be

1194:31

animating this Dev I mean like this spin

1194:33

to be precise so what I'm going to do is

1194:36

that I'm going to specify my variants

1194:38

come on v a r i NTS and for these

1194:41

variants we're going to be using the

1194:43

visible and provide our transitions on

1194:45

there so let's just choose this uh

1194:47

transition and provide our stagger

1194:49

children and for this stagger children

1194:51

I'm going to provide like 0.1 seconds

1194:54

for the delay I'm going to also use the

1194:56

initial when initially it renders we are

1194:58

going to be using the hidden prop and on

1195:00

the animate you want to use the visible

1195:02

and now if I just refresh the nothing

1195:05

will still happen because we also have

1195:06

to split this out I mean like we already

1195:08

split this out but we have to animate

1195:10

them so to animate that I'm going to go

1195:11

to the top and first of all we have to

1195:14

create our stagger variance so I'll use

1195:16

like con stagger variance and inside

1195:18

there we have to use the hidden prop and

1195:20

the opacity will be set to zero put a

1195:23

comma in there change that to visible

1195:25

and change that to one I'm going to copy

1195:28

a name of there go to the bottom and

1195:30

provide my variants right here and paste

1195:33

the Stagger variants check this out so

1195:35

now let me just refresh that and we are

1195:36

now getting each character one by one

1195:39

let's just refresh there once again

1195:41

that's a cool effect that's a cool 2007

1195:45

effect yeah I know 2007 effect so now

1195:49

let's just change there to like maybe 1

1195:50

second sa our file and now if I just

1195:53

refresh there 1 2 3 4 and it will take

1195:57

forever but yeah that was our amazing

1196:00

stagger animation practice and I hope

1196:03

you loved it welcome to the use motion

1196:05

value hook practice so in this one we're

1196:07

going to be building amazing animation

1196:09

so first of all we're going to be

1196:10

creating a dragable box then how link

1196:13

scale after that we are going to be

1196:14

building a string animated position and

1196:16

dynamic rotations so let's start from

1196:19

the first one which is a dragable box so

1196:21

create a dragable box that Updates this

1196:23

position using the use motion value so

1196:25

here are the instructions cre a motion.

1196:27

div that can be dragged around so use

1196:30

the used motion value to drag the x

1196:32

value and also the Y position of the Box

1196:34

finally we have to display the current

1196:36

position of the box as a text so let's

1196:38

just start working on there I'm going to

1196:39

go ahead and create my components folder

1196:42

and inside there we have to create a reg

1196:43

box. TSX and I'm going to just write my

1196:45

RFC inside there go to my app and

1196:48

register this component right in here

1196:52

like so I'm going to save this file I'll

1196:54

use npm run Dev run there so this is how

1196:57

it looks like so I'll also Prov a

1196:58

classes I'm going to say like the height

1197:00

will be set to screen flex and justify

1197:03

uh will be set to center items will also

1197:05

be set to center background will be this

1197:08

color so which is a 0 d101 7 and let's

1197:11

just close this our file and this is how

1197:14

it looks like also change the text to

1197:15

totally white now let's start working on

1197:17

our dragable box so the first thing that

1197:19

I'm going to do is that I'm going to

1197:21

grab the motion from where from the

1197:23

framer motion next I'm going to Define

1197:26

my motion value so I use like Con X and

1197:28

it's going to be equals to the use

1197:29

motion value hook now a template by use

1197:32

motion value and the initial value will

1197:35

be set to zero I'm going to also

1197:36

duplicate there and change the variable

1197:38

name to Y so now we are cre in two

1197:40

motion values and now we have to use the

1197:43

inside our UI so I'll provide a class

1197:45

name things can be set to flex and flex

1197:47

will be set to column and items will

1197:49

also be set to Center so inside this div

1197:51

now I'm going to be defining my motion.

1197:53

div so I'll use like motion. div and

1197:55

close there like so now the first thing

1197:57

that I want to do is that I want to

1197:58

style that a bit so I'll provide the

1198:00

width of 32 height will also be set to

1198:02

32 background will be set to totally

1198:04

blue 500 totally round there so now let

1198:07

me just save my file and this is how it

1198:09

looks like I'm going to also provide my

1198:11

drag and then I'll provide the drag I

1198:15

mean like then I'm going to provide the

1198:16

style and for this style I'm going to

1198:17

specify the x value and also the Y value

1198:20

which is now coming from these motion

1198:22

values so now underneath this div I'm

1198:25

going to create a paragraph and now this

1198:27

paragraph will have the text of toly

1198:29

white uh White like so now I'm going to

1198:32

render my position so I'll use like uh

1198:34

position come on p s t o n and here we

1198:38

have to render our position so I'll use

1198:39

like x.g and it's going to give us the x

1198:42

value I'm going to also put a comma here

1198:44

uh and I'm going to say like y.g and

1198:47

it's going to gives us you know what

1198:49

outside from this one I'm going to say

1198:51

like y.g and it's going to gives us the

1198:53

Y position so now let me just save my

1198:55

file and now here is the catch if I move

1198:57

there nothing will show up right here

1198:59

inside this position area but if I leave

1199:02

there and make some changes like for

1199:04

instance if I just remove this class

1199:05

name from here semi file now we are

1199:08

getting that value look at this

1199:10

they are super long so I'm going to

1199:12

change that to two fix so I'll use like

1199:14

do two fixed and fix there with two

1199:16

numbers I'm going to also provide the

1199:18

two fix right here and fix the with two

1199:20

numbers s our file and now we are

1199:22

getting the actual value so yeah if I

1199:24

move there nothing will show up like

1199:26

yeah nothing is showing up right here

1199:29

but now if I go ahead and just make some

1199:31

sort of a changes like I'm going to

1199:33

specify the class name of I don't know

1199:35

something like that and now let me just

1199:37

save my file now I can totally see the

1199:39

changes so so yeah that was our first

1199:41

dragable box next we have to create the

1199:43

how link scale so create a button that

1199:45

scales up when howed using the used

1199:47

motion value in this case Okay so just

1199:50

create a motion. button and then you can

1199:51

use the use motion value for the motion

1199:53

value to control the scale of the button

1199:55

and also update the scale value on H and

1199:58

reset day when we are not Hing so you

1200:00

know what if you want to give it your

1200:01

best shot you totally can but now let me

1200:03

just create this component with the name

1200:05

of our link scale. TSX and I'm going to

1200:08

use my rafc inside there go to my app

1200:10

comment this line out and register this

1200:12

component right here I'm going to go to

1200:14

this component and now let's start

1200:16

working on this so the first thing that

1200:18

I will need is the motion and we will

1200:20

also need the use motion come on the use

1200:22

motion value from where from the framer

1200:26

motion now we can totally do that so the

1200:28

first thing that I want to do is I want

1200:29

to Define my scale motion value so I'll

1200:31

just give it the name of like uh scale

1200:33

and it's going to be equals to the Ed

1200:34

motion value and the initial value I'm

1200:36

going to specify zero today because if I

1200:39

specify zero value we would not be able

1200:41

to see anything so I want to specify the

1200:43

motion value of one today so that we

1200:44

would be able to see something and now

1200:46

I'm going to also change that to motion.

1200:48

D and inside this de you know I'm going

1200:51

to say like how me or something like

1200:53

that and now let me just style that bit

1200:54

so I'll use like class name ping all

1200:56

around will be set to four background

1200:58

totally blue of 500 text toally white

1201:01

and rounded now let me save my file and

1201:03

here you can see we now getting our

1201:05

boring button but now I'm going to make

1201:07

a few changes today on how star we going

1201:10

to be firing this function which is the

1201:13

arrow function and we're going to be

1201:14

getting the scale. getet value and then

1201:17

we have to specify like 0.2 in there

1201:20

okay so now let me just save my file not

1201:22

get but set God damn it this is how we

1201:24

going to be setting this now I'm going

1201:25

to also proide the on how end and here

1201:28

we also have to specify the arrow

1201:30

function and on this Arrow function we

1201:32

are going to be using the scale and then

1201:33

setting a new value today so I'll just

1201:35

provide like one today and I'm going to

1201:37

also render my scale inside this this

1201:40

style so I'll use like uh scale right

1201:42

here s file and now if I hold over there

1201:44

so it's going to bump it up and now if I

1201:46

leave the mouse so it's just going to

1201:48

throw it back here you can see this is

1201:51

not looking that much cool but yeah we

1201:53

are achieving this animation by using

1201:55

the motion value from frame or motion

1201:57

next we have to create a spring animated

1201:59

position so create a box that spring to

1202:01

a new position when we click on it and

1202:03

to achieve there we're going to be using

1202:05

the use motion value hook the first

1202:06

thing that we have to do is that we have

1202:07

to create a motion. d that can be

1202:09

clicked to move to a new position we can

1202:11

use the use motion value for controlling

1202:13

the X and also the Y position and

1202:15

animate the box to a new position with

1202:17

the spring effect so you know what let's

1202:19

just start working on there I'm going to

1202:21

create this new file with the name of

1202:22

spring animated position. TSX and I'll

1202:25

use my RFC inside there go to the app

1202:27

commment this line out and register

1202:29

there right in here like so now let me

1202:32

go in there and the first thing that we

1202:34

would need is the motion and obviously

1202:37

we would need the use motion value hook

1202:39

from where from the frame or motion now

1202:42

inside there we're going to be defining

1202:43

the x value and X going to be equals to

1202:45

the used motion value and the initial

1202:48

value will be set to zero I'm going to

1202:50

also specify that for the Y AIS as well

1202:53

and now we have to change this D to the

1202:55

motion do or you know we're not going to

1202:57

be changing this div but we are going to

1202:59

be defining yet another div inside there

1203:01

so I'll use like motion. div and close

1203:03

there I'm going to also specify the

1203:05

class name of with will be set to 32

1203:07

height will also be set to 32 and

1203:09

background holy blue 500 only rounded

1203:12

and I'm going to say like click me save

1203:15

my file and we are now getting this

1203:16

amazing box once again now let me render

1203:19

the X and Y values by using the style so

1203:21

I'll provide the x value will be set to

1203:24

this x motion value and also we are

1203:26

going to be setting the y-axis value to

1203:28

this motion value as well and now let me

1203:30

attach the on click event hander so when

1203:32

somebody clicks on there we are going to

1203:34

be moving the box so how are we going to

1203:36

be doing there this is how we are going

1203:38

to be doing there so I'll just create a

1203:40

new function with the name of uh move

1203:41

box and inside this function we are

1203:44

going to be getting the x value then we

1203:46

can use the set method and now we need a

1203:48

random position so I'll use like m.

1203:50

random and then I'm going to just

1203:51

multiply there by I don't know maybe 300

1203:54

I guess 300 would be fine I'm going to

1203:56

also duplicate that and change that to

1203:57

the y- AIS as well and this is how we

1203:59

going to be getting a random number

1204:01

we're going to be getting a random

1204:03

position once we click on that box if I

1204:05

click on there it's going to move it to

1204:06

the bottom if I click on there so it's

1204:09

going to move it right here anytime I

1204:11

clicked on it so yeah this is also

1204:14

something that we achiev by using the

1204:15

use motion value that's also looking

1204:18

cool so now let's start working on the

1204:19

next one what we have to do next we have

1204:22

to create a dynamic rotation so create a

1204:24

component that rotates based on motion

1204:26

value r a motion. d that rotates when

1204:28

the button is clipped and use the use

1204:30

motion value to track the rotation angle

1204:33

animate the rotation of the Box based on

1204:35

the motion value now let's start working

1204:37

on there I'm going to go in there and

1204:39

Define my Dynamic rotation. TSX file now

1204:42

I'll use my RFC inside there go to the

1204:45

app comment this line out and render

1204:47

there right in here just like that I'm

1204:50

going to go into this component and the

1204:51

first thing that I would do is that I

1204:53

need the motion and also the use motion

1204:56

value from where from the frame and

1204:58

motion next we have to Define our

1205:00

rotation so I'll use the cons

1205:02

rotation it's going to be equals to this

1205:04

use motion value and the initial value

1205:07

I'm going to set there to zero now let

1205:08

me just remove and change that to the

1205:10

motion. D and here I'm going to provide

1205:13

the classes all used like with will be

1205:15

set to 32 and that same exactly the same

1205:18

classes I'll use like background of blue

1205:20

500 totally round it and now it's going

1205:22

to say like click me once again say our

1205:25

file I'm going to render the rotation so

1205:26

I'll use like style and we have to set

1205:29

that to rotate and rotate will be set to

1205:32

this rotation which is coming from this

1205:35

uh you know what I'm going to copy the

1205:36

name of this rotation I mean like rotate

1205:38

and we know no longer have to specify

1205:40

this rotation now let me save my file

1205:43

and I'm going to also attach the on

1205:44

click event hand let's all use like on

1205:46

click and we have to specify the roted

1205:48

Box function inside there and let's just

1205:50

create this function so I'll use like

1205:52

con roted box and then we have to call

1205:55

this function we have to use the rotate

1205:58

we have to use the set method on there

1206:00

here we're going to be using the rotate

1206:02

once again and then the dotk value so

1206:04

it's going to gives us that new value

1206:06

then we have to add like 45 to there 45

1206:09

like so so now let me save my file and

1206:11

now if I click on there here you can see

1206:13

it's going to start rotating ah what the

1206:15

hell was there but yeah we are now

1206:17

getting them by using the use motion

1206:18

video and it is not looking that

1206:21

impressive to be honest but here we are

1206:22

achieving something like this is just a

1206:24

practice of use motion value we are now

1206:27

working with the motion values we are

1206:29

not making some amazing animation which

1206:31

we will in this course but yeah that was

1206:34

amazing uh practice about the use motion

1206:37

value now very quickly we have to change

1206:39

all of their use motion value use the

1206:42

use spring animation so I'm going to

1206:44

copy the name of that and change that

1206:46

right here sa my file and test this out

1206:48

so now if I just refresh there still we

1206:50

are now getting this amazing animation

1206:53

okay that's super bouncy super duper

1206:55

bouncy but now if I change something

1206:58

inside there like you know what I'm

1207:00

going to change this this text white and

1207:03

here you can see we are still getting

1207:04

that same result but now we are getting

1207:06

that spring animation I'm going to go

1207:08

there comment this line up uncomment

1207:10

there save this file go in there once

1207:12

again and change there to the US spring

1207:15

okay us spring sa our file now if I just

1207:18

H over there it's going to gives us that

1207:20

springy animation cool I'm going to also

1207:22

comment that one out and uncomment this

1207:25

one go in there and change both of them

1207:27

to the use spring animation so my file

1207:30

and now if I click on there here you can

1207:32

see it's going to move there right here

1207:34

but that is smooth animation so if I

1207:36

click on that that is looking super cool

1207:39

I'm going to go to my app and comment

1207:41

that one out uncomment the dynamic

1207:42

rotation go there and change and change

1207:46

that to the use spring this our file

1207:49

once again if I click on there it's

1207:51

going to rotate there but it's going to

1207:52

also apply the spring animation to that

1207:54

so that's also looking cool and that was

1207:57

the US spring animation challenge or

1207:58

practice to be precise welcome to the

1208:00

while in view prop challenge or

1208:02

exercises or practice whatever you want

1208:04

to call there so in this one we are

1208:06

going to be building amazing stuff so

1208:08

the first thing that we are going to be

1208:09

doing is that we're going to be defining

1208:11

the Stagger fed in and slide in then

1208:14

we're going to be creating a card flip

1208:15

animation after the complex timeline

1208:17

animation and finally interactive H and

1208:20

in view animation so let's just start

1208:22

from the first one which is a stagger

1208:23

fed and slide animation so what we have

1208:26

to do we have to create a list of items

1208:27

that feds and slide in staggered when

1208:30

they move into the view what do we have

1208:31

to do we have to create an array of

1208:33

items to display there then we have to

1208:35

use the motion. for the list and motion.

1208:38

for each item finally we have to

1208:40

implement the SAG animation by using the

1208:42

variance and the transition prop so now

1208:44

let's just start working on there I'm

1208:46

going to go ahead and Define my

1208:47

component folder and inside there we're

1208:50

going to be defining our staggered list.

1208:52

TSX file and now let's just use our rafc

1208:55

inside there go to our app and register

1208:57

this component right in here just like

1209:00

that and we are now getting the Stagger

1209:02

animation and now I'm going to also

1209:03

provide a bit of classes to this one so

1209:05

I'll use like class name and right will

1209:07

be set to 150 rim

1209:09

and then I'm going to provide the flex

1209:11

and justify will be set to Center and

1209:13

items will also be set to center

1209:15

background will be set to 0 d10 17 and

1209:19

close there I'm going to save my file

1209:21

test this out so we are not even able to

1209:23

see something because we are now

1209:24

providing a lot of height today and now

1209:26

you'll be able to see that stagger list

1209:28

I'm going to also change the color of

1209:30

that totally white and now that's

1209:32

looking better let's go to the Stagger

1209:34

animation so the first thing that we

1209:35

have to do is that obviously we have to

1209:38

import the motion from where from the

1209:40

framer motion now inside there we have

1209:43

to define the items I'll use like items

1209:46

and can be equals to like item one and

1209:48

then I'm going to proide like item two

1209:51

item three and then we have to specify

1209:54

the item four finally we have to provide

1209:56

our item five inside there here we have

1209:59

to remove the and change the to the

1210:01

motion. and inside this motion. first of

1210:04

all I'm going to provide the class names

1210:06

it's going to be set to flex and flex

1210:07

will be set to column and items will set

1210:09

to Center come on item Center and now

1210:14

inside this UL we have to itate over

1210:16

through all of our items so I'll use

1210:17

like items. map we need the item we also

1210:20

need the index inside there and inside

1210:23

this one we're going to be using the

1210:24

motion. not just a motion but Li and

1210:28

close there and here we have to just

1210:29

render our items inside there I'm going

1210:32

to save this file the next thing that we

1210:33

have to do is that we have to create our

1210:35

variants so I'm going to go ahead and

1210:36

Define my list variants and it's going

1210:39

to be equals to this object you have to

1210:41

specify the hidden prop and it's going

1210:42

to be set to opacity of zero and I'm

1210:45

going to just duplicate the sign of code

1210:47

and change that to visible and change

1210:49

the opacity of that to one now we have

1210:51

to use this list variant inside this UL

1210:54

so I'm going to hit enter right here and

1210:56

provide my variants and for these

1210:58

variants we're going to be using the

1210:59

list variant I'm going to also provide

1211:01

the initial State and for the initial

1211:02

state is going to be set to hien and

1211:04

then we have to provide the while come

1211:06

on the while in view when it is in view

1211:09

then you want to set there to visible

1211:10

like so that's to done I'm going to also

1211:12

provide the transition today so for this

1211:15

transition we have to use the tager

1211:18

children and set the transition to 0.3

1211:21

I'm going to also animate each of these

1211:22

allies so I'll use like first of all we

1211:24

have to provide the key and key will be

1211:26

set to the index we also have to provide

1211:28

a bit of classes today like pound will

1211:30

be set to totally blue 500 pairing all

1211:32

around will be set to four text will be

1211:33

set totally wide Mar for the Y AIS will

1211:36

be set to two totally rounded large I'm

1211:38

going to say this file and provide my

1211:40

initial State and for this initial State

1211:43

what we have to do we have to provide

1211:44

the opacity and opacity will be set to

1211:46

zero and on the y- axis we want to set

1211:48

that to 20 while our item is in view so

1211:52

I'll use like while in View and in this

1211:54

situation we're going to be providing

1211:56

the opacity and opacity will be set to

1211:57

one and the y- AIS will be set to zero

1212:00

I'm going to also provide a transition

1212:02

come on transition and for this

1212:04

transition we're going to be setting

1212:06

that to a duration of 0.5 seconds now

1212:09

let me just save my file so you would

1212:10

not able to see that now let me just

1212:12

refresh there and if I scroll down Watch

1212:15

What Happens and bang bang bang bang

1212:18

bang you're now getting that animation

1212:21

that is looking super cool and watch

1212:23

what happened like initially that's

1212:24

going to be set to Hidden but now as

1212:26

soon as I scroll there each of the items

1212:28

are now coming up very smoothly and

1212:31

we're now providing this amazing

1212:32

transition to there so yeah you can

1212:35

totally change the colors off there you

1212:36

can totally change whatever you want to

1212:38

change inside there but in my case the

1212:40

Stager fed in is done next we have to

1212:42

create a flipping animation or card flip

1212:45

animation so here are the step create a

1212:47

card component with the front and also

1212:49

the back side and then we have to use

1212:51

the use motion I like use while in view

1212:53

drop to animate the rotation along with

1212:55

the y-axis and you can either use the

1212:57

tman CSS or just use a Pure CSS for them

1213:00

time to Define our flipping card so

1213:02

let's just use our card. flip I mean

1213:04

like card flip. TSX and Define my rafc

1213:08

inside there go to the app comment this

1213:10

line out and here we have to render our

1213:13

component like so okay so I'm going to

1213:15

go in there the first thing that I want

1213:17

to use I want to start from uh by

1213:19

importing the motion so I'll use like

1213:21

import motion from where from the frame

1213:25

or motion I'm going to save this file

1213:27

and now I'm going to remove that from

1213:29

here and provide my class name so I'll

1213:30

use like perspective 1,000 persective

1213:33

1,000 and withth will be set to 64 and

1213:37

height will also be set to 6 four inside

1213:40

there we have to Define our motion. Dev

1213:43

and close them and inside this motion

1213:45

Dev we have to Define our class with the

1213:47

name of absolute come on absolute and

1213:50

also width will be set to totally full

1213:52

height will also be set to totally full

1213:54

and we have to provide the background of

1213:55

totally blue 500 x will be set to

1213:58

totally white and we have to provide the

1213:59

flex and items will be set to Center

1214:01

justify will be Center and totally

1214:04

rounded so I'll use like rounded and

1214:06

save my file okay so here I'm going to s

1214:09

like front side now I'm going to

1214:10

duplicate there and change that to the

1214:12

back side okaye I'll use like back like

1214:15

so but I'm going to also specify the

1214:17

animate so I'll use like on animate come

1214:20

on we have to also change this one to

1214:22

the motion. D so I'll use like motion. d

1214:26

and here we have to specify the animate

1214:28

prop and on the animate prop we're going

1214:30

to be using the y axis and we have to

1214:32

change the to

1214:33

180° now we have to specify our motion

1214:36

values so what I'm going to do is that

1214:39

I'm going to hide this one and what the

1214:42

hell am I doing comment that I'm like

1214:45

hide that I'm going to provide a bit of

1214:46

classes to this div so it's going to be

1214:48

set to relative with will be set to full

1214:50

and height will also be set to full or

1214:53

screen whatever you want to call it now

1214:54

if i s my file here you can see we now

1214:56

getting these dos but they are not

1214:58

looking that cool so what I'm going to

1215:00

do is that I'm going to specify the

1215:02

initial and all of that states so I'll

1215:04

use like initial and for the initial

1215:06

State you want to rotate the Y AIS all

1215:09

use like rotate on the y- AIS and set

1215:11

that to zero while this is in view then

1215:14

you want to change the rotation of the

1215:15

y- axis to

1215:17

180° then we have to also specify the

1215:20

transition and for this transition we

1215:22

have to provide the duration of 0.6

1215:24

seconds I'm going to also use the style

1215:26

and provide the perspective to there so

1215:28

I'll use like transform style uh come on

1215:32

transform style I'm going to choose

1215:35

there and set there to preserve 3D and I

1215:38

just realized that I cannot do the

1215:40

animation right here so instead I'm

1215:41

going to have to use the style and

1215:43

provide my transform property and change

1215:46

that to the rotate on the Y AIS and

1215:48

change that to

1215:49

180° like so let me just close there sa

1215:52

my file now if I refresh then and go to

1215:55

the bottom and Watch What Happens so we

1215:58

are now getting this flipping animation

1216:00

go to the top we are now getting that

1216:02

back first of all we are going to be

1216:04

getting the front then we are going to

1216:05

be getting that back if I scroll to the

1216:07

top still we are now getting the that

1216:09

flipping card animation and I guess

1216:11

you've seen that in a lot of websites

1216:13

but I cannot just give you a quick

1216:15

example of that because I'm going to

1216:16

have to do a lot of research for them

1216:18

but you get the idea now we are getting

1216:20

this amazing animation or amazing card

1216:23

flipper okay so next we have to Define

1216:25

our timeline animation so what do we

1216:28

have to do we have to create a complex

1216:29

timeline animation create a sequence of

1216:31

Animation that occurs when the section

1216:33

comes into the view including the

1216:35

rotation scaling and also the fairing so

1216:37

what do we have to do we have to set up

1216:38

a multiple element that will animate in

1216:40

a sequence then we can use the variant

1216:42

for the complex animation like we Define

1216:44

the rotation scaling and also the feding

1216:46

and we can control the animation by

1216:48

using these transition properties so

1216:50

let's just start working on there I'm

1216:52

going to go ahead and Define my

1216:54

component with the name of timeline

1216:56

animation. TSX and I'm going to be using

1216:58

the rafc inside there go to the app come

1217:00

this line out and Define my timeline

1217:03

animation like so and let's start

1217:05

working on there the first thing I would

1217:07

need is the motion so I'll use like

1217:09

motion from frame and motion so I'll use

1217:11

like frame or motion like so next we

1217:13

have to change that to the motion. D so

1217:16

I'll use like motion. div and inside

1217:18

there we're going to be defining or you

1217:20

know what I'm going to use like one two

1217:23

three like so and we're going to be

1217:25

itating over through there so I'll

1217:26

provide a map I mean like item inside

1217:28

there and now we have to Define our

1217:30

motion. div once again so I'll use like

1217:31

motion. div and close that right here

1217:35

I'm going to also provide the key and

1217:36

key will be set to this item and I'm

1217:38

going to also put the class name and set

1217:40

there to background totally purple of

1217:42

500 and margin for the left will be set

1217:45

to two rims I'm going to also provide a

1217:47

pairing all around will be set to four x

1217:49

will be set to totally wide margin for

1217:51

the Y AIS will be set to two rounded

1217:53

totally large so this file and now we

1217:55

have to render and now we have to render

1217:58

our items right here all used like item

1218:00

next we have to Define our variant all

1218:02

used like cons item variance this going

1218:05

to be set to this object and we have to

1218:06

provide the hiden prop and on the hiden

1218:08

prop we're going to be changing not the

1218:10

MD opacity but just the opacity set that

1218:13

to zero to the scaling so scale will be

1218:16

set to scale will be set to 0.5 and

1218:19

rotation will be set to

1218:21

180° I'm going to duplicate this line of

1218:24

code and change that to visible and the

1218:26

opacity will be set to one the scaling

1218:28

will be set to one and the rotation will

1218:31

be set to zero now I'm going to copy the

1218:33

name of there and use there right here

1218:35

for each item so I'll use like variants

1218:38

and here we have to specify the items

1218:40

variant now I'm going to go to the top

1218:41

and also and provide my animation and

1218:43

stuff so I'll use like Flex and items

1218:45

will be set to totally Center and now

1218:47

here I'm going to hit enter a few times

1218:48

and for the initial State we're going to

1218:50

be providing a head instead and while

1218:52

this is in view then we're going to be

1218:54

setting there to visible now underneath

1218:57

that let's us also Pro a transition and

1218:59

the transition will be set to stagger

1219:01

children and set it to 0.5 I'm going to

1219:04

save this file and now if I just refresh

1219:06

this so 1 2 3 that's cool and everything

1219:09

but now let me just refresh there once

1219:10

again and now let me scroll down so

1219:13

animation will start right here just

1219:15

like that let me try that once again

1219:17

that's an amazing

1219:18

animation okay yeah I know that's simple

1219:21

but still that's an amazing animation

1219:23

and a creative want to be honest let's

1219:25

create the final one which is a

1219:26

interactive how and in view animation so

1219:29

create a grid of card that scale and

1219:31

changes the color when we H over there

1219:33

and animate them when they are in the

1219:34

view so what we have to do we have to

1219:36

create a grid of layout card then we can

1219:38

use the while in view Pro for the

1219:40

entrance of the animation and we can

1219:42

provide the how effect by using a TN CSS

1219:45

in the framer motion so you know what

1219:46

let's just start working on that I'm

1219:48

going to go ahead and create a component

1219:49

with the name of interactive cards. TSX

1219:52

not

1219:53

TSD so something like that let's just

1219:55

create this component and go to our app

1219:58

and Define the right here so I'll just

1220:01

remove the creative or interactive

1220:03

animated cards let's just go to there

1220:06

the first thing that we would need is

1220:07

the motion from where from the frer

1220:10

motion next you have to create our grid

1220:12

so I'll provide a class names and the

1220:14

class will be set to grade and gr

1220:16

columns will be set to two Gap will be

1220:19

set to four inside there we have to

1220:21

create a few items like 1 2 3 4 now we

1220:24

have to over through there so I'll use

1220:26

like only the item we don't need the

1220:28

index or yeah you know what I'm going to

1220:31

also specify the index right here and

1220:33

inside there we're going to be using our

1220:35

motion. div let's just use our motion.

1220:37

div and close or you know we're not

1220:39

going to be closing there like this

1220:40

we're going to be closing there like so

1220:42

so I'm going to use like H3 and I will

1220:44

say like card and render my items inside

1220:47

there I'm going to also provide the

1220:49

class name of text to Excel and save my

1220:52

file this is how that looks like so we

1220:53

now getting card 1 2 3 and four I'm

1220:56

going to also proide a bit of classes to

1220:57

this so I'll use like uh background blue

1221:00

of 500 and piring all around will be set

1221:02

to six text will be set totally white

1221:05

and text will be set to Center and we

1221:07

also have to make it totally rounded

1221:08

large s file and now we are getting

1221:11

these cards right here I'll also provide

1221:13

the key so for this key we have to

1221:15

provide our index sem my file and next

1221:17

we have to provide our initial St so

1221:19

initially my animation will start like

1221:21

this so we have to provide the scale and

1221:23

scale will be set to 0.8 and while they

1221:26

are in the view so in this situation

1221:28

we're going to be scaling it up to one

1221:31

while somebody how over there so in that

1221:33

case we going to be scaling there to 1.1

1221:36

and we are going to be also changing its

1221:37

background color to toally three come on

1221:40

3B at at2 F6 like so and I'm going to

1221:46

also for a bit of transition so for this

1221:48

transition duration will be set to 0.3

1221:50

seconds now let me save my file and now

1221:52

if I just refreshed there here you can

1221:54

see they are now appearing if I have my

1221:56

mouse over today they're also looking

1221:58

cool but now if I scroll up and now if I

1222:00

scroll down here you can see we're now

1222:02

getting this smooth kind of a yeah we

1222:05

are getting this animation but we can

1222:07

totally change the duration to like I

1222:08

don't know maybe 3 or 4 seconds rather

1222:11

now let's just refresh that and scroll

1222:13

down so it's going to take a while to

1222:15

complete this animation I'm going to

1222:17

change that to like maybe 1 second

1222:20

complete one second let's go to the top

1222:22

and when they are in the view so now we

1222:24

are getting these items right here so

1222:26

yeah that was our while in view Pro

1222:28

practice welcome to the projects module

1222:30

so in this one we're going to be

1222:31

building a lot of projects so we're

1222:33

going to be starting from the very

1222:34

Basics project and then we're going to

1222:36

be jumping into a bit Advanced so what

1222:38

I'm going to do is that I'm going to

1222:39

open my terminal right here and I'm

1222:42

going to make it a bit bigger so you

1222:43

guys can see it a bit clear like so I'm

1222:46

going to use npm create with at latest

1222:50

and hit enter right here I'm going to

1222:51

give it the name of like uh FM like for

1222:54

the frame or motion projects or

1222:56

something like that I'm going to choose

1222:57

reactjs and typescript let's just go

1222:59

into the FM projects and use npmi to

1223:02

install all of the packages now that's

1223:03

successfully done I'm going to go ahead

1223:05

and go to the framer motion now a framer

1223:08

but we want to go into the framer Dash

1223:11

motion okay so we are now inside the

1223:13

framer motion I'm going to click on the

1223:14

getting started I'm going to copy this

1223:16

script and place it right here inside

1223:19

the terminal whil it's doing that I'm

1223:21

going to also go ahead and Cy the tman

1223:22

CSS click on the getting started and

1223:25

then I'm going to choose the framework

1223:26

and guides go to the weed and copy all

1223:28

of them place it right here so it's

1223:30

going to install the tailin CSS and I'm

1223:32

going to also initialize the only

1223:34

hitting enter okay so now let me just

1223:36

hit enter so it's going to also

1223:37

initialize my CSS I'm going to copy all

1223:40

of that content and now let me open that

1223:41

in my vs code next I'm going to go into

1223:44

the where is my. config file and I'm

1223:47

going to replace it with this new

1223:49

content I'm going to also use npm run

1223:52

I'm going to do that in a few second but

1223:53

first of all we have to remove the

1223:54

public folder also the SS folder the f.

1223:57

CSS file and remove every single thing

1224:00

from the f. TSX and replace it with the

1224:02

rafc and remove every single thing from

1224:05

there as well and I'm going to copy all

1224:07

of that component Plus right here and

1224:09

then we have to just test this out so

1224:11

I'll go ahead and go to my app and

1224:13

replace that with this new content I'm

1224:15

going to use npm run Dev to run there on

1224:18

my Local Host

1224:20

5173 yep everything is working the way

1224:23

we expect him to work I'm going to also

1224:24

quickly go ahead and go to the

1224:25

package.json and check for there we go

1224:28

we are now using a frame motion which

1224:29

means like this is the correct version

1224:31

of the frame motion the first project

1224:33

that we are going to be building will be

1224:35

super basic project so what are we

1224:36

building we are building you guessed it

1224:40

first of all we have to create a

1224:41

component folder and we are now building

1224:43

a scroll indicator and now let me just

1224:45

create a TSX file and I'm going to be

1224:47

using the rafc inside there go to my app

1224:50

once again and register there right in

1224:53

here so I'll just remove it and replace

1224:55

it with the div and I'm going to be

1224:56

rendering my scroll indicator and close

1224:59

there check this out so now we are

1225:00

getting their scroll indicator which is

1225:02

looking cool so let's just start working

1225:05

on them I'm going to go back and the

1225:07

first thing that we would need is

1225:08

obviously we will need the motion from

1225:11

the framer motion come on from the

1225:15

framer motion I'm going to save this

1225:16

file next we have to provide a bit of

1225:18

height to this so I'll just provide like

1225:20

class name and the height will be set to

1225:22

200 viewport height and also the Ping

1225:25

will be set to 20 pixel I'm going to

1225:27

save this file and inside there we have

1225:29

to create first of all a red line okay

1225:32

or indicator line whatever you want to

1225:34

call there so to create that I'm going

1225:36

to only use the motion. D come on we

1225:39

have to use our motion. div and I'm

1225:41

going to close them like so I'm going to

1225:43

also put a bit of styling to this so

1225:45

it's going to be set to fix and the top

1225:46

will be set to zero left will also be

1225:49

set to zero right will be set to five

1225:51

pixel you can increase and decrease

1225:52

there if you want it to and then we're

1225:54

going to be changing the color of that

1225:56

like fed 500 like so I'm going to save

1225:58

this file and go back check this out so

1226:00

we are not able to see anything that's

1226:02

because we are now setting the Top Value

1226:04

to zero and also the left value to zero

1226:07

so that's why we cannot see something

1226:08

but we will see that in a few seconds

1226:10

next we have to create a random text so

1226:13

if you want to get a lot of text first

1226:15

of all we going to be creating a DAT

1226:16

with the class of margin for the top

1226:18

that's going to be an arbitrary class so

1226:19

I'm going to be providing like 50 pixel

1226:22

to there and inside this de I'm going to

1226:24

be using like my array so I'll use like

1226:27

dot dot dot array and then here I'm

1226:29

going to provide like 100 item now you

1226:32

want itate over through all of that 100

1226:34

item we don't need the data we only need

1226:36

the index okay so inside there I'm going

1226:39

to be using my paragraph and I'm going

1226:40

to close there and I'll just say like LM

1226:43

EP or something like that and here we

1226:45

also have to specify margin for the top

1226:47

of 20 pixel and here for the key I'm

1226:49

going to also specify the index right

1226:51

here so if I save that now we are

1226:53

getting this UI and we are also getting

1226:55

a lot of text which we can scroll

1226:57

through finally we have to work on our

1226:59

indicator so to work on that so the

1227:01

first thing that we would need is the

1227:03

scroll on the y- axis progress from

1227:06

where you guessed it from the use scroll

1227:09

function so now we are going to be

1227:11

getting there and this should be God

1227:13

damn it scroll y progress okay so we're

1227:16

going to need them next we have to use

1227:18

our use transform for the line width so

1227:20

I'll use like con line width and that's

1227:23

going to be set to the use transform

1227:24

hook not a St but transform hook for the

1227:27

initial value we are going to be

1227:29

providing this motion value which is a

1227:30

scroll y progress and I'm going to

1227:32

specify the comma and what we have to do

1227:35

I'm going to provide both of these stats

1227:36

on the initial St when when it start

1227:38

from zero you want to set the width to

1227:40

be 0% but when it reaches to the one we

1227:43

want to change that to 100% as simple as

1227:48

that okay and now we have to render the

1227:50

inside our Dev so what I'm going to do

1227:52

is that I'm going to be using my style

1227:54

because now in this case we cannot use

1227:55

the animated prop and for the width I'm

1227:57

going to set there to the line width I'm

1227:59

going to also provide a bit of

1228:00

transition to this so I'll just use like

1228:03

um transition and for this transition

1228:06

it's going to be set to like WID and

1228:07

zero .1 second and is let me just save

1228:11

my file check this out so now if I

1228:12

scroll there I want you to notice this

1228:14

area right here so as soon as I scroll

1228:17

there it will scroll with me and this is

1228:19

a lot of text so here you can see we are

1228:21

now getting this amazing indicator and

1228:24

you can totally change the shape of

1228:25

there you can totally change the color

1228:26

of there you can do a lot sort of stuff

1228:28

with there but yeah I am done with this

1228:31

basic scroll indicator project and that

1228:34

was our basic first project welcome to

1228:36

the basics project number two so in this

1228:38

this one we're going to be creating

1228:39

amazing lower so how are we going to be

1228:41

doing that first of all we have to

1228:43

create our components folder and inside

1228:45

that we have to Define our loader. TSX

1228:47

file and I'm going to be using my rafc

1228:50

and render there right here to the Dom

1228:53

like so check this out we are now

1228:55

getting a loer which is looking cool so

1228:58

first thing first if I can get my cursor

1229:01

today I'm going to have to grab the

1229:03

motion from where you guessed it and

1229:06

then we have to provide or classes to

1229:09

it's all used like legs and also items

1229:11

will be set to to Center justify will

1229:13

also be set to Center and height will be

1229:15

set to totally screen so that we can set

1229:18

every single thing totally on the center

1229:20

of the view next we have to Define our

1229:22

div so I'll Define my div and I'm going

1229:24

to also put a of classes today it's

1229:26

going to be set to relative and the

1229:27

width will be set to 16 the height will

1229:30

also be set to 16 border all around will

1229:32

be set to four and Border for the top

1229:35

will be set to four and Border color

1229:38

will be set to Blue 500 border will be

1229:41

totally solid rounded so now let me save

1229:43

my file and check this out so now we are

1229:45

getting this amazing circle at the

1229:47

middle of the viewport next we have to

1229:49

Define another div so I'll use like div

1229:51

once again I'm going to also specify

1229:53

classes to it so it's going to be set to

1229:55

Absolute and here we're going to be

1229:57

using inset of zero border come on

1230:00

Border will be set to four border color

1230:02

will be set to Blue 300 and Border

1230:05

totally solid make it totally rounded

1230:08

for and save my file let's just test

1230:10

this out we now getting this inner

1230:12

border inside there finally we have to

1230:14

animate there and to animate there we're

1230:16

going to be converting our D to the

1230:17

motion div and also convert this D to

1230:20

the motion. D like so and now we can

1230:24

specify our animation inside there so

1230:26

I'll use like animate and on the animate

1230:28

we're going to be rotating there let's

1230:30

just use the rotate and rotate come on r

1230:33

o t t e rotate there on the

1230:36

360° I'm going to also ify transitions

1230:38

today for the transition we're going to

1230:40

be providing a duration and duration

1230:42

will be set to one and it's going to

1230:44

repeat infinitely I'm going to also

1230:46

proide the eing and eing will be set to

1230:48

linear s file and now it's not going to

1230:52

do anything for now because we also have

1230:54

to change this one to the motion. div

1230:56

and also specify animation for there so

1230:58

I'll use like motion. div now we can

1231:01

specify our animation inside their Dev

1231:03

only use animate and on this animate I'm

1231:06

going to provide the opacity and on this

1231:08

opacity we're going to be using our key

1231:10

frame so start from zero I mean like

1231:12

start from one and then go to 0.5 and

1231:15

then go to one back okay so we are going

1231:17

to be also copying this transition now

1231:20

let me just place it right here say our

1231:22

file and let me just refresh there

1231:25

nothing is happening I don't know why oh

1231:27

I forgot to include the transparency so

1231:29

I'll use like style and here for the

1231:31

style we're going to be setting the

1231:32

Border top color we have to make that as

1231:35

a transparent so now if I just provide

1231:37

this sem my file and now we are getting

1231:39

this amazing ler right here so we only

1231:42

have to write this amount of code like

1231:44

we have to provide the animate and set

1231:45

there to like

1231:46

360° and then we can specify the

1231:48

transition and duration stuff like that

1231:51

and we have to set the Border top color

1231:52

to transparent it's going to gives us

1231:54

this amazing loader animation right here

1231:56

welcome to the project number three so

1231:58

in this one we're going to be creating

1232:00

our dragable card and trust me this is

1232:02

not going to be just a simple dragable

1232:04

card okay so let's just work on there

1232:06

first of all we're going to create our

1232:08

components components folder and inside

1232:10

there we're going to be creating our

1232:11

dragable card. TSX file not TXS file

1232:16

just a TSS TSX and I'm going to be

1232:18

defining my RFC inside there go to our

1232:21

app component and register there right

1232:23

in here not like this but we're going to

1232:26

be closing there because here we're

1232:28

going to be also specifying a text

1232:29

inside there so I'll use like card one

1232:32

and then I'm going to save there I'm

1232:34

going to duplicate there a few times so

1232:35

now let's just change that to card two

1232:37

and card three we're going to be also

1232:40

providing different styles today so for

1232:42

the styling we're going to be specifying

1232:44

something called the linear gradient

1232:46

okay so I'll use like background and I'm

1232:48

going to provide a linear gradient for

1232:50

all of these component so I'll use like

1232:52

uh linear and then g r a d i e n t and

1232:55

close there so for the first one

1232:59

135° and then we're going to be

1233:01

providing this color like

1233:03

f93 FB and starting from the 0% now we

1233:07

have to specify the last color so I'll

1233:09

use like f55 76 and then C and we want

1233:13

to show that totally 100% that's going

1233:16

to be the first gradient now for the

1233:18

second one uh we're going to be

1233:19

providing 135 degree once again just use

1233:23

our degree and we are going to be using

1233:25

this color like 5 e e 7 DF it's going to

1233:29

start from the 0% and then we want to

1233:32

use this color like B 490 come on 90 and

1233:37

then CA and we will show them 100% and

1233:40

now we have to provide like

1233:42

135° once again and provide this color

1233:45

like FF 9 a 9 e and starting from the

1233:49

zero then provide like f e c f e f 99%

1233:54

like that I'm going to save this file

1233:57

and yeah this is how we're going to be

1233:58

providing our background color of linear

1234:00

gradient today and now let's start

1234:02

working on our dragable component the

1234:04

first thing that we would need is our uh

1234:07

motion so will use like motion come on

1234:09

motion from where from the frame or

1234:12

motion and inside there we're going to

1234:14

be restructuring all of the children

1234:16

like this text which you can see right

1234:18

here like this card two card three and

1234:20

so on and so forth and we would also

1234:22

destructure The Styling which we are now

1234:24

providing right here like this style

1234:26

which will have the background of this

1234:27

linear gradient okay so now we are

1234:29

destructuring there but we are going to

1234:31

be also creating an interface for this

1234:33

so I'll use like uh interface this is

1234:35

just a typescript stuff if you don't

1234:37

know typescript scpt you don't even have

1234:38

to worry about that and I'm going to say

1234:40

like

1234:40

dragable card prop okay so I'll just

1234:43

create the word here and I'm going to

1234:46

provide the children and children will

1234:47

be coming from the react node and then

1234:50

come on let's just grab that from the

1234:52

react node and then we're going to be

1234:53

using the style property and we

1234:55

shouldn't have to put the comma in there

1234:57

and the style will be a CSS properties

1235:00

like that now I'm going to copy the name

1235:02

of them and annotate that right here

1235:05

just like that now we have to use the

1235:07

inside or UI so I'll just change that to

1235:09

like motion. div and here I'm going to

1235:12

render that children so I'll use like uh

1235:14

children like so and inside there let's

1235:17

ISRO our class name so I'll use like

1235:19

call rounded 2XL and Shadow will be set

1235:23

to large pairing all around will be set

1235:25

to five margin four all around will be

1235:27

set to two width will be set to 52 and

1235:30

height will be set to 72 in this case

1235:32

this is use our 72 flex and items will

1235:35

be set to Center justify we also so will

1235:38

be set to Center God damn it I can't

1235:41

even type today and text will be set to

1235:43

White text will be set to extra large so

1235:45

these are going to be forward styling

1235:47

now here we're going to be also

1235:49

rendering our background gradient which

1235:51

we are now specifying right here so we

1235:53

have to use a style prop for there and

1235:55

then we going to be getting that style

1235:57

and we have to paste it right here and

1235:59

now if I sa my file this is what we are

1236:01

getting right now we are now getting the

1236:03

card one two and three and they're

1236:05

looking cool I'm going to also make them

1236:06

Center so I'm going to go into my a once

1236:08

again and here for this Dev we going to

1236:11

be providing a class name it's going to

1236:12

be set to flex and justify will be set

1236:14

to Center and also items will be set to

1236:17

Center and height will be set to 100 V

1236:20

close there and I'm going to also

1236:21

provide a background color of F3 F3 F3

1236:25

close there and here you can see we are

1236:27

now getting our cards but they are not

1236:29

dragable so now let's just make them

1236:31

dragable and to make them dragable they

1236:34

are super amazing to make dragable so

1236:36

I'll use like drag and I'm going to also

1236:38

provide a constraints for them and for

1236:40

this constraint we're going to be

1236:41

providing a left value and it's going to

1236:43

be set to minus 200 I'm going to also

1236:45

provide the right value and it's going

1236:46

to be set to positive 200 and the Top

1236:48

Value will be set to minus 200 once

1236:50

again and provide the bottom value of

1236:53

200 so now let me just save my file and

1236:55

this is how they looks like but they are

1236:57

not looking still that cool I also want

1237:00

to provide the while how animation so

1237:02

while somebody how over there so we want

1237:04

to do something with them so I'm going

1237:06

to provide the while power and here we

1237:09

have to provide the scaling and scaling

1237:10

will be set to 1.1 we just only want to

1237:13

increase that by 1% let me test this out

1237:15

so let's just refresh there if I hover

1237:17

over them yep they are looking cool but

1237:19

now I'm going to also provide the wild

1237:21

tap when somebody Taps over there so

1237:23

when I tap

1237:24

[Music]

1237:25

them so while tap and on the while tap

1237:29

I'm going to provide the scaling of 0

1237:30

point was trying to be some goddamn

1237:33

per so you know if I just H over

1237:36

there and click on there now getting

1237:37

this animation and that's looking super

1237:40

cool and yeah you can proide transitions

1237:42

if you want to Sol just right like

1237:44

transitions of duration 2 seconds and

1237:47

now if I hover over there it's going to

1237:51

gives us a slow

1237:53

transition let me change there to one

1237:56

and here you can see still they are

1237:57

looking cool but this is super slow I'm

1237:59

going to also change there to like 0.6

1238:01

or something like that let me H over

1238:03

there and yeah they are now looking a

1238:05

bit cool in my opinion that was our card

1238:10

or dragable card project in the framer

1238:12

motion welcome to the project number

1238:14

four so in this one we're going to be

1238:16

building amazing Carousel so I'm going

1238:18

to go ahead and create a components

1238:19

folder and inside there I'm going to

1238:21

define the carousel TSX file I'll use

1238:24

the rafc save this file and now register

1238:26

the inside our app component like so so

1238:29

I'm going to save this file and test

1238:31

this out so here you can see we now

1238:32

getting the carousel but this is not

1238:34

something that we want so I'm going to

1238:35

go ahead and make that tot l so I'll use

1238:38

like Flex and justify will be set to

1238:40

Center and items will also be set to

1238:42

totally Center and height will be set to

1238:44

totally screen and here you can see we

1238:46

now getting a carel which is now

1238:48

perfectly at the center of the viewport

1238:50

next I'm going to go into the carel and

1238:52

the first thing that I want to do is

1238:53

that I want to import the motion from

1238:56

where from the framer motion next we

1238:58

also have to Define our images so here

1239:00

are all of the images that I'm going to

1239:02

be using inside this project so if you

1239:04

want to use these same images you are

1239:06

more than welcome to use them or if you

1239:07

want to use your own one you are still

1239:10

more than welcome to use your own one if

1239:12

you wanted to now I'm going to go ahead

1239:13

and go to the index. CSS file and place

1239:15

a bit of styling right here so the first

1239:18

thing that I'm going to do is that I'm

1239:19

going to change the background color to

1239:20

totally black or the button the

1239:22

background color will be set to blank

1239:24

border will be set to none pairing 10

1239:25

pixel cursor position top will be set to

1239:28

50 transform property will be set to

1239:30

translate on the y axis ofus 50% Z index

1239:33

will be set to 10 color will be set to

1239:35

totally white and font size will be set

1239:36

to 1 .5 frame and when somebody how over

1239:39

there so we are going to be changing its

1239:41

color to like the opacity of that so you

1239:43

know what this is how it looks like

1239:44

right here currently we cannot see

1239:46

anything because we don't have any

1239:48

content inside there so now let me go

1239:50

ahead and start working on there so the

1239:52

first thing that I'm going to do is that

1239:53

I'm going to Define my stats so I'll use

1239:55

like first of all the current index and

1239:58

it's going to be set to the Set current

1240:00

index and now we are going to be using

1240:02

our use State and the initial value will

1240:04

be set to zero I'm going to also Define

1240:06

for the the Howard state so I'll use

1240:08

like is Howard and then set is it's

1240:11

going to be equals to the U State and

1240:13

the initial value will be set to false

1240:14

I'm going to also create one more for

1240:16

the thumbnail so I'll use like show

1240:18

thumbnails and then set show thumbnails

1240:22

it's going to be equals to the US St and

1240:24

the initial value will be set to false

1240:26

so that's cool now let me go ahead and

1240:27

go to the UI and remove the scel from

1240:29

there and here I'm going to provide a

1240:31

bit of styling today so I'll use like

1240:33

class name relative and with will be set

1240:36

to 50% and also totally rounded large

1240:39

overflow will be also set to here and

1240:42

inside this div we're going to be first

1240:43

of all defining our clickable thumbnails

1240:46

so I'll just write like uh clickable

1240:48

come on clickable thumbnails just for

1240:52

myself I'm going to use the motion. D

1240:54

because we're going to be animating

1240:55

there so now let me renter the div in

1240:57

this div we'll have a few classes so we

1240:59

use like the class name and we are going

1241:01

to be rendering all of that classes

1241:02

totally dynamically so that's why I'm

1241:04

using this template later Al so use like

1241:06

Flex margin for the bottom will be set

1241:08

to two RM and

1241:11

transition uh come on this not

1241:13

transition all and transition will be

1241:14

set to opacity and duration will be set

1241:17

to 300 now we are going to be rendering

1241:20

our thumbnail totally dynamically so if

1241:22

show thumbnail or is H if that is the

1241:26

case so then we are going to be changing

1241:27

the opacity to 100 but if that's not the

1241:30

case so what we have to do we have to

1241:32

use the opacity of zero inside there

1241:35

okay that's also done now here here

1241:37

inside this D we're going to be

1241:38

iterating over through all of their

1241:40

images that we are now currently setting

1241:42

okay so now let me just provide there

1241:44

right here and inside there I can use

1241:46

the map method on there and I can get

1241:48

the image and also the image index so

1241:50

inside there we also have to Define our

1241:52

div I'm going to duplicate this line of

1241:54

code and close there and here we have to

1241:56

specify the key and the key will be set

1241:58

to this index so I'm going to copy the

1242:00

name of there and place it right here

1242:01

and I'm going to also attach a lot of

1242:03

classes today and once again we are

1242:05

going to be using a dynamic class so so

1242:07

that's why we are now using these

1242:08

template literals so I'll use like

1242:10

withth will be set to 10 rim and also

1242:13

height will be set to five rim and then

1242:15

outside from them margin for the top

1242:17

will be set to two rims I'm going to

1242:19

also set the cursor to to pointer and

1242:21

rounded large overflow will be set to

1242:24

totally hidden border all around will be

1242:27

set to two now let me just save my file

1242:29

and that's going to be it but I'm going

1242:30

to also render my content dynamically so

1242:33

if our current index is equal to this

1242:35

index let me just write triple equals to

1242:38

if there is set to this specific image

1242:41

index so in this situation we want to

1242:42

provide the Border blue of 500 but if

1242:46

that's not the case we're going to be

1242:47

changing the border to totally

1242:49

transparent so now let me just save

1242:50

there and inside this div I'm going to

1242:52

render my image so I'll use like the IMG

1242:55

tag also the SRC for the source and for

1242:58

the source we are going to be rendering

1242:59

that image which we are now iterating

1243:01

over through okay so we are going to be

1243:03

rendering all of that images and I'm

1243:05

going to also provide the alternative

1243:06

text for the so I'll use like alt and

1243:08

for this alt I'm going to say like uh I

1243:10

don't know thumbnail or something like

1243:13

that and then index come on index + one

1243:16

I'm going to also Pro a bit of classes

1243:17

today so width will be set to totally

1243:19

full and height will also be set to

1243:21

totally full object toly cover and come

1243:25

on cover and close there like so so I'm

1243:28

going to save my file and now let me

1243:29

just refresh there we are now getting

1243:31

our images we cannot see anything and

1243:33

the reason is we are now setting there

1243:35

to false so now if I set the true come

1243:38

on let's just write a true and sem my

1243:39

file so now we are getting these images

1243:41

I can also change that to like maybe two

1243:43

or something like that and now if I just

1243:45

refresh there we would be able to see

1243:46

this image selected right here okay so

1243:48

if I change it to I don't know maybe one

1243:50

and now if I save my file so it's going

1243:51

to select this image right here so which

1243:53

is something yeah that we want okay so

1243:56

that's our basic thumbnail images and

1243:59

now let's work on the real images so

1244:01

what I'm going to do is that I'm going

1244:02

to comment or hide there from the UI and

1244:06

next we're going to rendering the actual

1244:09

uh come on actual images right here so

1244:11

now underneath them they're going to be

1244:12

creating our div and this div will have

1244:14

the class name of leg and also inside

1244:17

this div what do you want to do you want

1244:18

to Define another div so for this div we

1244:21

are going to beating over through all of

1244:23

our item so I'll use like the images

1244:24

once again come on that images and now

1244:27

let's just iterate over through this

1244:28

I'll use the map method and proide the

1244:31

image and also uh the index itself so

1244:34

inside there we're going to be using a

1244:36

div and now just duplicate that and

1244:37

change that to a d one more time and

1244:39

here I'm going to have to specify the

1244:41

index like so and also I'm going to

1244:43

provide the class name of minimum height

1244:45

will be set to totally okay so I mean

1244:47

like minimum width will be set to

1244:48

totally full and here we have to also

1244:50

render our image so I'm going to also

1244:51

provide the SRC and for the source we

1244:53

going to be providing the image and for

1244:55

the alternative text I'm going to say

1244:57

like uh slide come on slide and here we

1245:00

have to render our index + one and

1245:02

that's toally done I'm going to close

1245:04

there but I'm going to also provide the

1245:06

class name of with will be set to

1245:07

totally full save my file and we are now

1245:09

getting these images which are not

1245:11

looking that great to be honest but yeah

1245:14

we are going somewhere and now we are

1245:16

getting these images you know what I'm

1245:17

going to also go ahead and provide the

1245:19

class name of flex to this one now if I

1245:21

save my file and or UI is looking more

1245:24

than great right here so we are now

1245:26

getting all of their images and by the

1245:28

way you can also definitely go ahead and

1245:30

change change these images to something

1245:31

else that you prefer but in my case

1245:33

that's going to be a I'm going to also

1245:35

hide there and now underneath then we

1245:37

are going to be providing our buttons so

1245:39

let's just write like uh render buttons

1245:42

or something like that so what I'm going

1245:43

to do is that I'm going to Define my

1245:45

button and this button will have a lot

1245:47

of classes but I'm going to provide my

1245:48

left eye conso used like the HTML entity

1245:51

which is to use the end and then HH

1245:54

1094 this is a special HTML entity and I

1245:57

also forgot to close this so we're going

1245:59

to be also closing there now if I save

1246:01

my file so here you can see we are now

1246:03

getting this left or right entity or

1246:05

whatever you want to call I'm talking

1246:07

about this icon right here so this is

1246:09

basically something called the HTML

1246:11

entity if you guys don't know about you

1246:13

can definitely go ahead and check out my

1246:15

HTML and CSS course if you prefer that

1246:17

but I'm going to provide the class names

1246:19

and these class names will be totally

1246:21

Dynamic so I'm going to use like the

1246:22

absolute and the left value will be set

1246:24

to four transform and here not translate

1246:28

but transform and here we also have to

1246:31

set the translate to the Y AIS so I'll

1246:34

use like y AIS on one O2 and then

1246:38

pairing all around will be set to two

1246:40

we're going to be also providing a bit

1246:41

of transition today so let's just use

1246:43

our transition and the transition will

1246:45

be set to the opacity and I'm going to

1246:47

also provide the duration of 300 in this

1246:50

case and now we have to render our

1246:52

content totally dynamically so is howed

1246:55

so in that situation we going to be

1246:56

providing the opacity of 100 but if

1246:58

that's not the case we're going to be

1247:00

providing the opacity of zero today so

1247:02

now let me show you that here you can

1247:03

see nothing is happening but now if I H

1247:06

over there oh you cannot see that

1247:07

because we also have to change the set I

1247:09

forgot to do that so I'm going to

1247:12

duplicate this line of code like so and

1247:15

here I'm going to also change the HTML

1247:16

entity to something else so I'll use

1247:18

like um instead of providing a four I'm

1247:21

going to change that to five and this is

1247:23

how it looks like we cannot see that but

1247:25

you will see that very soon so what I'm

1247:27

going to do is that I'm going to take

1247:29

care of the UI and also the starts I'm

1247:32

going to hide there so let's start from

1247:34

the thumbnails I'm going to expand there

1247:36

and here we're going to be attaching the

1247:38

what do we call it or event handler so

1247:39

I'll use like the key and the key will

1247:41

be set to the index I'm going to also

1247:43

attach the on click event handler when

1247:45

somebody clicks on there we're going to

1247:46

be firing this function which is a uh

1247:48

selected slide and here we have to

1247:51

specify our index inside there now let

1247:53

me go ahead and create this selected

1247:55

slide so I'll use like con selected

1247:58

slide it's going to take a index and

1248:00

index will be set to a number we have to

1248:02

annotate as a number for our typescript

1248:04

and now we are going to be using like

1248:05

Set current index index and it's going

1248:07

to be set to that index which we are now

1248:09

getting and we also have to provide like

1248:11

uh set show thumbnail and we have to set

1248:13

that to true and also I'm going to be

1248:15

using a Windows object and obviously giv

1248:17

this a Time script error so I'll use

1248:19

like Windows set time out come on uh set

1248:23

time out and here we have to specify

1248:26

oret show thumbnail and we're going to

1248:28

be setting that to false and the

1248:30

duration will be set to 5 seconds so I'm

1248:32

going to save this file I'm going to

1248:33

copy the name of there and provide there

1248:36

right here in a selected we're going to

1248:38

be changing that to a select oh and what

1248:40

the hell am I doing I'm going to have to

1248:42

cut that from there and put that right

1248:45

here like so so now let me just save my

1248:47

file and now if I just refresh there

1248:49

here you can see we now getting the

1248:50

images but now if I click on this one

1248:52

it's going to select that one if I

1248:53

remove my cursor from there and here you

1248:55

can see that images will disappear so if

1248:57

I H them back and click on there here

1249:00

you can see it's going to make it appear

1249:01

once again so that's also cool but now

1249:04

let's just take care of these images so

1249:05

like whenever I choose some image from

1249:07

there we also want to update that image

1249:10

first thing first I'm going to hide that

1249:12

and I'm going to go ahead and go to the

1249:14

actual images and expand this one now

1249:16

let me attach my on Mouse enter and here

1249:20

we have to set the two the said is

1249:23

Howard and that's going to be set to

1249:24

true and now I'm going to also proide

1249:27

the on Mouse leave and here it's going

1249:30

to be set to come on what the hell it's

1249:33

going to be set to the is Howard and

1249:35

that's going to be set to false in this

1249:37

case so I'm going to save my file inside

1249:39

this div I'm going to make that as a

1249:40

motion div so I'll just change that to

1249:42

motion. div and I'm going to also change

1249:45

this one to the motion. div okay so I'll

1249:48

just use like motion. div and let is sa

1249:51

there we are getting some sort of error

1249:54

and we did import it there I don't know

1249:56

why we are getting this error what the

1249:58

hell we now closing the here you know

1250:00

I'm going to change the okay now that's

1250:02

looking better and now if I sa my file

1250:04

and test this out so here you can see we

1250:06

are now getting these images and now if

1250:08

I H over there we're also getting these

1250:10

HTML entities right here which is also

1250:12

something that we want but I don't know

1250:14

why the hell we are getting these images

1250:16

I'm going to go to the top and you

1250:17

guessed it I forgot to include the N now

1250:20

let me just save there we are only

1250:21

getting this one image and I'm going to

1250:23

also take care of this HTML entity so

1250:26

let's just go to the bottom and here

1250:28

instead of riding a left I'm going to

1250:29

change there to the right and now if I

1250:31

are over there so now we are getting

1250:33

this amazing UI I can also choose

1250:35

different images if I want to but now if

1250:37

I click on this image what if I click on

1250:39

these buttons I want to change this

1250:41

image how can I go about doing there

1250:44

this is how we are going to be doing

1250:45

this so let's just go ahead and go to

1250:46

the button and attach my own click event

1250:48

handler on there and previous slide okay

1250:52

so this is going to be a function which

1250:53

we going to be creating in a few seconds

1250:55

and also on this one we are going to be

1250:57

attaching the event handler and we're

1250:59

going to be saying like next slide okay

1251:01

so now let me just copy this previous

1251:03

one and let's just start working on that

1251:04

one so what I'm going to do is that I'm

1251:07

going to Define my previous one so I'll

1251:09

use like cons previous slide and inside

1251:11

there uh we have to Define what Set

1251:14

current index and inside this Set

1251:16

current index we're going to be

1251:17

providing our previous index now here

1251:20

what we have to do uh we have to get the

1251:22

previous index and then minus1 times the

1251:26

images. length then we have to multiply

1251:28

there and we also want to get the

1251:29

remainder so that's why we are using

1251:31

this module operator so let's just use

1251:33

our images. length Okay so it's going to

1251:35

gives us a previous image so now let me

1251:37

just refresh there we are not going to

1251:38

be able to see anything in this because

1251:41

of this function so I'm going to also go

1251:43

ahead and create this function right

1251:45

here up above so I'll use like cons uh

1251:48

next slide and inside there we're going

1251:50

to be setting the current index to the

1251:52

previous index come on uh previous index

1251:56

and then here we have to use our

1251:58

previous index once again and then plus

1252:00

one now we have to use the module

1252:02

operator on the images. length so now if

1252:05

i s my file and here you can see we now

1252:07

getting the CI if I click on there it's

1252:09

going to gives us the next image right

1252:11

here but it is not updating this one

1252:13

okay so I can also click on that one I

1252:15

can also click on this previous one it's

1252:17

going to also update there so here you

1252:19

can see if I click on that one and click

1252:21

on the previous one okay it is not even

1252:23

showing nothing so to fix that issue

1252:26

we're going to be first of all providing

1252:27

our initial State and for this initial

1252:29

State we're going to be setting that to

1252:30

the xaxis of - 100% And also underneath

1252:34

that we going to be using the animate

1252:36

cross and on this animate prop we going

1252:38

to be changing that to this minus the

1252:41

current index and then times come on

1252:43

times 100% not th000 but just 100% And

1252:48

also you want to put a bit of

1252:49

transitions to there so I'll use like

1252:50

the duration and the duration will be

1252:52

set to one and here you can see if I

1252:54

just click on this image it's going to

1252:56

show us that image if I click on that

1252:58

it's going to show us this image now if

1253:00

I click on this one I don't know what

1253:02

just

1253:03

happened this is some kind of a bug or

1253:05

something no this is cool we are now

1253:08

getting these images if I click on there

1253:10

it's going to bring it back this is not

1253:12

something that I wanted let's just go

1253:14

ahead and figure this out so we have a

1253:16

previous slide and then we have a next

1253:18

slide I guess there is something wrong

1253:19

with the previous slide oh you know what

1253:21

I'm providing a times instead of a times

1253:23

we have to change that to plus sampol so

1253:26

now if I just refresh that we're going

1253:28

to be getting all of that images if I

1253:29

click on this one so it's going to use

1253:31

us the last image then the next one and

1253:33

then the next one and so on and so for

1253:36

so yeah that was our basic Carousel by

1253:39

using our frame or motion welcome to the

1253:41

fifth project of this course so in this

1253:43

one we're going to be building amazing

1253:45

animated sidebar so what I'm going to do

1253:47

is that I'm going to Define my

1253:48

components folder and inside there we're

1253:51

going to be defining the sidebar. TSX

1253:53

file so I'll use like the rafc sa my

1253:55

file and registered there right here

1253:58

just like that I'm going to also make it

1254:00

totally perfectly centered so I'll use

1254:01

like Flex and justify will be set to

1254:03

Center and also items will be set to to

1254:06

the center the height will be set to

1254:08

screen width will be full and also

1254:10

background cray of

1254:12

950 let is say our file and this is how

1254:15

it looks like so what I'm going to do is

1254:17

that I'm going to also specify the text

1254:19

of totally white and yeah this is how it

1254:21

looks like currently now let's get into

1254:24

the sidebar and start working on there

1254:26

the first thing I would do is that I'm

1254:27

going to import the motion from where

1254:30

from the framer motion we're going to be

1254:31

also defining our state like whether our

1254:34

sidebar is open or close so I'll use

1254:36

like is open and then set is open it's

1254:39

going to be equals to the use St and

1254:41

here we have to specify the initial

1254:43

value of Fes today now let's get into

1254:45

the UI so I'll just remove them and

1254:47

provide the class of relative today okay

1254:50

so inside there we're going to be first

1254:52

of all defining our backdrop which we

1254:54

going to be doing in a few seconds but

1254:56

now underneath them we have to start

1254:58

working on our actual sidebar content

1255:01

okay I'll use like sidebar content and

1255:03

here we can use our motion. D so I'll

1255:05

use like motion. and close there and

1255:07

inside this motion D I'm going to

1255:09

specify a few classes like it's going to

1255:10

be set to totally fix stop will be set

1255:12

to zero and left will be also set to

1255:15

zero height will be set to totally full

1255:17

and width will be set to 64 come on 64

1255:21

like that take around gray of 900 and

1255:24

text totally white shadow will be set to

1255:27

totally large so now let me just save

1255:29

this file next we're going to be

1255:30

defining our variant so I'm going to go

1255:32

to the top and Define my sidebar

1255:34

variants right here so first of all

1255:36

provide the open St when it is open so

1255:39

we want to set the initial x value to

1255:41

zero and I'm going to also specify the

1255:43

opacity to one and the scaling will be

1255:45

also set to one so now I'm going to just

1255:47

put a comma and I'm going to also

1255:48

provide the closed one so close so when

1255:51

it is closed we want to set the xais to

1255:53

minus 100% And also the

1255:56

opacity opacity will be set to zero in

1255:59

scaling will also be set to 0.8 so I'm

1256:02

going to copy the name of there and

1256:04

provide there right here inside

1256:06

or sidebar okay so I'll use like the

1256:08

variants and for these variants we're

1256:10

going to be providing our sidebar

1256:12

variants now which means like I can

1256:13

definitely use my initial State and for

1256:15

the initial State we're going to be

1256:17

setting there to closed I can also use

1256:19

the animate so here what I'm going to do

1256:22

is that I'm going to pass my content

1256:23

totally dynamically so if this is open

1256:26

you want to use the open St but if

1256:28

that's not the case you want to use the

1256:29

closed state I'm going to also put the

1256:32

transition to this so I'll use like the

1256:33

transition the type will be set to one

1256:35

of my favorite type which is a spring

1256:38

and also the stiffness will be set to

1256:40

300 and damping will be set to 30 now

1256:44

let me just save there inside there you

1256:46

cannot see anything but what I'm going

1256:48

to do I'm going to provide a bit of

1256:49

content to there so I'll use like

1256:51

pairing all around will be set to four

1256:53

and inside that we have to Define our

1256:54

button and this button will also have a

1256:56

few classes like absolute also the top

1256:58

will be set to four right will be set to

1257:01

four and Z index will be 10 so now let

1257:04

me just hit tab we also have to specif

1257:06

if I pading all around to two and

1257:08

background gray of 800 T toally white

1257:11

and round it full and on the focus we

1257:14

want to change the outline to totally

1257:16

none and it's going to just say like uh

1257:19

you know what we have to render the icon

1257:21

first of all we have to install our

1257:22

icons Library so I'm going to be using

1257:23

like npmi and then react icons so it's

1257:26

going to install that inside my project

1257:29

now then successfully install so use

1257:31

like npm run Dev now here we have to

1257:33

render our iomd Arrow back this I'll

1257:37

just rendered there and I'm going to

1257:38

also provide a bit of classes to it so

1257:40

I'll use like the height will be set to

1257:41

six and the width will be also set to

1257:43

six so now let me just save my file and

1257:45

refresh there we cannot see anything

1257:48

that's because now our initial state is

1257:50

set to false so if I set that to True

1257:52

save my file and here you can see we now

1257:54

getting this sidebar with this icon so

1257:56

if I set that to the false once again

1257:58

save my file yeah it will totally make

1258:00

it disappear now I'm going to collapse

1258:02

this button and underneath this button

1258:04

I'm going to specify my H2 so use like

1258:06

H2 with the class of text to Xcel and

1258:09

font will be set to totally Bard margin

1258:11

for the bottom will be set to four and

1258:13

I'll use like filters inside there you

1258:15

know what I'm going to go to the top and

1258:17

make there as a true so that we can see

1258:19

them and here you can see we're now

1258:20

getting our filters which is something

1258:22

that we want and now underneath this H2

1258:25

what we have to do we have to once again

1258:26

Define our motion. D so I'll use like

1258:29

motion. d and close them inside this

1258:31

motion. D I'm going to specify the

1258:32

classes of space on the Y AIS of four

1258:35

I'm going to also provide the the

1258:36

variants I'll go to the top like so and

1258:39

Define my variants right here and these

1258:41

variants are going to be a lot of

1258:42

variants so I'll use like con and here

1258:44

we have to create our container variants

1258:47

and inside there first of all we are

1258:48

going to be providing the open State

1258:50

then we are going to be also providing

1258:51

the closed State okay so let's start

1258:54

from the first one which is the open

1258:55

state so we're going to be using our

1258:57

transition come on t r a n s i t i o in

1259:00

and inside this transition we're going

1259:02

to be providing a stagger come on

1259:04

stagger children s a g e r children and

1259:08

that's going to be set to come on Stager

1259:11

children will be set to 0.2 and I'm

1259:13

going to also provide the delay between

1259:15

them so delay between the children it's

1259:17

going to be set to 0.1 and same thing

1259:20

we'll apply for this closed one so I'm

1259:22

going to copy them now let me just place

1259:24

it right here and instead of providing a

1259:26

one I'm going to change there to zero

1259:28

and I guess that's going to be fine now

1259:29

I'm going to copy the name of there and

1259:31

go to the bottom and here we have to

1259:33

specify there right here so I'll use

1259:35

like variants and provide my container

1259:38

variants inside there so now let me just

1259:40

save my file and which also means that

1259:42

now I can use the initial State and

1259:44

initially my state will be set to close

1259:46

and on the animate we want to use like

1259:48

if it is open then we want to use like

1259:50

the open state if that's not the case so

1259:53

we want to choose the closed one so now

1259:54

let me just save my file inside this div

1259:56

we are going to be defining yet another

1259:58

div which will be also motion. div so

1260:01

now let me just close them and here for

1260:03

this motion. div we are going to be also

1260:05

providing a Vari so I'm going to go to

1260:06

the top once again and here we have to

1260:09

specify our item variant so I'll use

1260:11

like cons item variants and inside that

1260:14

we have to use the open State and for

1260:16

this open State we're going to be

1260:17

setting the opacity to one and on the y

1260:19

axis is going to be set to zero and for

1260:21

the scale we're going to be increasing

1260:23

there to one now here we also have to

1260:24

provide for the close state so I'll use

1260:26

like the opacity and opacity will be set

1260:28

to zero on the Y AIS is going to be set

1260:31

to minus 20 and for the scaling we're

1260:33

going to be using like

1260:34

0.95 I'm going to go ahead and copy the

1260:36

name of there and place there right here

1260:39

for this de so I'll use like the

1260:41

variants and here we have to specify our

1260:43

items variant inside there first of all

1260:45

I'm going to be using the H3 with the

1260:47

classes of text only extra large and the

1260:49

font will be set to semi B it's going to

1260:52

say like category or categories rather

1260:56

and here now underneath we're going to

1260:58

be using our ul and then Ali and for

1261:00

this each Ali we're going to be defining

1261:02

a label with the class of inline Flex

1261:05

and also the items will be set to Center

1261:08

and margin for the top will be set to

1261:09

two we're not going to be providing the

1261:11

HTML 4 and for the label we're going to

1261:14

be defining our input field with the

1261:15

type of checkbox so I'll use that

1261:17

checkbox and then we're going to be also

1261:19

putting a class names in the form it's

1261:21

going to be set to a form check box like

1261:24

so underneath that we also have to

1261:25

provide our span and it will have the

1261:27

margin for the left and it's going to be

1261:28

set to two and here we have to specify

1261:31

like the option one now let me S there

1261:34

check this out so here you can see we

1261:35

are now getting this checkbox and we are

1261:37

also getting these categories right here

1261:40

which is something that we wanted so

1261:42

what I'm going to do is that I'm going

1261:44

to duplicate there like a few time maybe

1261:46

three times so I'll just select this lii

1261:49

and I'm going to just duplicate there

1261:50

one time and another time so I'll just

1261:53

change that to like two and this one to

1261:55

three let me just save my file and this

1261:57

is how it looks like right here now

1261:59

underneath this div I'm going to

1262:01

collapse this div we're going to be

1262:03

defining yet another div so I'll use

1262:05

like the motion. D once again and close

1262:08

them and here we have to specify not the

1262:10

class name but the variance and we're

1262:12

going to be using that irem variance

1262:14

once again okay so inside this D we're

1262:16

going to be defining the H3 H3 with the

1262:19

class of text Excel and the font will

1262:22

also be set to totally semi Bard it's

1262:25

going to say like price range so now if

1262:27

I sa there test this out so we are now

1262:30

getting our price range right here now

1262:31

underneath this hed3 we are going to be

1262:33

defining the input field and it's going

1262:35

to have the type of range and also you

1262:37

want to specify the minimum height and

1262:39

the minimum will be set to zero we also

1262:42

want to provide the maximum and for the

1262:43

maximum you're going to be setting there

1262:45

to like 100 and the class name will be

1262:47

set to full and I'm going to also put

1262:49

the step not stop but step and step will

1262:51

be equals to 10 so if I save them now we

1262:54

are getting this awful looking slider if

1262:57

I weren't using 10 CSS there wouldn't be

1262:59

cool slider but yeah we are getting this

1263:01

awful slider you can definitely go ahead

1263:03

and change that if you want it to but in

1263:05

my case

1263:06

that's going to be it so I'll just

1263:08

collapse that and underneath this one we

1263:11

have to Define yet another div so I'll

1263:14

use like the motion motion. D once again

1263:17

close them and here we have to provide

1263:19

our variants once again so I'll use like

1263:21

the items variant and inside there we

1263:24

have to define the H3 with a class of

1263:25

text Excel and the font will be set to

1263:28

semi B inside there will proide the

1263:31

rating s file and here you can see we

1263:33

now getting the rating now underneath

1263:35

there we're going to be using the UL and

1263:37

then the Ali for each Ali we're going to

1263:39

be providing a label and for this label

1263:42

we are going to be providing like in

1263:43

line uh come on in line flex and also

1263:46

the items will be set to to the center

1263:48

margin for the top will be set to two

1263:50

inside then not HTML 4 inside this level

1263:54

we're going to be defining our input

1263:56

field with the type of radio in this

1263:58

case and here we have to provide the

1263:59

name and the name will be set to rating

1264:02

and the value will be set to one I'm

1264:05

going to also Pro the class name of like

1264:07

home ready you know we not going to be

1264:08

providing that let's just remove the

1264:10

class name from there sa file and yeah

1264:13

we are now getting or whatever you want

1264:15

to call that so now underneath that we

1264:17

going to be also using a spin with the

1264:18

class of margin for the left of two it's

1264:20

going to say like first star and here

1264:22

you can see we're now getting the stars

1264:24

and I'm going to also duplicate this Li

1264:26

a few times so that star 1 2 3 4 and I

1264:29

guess four would be fine so I'll just

1264:31

change there to star two and this one to

1264:34

Star three

1264:36

this one to Star four and you know what

1264:38

we want to make there as a five star so

1264:39

I'm going to also duplicate there one

1264:41

more time and change that to the star

1264:43

five that's all done so now let's just

1264:45

save our file and here you can see if I

1264:47

just refresh there okay we first of all

1264:49

have to save there if I just refresh

1264:51

there we are now getting this amazing

1264:52

looking UI and also the animation so if

1264:55

I just refresh there once again yeah you

1264:57

will see that in a few seconds so now

1264:59

underneath this T I'm going to collapse

1265:01

this T right here underneath this T

1265:04

we're going to be defining our button

1265:05

which will allows us to hide or show

1265:07

that sidebar so I'll use the button with

1265:09

the class of absolute and also the Top

1265:12

Value will be set to four the left value

1265:14

will be also set to four the Z index

1265:16

will be set to 10 pairing on around will

1265:19

be set to two background Ray of add 100

1265:22

Tex to White and round it for Focus ST

1265:26

we're going to be taking care of the

1265:27

Focus ST in a few seconds so I'll use

1265:29

like the out come on outline will be set

1265:32

to none and for the label we're going to

1265:34

be providing this level totally

1265:36

dynamically so if our state is open in

1265:38

this situation you want to show one icon

1265:41

but if that's not the case we want to

1265:42

show another icon so I'll use like IO MD

1265:46

and then Arrow back okay so I'll also

1265:49

proide the class name of it will be to

1265:51

set to six with will be also set to six

1265:53

and close them now here if that's not

1265:56

the case we are going to be using like

1265:58

the I MD Arrow forward and we also have

1266:01

to provide these classes like the height

1266:03

will be set to six the width will be

1266:05

also set to to six and close there now

1266:07

this is how it looks like so if I click

1266:09

on there nothing will happen and why

1266:11

because we have to provide our event

1266:13

listener on there or attach what EV

1266:15

listener on there so when somebody try

1266:17

to click on there we going to be firing

1266:18

this function which is a set is open and

1266:21

not is open so now let me just save my

1266:23

file if I click on there that's gone if

1266:27

I click on there once again it will make

1266:29

it appear I also want to make it so that

1266:31

if I click on this icon I want to hide

1266:33

there so what I'm going to do is that

1266:35

I'm going to go to the top and here on

1266:37

this icon if somebody try to click on

1266:39

there on clicks so we're going to be

1266:41

firing this function which is a set is

1266:43

open and not is open so now let me just

1266:46

save there if I click on there it's

1266:48

going to hide it if I click on there

1266:50

once again so it's going to show there

1266:51

and this is how it looks like I'm going

1266:53

to also take care of this backdrop so

1266:55

that's going to be a lot of fun but this

1266:57

is super simple so I'll just create a

1266:59

motion div and close them like so and

1267:03

here we have to specify our class name

1267:05

so use like only fix and insert will be

1267:07

set to zero background gray of 8 100

1267:11

like so and also on the initial State

1267:14

it's going to be set to close and then

1267:17

on the animat state we can totally show

1267:19

there and also hide there so if this is

1267:21

open like if our state is open then we

1267:24

want to provide the state of open to the

1267:26

from the variants but if that's not the

1267:28

case we want to set there to close St

1267:30

okay so we're going to be also providing

1267:32

a variance today I'm going to also

1267:34

provide this variance right here here so

1267:35

I'm going to go to the top and create

1267:37

this variant right here and this is

1267:39

going to be quite simple and easy so

1267:40

I'll use like con backdrop variant and

1267:43

inside there we have to provide the open

1267:45

State and on this open State we're going

1267:47

to be setting the opacity to opacity to

1267:50

0.6 and now underneath there on the

1267:52

close St we want to change the opacity

1267:55

to totally zero okay so now we

1267:58

successfully provided there next I'm

1268:00

going to also specify the transition so

1268:02

I'll use like the transition and the

1268:03

duration will be set to 0.3 and when

1268:06

somebody clicks on there we're going to

1268:08

be setting that set is open to false now

1268:12

let me just s my file now if I click on

1268:15

there once again it's going to hide it

1268:17

okay so yeah that was our basic project

1268:19

time to create one of my favorite

1268:20

project which is called the scrollable

1268:22

carousel but we are going to be

1268:24

animating there so first of all I want

1268:26

to talk about this UIL folder so inside

1268:28

this utils folder we have this data. TS

1268:31

file and here you can see I have a few

1268:33

images which I copied from the unsplit

1268:36

if you care to use these images you can

1268:38

totally find them in my giab repository

1268:40

but if you don't want to use them you

1268:42

can definitely use your own one if you

1268:43

wanted to but yeah I'm going to be using

1268:45

this data for my card images so I'll

1268:48

just close them and now let's start

1268:49

working on there the first thing that I

1268:51

want to do is that I want to Define my

1268:53

components come on components folder and

1268:56

inside there we are going to be defining

1268:57

our scroll carl. TSX or use the rafc and

1269:01

go to my app and register this component

1269:04

right in here oh my goodness and now I'm

1269:08

going to close there save my file let's

1269:09

get into the scroll level Carousel and

1269:12

start working on there okay I'll use

1269:14

like import motion from where from the

1269:17

framer motion I'll sa there or you know

1269:20

we're not going to be using any frame or

1269:21

Motion in this one so yeah we are going

1269:24

to be using them I'm going to also go

1269:26

ahead and Define the card. TSX file and

1269:29

use my RFC inside there and import it

1269:32

inside the scroll car so use like import

1269:35

card and from card you would also need

1269:38

to grab our data so I'll use like import

1269:41

come on import the cards from where come

1269:44

on

1269:46

cards uh from where from the let's just

1269:49

go ahead and go to the top go to the UIL

1269:51

folder and choose this data from there

1269:53

now that we successfully grab all of the

1269:55

data we're going to be actually

1269:56

interacting with the Dom so for that we

1269:58

have to use our Target ref so I'll use

1270:01

like the use ref and here for the

1270:03

initial value I'm going to set there to

1270:05

now we're going to be scrolling so which

1270:06

means like we would need the use scroll

1270:09

Hook from the framer motion I'll just

1270:10

grab the Y scroll from there so I'll

1270:12

just destructure that from here I'm

1270:14

going to say like the scroll on the Y

1270:17

progress we only want to get there I'm

1270:19

going to also provide the target so I'll

1270:20

use like the Target and the target will

1270:22

be coming from the target ref okay which

1270:25

we are now specifying as a reference

1270:27

right here next we have to Define our

1270:28

transform property all use like the use

1270:31

transform and here first of all we are

1270:33

going to be providing our scroll on the

1270:34

Y progress as a motion value and then we

1270:37

have to specify our initial State and

1270:39

also our ending state so when our

1270:41

animation start from zero so we want to

1270:44

make the

1270:46

1% but if it reaches to 1% then we want

1270:50

to make it -

1270:53

95% just like that I'm going to save

1270:55

this file and I'm going to also store

1270:57

that in the X variable now let me go

1270:58

ahead and go to this UI and remove that

1271:00

from here and I'm going to put the class

1271:02

names and it's going to be set to

1271:03

relative the height will be set to 300

1271:05

pH like the viewport height and

1271:07

background will be set to neutral

1271:10

900 like so and for the ref we are going

1271:13

to be providing our Target Come On

1271:15

Target ref inside there now inside this

1271:17

div we're going to be defining yet

1271:19

another div with a class of sticky the

1271:21

top will be set to zero legs and height

1271:24

will be also set to screen item toly

1271:26

Center and

1271:28

overlow will be hidden okay so inside

1271:30

this D we're going to be defining our

1271:32

motion. D and close there I'm going to

1271:34

also the class name of flex and the

1271:36

gapping will be set to four and for The

1271:38

Styling let me just put the style right

1271:40

here we're going to be using this

1271:42

transform value which is now set to this

1271:44

x so I'm going to copy there and place

1271:45

it right here inside this motion da

1271:48

we're going to beating over through all

1271:49

of that card so I'll use like cards. map

1271:52

and here we have to specify each card

1271:54

and now inside there let's just render

1271:56

our card component which we just created

1271:58

it's going to take the prop of card and

1272:00

now let me just close there you're Now

1272:02

using this cards you know rating over

1272:05

through all of that cards and then we

1272:07

are creating a separate card inside

1272:09

there as you can see and we're now

1272:10

passing that each image as a card prop

1272:13

to there so now let me go ahead and go

1272:15

to the card and start working on this

1272:17

card so what I'm going to do is that I'm

1272:19

going to go to the top and here we are

1272:20

going to be destructuring the cards or

1272:22

was there a cards or yeah it's just a

1272:25

card so I'm going to just destructure

1272:27

them and annotate as a string maybe or

1272:30

you know what card then string so now

1272:33

let me just save my file and we have to

1272:35

use the I'll remove this card from here

1272:37

and I'm going to also provide a bit of

1272:39

class or you know what we're going to be

1272:40

providing the key I'm going to provide

1272:42

the key right here so key or index or

1272:45

idx would be fine so for the idx we're

1272:48

going to be passing this index which

1272:49

will be coming from this cardr Index

1272:52

right here so I'll just also destructure

1272:54

this index let's just destructure them

1272:56

and I'm going to also annotate that

1272:57

right here so I'll use like ID IDK it

1273:00

should be idx God damn it idx come on

1273:03

idx and now let me just copy the name of

1273:06

there and destructure the idx instead

1273:08

and also this idx this will be a number

1273:11

so now let me just save there this is

1273:12

how we going to be annotating there but

1273:14

I'm going to also specify this idx right

1273:16

here that's totally done I'm going to

1273:18

also put the class names and it's going

1273:20

to be set to group and also

1273:23

relative with will be set to 10 Rim come

1273:26

on 10 rim and I'm going to also put the

1273:28

height of 10 Rim overflow will be set to

1273:31

totally hidden and the background will

1273:33

be set to neutral 200 inside this div

1273:37

we're going to be defining another div

1273:39

and here we're going to be rendering our

1273:40

image so I'll use like The Styling right

1273:42

here and for these styling I'll provide

1273:44

the background image first of all and

1273:47

it's going to be set to this URL this is

1273:49

for URL and close there and here we're

1273:52

going to be rendering our image only

1273:53

dynamically so I'll use like card. URL

1273:56

and now let me just save this file and

1273:58

now underneath that we are going to be

1273:59

also providing the background come on

1274:01

not backdrop but the background will be

1274:03

set to size and it's going to be set to

1274:06

totally cover I'm going to also provide

1274:07

the background position and the

1274:09

background Position will be set to

1274:11

totally Center like so I'm going to also

1274:14

put a bit of classes to this so I'll use

1274:16

like only absolute and the inser will be

1274:18

set to zero Z index will be set to and

1274:20

the transition will be set to transform

1274:23

I'm going to also put the duration and

1274:25

duration will be set to 300 uh we're

1274:27

going to be setting the two scale of 110

1274:30

now let me S my file now let me just

1274:32

refresh my file and now if I scroll down

1274:35

here you can see we now getting all of

1274:36

that carel images right here and now if

1274:39

I H my mouse over to each of these

1274:40

images we are now getting the kind of

1274:42

amazing animation right here that's also

1274:45

looking cool and that was our scrollable

1274:47

animation I'm not scrolling on the xaxis

1274:50

I'm scrolling on the Y AIS and now if I

1274:52

scroll there we now getting all of that

1274:54

images and that's looking super amazing

1274:57

welcome to the new project so in this

1274:58

one we are going to be building advanced

1275:00

level sticky navigation bar by using the

1275:02

frame or motion so what we have to do

1275:04

first of all I'm going to go ahead and

1275:06

Define my components folder and inside

1275:08

there we are going to be defining a

1275:09

sticky n. TSX file I'm going to also

1275:12

Define the card. TSX file as well okay

1275:15

I'll use the RFC inside the sticky

1275:17

navigation bar and also the RFC inside

1275:19

the card I'm going to go ahead and

1275:21

Define my uh what do we call Sticky

1275:23

navigation inside our app I'm going to

1275:25

save this file and now let's just start

1275:27

working on there okay so yeah we already

1275:30

started there I'm going to import

1275:31

something called the motion from where

1275:33

from the framer motion that's going to

1275:35

be the first thing that we have to do

1275:37

next we have to Define our variant so

1275:39

that we can use the inside our animation

1275:41

so I'll use like first of all we're

1275:43

going to be creating the menu variants

1275:45

here we have to Define our hidden State

1275:47

when it is hidden so we're going to be

1275:49

changing the height to 5.6 Ram okay and

1275:53

when it is visible so in that situation

1275:55

let's just write a visible in this

1275:57

situation it's going to be set to 29

1275:59

rims and I'm going to also provide a

1276:01

transition to there so let's just use a

1276:03

transition and this going to be set to

1276:05

the duration and the duration will be

1276:07

set to 0.3 seconds so that's going to be

1276:10

it for our menu variance and now let's

1276:12

just create one more for the expand row

1276:14

variance so I'll use like expand what we

1276:17

have to do we have to first of all

1276:18

Define the hidden stad and when it is

1276:20

here and so we going to be changing the

1276:22

opacity to zero and also the y- AIS will

1276:24

be set to 50 and now underneath that we

1276:26

also have to Define our visible State

1276:28

and it's going to take the index and

1276:30

index can be basically anything so I'll

1276:32

just write like any I'm going to define

1276:33

the opacity and the opacity will be set

1276:35

to one y AIS will be set to zero in this

1276:38

case and also we're going to be

1276:39

attaching a bit of transitions to there

1276:41

but first of all we have to wrap that

1276:44

inside the parentheses so let me just

1276:46

wrap that now here we have to specify

1276:48

our transition so I'll use like

1276:50

transition that transition will take the

1276:52

delay and now let's just use the index

1276:54

times 0.1 and then we have to provide

1276:57

the duration and duration will be set to

1276:59

0.6 I'm going to save my file I'm going

1277:01

to collapse this one and also collapse

1277:03

that variance now let's just go ahead

1277:05

and go to what UI and I'm going to

1277:07

remove that from here I'll use the

1277:09

classes I'll use like background of

1277:11

totally black and minimum height will be

1277:13

set to totally screen inside this div we

1277:16

have to Define our motion. div and I'm

1277:18

going to close there so here I'm going

1277:20

to specify the class name like it's

1277:21

going to be set to totally fix the Top

1277:23

Value will be set to zero the width will

1277:25

be set to totally full and pairing all

1277:27

around will be set to add background

1277:29

totally white and text totally black

1277:31

rounded totally large and Shadow will

1277:34

also be to large so I'm going to save my

1277:36

file right now and here now we have to

1277:38

specify our variants so I'll use like

1277:40

the variant and now we are going to be

1277:42

providing our menu variance inside there

1277:44

I'm going to also provide the initial

1277:45

State and for the initial State we're

1277:47

going to be setting there to hiden and

1277:49

also when somebody how over there so in

1277:51

this situation we're going to be setting

1277:53

the state of there to visible so v i s i

1277:55

b e inside this motion Dev we're going

1277:57

to be defining or D once again it's

1277:59

going to have the classes of flex and

1278:01

also the flex of toly column inside this

1278:03

D we're going to be defining yet another

1278:05

day which you have the class of flex

1278:07

justify will be set to between and items

1278:10

will be set to tot the center inside

1278:12

there we also have to create one more

1278:13

for the items so let's just choose like

1278:15

item Center and I'm going to also

1278:16

specify margin for the left of two and

1278:19

font will be set to uh semi bold I'm

1278:22

going to also provide the upper case on

1278:24

the cas so I'll just write my own name

1278:26

like hose check this out so here you can

1278:28

see we now getting this navigation area

1278:30

so if I hold over there so here you can

1278:31

see we now getting this expanding

1278:33

navigation so if I leave it back so it's

1278:35

going to expand it back now let me go

1278:37

ahead and take care of the rest of the

1278:39

UI so now underneath this div I'm going

1278:41

to go ahead and Define another div so

1278:43

which will have the class of hidden and

1278:45

also on the medium screen uh I'm going

1278:47

to set the two to flex and also the

1278:49

spaces on the xaxis will be set to five

1278:52

and text of to Center inside this D

1278:55

we're going to be providing an anchor

1278:56

tag which will have the class of text

1278:58

toally black and font of totally bold

1279:01

and I'm going to just write like this

1279:02

pound symbol inside there and I'm going

1279:04

to say like products I'm going to

1279:05

duplicate there a few times so I'll just

1279:07

change that to like uh use cases and

1279:10

also change this one to resources I'm

1279:12

going to also duplicate that and change

1279:14

that to pricing now underneath this div

1279:16

we're going to be defining a div so

1279:18

let's just write like black and it's

1279:19

going to be set to the item store L

1279:21

Center inside there I'm going to create

1279:23

my anchor tag once again and which will

1279:25

take this own symbol and I'm going to

1279:27

say join I'm going to also provide the

1279:29

class of text toally blank and font of

1279:31

toally light inside this so now let me

1279:33

just save my file and here here you can

1279:34

see we're now getting this amazing

1279:36

sidebar but this is not looking that

1279:38

cool so I'm going to go ahead and remove

1279:41

this font of light from there and yeah I

1279:43

guess that's looking better I can also

1279:45

remove this spont of totally boldness

1279:47

from there so I'll just select there and

1279:49

remove there and yeah I guess that's

1279:51

looking cool now underneath this div I'm

1279:54

going to Define my motion div once again

1279:56

so what I'm going to do is that I'm

1279:58

going to Define my motion. D and I'm

1280:01

going to close there inside there I'm

1280:03

going to also Define the classic of flex

1280:05

and flex will be set to totally column

1280:07

and pairing for the y axis will be set

1280:08

to totally six okay and I'm going to

1280:11

also Define the variance inside there we

1280:12

already created this expand variance so

1280:15

I'm going to use the inside there okay

1280:17

so now inside this Dev we're going to be

1280:18

defining a span which will have the

1280:20

class of totally block with will be set

1280:21

to totally full and also height will be

1280:24

set to PX and background gray of 300 and

1280:28

now underneath them I'm going to define

1280:29

the motion D once again and close them

1280:32

I'm going to first of all Define my

1280:33

variance and it's going to take the

1280:34

expandable card or expandable row

1280:37

variance I'm going to also specify the

1280:39

custom value to there so custom and here

1280:41

we have to specify one inside there and

1280:44

for the classes we're going to be using

1280:45

a flex and also items will be set to to

1280:47

the center margin for the top will be

1280:49

set to five inside there we have to

1280:51

Define our Spin and spin will have the

1280:53

class of border and also border totally

1280:56

black totally rounded full and pairing

1280:59

for the xais of two and text will be set

1281:01

to smaller extra small rather and it's

1281:04

going to say apple let me just save my

1281:06

file if I H over this we are now getting

1281:08

this line and also this spill off Apple

1281:10

so yeah that's looking cool now

1281:12

underneath this pen I'm going to Define

1281:13

a paragraph which will have the margin

1281:15

for the left of two and I'm going to say

1281:17

like MacBook Pro let's just say our file

1281:21

and how over there so now we are getting

1281:22

this MacBook Pro and now finally we have

1281:25

to start working on our custom card I'm

1281:27

going to start working on there but now

1281:29

underneath this div we have to Define

1281:31

yet another div so I'll use like motion.

1281:34

d one again and close there and here we

1281:36

have to specify that exact same value so

1281:39

I'm going to copy the name of the I mean

1281:41

like class of there and place it right

1281:43

here so we are going to be using the

1281:44

variance custom will be set to one and

1281:46

also here we are not going to be

1281:48

providing all of them but we are going

1281:49

to be only providing a flex and margin

1281:51

for the top will be set to five okay so

1281:53

now here we already created this card

1281:56

component so we have to use that inside

1281:58

this D so I'll use like card and execute

1282:01

there like so and this card is going to

1282:03

take a few props so I'll use like title

1282:05

and I'm going to set that to like my

1282:06

amazing card or something like that and

1282:09

the description I'll say like um this is

1282:12

some random description or something

1282:14

like that and also I'm going to specify

1282:17

the image URL so I'll use like the image

1282:18

URL and it's going to be set to this

1282:21

image URL so you know what we have to

1282:22

specify it like this I'm going to place

1282:24

the image URL right here and this should

1282:27

be HTTP so let's just write H right here

1282:30

check this out so if I have my mouse

1282:31

over today we are only getting this card

1282:34

because because we did not create this

1282:36

card so now let me just go ahead and go

1282:37

to this card and start working on there

1282:40

the first thing that I want to do is

1282:41

that I want to destructured all of the

1282:43

props that we are now taking so I'll use

1282:45

like title I'm going to also put the

1282:47

description d s c r i p t i o n and also

1282:50

the image URL okay so now we have to

1282:53

create an interface for this so I'll use

1282:55

like the interface and then I'm going to

1282:57

give it the name of like card props and

1282:59

if you guys don't know what in the world

1283:00

is the interface so you should

1283:01

definitely go ahead and check out my

1283:03

typescript course about there I'm going

1283:04

to be using a title and title will be

1283:06

set to a string

1283:08

description description will be set to

1283:10

string and also the image come on the

1283:13

image URL will be also set to string I'm

1283:16

going to S my file copy the name of

1283:18

there let's just copy the name of there

1283:20

and annotate there with this card props

1283:22

the next thing that we have to do is

1283:24

that we have to use this so I'll just

1283:25

remove that from here I'm going to

1283:27

specify B of classes to this all use

1283:28

like Flex and flex will be set to column

1283:31

and margin all around will be set to

1283:33

five background white rounded large and

1283:37

Shadow will be set to totally large I'm

1283:39

going to also provide the Overflow and

1283:41

overflow will be set to totally hidden

1283:43

okay so now inside this D what do we

1283:45

have to do we have to use our image so

1283:47

I'll use like the image I'm going to

1283:49

also specify the source to there and

1283:51

also the alternative text to there I'm

1283:53

going to also use the class name so the

1283:55

width will be set to totally full and

1283:57

the height will be also set to 28 I'm

1283:59

going to also set that to object holy

1284:01

cover and close there like so the next

1284:03

thing we have we have to do is that we

1284:05

have to grab the image URL and we have

1284:06

to place there as a source I'm going to

1284:08

also copy the title and place there as

1284:10

alternative text so now let me just sa

1284:12

my file and now if I have my mouse over

1284:14

today so it's going to gives us the

1284:15

image of that Macbook so what I'm going

1284:17

to do is that I'm going to also use this

1284:19

description so I'm going to copy the

1284:20

name of there we have to define a d with

1284:22

the class of padding all around will be

1284:23

set to four and inside there we have to

1284:26

use the H3 with the class of font toally

1284:28

bold and text large and it's going to

1284:31

take their title first of all we have to

1284:32

render the title and then we are going

1284:34

to be rendering the description so I'll

1284:36

use like text of to gray 700 700 and

1284:40

also margin for top will be set to two

1284:42

and here we have to render their

1284:44

description underneath there we're going

1284:46

to be creating a button which will have

1284:47

a few classes all used like margin for

1284:49

top of four and background toally black

1284:52

text toally white and also pairing for

1284:54

the Y AIS will be set to two pairing for

1284:55

the xaxis will be set to four totally

1284:58

rounded so I'll just say like learn more

1285:00

or something like that now let me just

1285:02

refresh that and if I have my mouse over

1285:03

to that so it's going to giv us that

1285:05

card so if I want that card to be like a

1285:08

lot of time so I can just duplicate this

1285:10

card and it's going to give us that card

1285:12

like a lot of time so yeah you can

1285:14

totally change the UI if you wanted to

1285:16

but that was our amazing animated

1285:19

navigation or sticky navigation to be

1285:21

precise so before we get into this

1285:22

project I want you to keep in mind one

1285:24

thing this project will be a bit

1285:26

Advanced so let's just start working on

1285:28

there what in the world are we building

1285:30

and how are we even going to be building

1285:32

there we are building something called

1285:34

the progress steps and you will see that

1285:36

in a few seconds so first of all we are

1285:38

going to be creating a components folder

1285:40

c m p o n NTS and we have to Define our

1285:44

progress step. TSX file inside there

1285:46

I'll use the rafc go ahead and go to our

1285:49

app and register their progress steps

1285:51

right here and I also want to mention

1285:54

one more thing so if I go ahead and go

1285:55

to the index. CSS file I already

1285:57

specified the background color and the

1285:59

background color is now set to this

1286:00

color and we are also changing the color

1286:02

to totally White okay so that's the

1286:05

first thing that we have to do next we

1286:06

have to import something called the

1286:09

framer motion from the motion I said it

1286:12

wrong the motion from the framer motion

1286:15

okay so next we have to Define our steps

1286:17

so I'll use likeon steps and here we are

1286:20

going to be creating an array and inside

1286:22

this array we are going to be defining a

1286:23

few objects so I'll just proide like the

1286:25

title and the title will be set to step

1286:27

one and also I'm going to be providing a

1286:30

bit of description to them and for this

1286:32

description I'm going to just say like I

1286:33

don't know some s of like random

1286:36

description so say like this is the

1286:38

first step or something like that and

1286:41

I'm going to provide a comma there and

1286:42

I'm going to duplicate that a few times

1286:43

so I'll just change the two I'm going to

1286:46

select them and yeah we have to just

1286:48

change the two three and four now I'm

1286:51

going to go ahead and go to my component

1286:53

and the first thing that we have to do

1286:54

is that we have to Define our current

1286:56

step and then we have to Define our Set

1286:58

current step it's going to be equals to

1287:00

the US St and the initial value we have

1287:02

to specify 0 to the that's done we also

1287:05

have to go ahead and go to the UI and

1287:07

provide a bit of classes to this all use

1287:09

like Flex and flex will be set to column

1287:11

and items will be also set to Center

1287:13

pairing all around will be set to five

1287:15

inside the div we have to Define yet

1287:17

another div which will have like

1287:18

relative and also Flex justify will be

1287:21

set to totally between b t w n between

1287:25

and also the width will be set to 40 Rim

1287:29

so I'll use like 40 rim and close there

1287:32

I'm going to also specify margin for the

1287:33

bottom and inside this div we have to

1287:36

Define our motion. div so I'll use like

1287:38

motion. div come on div and close there

1287:42

on this motion div I'm going to specify

1287:44

a bit of classes to this so I'll use

1287:45

like uh absolute because we're now

1287:48

providing a relative so this class will

1287:50

be absolute to this relative class

1287:52

that's done and also background will be

1287:54

set to totally blue of 500 and I'm going

1287:57

to provide the margin for the top of one

1287:59

rim to there I'm going to also put a bit

1288:01

of styling to this so I'll use like this

1288:02

style and here we have to specify our

1288:05

styling dynamically so I'll just change

1288:06

the width and the width will be the

1288:09

dynamic width so what am I going to do

1288:11

I'm going to first of all add one

1288:12

parenthesis and inside that I'm going to

1288:14

attach yet another parenthesis so I want

1288:16

you to notice we are now working with

1288:19

double parenthesis first thing that I

1288:21

want to do is that I want to grab this

1288:22

current step and I'm going to place

1288:24

there then we're going to be adding only

1288:26

zero to there and now outside from there

1288:29

we are going to be defining the steps.

1288:31

length like how many item we have there

1288:33

you want to divide there by current step

1288:36

+ one okay outside from there we also

1288:39

have to multiply there to

1288:42

130% just like this okay so that's going

1288:44

to be at forward width I'm going to also

1288:46

specify the transition so I'll use like

1288:48

the transition and here we have to

1288:51

specify the width and 0.3 seconds and

1288:54

ease this is right there and I'm going

1288:56

to also specify a comma inside there I'm

1288:58

going to save this file and now inside

1289:00

this Dev what we have to do we have to

1289:02

iterate over through all of our steps so

1289:04

I'll use like steps. map and we also

1289:06

need the step inside there come on step

1289:09

and also the index from there so what

1289:11

I'm going to do is that I'm going to go

1289:14

ahead and Define come on let's just use

1289:17

our parenthesis if I can do that today

1289:19

I'm going to Define my div and inside

1289:21

this div it's going to take a key so

1289:22

I'll just write a key and key will be

1289:24

set to an index I'm going to also

1289:26

provide a class name today it's going to

1289:27

take a flex and flex will be set to

1289:29

totally column and items will be set to

1289:31

totally Center and it's going to be also

1289:32

set to totally Rel inside there we have

1289:35

to Define our motion. D once again and

1289:37

close there and for this motion D we're

1289:40

going to be attaching a class names and

1289:42

we are going to be rendering our classes

1289:43

dynamically so that's why we are now

1289:45

using this template literal so I'll use

1289:47

like the height will be set to hold 10

1289:49

withd will be set to toly 10 flex and

1289:51

justify will be also set to Center I'm

1289:53

going to also provide the items of

1289:54

totally Center to them round it totally

1289:57

full and Border will be set to two so

1289:59

I'm going to save my file right now and

1290:01

then here we have to specify our styling

1290:03

to totally dynamically so I'll just say

1290:05

like if the index which we are now

1290:07

getting by iterating over through all of

1290:09

the steps so if that index is less than

1290:11

or equal to the current step which is

1290:14

the state of our entire component so if

1290:17

that's the case so what do we have to do

1290:18

in that situation we have to change the

1290:20

background color to totally blue of 500

1290:23

but if that's not the case we want to

1290:25

keep it as background gray of 200 and

1290:28

when somebody H over this I'm going to

1290:30

be using like while how we only want to

1290:32

scale that to 1.1 one and I'm going to

1290:34

also specify the transition and for the

1290:36

transition we're going to be setting the

1290:38

duration to 0.2 seconds inside this Dev

1290:41

we're going to be rendering our index so

1290:42

I'll use like if our index is less than

1290:45

the current step which is going to be

1290:47

our state so in this situation I'm going

1290:49

to only write this check mark if that's

1290:51

not the case we are going to be setting

1290:52

that to null okay this should be a

1290:55

question mark because we are now using a

1290:56

tary and now under underneath this D we

1290:59

have to define the paragraph and it's

1291:00

going to have a few classes all just

1291:02

defined there and here we have to render

1291:04

or step. title and now we're going to be

1291:07

defining our class names and we're going

1291:09

to be defining them totally dynamically

1291:11

so I'll just use like margin pH top of

1291:13

two and here we have to Define our index

1291:16

so if our index is less than or equal to

1291:19

the current steps so in this situation

1291:21

once again we're going to be changing

1291:22

the the text to totally blue of 500 but

1291:25

if that's not the case we are going to

1291:27

be changing the text to to gray of 500

1291:30

so now let me just save my file test

1291:31

this out so we are now getting this

1291:33

awful looking UI we will fix that in a

1291:36

few seconds but yeah we have to take

1291:37

care of this UI first of all underneath

1291:39

this div we're going to be defining our

1291:41

motion D once again so I'll use like

1291:43

motion. d close there and here inside

1291:47

there first of all we have to provide a

1291:48

bit of classes to this so I'll use like

1291:49

Trix of toally Center ping all around

1291:52

with five and the width will be set to

1291:53

40 Rim close then and proide the height

1291:57

of 10 rim to there I'm going to also

1291:59

provide the border and round it totally

1292:02

large Shadow will be set to toly medium

1292:05

I'm going to also specify the key and

1292:06

the key will be that current step I'm

1292:08

going to also proide the initial State

1292:09

and initially it's going to be set to

1292:11

the opacity and opacity will be set to

1292:13

zero the y- axis will be set to minus 20

1292:16

let's just say our file underneath this

1292:18

initial State we have to provide our

1292:19

animate State and for this animate State

1292:21

we have to provide the opacity of one

1292:23

and the Y AIS will be set to zero I'm

1292:25

going to also provide the exit prop and

1292:27

for this exit uh let's just Define our

1292:30

opacity and opacity will be set to zero

1292:33

and the one X will be set to minus 20

1292:35

I'm going to also Define the transition

1292:37

and for this transition we have to

1292:39

define the duration of 0.3 seconds to

1292:41

there okay so finally we have to render

1292:44

our main card so I'll use the H2 and the

1292:48

classes will be set to text toally extra

1292:50

large and for totally Bard and here we

1292:53

have to render our steps come on steps

1292:56

and now let's just use our current step

1292:58

and now get the title out of there I'm

1293:01

going to duplicate this oh you know

1293:02

we're not going to be duplicating this

1293:03

I'm going to be creating a paragraph

1293:04

with the class of margin for the top of

1293:06

two and I'm going to duplicate this step

1293:09

right here so this's just copy there and

1293:12

place there instead of providing a title

1293:14

I'm going to change that to the

1293:15

description so let's just say our file

1293:17

and here you can see we're now getting

1293:18

our card and this is not something that

1293:20

I want but yeah we are getting there now

1293:23

underneath this motion div uh we have to

1293:25

Define just a regular div and we are

1293:28

going to be setting that to flex margin

1293:30

for top of five and spaces on the x-axis

1293:33

will be set to four inside there we have

1293:35

to create a button and this button will

1293:37

have few classes so first of all we have

1293:38

to write a previous button and then

1293:40

we're going to be also creating one more

1293:42

button for the next one so let's just

1293:44

add there so I'll use like uh you know

1293:46

what change that to the dynamic classes

1293:48

and pairing for the xais will be set to

1293:49

four pairing for the Y AIS will be set

1293:52

to two text of to white background blue

1293:54

500 rounded and here we have to render

1293:57

our classes to dynamically so if our

1293:59

current step is triple equals to zero so

1294:02

in this situation what we have to do we

1294:04

have to use the opacity and set the 250

1294:07

and also the cursor will be not allowed

1294:10

okay but if that's not the case we're

1294:12

going to be only using the empty string

1294:14

which means like we don't want to

1294:15

provide nothing to them now underneath

1294:18

that we're going to be also attaching

1294:19

the disable State and for the disabled

1294:21

state if the current state is equal to

1294:23

the zero so you want to just disable

1294:25

this button and I'm going to copy this

1294:27

button and duplicate there one time and

1294:30

change a few things inside there so if

1294:32

our current STP in this situation is

1294:34

equal to the steps. length minus one

1294:37

which means like the last element so in

1294:39

this situation we're going to be setting

1294:40

the opacity to 50 and cursor will not be

1294:43

allowed and here instead of providing a

1294:45

current step is equal to zero we're now

1294:47

going to be attaching like steps. length

1294:49

minus one which means like gives us the

1294:51

last element and also we are going to be

1294:53

changing that to next so I'm going to

1294:54

save my file and something is awfully

1294:57

wrong with my component and I don't know

1294:59

why let me just click on this it's going

1295:01

to give us the next one and the previous

1295:02

one but we also have to attach the on

1295:05

click man Handler I'm going to attach

1295:07

that but I don't know what's wrong with

1295:08

my UI there is something off going on

1295:10

with my UI so I'm going to have to fix

1295:12

there first of all I'll just hide there

1295:15

oh you know what we have to take all of

1295:17

that steps logic and then we have to

1295:20

close this div like so and now

1295:23

underneath this div you know we have to

1295:25

remove the and render our content right

1295:27

here now let me just save my file and

1295:29

yeah this is now looking better and now

1295:31

if I click on that nothing will happen

1295:33

but now let me just go ahead and Define

1295:35

or attach the event handler on the next

1295:38

button and also on the previous button

1295:40

let me just go ahead and go to the

1295:41

previous button and when somebody clicks

1295:43

on there we going to be firing this

1295:44

function which is a previous step I'm

1295:46

going to copy a name of there and also

1295:48

we going to be attaching event handler

1295:50

on the next button so when somebody

1295:52

clicks on there we're going to be firing

1295:53

a Next Step function so now let me just

1295:55

go to the top and Define there right

1295:57

here first of all let's just take care

1295:59

of the previous one but you know first

1296:01

of all we have to take care of the next

1296:02

one so I'll use like

1296:04

uh next step is going to be equals to

1296:06

this function and inside there we have

1296:08

to first of all check if our current

1296:10

step is less than the steps. length

1296:12

minus one which means like the last

1296:14

element okay then we're going to be

1296:16

changing the current step to the current

1296:18

step + one which means like basically

1296:20

we're going to be incrementing there but

1296:22

if that's not the case like if somebody

1296:25

did not click on the next button and

1296:27

they inste click on the previous button

1296:28

so we're going to be creating this

1296:30

function so I'll use like cons previous

1296:32

button and in side then we have to check

1296:35

so if the current index or the current

1296:37

step is greater than zero then we're

1296:39

going to be setting the current step to

1296:41

the current step minus one I'm going to

1296:43

save my file right now now here you can

1296:46

see we're now basically getting our

1296:47

basic animation if I click on there here

1296:49

you can see we're now getting a checkbox

1296:51

and also we are getting this line if I

1296:53

click on the previous button one more

1296:54

time we are not allowed to click on the

1296:57

once again because this is the first

1296:58

item if I click on there once again the

1297:01

content will totally update the

1297:03

description will totally update we're

1297:04

going to be getting an animation and

1297:06

also this line will cross out to the

1297:08

next step if I go ahead and click on

1297:10

there once again we're now getting that

1297:12

same animation and which is looking cool

1297:15

so yeah that's an amazing project and it

1297:18

was a lot of typing I know trust me that

1297:21

was a lot of typing so yeah that was our

1297:24

basic or not a basic but our advanced

1297:26

level progress step so what is zustan

1297:29

zustan is a lightwe state management

1297:31

library for re applications it help you

1297:34

manage and share straight across

1297:35

different part of your application

1297:37

without needing to pass prop through

1297:39

many layer or use some complex solution

1297:41

like context apis or using the use

1297:43

context H or also using the Redux tool

1297:46

kit which is something which we going to

1297:48

be also learning throughout the course

1297:49

but yeah that was just a definition of

1297:51

what a zustan is but now let's talk

1297:53

about why should Ione care about

1297:55

learning zustan so here you can see I

1297:57

have a component hierarchy so I have a

1297:59

app header nav card users date and time

1298:02

component and inside the app component I

1298:05

have some sort of a data and let's

1298:06

suppose if I want to use that data

1298:08

inside the de component so how can I go

1298:10

about using there well to use there

1298:12

first of all we are going to be passing

1298:14

that data to the card component then we

1298:16

going to be passing that data to the

1298:17

user component and after that we're

1298:20

going to be passing the data to the de

1298:22

component and then we will be able to

1298:23

use that we can also solve this problem

1298:25

by using a context API but let's imagine

1298:27

for a second that you are working with a

1298:29

Google so you will just W your entire

1298:31

application by using the context API of

1298:34

course not so you're going to be using

1298:35

some sort of other solution either using

1298:38

the Redux toolkit or also using a Zeus

1298:41

St so now in this case we learning about

1298:43

the zo so first of all we are going to

1298:45

be creating some sort of a store inside

1298:47

that store we are going to be putting

1298:48

our data and then we can use the data in

1298:51

any component that we like suppose if we

1298:53

want to use the inside the card

1298:55

component we can totally use them and if

1298:57

you want to use the in the navigation

1298:59

totally allowed to do the in finally if

1299:01

you want to use the inside the DAT

1299:02

component so so we can totally use that

1299:04

so this is how we're going to be

1299:06

extracting our state from our components

1299:08

and we're going to be storing that in

1299:09

the store and then we can use it in any

1299:11

component that we desire so now let's

1299:14

just make a setup four resistant now to

1299:16

make a setup first of all we have to

1299:17

open our terminal I'm going to use npm

1299:20

create we at latest I'll give it the

1299:23

name of like Zeus demos and I'm going to

1299:26

choose react J with typescript now let

1299:29

me go into the Zeus demos folder and I'm

1299:31

going to install every single thing

1299:32

inside so then successfully done I'm

1299:34

going to open that in my vs code inside

1299:37

my vs code I'll open my terminal and now

1299:39

we are going to be installing Zeus

1299:40

inside our project so I'm going to use

1299:42

npmi or you can also use install if you

1299:44

prefer that so I'm going to use npmi and

1299:46

then Ze turn and I'm going to hit enter

1299:49

now then successfully done now let me

1299:51

open that in my vs code and this is how

1299:53

everything looks like so now let me just

1299:54

make a bit of cleanup we don't need this

1299:56

public folder so I'm going to delete

1299:58

that we also don't need this SS folder

1300:00

and also app. CSS and I'm going to also

1300:02

remove every single thing from the or

1300:03

you know let me just delete this folder

1300:05

or file to be precise I'm going to also

1300:07

remove this import and go into my app

1300:09

component remove every single thing from

1300:11

there and I'm going to just use my rafc

1300:14

sa my file and this is how it looks like

1300:16

right here so that was it about for the

1300:18

setup now let's create our store so what

1300:20

I'm going to do is I'm going to just

1300:21

create a file with store. and inside

1300:24

there we're going to be defining our set

1300:26

and we're going to be also tning it like

1300:28

how we're going to be modifying updating

1300:31

or mutating or change changing or state

1300:34

so the first thing that we have to do is

1300:35

that we have to import something called

1300:37

the create function from where from The

1300:39

Zo stand library in this create function

1300:42

is the heart of this Ze okay so this is

1300:45

how we're going to be importing there

1300:46

next we have to create our custom hook

1300:48

so to do them we're going to be using

1300:50

like use counter and basically you can

1300:52

give it any name that you prefer you can

1300:54

give it the name of hoseen you can give

1300:55

it the name of banana you can give it

1300:56

the name of Alex you can give it any

1300:58

name that you like but in my case I'm

1301:00

going to only give it the name of like

1301:01

use counter and that's going to equals

1301:03

to this create function now we're going

1301:05

to be calling that function from The Zo

1301:08

and here it will also take a call back

1301:10

function so I'll just put a callback

1301:12

function right here just like that now

1301:14

we have to tell it like what will be the

1301:16

initial value of my store so I'll just

1301:18

write like count and count will be set

1301:20

to zero you can also set that to some

1301:22

sort of a string you can also provide

1301:24

some sort of array if you want to and

1301:25

also the object if you wanted to but in

1301:28

my case I'm going to only provide this

1301:29

counter and the value will be set to

1301:31

zero next we're going to be taking

1301:33

something called the set perimeter and

1301:35

keep in mind this set is a special name

1301:38

it's going to allows us to change your

1301:40

value like change our state so this is

1301:43

how we're going to be defining our

1301:44

initial State and this set method will

1301:47

allows us to change our initial state so

1301:49

how are we going to be doing them you

1301:51

know what let me just create a function

1301:52

with the name of like

1301:54

increment and that's going to be just an

1301:56

arrow function like so and I'm going to

1301:58

use that set method and inside this set

1302:01

method we are going to be also providing

1302:02

a Cod back function once again so I'll

1302:04

just use like State and then we're going

1302:06

to be getting our data so to get our

1302:08

data I'm going to just use like count

1302:10

and that count will be coming from a

1302:11

state. count and we will just increment

1302:14

one with there and here I forgot to

1302:16

include the parenthesis so now let me

1302:18

just add that parenthesis right there

1302:20

and also at the end and we're not going

1302:22

to be using this colon we are going to

1302:24

be using a commas there okay so that's

1302:26

St done and this is how we're going to

1302:28

be defining our state and this is how

1302:30

we're going to be changing the value of

1302:32

our state so what I'm going to do is

1302:34

that I'm going to just remove the curly

1302:35

braces from here we also don't need that

1302:38

so I can just toly remove that if I

1302:39

wanted to and also just put a comma

1302:42

there and this is how we are going to be

1302:43

making the as a one liner but now we are

1302:45

getting a few errors from a typescript

1302:47

so now let me just fix that so I'll just

1302:49

create a type with the name of like

1302:50

counter or counter store will be fine

1302:54

and inside then we're going to be

1302:55

defining our count and count will be set

1302:57

to number and also we have a increment

1303:00

function and here we're going to be only

1303:02

returning the white from there duplicate

1303:04

that change that to decrement d e c r e

1303:07

m e n there we go I'm going to copy them

1303:10

and annotate my create function with

1303:12

counter store so now let me just save

1303:13

there and now we have to Define this

1303:15

decrement function so I'm going to just

1303:17

duplicate this line of code go back and

1303:19

just write a decrement right here

1303:21

instead of providing this plus we're

1303:23

going to be removing that and replace it

1303:25

with this minus and there was it that

1303:28

was it so finally we have to just export

1303:31

this so that we can use that in other

1303:32

file let me just say that once again

1303:34

first of all we're going to be importing

1303:36

the heart of zus which is called a

1303:37

create function then we're going to be

1303:39

defining our custom hook and we're going

1303:41

to be defining them by using this create

1303:43

method or function whatever you want to

1303:45

call them and this create function will

1303:47

take a call back function and here we're

1303:50

going to be defining our initial value

1303:52

and then we have a set method which will

1303:53

allows us to change or mutate or update

1303:56

or whatever you want to call them or St

1303:59

okay so this is how we going to be

1304:01

providing an increment function and this

1304:02

is how we going to be providing a

1304:03

decrement function to change our values

1304:06

so this is how we are going to be

1304:07

creating our custom hook but now let's

1304:09

talk about how we going to be accessing

1304:11

the inside our component so to access

1304:13

them obviously we would need or use

1304:15

counter so if I just use the and hit

1304:17

enter so it's going to Auto Import there

1304:19

from my store like so so now inside

1304:22

there if you want to get the state or

1304:23

the count value from there so there are

1304:25

a few ways to do that the first way is

1304:27

to just provide error functions I'll

1304:29

just use like St and then I'll just

1304:31

write like st. count and we can store in

1304:33

some sort of variable like cons count or

1304:35

something and that's going to be equals

1304:37

to this custom hook and now we can

1304:39

totally render there by using this H1

1304:41

and I'll just write like count and here

1304:43

we have to render the value of that

1304:45

count so now let me just save my file

1304:46

and go back and what are we getting we

1304:48

are now getting our count of zero which

1304:50

means like everything is working the way

1304:52

we expect him to work so I can also

1304:54

change this initial value to like 10 or

1304:56

100 or something like that so it's going

1304:58

to gives us that count and that specific

1305:00

value from our counter which means like

1305:02

everything is working so this is how we

1305:04

going to be accessing the data that's

1305:06

the first way to access our data now the

1305:09

second way is to destructure our data so

1305:11

we can just destructure our increment

1305:13

function like increment and we can also

1305:16

destructure our decrement function from

1305:18

this St then we don't have to specify

1305:21

this do count there so I'm going to just

1305:23

remove that from there and now we can

1305:24

just create two buttons like button and

1305:27

I'll just write like increment and I'm

1305:29

going to also duplicate then just write

1305:30

a decrement right here I'm going to

1305:32

attach my on click event handler and the

1305:34

first one will just say like increment

1305:36

and the second one will just say

1305:37

decrement okay and now if I click on the

1305:40

increment so it's going to increment my

1305:41

counter by one and now if I click on the

1305:43

decrement so it's going to decrement my

1305:45

counter by one which means like both of

1305:47

these functions are working but now in

1305:49

this case we also don't have to specify

1305:52

this Arrow function so I can totally

1305:54

remove there now if I save my file and

1305:56

now let me just refresh there I can

1305:58

totally click on this so it's going to

1305:59

increment my counter and I can totally

1306:01

click on this one so it's going to DEC

1306:03

my counter so yeah this is how we are

1306:05

going to be accessing the data but this

1306:07

is not how I want to access my data I'm

1306:10

going to just remove it and now let me

1306:11

give you one more example of how we

1306:13

going to be using our store or state

1306:16

inside other component so what I'm going

1306:18

to do is that I'm going to only access

1306:20

my count from the use store and not

1306:22

start God damn it use counter to be

1306:25

precise you're going to be accessing our

1306:27

data by use counter and I'm going to

1306:29

just destructure that value and as you

1306:31

can see right here we are now getting

1306:32

the value of zero so next I'm going to

1306:34

also create another component with the

1306:36

name of other component. TSX and inside

1306:40

there let's just use our RFC inside

1306:42

there and now I can totally access my

1306:44

data separately if I wanted to so now

1306:46

let me just write like increment it's

1306:48

going to equals to or use counter and we

1306:51

can totally access our data by using by

1306:53

providing our Arrow function like start.

1306:55

increment and we can also get our data

1306:58

by just using st. decrement copy the

1307:01

name of there place there right here and

1307:03

I can just say like uh button and which

1307:06

will say increment let me just write

1307:08

increment right here change that to

1307:10

decrement and provide my own click event

1307:13

handler on there the first one will

1307:15

increment our counter the second one

1307:17

will just decrement our counter now I

1307:19

can totally use this component inside my

1307:22

ab. TSX file so I'll just uh run this

1307:25

component right here I'm going to import

1307:27

the sve my file and now here you can see

1307:29

we have two buttons I can increment and

1307:31

I can also decrement my counter which

1307:33

means like everything is working now let

1307:35

me just go ahead and like yeah this is

1307:38

just a one way importing or using or

1307:40

store data but this is not the better

1307:43

way so as I showed you a few seconds ago

1307:45

like we don't have to specify this aror

1307:47

function we can just to the access our

1307:49

data by using this method like increment

1307:52

and then decrement and this is something

1307:54

called destructuring in JavaScript and

1307:57

still it will work so if I increment

1307:59

there and I can also decrement there so

1308:01

yeah that was the entire Theory and the

1308:04

entire story about zeust first of all we

1308:06

have to import them then we have to grab

1308:08

them and then we have to use them and

1308:10

provide our rules inside there and now

1308:12

if you want to access there we just have

1308:14

to access there by using this use

1308:15

counter and then we can destructure the

1308:18

data or yeah the data or the state or we

1308:21

can also just get our data by using the

1308:24

dot notation which I just show you Evo

1308:26

is EO lesser greater middling makes no

1308:30

difference the degree is arbitrary the

1308:34

definition is blurred if I have to

1308:36

choose between one evil and another I

1308:38

would rather not choose it all okay that

1308:41

was a lot of Witcher wise God damn it so

1308:44

now let's just make a set of four

1308:45

recording journey and then we are going

1308:48

to be making a lot of project like 10

1308:51

amazing projects so what I'm going to do

1308:53

is that I'm going to write like npm

1308:54

create we at

1308:56

lat God damn it create

1308:59

we we at latest like so I'm going to

1309:04

give it the name of like Zeus projects

1309:07

and now I'm going to choose reactjs with

1309:10

tcri go into the Zeus project Zeus

1309:14

project and I'm going to install every

1309:16

single thing inside there I'll also

1309:18

install the Ze so I'll use like npm

1309:21

install

1309:22

Zeus it's going to install the in my

1309:25

machine that's already done so I'm going

1309:27

to open that in my vscore and that's

1309:29

looking better so what I'm going to do

1309:31

is I'm going to just remove this public

1309:32

folder I'm going to also remove this

1309:34

assets f. CSS and also we have to remove

1309:37

a single thing from there now let me

1309:40

just search for the tailman

1309:43

css.com let's just go to the tailman CSS

1309:46

and I'm going to click on this getting

1309:47

started button I'm going to choose

1309:48

framework and guides go to the V and

1309:51

copy this command open my terminal and

1309:54

place this Command right here once again

1309:56

hit enter so it's going to initialize my

1309:58

tment CSS so so that's already done I'm

1310:00

going to copy there go into my taing

1310:03

config file and replace it with this new

1310:06

content that's already done I'm going to

1310:08

also go into my index. CSS and replace

1310:11

that with these new directives okay and

1310:14

finally we also have to copy this H1 to

1310:16

test it out so I'm going to go into my

1310:18

F.C not CSS but f. TSX and now I'm going

1310:23

to replace there with this content I'm

1310:25

going to use my npm run Dev to run my

1310:27

server and now let's just go into my

1310:30

Local Host run there yep this is working

1310:33

first thing first we have to Define our

1310:35

store or create our store so I'll just

1310:37

give it the name of like store and

1310:39

inside there we are going to be defining

1310:40

where UST store. TSX or TS to be precise

1310:44

first we have to import the create from

1310:46

where from the zoo stand now underneath

1310:49

them let's just create our custom hook

1310:51

with the name of like Ed store you can

1310:52

give it like basically any name that you

1310:54

prefer and I'm going to use my create

1310:56

function is going to take a set as a

1310:58

perimeter and also this call back

1311:00

function but we have to wrap that inside

1311:02

this parentheses first of all we would

1311:04

need our initial stat so I'll just write

1311:05

like recipes r e c i p s and recipes

1311:09

will be empty array and then we would be

1311:12

able to add a recipe and also remove a

1311:14

recipe so I'll write like add recipe

1311:17

recipe it's going to be a function so

1311:18

it's going to take a perimeter of like

1311:20

recipe like so and now let me just

1311:23

create my arrow function without

1311:25

providing these curly braces I'll call

1311:27

my set method and inside this set method

1311:29

once again we have to call our state and

1311:31

now we have to Define our initial St so

1311:33

we are going to be taking our recipes

1311:35

their array so I'm going to copy there

1311:37

and now let me just past it right here

1311:39

and we are going to be first of all

1311:40

making a clone of the existing recipes

1311:42

so we are going to be saying like dot

1311:43

dot dot which means like spread operator

1311:46

and we're going to be making a clone of

1311:48

these recipes after that we are going to

1311:50

be providing our new recipe which we are

1311:53

taking as a perimeter from this function

1311:55

so that's to you done now we also have

1311:57

to provide our types so first of all let

1311:59

me just create an interface or you can

1312:01

also create a type if you want to and

1312:03

I'm going to give it the name of like

1312:04

recipe like so and inside this interface

1312:07

we're going to be providing the id id

1312:09

will be set to number we're going to be

1312:11

also providing a name of the recipe and

1312:12

that's going to be set to string we're

1312:14

going to be also including the

1312:15

ingredients and ingredients will be a

1312:17

string of array after that we're going

1312:20

to be also providing the instructions

1312:22

and instructions are going to be a

1312:25

string okay now let me also create an

1312:27

interface for the store so I'm going to

1312:29

go ahead and create an interface and

1312:31

that's going to be the rest recipe and

1312:33

inside there let's just Define our

1312:34

recipes that's going to be set to that

1312:36

recipes which we have created up above

1312:38

you know let me just copy the name of

1312:40

there I'm going to copy the name of

1312:42

there place it right here and we're

1312:44

going to be placing array of recipes

1312:46

after that we would also need the add

1312:48

recipe function which we have already

1312:50

defined right here so I'm going to copy

1312:51

a name of there and place it right here

1312:53

and this going to be a name so we have

1312:55

to specify the recipe as a perimeter and

1312:58

that recipe will be that recipe typ so

1313:01

now let me just also Define there right

1313:03

here and it's going to just return the

1313:05

wide after them we would also need to

1313:07

remove that recipe so I'll just write

1313:09

like remove recipe like so it's it's

1313:12

going to take the perimeter of ID and

1313:14

then that ID will be a numbers so that's

1313:16

what we have to do right now we also

1313:18

have to annotate our create function

1313:20

with our recipe store and we have to

1313:23

close them now it is freaking out

1313:24

because we also have to create our

1313:26

remove recipe function so I'll just

1313:28

write like remove recipe and that's

1313:30

going to take the ID and in there we're

1313:32

going to be once again using our set

1313:34

method let's space our St inside there

1313:37

like so and then we're going to be

1313:39

providing our object and inside there

1313:41

we're going to be getting that recipes

1313:42

once again and we have to get that from

1313:44

the standard recipes and we're going to

1313:47

be using the filter method on there and

1313:49

now we are going to be filtering out all

1313:51

of the recipes so I'll just write a

1313:53

recipe right here and yeah I'm going to

1313:55

have to store there in the parenthesis

1313:58

now outside from there we have to check

1313:59

if recipe. ID is not equal to what not

1314:04

equal to this ID right here so if I copy

1314:07

that and place that then we want to

1314:09

remove that specific recipe equal to

1314:12

sign so we have to provide three equal

1314:13

to sign and that's done finally we have

1314:16

to export this so we can use this so

1314:17

I'll just use like export and that's

1314:19

totally it about the St so this is how

1314:21

we're going to be defining our St and

1314:23

then this is how we're going to be

1314:25

adding our recipe this is how we going

1314:27

to be removing our recipe the store part

1314:29

is done now let's use the inside our

1314:31

component I'm going to create a folder

1314:33

with name of components and inside that

1314:35

we're going to be defining our recipe.

1314:37

TSX and I'll use my RFC inside there and

1314:40

I'm going to go into my app and render

1314:43

there right in here like recipe app and

1314:46

close there yep we are getting our

1314:48

recipe app now let me go into that

1314:50

recipe app and start working on there

1314:52

the first thing that I want to do is

1314:54

that I want to Define my state or you

1314:55

know what first of all we're going to be

1314:57

importing a lot of stuff from our use

1314:59

store okay and what are we going to be

1315:01

importing we are going to be importing

1315:03

or

1315:04

destructuring the first of all the

1315:06

recipes also the add recipe remove

1315:09

recipe and that's going to be it now

1315:11

underneath that we also have to Define

1315:13

our state so I'll just write name and

1315:14

set name and that's going to be equal to

1315:17

the use State not store but used St God

1315:20

damn it used St there we go let me just

1315:23

import there and for the initial value

1315:25

I'm going to specify string and I'm

1315:27

going to also inate with the string

1315:29

because I know a lot of people will ask

1315:30

me hose you are not using types script

1315:32

so now I am using that next we're going

1315:35

to be defining a state for the

1315:36

ingredients and set ingredients it's

1315:38

going to be equals to the use St once

1315:40

again and the initial value will be

1315:42

still that empty string so I'll just

1315:44

write a string inside there and now

1315:46

underneath let's just create for the

1315:47

instructions this should be const so we

1315:51

have instructions and also set

1315:53

instruction it's going to be equals to

1315:55

the US St once again and the initial

1315:57

value will be empty string and I'm going

1315:59

to also annotate there with the empty

1316:01

string finally let's just write where

1316:02

editing recipe so I'll use like editing

1316:05

recipe and then set editing recipe it's

1316:08

going to be equals to the used St and

1316:10

for the initial value is going to be set

1316:12

to know so I'm going to otate the with

1316:14

first of all you know let me just create

1316:16

a state for the or not a state but a

1316:17

types so let's just Define our interface

1316:20

with not inferior but the interface and

1316:23

I'm going to give it the name of like

1316:25

recipe and inside there the ID will be

1316:27

set to the number and also we have a

1316:31

name name will be set to Str

1316:32

we have ingredients and ingredients will

1316:34

be set to string of array now underneath

1316:37

there finally we have to provide our

1316:39

instructions like so i n s r u c t i o n

1316:44

instruction will be also set to string

1316:46

so now let me just annotate there by

1316:48

either using the recipe or using null

1316:52

value so now we are providing the

1316:54

initial value of null today so now the

1316:55

final thing that we have to do is that

1316:57

we have to use all of them let me go

1316:58

inside the UI and start using this so

1317:00

I'll just remove that from here and

1317:02

first of all I'm going to define a lot

1317:03

of classes for the first St so the Min

1317:06

height will be set to screen let me go

1317:08

back I'm going to provide a flex and

1317:10

items will be set to Center justify will

1317:12

be also set to center background will be

1317:14

set to totally green of 100 and inside

1317:17

this D we're going to be creating a div

1317:19

with a class of background totally white

1317:21

and pairing on around will be set to six

1317:23

round it totally large and Shadow will

1317:26

be also set to large width will be full

1317:28

and maximum width will be set to 2 XL

1317:31

inside this we're going to be creating

1317:33

our H1 which will be the text 3 XL and

1317:36

the font will be set to bold and margin

1317:39

for the bottom will be set to six text

1317:41

will be set to Center Green of 800 800

1317:45

like so and I'm going to only say like

1317:46

recipe book or something like that now

1317:48

let me just test this out so we are

1317:51

getting some sort of error okay can I

1317:53

read the property of un reading

1317:55

subscribe cannot read the property of

1317:58

undefined reading subscribe and I

1318:00

realize that we are now import that from

1318:02

the zoo stand and we shouldn't be doing

1318:04

this let's just remove that and import

1318:07

my uh use store from where from my use

1318:10

store inside the store so now if I save

1318:12

my file check this out and yeah this is

1318:15

now looking cool let me go back I very

1318:18

zoomed in so now this is looking cool so

1318:20

what I'm going to do is that I'm going

1318:21

to just take care of the rest of the UI

1318:23

now underneath this H1 I'm going to

1318:25

create a d with a class of space on the

1318:27

y axis will be set to four and margin

1318:29

for the bottom will be set to six inside

1318:31

there create word input field with the

1318:33

type this is crew input field with the

1318:35

type of text and I'm going to also

1318:37

provide the value and value it will take

1318:38

the name which is coming from the state

1318:41

like this name and here what I'm going

1318:43

to do is that I'm going to put the on

1318:44

change event handler and when somebody

1318:47

types something inside we're going to be

1318:48

firing this function like set name and

1318:51

the initial value will be set to e.

1318:53

target. value I'm going to also provide

1318:55

the placeholder which will say like

1318:57

recipe and let's just put a bit of

1318:59

classes to there like styling so with

1319:01

will be set to to full pairing for the

1319:03

xaxis will be set to four pairing for

1319:05

the y axis will be set to two border and

1319:07

totally rounded large and Border will be

1319:10

set to gray of 300 and for the Focus ST

1319:13

I'll just put the outline and that's

1319:15

going to be set to n and for the focus

1319:17

once again we are going to be providing

1319:19

a ring of two and focus ring will be set

1319:22

to totally green of 500 so now let me

1319:24

just save my file and by the way if you

1319:25

guys don't know what I'm typing right

1319:27

here you should definitely watch my T

1319:29

CSS course and yep we are getting our

1319:31

amazing input field and that's looking

1319:33

great underneath there or you know let

1319:35

me just uh duplicate this input field

1319:37

for a few times so first of all you

1319:39

would have for the name next we will

1319:41

have for the ingredients so I'll just

1319:43

write like ingredients right here and

1319:45

then set ingredients like so and I'm

1319:47

going to just replace this placeholder

1319:49

with ingredients and then comma

1319:52

separated and The Styling would be fine

1319:54

yep that's looking cool I'm going to

1319:56

also duplicate there once again for the

1319:58

instruction so let's just duplicate

1320:00

there for the in instructions instead of

1320:03

writing this ingredients I'm going to

1320:04

write like instructions and then set

1320:08

instructions and for the level I'm going

1320:10

to only copy this instruction and put

1320:12

there right here for this placeholder

1320:16

like so yep that's also looking cool oh

1320:19

and this should be a text area iner so

1320:21

I'll just change there to text area and

1320:25

yep that's looking cool but I'm going to

1320:27

also remove that type and now that's

1320:28

looking better and underneath this text

1320:30

area we going to be entering all of our

1320:32

recipes so I'll just write like d with

1320:34

the name of or with the class of legs

1320:36

and justify will be set to between and

1320:39

inside there we're going to be first of

1320:41

all checking like if we have the editing

1320:43

recipe then we are going to be come on

1320:46

if we have the editing recipe then we're

1320:48

going to be rendering this UI so inside

1320:50

this UI I'll just write a react

1320:52

fragments like so and for now I'll just

1320:54

create a button and let me just save

1320:56

there yep we are getting some sort of

1320:58

error I don't know why but we are

1321:00

getting this error now that is gone so

1321:02

I'm going to just create my react

1321:04

fragments and inside this react

1321:06

fragments first of all we're going to be

1321:07

defining our button and I guess we are

1321:10

getting that error because of that react

1321:11

fragments not quite sure but I'm going

1321:13

to just leave it right here just for now

1321:15

or you know let me just change that to

1321:17

Dev what the hell so I'm going to just

1321:19

change that to D still getting that

1321:21

error by the way okay so got there you

1321:24

know let me just leave that the way it

1321:25

is and I'm going to write like update

1321:27

recipe here but what the hell is wrong

1321:31

with this

1321:32

oh that's because here we are not

1321:35

providing the closing tag so I'm going

1321:37

to provide my closing fragments right

1321:39

here and also the opening and closing

1321:41

there now this is looking better I'm

1321:43

going to just God damn it so I'm going

1321:45

to just replace it with this new one and

1321:47

I'm going to just change this D to just

1321:49

react fragments and somebody clicks on

1321:51

this button we're going to be firing

1321:53

this function like handle update recipe

1321:56

and we're going to be creating this

1321:57

function in a few second but now let me

1321:58

just put a bit of class into this um

1322:00

button so I'll just write a background

1322:02

of totally yellow 500 and text will be

1322:05

set to totally white pairing for the

1322:07

xaxis will be set to four pairing for

1322:09

the Y AIS will be set to two toally

1322:11

rounded and then large when somebody H

1322:13

over this button we just want to change

1322:15

the color of that to Yellow of 600 we

1322:17

also want to provide the Focus ST of

1322:19

outline of none and also for the focus

1322:22

we want to provide the Ring of two and

1322:24

on the focus the ring will be set to

1322:26

Yellow 500 so now let me just save my

1322:29

file we are going to be creating this

1322:31

function in a few seconds underneath

1322:33

there we're going to be defining one

1322:34

more button so I'll just create a button

1322:36

and inside this button I'll just say

1322:38

like can card cancel and I'm going to

1322:41

just provide a bit of styling to that

1322:43

and also when somebody click on this

1322:44

button we're going to be firing like

1322:46

handle cancel edit and I'm going to

1322:48

provide a classes of you know exactly

1322:50

that same classes but instead of

1322:51

providing that yellow here we are

1322:53

providing this gray color right here so

1322:55

if I save there now let me take care of

1322:57

these two what you want first of all let

1322:59

me also take care of this area then

1323:01

we're going to to be taking care of that

1323:02

other one so what I'm going to do is

1323:04

that I'm going to create a button once

1323:06

again and it's going to say like add

1323:08

recipe and when somebody clicks on there

1323:10

we're going to be firing this function

1323:11

which is a handle add recipe like so I'm

1323:15

going to also provide a closes to there

1323:16

so I'm not going to waste your time let

1323:18

me just proide these classes right here

1323:20

and yeah you can pause the video and

1323:21

just proide these classes so now

1323:22

underneath this Dev what I'm going to do

1323:24

is that I'm going to just write a UL

1323:26

with a class of space on the Y AIS will

1323:28

be set to four and now let me iterate

1323:29

over through all of that recipes so I'll

1323:31

just use like uh recipes do God damn it

1323:35

RC yeah there we go and now we are going

1323:38

to be rendering all of for recipe so

1323:40

I'll just use like recipe and inside

1323:42

there I'm going to render my Ali and

1323:44

inside this Ali first of all let me just

1323:46

provide a key and the key will be coming

1323:48

from that recipe. ID I'm going to also

1323:50

provide the class name today so pairing

1323:52

for all around will be set to four and

1323:54

background will be set to totally green

1323:55

of five of 50 rounded large Shad or

1324:00

small inside this Al we're going to be

1324:02

rendering our H2 which will say like

1324:04

text will be set to totally extra large

1324:06

font will be set to semi bolt text will

1324:09

be set to Green 800 let me just write

1324:11

800 and margin for the bottom will be

1324:13

set to two here inside there we have to

1324:15

render our recipe and then name their

1324:18

specific recipe name underneath this

1324:20

issue we have to also render our

1324:22

ingredients so I'll just write a

1324:23

paragraph with the class of text Gray of

1324:26

700 and margin for the bottom will be

1324:28

set to two and we're going to be using a

1324:30

strong tag inside there there and I'm

1324:32

going to write like ingredients that

1324:33

ingredient will be set to recipe not

1324:35

recipes but just a singular recipe I'm

1324:38

not even getting a recipe and then that

1324:41

ingredient

1324:43

ingredients do join and here we have to

1324:46

just put a comma here and space It

1324:48

should be a recipe instead underneath

1324:50

this paragraph I'm going to create a d

1324:52

with a class of flex and justify will be

1324:55

set to Center or not even Center but

1324:57

between we're going to be also creating

1324:58

a button which will say like edit and

1325:00

I'm going to also put the on click event

1325:02

handler to there and when somebody

1325:04

clicks on this we're going to be firing

1325:05

this handle edit recipe function it's

1325:08

going to take a recipe as a perimeter

1325:11

and let's just put our classing today so

1325:13

I'm going to place this classing Right

1325:14

Here and Now underneath this button what

1325:16

do you want to do we just want to create

1325:18

here another button and which will

1325:20

select delete I'm going to also provide

1325:22

the own click event handler on this one

1325:23

so when somebody clicks on there they're

1325:25

going to be firing this function which

1325:27

is a remove recipe there we go and it's

1325:30

going to take a recipe ID just a

1325:32

singular recipe. ID there we go I'm

1325:34

going to also provide a classes to this

1325:36

one so that we can style there a bit and

1325:38

this should be a

1325:42

REI re e c IP there we go I'm going to

1325:45

copy this one put the right here also in

1325:49

there also here and recipe. ID and it's

1325:53

going to take a recipe there we go now

1325:55

that's looking better I'm going to

1325:57

create these functions like handle edit

1325:59

recipe handle delete recipe and so on

1326:01

and so forth so now let me just go to

1326:03

the top and create them so we'll start

1326:05

by first of all adding the recipe so

1326:07

I'll use like handle add recipe it's

1326:10

going to be equals to this Arrow

1326:11

function and first of all we are going

1326:13

to be checking we have name. trim we

1326:15

also want to remove that empty spaces

1326:17

from there if that is equal to empty

1326:19

string or ingredients ingredients. trim

1326:23

going to be also removing empty spaces

1326:24

from there if that is equal to empty

1326:26

string or

1326:28

instructions. frame if that is equal to

1326:31

empty strings in that situation what do

1326:33

you want to do we just only want to

1326:35

return but if that's not the case so

1326:37

we're going to be creating our recipes

1326:39

all use like a recipe and here we have

1326:41

to specify the ID and that's going to be

1326:43

equals to dead. now and also I'm going

1326:46

to be providing a name today and here we

1326:48

have to specify the ingredients start ID

1326:50

or just ingredients so I'll use not

1326:53

instruction but ingredients that's going

1326:55

to be also set to this ingredients from

1326:57

the St and we're going to be using a

1326:58

split method on there and we only want

1327:00

to split there by comma and then we want

1327:02

to it right over through all of them and

1327:04

let's just provide our ingredients as a

1327:06

perimeter for this function and we're

1327:08

going to be removing empty spaces from

1327:09

them so I'll use like trim method inside

1327:11

there and also let me just provide a

1327:13

comma and here we have to also render

1327:15

the instructions now let me just save my

1327:17

file and whenever we add our ingredients

1327:20

we also want to empty out our St so I'll

1327:22

write like set name and empty this out

1327:25

and set ingredients empty this out and

1327:28

also set instructions empty that out out

1327:31

as well let me test this out so I'll

1327:33

just write like no and then I don't know

1327:35

one I don't know two and then I don't

1327:38

know and if I click on this add recipe

1327:40

we cannot edit there but we can totally

1327:42

delete there if you wanted to now let me

1327:44

take care of the handle edit recipe so

1327:47

what I'm going to do is that I'm going

1327:48

to just create a function with the name

1327:50

of handle edit recipe like so and it's

1327:53

going to be taking a recipe as a

1327:54

perimeter just a single recipe and we

1327:57

have to annotate there with our recipe

1327:59

like so and inside there we're going to

1328:01

be using like set editing recipe and we

1328:03

have to provide our recipe as a

1328:05

perimeter to them now for the name we're

1328:07

going to be also providing a recipe.

1328:09

name and now underneath that we're going

1328:11

to be using our set ingredients and for

1328:13

the ingredients we're going to be

1328:14

providing the recipe. ingredients and we

1328:16

also have to use the join method on

1328:18

there and we have to join there by by

1328:20

just providing a comma we also have to

1328:22

take care of the instructions we are

1328:23

going to be using like Set uh yeah

1328:26

instructions you have to provide the

1328:28

recipe do instructions right here and

1328:30

that's going to be it for the hand edit

1328:31

recipe now let me test this out so right

1328:34

like test and then test two and testing

1328:38

testing dot dot dot click on the Ed

1328:41

recipe now you can click on this edit so

1328:43

it's going to gives us an error let me

1328:44

just go to the console go to the top and

1328:47

handle update recipe oh we also have to

1328:50

update there so you know let me just

1328:52

also take care of there right here so

1328:54

now let me just create my handle update

1328:56

recipe so I'll use like const and handle

1328:58

update recipe it's going to be equals to

1329:01

this Arrow function it's not going to

1329:02

take any perimeters and I'm going to go

1329:05

ahead and copy a few things from this

1329:07

function so I'm going to copy there and

1329:09

put that right here inside this function

1329:11

so that's done now underneath there

1329:13

we're going to be first of all checking

1329:15

so if we have editing recipe in this

1329:19

situation we're going to be removing our

1329:21

recipe by providing our editing recipe.

1329:23

ID to the next we're going to be

1329:25

creating our recipe so I'll just go to

1329:27

the top and then I'm going to just copy

1329:30

this stuff and put there right here and

1329:33

now underneath this one we're going to

1329:35

be just providing like set editing

1329:36

recipe and we only have to provide a

1329:38

null value to there and finally let me

1329:40

just go to the top once again and copy

1329:43

all of that empty stuff copy there and

1329:46

put there right here inside or set

1329:49

updating recipe now let me just save my

1329:51

file and then that's going to be it for

1329:52

the handle update recipe let's just test

1329:54

this out so I'll just write like test

1329:56

and then test two and then test come on

1329:59

testing now if I click on this add now I

1330:02

can click on the edit still getting an

1330:04

error and I know why we are getting this

1330:07

error that's because we also have to

1330:09

create this handle cancel edit component

1330:13

or a function so I'll just collapse this

1330:15

one and I'm going to also collapse that

1330:17

one and you know what I'm going to also

1330:19

collapse this function and now finally

1330:21

we have to just create or handle cancel

1330:23

edit and that's going to be the most

1330:25

easiest one so I use like cons handle

1330:27

cancel edit that's going to be equals to

1330:30

this Arrow function and we have to write

1330:32

like set editing editing recipe and we

1330:35

have to set that to now and we also have

1330:37

to change like all of that stuff so you

1330:38

know I'm going to copy that from here

1330:40

I'm not going to waste your time I'm

1330:42

going to copy both of these three or all

1330:44

of their three and put that right here

1330:46

and that's going to be for the

1330:47

cancelling so if I click on this edit so

1330:50

it's going to allows us to edit our

1330:51

recipe so I'll just write like

1330:54

um hosan then hosan 2 and then uh hosen

1331:00

22 22 two now I can click on this update

1331:02

recipe so it's going to update that to

1331:04

husan and also husan 2 and all of that

1331:07

and I can totally delete that and by the

1331:09

if I click on this edit once again I can

1331:11

totally cancel this edit if I wanted to

1331:14

I can totally delete there and yeah we

1331:16

can add a recipe like uh computers and

1331:19

then chair GPT and then amazing amazing

1331:24

AI stuff that's going to be my recipe

1331:28

book and if I click on there and yep

1331:30

they are now suc sucessfully added to my

1331:32

list and that ladies and gentlemen was

1331:36

our first project by using Zen so now

1331:38

let's make a set of 4 or expense tracker

1331:40

project so I'm going to open my terminal

1331:42

right here and now let's just use our

1331:43

npm create weed at

1331:46

latest I'm going to give it the name of

1331:48

like expense tracker I'll choose react

1331:51

JS with typescript let's just go into

1331:53

our expense tracker project and I'm

1331:55

going to use npmi to install every

1331:56

single thing inside there I'm going to

1331:58

also install Ze so I'm going to use like

1332:00

npmi Zeus 10 z s n d so it's going to

1332:05

install zus inside our project that's

1332:07

done now I'm going to go into my tailin

1332:08

CSS and click on the getting started now

1332:10

I'm going to choose framework guides go

1332:12

to the weed and copy this command and

1332:15

place it right here let me hit enter one

1332:17

more time so it's going to initialize my

1332:19

T CSS right here and finally we have to

1332:21

open that inside our vs code now what

1332:23

I'm going to do is that I'm going to

1332:25

copy this content and let me just go

1332:28

into my T when config.js and place there

1332:31

with this new content so that's done we

1332:33

also have to provide the forward index

1332:35

file so I'm going to open my index. CSS

1332:37

remove every single thing from there and

1332:39

place my components right there so

1332:41

that's done I'm going to also remove the

1332:42

public folder the SS folder the amp. CSS

1332:45

and I'm going to remove every single

1332:47

thing from the app and I'm going to

1332:48

replace that with the RFC and go into my

1332:51

index. CSS and and that's cool so you

1332:53

know what let me test this out by

1332:55

providing this H1 so I'll just copy

1332:57

there go into my app and provide there

1333:00

right here sa my file open my terminal

1333:02

and I'm going to write like npm runev

1333:04

and let's just test this out right here

1333:06

and yep The Styling is working and

1333:08

everything is not toly done that's done

1333:10

now we have to create our store to

1333:12

initialize our state inside this I'll

1333:13

just create a file with the name of

1333:14

store. TS and now the first thing that

1333:17

we have to do is that we have to import

1333:18

the create function from where from the

1333:21

zean and now underneath that we're going

1333:23

to be defining our use store once again

1333:25

and that's going to be equals to the

1333:26

create function and here inside we're

1333:28

going to be providing a callback

1333:30

function which will take a set as a

1333:31

perimeter and inside there we are going

1333:33

to be providing our initial state so

1333:35

that's going to be set to expenses

1333:38

expenses and the expenses will be equal

1333:40

to this empty array I'm going to provide

1333:42

a comma so we would be able to add our

1333:44

expense and also remove our expense and

1333:47

then in the UI we're going to be also

1333:49

calculating our expense so what I'm

1333:50

going to do is that I'm going to just

1333:51

write like add expense and that's going

1333:54

to be equals to this errow function and

1333:55

it's going to take the expense right

1333:57

here e pnse and here inside then we're

1334:01

to be using our set method to change our

1334:03

set and I'm going to provide my callback

1334:04

function right here and inside this

1334:07

callback function first of all we are

1334:08

going to be getting all of our expenses

1334:10

and we're going to be making a clown of

1334:12

this I'll use like dot dot dot and then

1334:14

instead do expense and then we have to

1334:17

provide our new expense which we are now

1334:18

taking as a perimeter for this function

1334:21

like so now I'm going to save my file so

1334:23

we are now getting a lot of typescript

1334:25

error the first thing that I'm going to

1334:26

do is that I'm going to export this so I

1334:28

can use the in other file next we have

1334:30

to create our interface for the expense

1334:31

so I'll just create interface for the

1334:33

expense e pnse e and inside that we are

1334:37

going to be providing the ID and ID will

1334:39

be set to number we're going to be also

1334:40

providing the description and

1334:42

description will be a string and finally

1334:44

we also have to provide the amount so

1334:46

amount will be set to number so that's

1334:48

going to be the first interface now

1334:50

we're going to be creating yet another

1334:51

one for the expense store so I'll just

1334:53

write like expense store and inside

1334:57

there what do you want to do we just

1334:58

want to initialize our expense like so

1335:00

or expenses rather and that's going to

1335:02

be equals to our expense interface which

1335:04

we' have created above like this one and

1335:07

that's going to be equals to array of

1335:08

that expenses now underneath that we're

1335:10

going to be also adding the expense and

1335:12

also removing what expense so what I'm

1335:14

going to do is that I'm going to just

1335:16

write like add expense and that is going

1335:18

to be taking expense as a perimeter and

1335:21

now we have to annotate that with this

1335:23

expense perimeter now we have to just

1335:25

return or wi from there and that's going

1335:26

to be done I'm going to also duplicate

1335:28

and change the name of there to like

1335:29

remove expense

1335:31

and here instead of proving an expense

1335:33

I'm going to write like ID and ID will

1335:35

be set to a number and that's done now

1335:37

we have to annotate or create method by

1335:40

using our expense tool like so and I'm

1335:43

going to close there now this one is

1335:44

freaking out because we also have to add

1335:46

our remove expense so I'll just write

1335:48

like remove expense and here it's going

1335:50

to take the ID and now we're going to be

1335:52

using our set method and inside this set

1335:54

method we're going to be providing our

1335:55

call back function and here we also have

1335:58

to first of all get all of our expenses

1336:00

and to get there we are going to be

1336:02

getting there from the st. expenses and

1336:04

now we have to use the filter method on

1336:06

there so now we can use like filter

1336:08

method and for this filter method we're

1336:10

going to be providing our expense as a

1336:12

perimeter so I'll write like expense and

1336:14

then uh we have to use our expense. ID

1336:18

and if that ID does not equal to this ID

1336:21

which we now taking as a perimeter for

1336:23

this function so then we want to just

1336:25

remove that specific expense and this is

1336:28

freaking out because we have to provide

1336:29

s inside there that's done and also s

1336:33

here expenses now that's looking better

1336:36

okay so that was at about 4 hour store

1336:38

and now let's just Implement there

1336:39

inside our UI so what I'm going to do is

1336:41

that I'm going to create a folder with

1336:43

the name of components components and

1336:45

inside we going to be creating our

1336:47

expense tracker. TSX component inside

1336:51

there I'll just use my rafc S my file

1336:54

and go to my app and here we have to

1336:56

render that component so I'll just write

1336:58

like expense tracker and I'm going to

1337:00

also close there and you know what I'm

1337:02

going to also just inside the div and

1337:05

inside this St we're going to be calling

1337:06

our expense tracker so that's done let

1337:08

me test this out so yep we are getting

1337:10

our expense tracker so the first thing

1337:12

that we want to do is that we want to

1337:13

grab the expenses add expense and also

1337:16

the remove expense from the use store

1337:18

not a St God damn it use store which

1337:21

we've just created but not from Z what

1337:24

the hell am I doing today God damn it

1337:26

you know let me just import them

1337:27

manually so I'm going to import the use

1337:30

T from where from let's just go ahead

1337:33

and go to our store from our store there

1337:35

we go now we have to use that so to use

1337:37

that we're going to be using our use

1337:39

store and initialize it and now we're

1337:41

going to be destructuring the expenses

1337:43

so I'll use like expn sces and also

1337:47

that's going to be equals to this use

1337:48

store now we're going to be also

1337:49

importing or destructuring the add

1337:52

expense and also the remove expense and

1337:55

we are going to be getting that from the

1337:56

use store we're going to be also

1337:57

creating a few step forward description

1338:00

and also for for or amount so I'll just

1338:01

write like description and then set

1338:04

description there we go it's going to be

1338:07

equals to the used St and now store but

1338:09

use state in this case and the initial

1338:11

value will be just empty string I'm

1338:13

going to also just annotate with a

1338:14

string doesn't really matter but I'm

1338:16

going to still do that now we have to

1338:17

create one for the amount and then set

1338:19

amount and that's going to be equals to

1338:21

the use St and for this St that's going

1338:23

to be also equals to empty string but

1338:25

now we have to annotate there with

1338:27

either the number or empty string like

1338:29

so and I'm going to close them we're

1338:31

getting a lot of Errors I don't know why

1338:34

we are getting these errors I'm going to

1338:37

restructure there and now there it is

1338:39

gone so now we have to just use the

1338:40

inside of our project and then that's

1338:41

going to be done so what I'm going to do

1338:43

is that I'm going to go to my UI and

1338:45

remove that from there and provide a lot

1338:46

of styling today so I'm not going to go

1338:48

ahead and tell you every single 10 when

1338:50

CSS class but we are going to be

1338:51

providing these classes to it so you can

1338:53

totally pause the video and provide the

1338:55

styling today if you wanted to if you

1338:57

don't want to provide the styling I

1338:59

totally get it like you don't even have

1339:00

to provide all of that styling so I'm

1339:02

going to just fast forward this video

1339:04

I'll create a div first of all and

1339:06

inside this div we're going to be

1339:07

providing these classes so you know let

1339:09

me just highlight there for you we going

1339:11

to be providing these classes so you can

1339:12

totally pause the video once again and

1339:15

provide there now I'll create my H1 and

1339:17

inside this H1 we're going to be

1339:19

providing these classes and now inside

1339:20

this H1 I'll just write like expense

1339:23

tracker and now I save my file and this

1339:26

is how it looks like baby that's looking

1339:29

cool

1339:30

and now underneath this H1 what do you

1339:32

want to do we just want to create our D

1339:34

with a class of space on the y- AIS of

1339:36

four and also margin for the bottom will

1339:39

be set to six and inside there let's

1339:41

just create our input field with the

1339:43

type of text and also the value will be

1339:45

set to description and when somebody try

1339:47

to type something inside there so we are

1339:49

going to be firing this function which

1339:51

will be equal to the set description and

1339:53

let's just Prov our event. target. value

1339:55

inside there okay now outside from there

1339:58

we going to be also providing our

1339:59

placeholder which will say like expense

1340:02

descript DC r p TI o and now let me just

1340:06

save my file and finally we have to

1340:08

provide these classes to it for the

1340:10

styling so let's just go back so you

1340:12

guys can see everything a bit better and

1340:13

that's looking cool yep we are getting

1340:16

what expense and that's looking great

1340:18

that's going to be for the first one I'm

1340:19

going to create yet another input field

1340:21

with the type of number in this case

1340:23

because we're going to be taking care of

1340:24

the amount and here we have to specify

1340:27

the value of amount that stat which we

1340:29

just created up above and when somebody

1340:31

try to typee something inside this we

1340:33

are going to be firing this function

1340:35

which will be set to or set amount and

1340:38

here we have to specify our event.

1340:40

target. value if that is triple equals

1340:42

to empty string so we're going to be

1340:44

setting that to just empty string but if

1340:46

that's not equal to empty string then we

1340:48

are going to be getting the value of the

1340:50

and we also have to convert that value

1340:53

to a number because we are now working

1340:55

with the amount and we have to convert

1340:57

that amount to a number so we can

1340:59

convert our amount to a number by just

1341:01

using this number Constructor you know

1341:03

let me just highlight there we can use

1341:05

this number Constructor for there or

1341:08

there is another way if you guys take my

1341:10

JavaScript course you guys probably know

1341:12

that but if you don't that's completely

1341:13

okay so now I can totally remove that

1341:16

and change there with this plus symbol

1341:19

that's everything that I have to do for

1341:21

this input field now I'll also provide

1341:23

the placeholder to this so I'll just use

1341:25

like placeholder which will say amount

1341:27

now underneath there I'm going to also

1341:28

provide these classes today that's done

1341:31

now finally we have to create our button

1341:33

which will allows us to add our expense

1341:35

or remove our expense or on and so forth

1341:37

so I'll just create a button with the

1341:38

level of add expense and here when

1341:41

somebody clicks on their button not

1341:43

change but on click so we're going to be

1341:45

fing this function which is a handle add

1341:48

add expense okay we're going to be

1341:50

firing this function and we also have to

1341:52

provide these classes today you can

1341:54

totally pause the video and just type

1341:56

there if you wanted to now let me take

1341:58

care of this ad expense so I'm going to

1341:59

copy the name of there go to the top and

1342:02

use that right here so what do we want

1342:03

to do first of all we have to create our

1342:06

handle h n DL yep the spelling is

1342:09

correct and we have to create this aror

1342:11

function then we're going to be checking

1342:13

if our description dot God damn it d s c

1342:18

r i p t i o n if or description. trim we

1342:21

want to remove every single empty space

1342:23

from there if there is equal to empty

1342:25

string or the amount is equal to empty

1342:28

string so in that situation we don't

1342:30

want want to do nothing but we only want

1342:32

to return that's going to be it okay but

1342:34

if that's not the case we're going to be

1342:36

adding our expens so how are we going to

1342:38

be doing there you'll just use our add

1342:40

expense function which is coming from

1342:42

our zust store and we have to provide

1342:44

the ID and ID will be set to dat. now

1342:47

and then we also have to specify the

1342:49

description and for this description we

1342:51

are going to be taking the from our

1342:53

state like this one and finally we have

1342:55

to provide the amount so I'll just write

1342:57

like amount and amount will be set to a

1342:59

number and we can just specify our

1343:01

amount or we can just write a plus and

1343:04

it's going to also convert there to a

1343:06

number so that's done now underneath

1343:08

that we also have to clear out our

1343:10

description and also our amount input

1343:12

field so we can just say like uh set

1343:14

description empty this out and then set

1343:16

amount empty this out and that's done

1343:19

okay so this how we are going to be

1343:20

adding our expense but now the question

1343:23

is how are we going to be rendering

1343:24

there like I can totally add expense

1343:26

right here I can provide some sort of

1343:28

amount to there if I click on this so

1343:30

it's going to empty this out but we

1343:32

cannot see the result of there so now to

1343:34

see the result of there underneath this

1343:35

button then we are going to be iterating

1343:37

over through or expenses so I'll just

1343:39

use like ul and this UL will take the

1343:41

classes of spaces on the y axis of four

1343:44

and margin for the bottom will be set to

1343:45

six and now inside this Ur we're going

1343:48

to be trading or uh through our expenses

1343:50

like expenses which we are now getting

1343:53

from or Us store right here like we now

1343:55

iterating over through all of our

1343:56

expenses and what I'm going to do is

1343:59

that I'm going to be fing not even

1344:00

fighting but I'm going to be using a map

1344:02

method which will take a arrow function

1344:04

with the perimeter of expense not

1344:06

expenses but just expense okay and then

1344:09

we have to create this Arrow function

1344:11

and inside that we're going to be

1344:12

creating our Li and that Li will take

1344:14

like the key and the key will be coming

1344:16

from our expense. ID and we're going to

1344:18

be also providing these classes today

1344:20

and now inside this Ali what do you want

1344:22

to do first of all you want to create

1344:24

our span and classes will be text Gray

1344:27

of 800 and also font will be to semi Bol

1344:31

and inside this Pence first of all we

1344:33

have to render the expense description

1344:34

so I'll use like expense. description

1344:38

and then what do you want to do we just

1344:39

want to render our description right

1344:41

here like uh let's just use our expense.

1344:44

amount. to fix and we want to just fix

1344:46

there with two characters or two numbers

1344:49

like let's suppose we have some sort of

1344:51

amount with the numbers of 20 dot uh

1344:53

this amounts we want to remove every

1344:55

single thing and we only want to provide

1344:58

these two numbers right here so for that

1345:00

we are now using this fixed method right

1345:02

here okay so if you want to learn more

1345:03

about that I already explained all of

1345:05

their topics in my JavaScript so if you

1345:07

guys care about that you can definitely

1345:08

go ahead and watch my course on there oh

1345:11

I made a mistake I'm going to have to

1345:13

cut that and then we have to create a

1345:15

span with a class of text PPL of 600 and

1345:20

inside that then we're going to be

1345:21

rendering or expense there we go now

1345:23

finally we also have to create a button

1345:26

which allows us to remove our expense

1345:28

I'll just write like button and when

1345:29

somebody it clicks on this button we are

1345:31

going to be firing this function which

1345:33

will be a remove expense which is coming

1345:35

from our store and we're going to be

1345:37

providing our expense. ID inside there

1345:40

now let me go ahead and just write uh

1345:42

Delete delete would be fine and I'm

1345:44

going to also write some sort of a

1345:45

sample like X I'm going to also style

1345:48

there so let's just provide a space and

1345:50

provide these classes you can pause the

1345:51

video and provide these classes by

1345:53

yourself if you wanted to and here you

1345:55

can see we're now getting that expense

1345:56

so now let me just refresh there I'll

1345:58

right like um he computer with the

1346:01

amount of 4 million and add that so here

1346:06

you can see we now getting our uh yeah

1346:08

the description and also the amount and

1346:10

now if I click on the delete this can

1346:12

also delete there now what I'm going to

1346:14

do is that now underneath this UL we're

1346:16

going to be creating a d with the class

1346:18

of text all Center and now inside the

1346:20

let's just create our H2 with the class

1346:22

of text text of 2 XEL and the font will

1346:25

be set to semi Bol and text will be set

1346:27

to totally purple and then 700

1346:30

this is right this God damn it oh my God

1346:33

700 there we go and write a total

1346:35

expenses expn s and here we're going to

1346:39

be rendering our entire expenses so I'll

1346:42

use like span with a class of text only

1346:44

purple and 600 and finally we have tried

1346:47

our dollar symbol and now let's just use

1346:49

our expenses. reduce method on there and

1346:52

on this reduce is going to take the

1346:54

total and also for the accumulator value

1346:56

we're going to be providing our expense

1346:58

right here our expenses but just expense

1347:01

and then we have to use our total plus

1347:03

our expenses. amount and then we have to

1347:06

provide the comma and we want to

1347:08

accumulate the by zero and then we going

1347:11

to be getting some sort of a random

1347:12

value like 20 point something something

1347:15

we want to just only prefix there with

1347:17

these two characters or two numbers so

1347:20

for that let's just use our DOT to fix

1347:23

method and here we have to specify only

1347:25

two and now if I save my file and here

1347:27

you can see we're now getting a total

1347:29

amount and if I write like some sort of

1347:31

a I don't know I don't know and some

1347:33

sort of amount and click on the add

1347:35

expense so it's going to add there right

1347:37

here and then I can add something

1347:41

something else and then yep another

1347:44

amount just going to add there right

1347:46

here so that was our expense tracker by

1347:49

using reactjs TN CSS and zustan and also

1347:53

typescript welcome to the Call of Duty

1347:55

Ghost Edition I'm your host Charlie I

1347:58

mean um moist I mean penguin z0 okay

1348:03

let's just build our project so what I'm

1348:05

going to do is that I'm going to just

1348:06

open my terminal and inside this

1348:08

terminal what I'm going to do is that

1348:11

I'm going to use npm create be at latest

1348:16

and hit enter I'll give it the name of

1348:18

password generator I'm going to choose

1348:21

reactjs with

1348:26

timecrimes there now that's done I'll

1348:29

also install a zoo and hit enter so it's

1348:31

going to install a zo stand inside my

1348:33

project next I'm going to go into my TN

1348:35

CSS go to the framework guides go to the

1348:38

weed copy there place it here and paste

1348:42

it anyways and yep hit enter one more

1348:45

time to initialize T when CS is inside

1348:47

our project that's cool and everything

1348:49

so I'm going to open that in my vs code

1348:50

so I'll use like code dot it's going to

1348:53

open that in my vs code time to go to

1348:55

our tailin config file I'll use my

1348:57

tailin config and replace the with this

1349:00

new one copy the index. CSS uh stuff and

1349:04

replace it with this one and also copy

1349:08

this H1 from there go to my ab do not

1349:11

CSS ab. TSX and remove every single

1349:15

thing from there and I'm going to use my

1349:16

R fce sem my file and replace that with

1349:19

this new one finally let's just run

1349:21

there by using npm run Dev go to my

1349:24

local host hit enter so it's going to

1349:26

open there right here and that's looking

1349:28

cool so what I'm going to do is that I'm

1349:31

going to just make a bit of cleanup so

1349:32

we don't need the SS folder the app. CSS

1349:35

folder we need the app do I mean like

1349:37

index. CSS folder file and I'm going to

1349:40

also remove the public folder and that's

1349:42

done and now let's just start working on

1349:43

our store let's just create our store.

1349:46

TS file and here first we need the

1349:49

create function from zust and underneath

1349:53

that we have to create our custom Hook

1349:55

by defining use

1349:57

password uh store and here we have use

1350:00

our create method and let's just Pro our

1350:02

callback function with the name of set

1350:05

and that's going to be it so what I'm

1350:06

going to do is that I'm not going to

1350:07

waste your time by defining the

1350:09

interface but I'm going to just place

1350:11

that interface right here let me go back

1350:13

so you guys can see everything a bit

1350:15

better first of all we have our password

1350:17

St or store whatever you want to call it

1350:19

it's going to take the property of

1350:20

length which will be a number it's going

1350:22

to take the property of include numbers

1350:24

which will be a Boolean then include

1350:25

sample then include uppercase include

1350:27

lower case generated password set

1350:30

password which will be a function and

1350:32

the rest of these will be a functions

1350:33

too and toggle number then toggle sampol

1350:36

then toggle uppercase toggle lowercase

1350:38

and generate password so there our state

1350:41

or interface to be precise so now let's

1350:44

just annotate or create function by

1350:46

providing our password State like so I'm

1350:49

going to save my file and go into my

1350:51

store first we have to provide our

1350:53

length and length will be set to 12

1350:55

that's going to be just my initial value

1350:58

okay we also have to provide the initial

1351:00

value for the include numbers which will

1351:02

be set to true we also have to provide

1351:04

for the include sampol or samps rather

1351:07

this going to be set to false we also

1351:09

have to provide therefore the include

1351:11

uppercase that's going to be set to true

1351:13

we also have to provide therefore the

1351:15

include lower case and this can be set

1351:17

to True once again you also have to

1351:19

provide therefore the

1351:21

generated generated password and

1351:23

generated password will be set to empty

1351:25

string so then done now we have to

1351:27

Define like how we are going to be

1351:29

changing ing these St so to do that I'm

1351:31

going to be creating first of all the

1351:32

set length function which will allows us

1351:35

to change your length Okay so I'll just

1351:37

write like length as a perimeter to this

1351:39

function and we're going to be using

1351:40

this set method and here we just have to

1351:43

provide the value of our length which we

1351:45

now taking as a perimeter for this

1351:47

function so that's done now we also have

1351:49

to specify the toggle number and that's

1351:52

going to be a function two so here it's

1351:54

not going to take any perameters but now

1351:56

we're going to be providing a set method

1351:58

and inside there let's just your State

1352:00

method it's going to also take the call

1352:02

back function all provide the perimeter

1352:03

of state and here we only have to get

1352:06

first of all our include numbers and

1352:08

that's going to be set to not state.

1352:11

include come on include numbers there we

1352:13

go so if this value gives us true this

1352:16

will make it false if this value gives

1352:18

us false it's going to make it true so

1352:21

this is how we going to be toggling that

1352:23

number okay now I'm going to also put a

1352:25

comma there and we also have to create

1352:27

our toggle symol function and here we

1352:29

have to once again Define our Arrow

1352:31

function and let's just provide our set

1352:33

method it's going to take a St and what

1352:36

we want to do is that we want to just

1352:37

find this function like so and let's

1352:40

just get our include sambols that's

1352:42

going to be equals to the not state.

1352:44

include sambols in this case once again

1352:47

if this is true it's going to make it

1352:49

false if this is false it's going to

1352:52

make it true once again okay now we also

1352:54

have to create a toggle uppercase and

1352:57

here we have to specify our callback

1352:59

function let's just proide our state

1353:00

inside there what the hell am I doing

1353:03

and here we have to get our include

1353:05

uppercase upper case and that's going to

1353:09

be still St do include uppercase finally

1353:12

we also have to get our toggle lower

1353:14

case and that's going to be equals to

1353:16

this thir function or you know what the

1353:18

hell am I do that's going to be equals

1353:20

to this Arrow function and it's going to

1353:21

take a set as a perimeter and also we

1353:24

have to provide our St inside there and

1353:26

once again include uppercase in this

1353:28

case and then then that's going to be

1353:30

not equals to A st. include and this

1353:32

shouldn't be uppercase this should be

1353:34

include lower case because now we are

1353:36

working with the lower case values

1353:38

that's done and now for the final

1353:40

function which is a generated or

1353:42

generate password that's going to be a

1353:44

bit complicated so just create this

1353:46

function right away like so and what you

1353:49

want to do is you just want to find this

1353:51

set function it's going to take a state

1353:52

as a perimeter and we have to provide

1353:54

our callback function today and inside

1353:57

this callback function first we have to

1353:59

Define our numbers I'll use like numbers

1354:01

and we're going to be starting our

1354:03

number from 0o through 9 let me just

1354:05

place there then we also have to create

1354:08

our symol so I'll just write like cons

1354:10

sbol Sy ym B LS and symbols will be

1354:13

equals to so if you just hold shift and

1354:15

hit one so it's going to give us this

1354:17

one if you hold shift and then hit two 3

1354:20

4 5 and so on and so forth okay so yeah

1354:23

this is going to be our symbols and

1354:25

create uppercase lat so I'll just write

1354:26

like cost uppercase it's going to be

1354:29

equals to all of the uppercase letters

1354:31

starting from a through z okay then we

1354:34

also have to create a lower case so I'll

1354:36

just use like lower case it's going to

1354:38

be equals to all of the lowercase

1354:40

characters starting from a through z

1354:43

next we have to Define our character so

1354:45

I'll just use like uh characters and

1354:47

it's going to be equals to this empty

1354:49

string now we have to provide a lot of

1354:51

checks okay so if or st. include numbers

1354:55

so in this situation we're going to be

1354:57

getting that characters this variable

1354:59

which we are now defining right here and

1355:01

then we're going to be using the plus

1355:03

equals to the numbers from our state

1355:05

like these numbers okay so that's going

1355:07

to be for the first one and now you know

1355:10

let me just duplicate there a few times

1355:12

now we're going to be changing this

1355:13

value like we have include sambols and

1355:16

then we're going to be using the sbol

1355:19

right here like sampol there we go we

1355:21

also have to change that to the include

1355:23

uppercase and change this number to the

1355:26

uppercase and finally we have to change

1355:29

this includ numbers to the include lower

1355:32

case and we have to change that to the

1355:33

lower case there we go now underneath

1355:35

there what do you want to do we just

1355:36

want to create our password so that

1355:39

password will be equals to this empty

1355:40

string and now we have to iterate over

1355:43

through our St I'll use like for let I

1355:45

equals to zero and then I is less than

1355:47

state. length Okay and then i++ so where

1355:50

in the word is our St if I hold control

1355:53

and how over this and if I click on

1355:55

there here is our state which is a

1355:57

perimeter for this function okay so yeah

1356:01

now we are going to be iterating over

1356:02

through all of that state then we're

1356:03

going to be getting our password

1356:05

variable and which is that password

1356:08

variable which we just defined a few

1356:09

seconds ago and that's going to be plus

1356:11

equals to that all of that characters

1356:13

and here we have to only get the random

1356:16

password like the random character out

1356:18

of there we can get a random character

1356:20

by using math. floor everybody knows

1356:23

there and then excuse me m. random and

1356:27

then we have to multiply the by the

1356:29

length of our characters so we're going

1356:31

to be using like characters. length so

1356:33

basically it's going to gives us a

1356:34

random character each time now we're

1356:36

iterating over through there and finally

1356:38

we just have to return our uh generated

1356:42

password and that's going to be set to

1356:44

our password so that was a lot of

1356:47

explanation now finally we also have to

1356:49

export our function like export default

1356:52

let's just write export default and use

1356:55

password store like so and that's all

1356:58

done but I don't know why we are this

1356:59

error from and it took me a lot of time

1357:03

but finally I figured out like why we

1357:04

are getting this error here you can see

1357:07

we are now setting this generated

1357:10

password to string and now we are

1357:12

returning the generate password right

1357:15

here this shouldn't be generated it

1357:17

should be generated so now let me just

1357:19

replace there with got this generated

1357:23

pass oh my goodness what the hell am I

1357:26

doing today let me just copy this

1357:28

generated copy that from there and put

1357:31

there right here like so and now here

1357:35

you can see that it is now successfully

1357:37

gone but we also made a typo right here

1357:39

this should be l n GT I'm going to copy

1357:42

there and now here you can see we're

1357:44

also getting this name so then was there

1357:47

about four our state next we're going to

1357:49

be implementing all of that state inside

1357:51

our component time to create our

1357:53

components I'll create a folder with the

1357:54

name of components and then generate or

1357:58

password

1357:59

generator. TSX let's just use our RFC

1358:03

inside there go to my app. TSX and

1358:06

remove this return statement and replace

1358:08

that with our password generator and you

1358:11

know what I'm going to cut that first of

1358:14

all we need a d with the class of

1358:15

minimum height of screen height of

1358:18

screen like so background will be gray

1358:21

of 50 F will be also set two items and

1358:25

then Center justify will be set to

1358:28

center now inside the let's just put our

1358:30

password generator and here you can see

1358:33

we are now getting our password

1358:34

generator which is looking cool the

1358:36

first thing that I want to do is that I

1358:38

want to import my used password

1358:39

generator and we have to use that right

1358:42

here so now we are going to be importing

1358:45

a lot of data like we're going to be

1358:47

destructuring a lot of data so what are

1358:49

we doing here you can see we have our

1358:50

constant then we are now destructuring

1358:52

all of the data from where use password

1358:55

generate or use pass use password store

1358:58

to be precise so we are now

1359:00

destructuring the length set length

1359:02

include number toggle number include

1359:04

symbol and then toggle symbol include

1359:06

uppercase toggle upper case include

1359:08

lower case and then toggle lower case

1359:10

generated password and then generate

1359:13

password okay so now we're going to be

1359:14

importing all of that next we have to

1359:16

take care of this UI I'm going to remove

1359:19

this password and provide a bit of

1359:21

classes to this one so now let me just

1359:22

Place The Styling and inside this T what

1359:24

we want to do we just want to create our

1359:26

H1 with the class of text 2 Excel and

1359:29

the font will be set to totally B margin

1359:31

for the bottom will be set to four and

1359:33

here I'll just write like password

1359:35

generator sa my file and yeah we are

1359:38

getting our password generator which is

1359:40

looking cool now underneath this H1 we

1359:42

are going to be creating a d with the

1359:43

class of flex and flex will be set to

1359:45

column and GAP will be set to four

1359:47

inside there we're going to be defining

1359:48

our empty div and inside this D let's

1359:51

just create our label for the HTML 4

1359:53

I'll just write like length and here

1359:55

I'll just write like password length

1359:58

like so l e n GT there we go I'm going

1360:01

to also provide a bit of classes to this

1360:02

I'll use like block text to is small and

1360:05

font will be set to medium and text Gray

1360:08

of 700 so that's going to be our label

1360:11

now underneath this label we also have

1360:13

to Define our input field so I'll create

1360:15

input field with a type of text or you

1360:17

know what instead of a text we we have

1360:19

to change that to a number and then the

1360:21

ID will be set to a length and also put

1360:23

the value and value will be coming from

1360:27

this length here you can see we're now

1360:28

grabbing the there from our use store

1360:30

now we have to put that inside or value

1360:33

now when somebody types something inside

1360:35

they we're going to be firing this

1360:36

function which will be a set length once

1360:38

again which is coming from our store and

1360:40

we have to convert that to a number by

1360:42

using this Constructors all use like

1360:44

event. target. value or we can use just

1360:47

a plus so I'll remove that and just

1360:50

write a plus it's going also convert

1360:51

that to the number there we go now I'm

1360:53

going to also provide the minimum value

1360:55

which will be set to four and the

1360:57

maximum value will be 6 to 64 four okay

1360:59

so now let me just save my file and this

1361:01

is how it looks like but finally we also

1361:03

have to provide these classes for The

1361:05

Styling and here you can see we are now

1361:07

getting our input field with the type of

1361:09

or the value of 12 and where in the word

1361:11

is this 12 coming from this 12 is coming

1361:13

from this length right here okay now

1361:16

underneath this div what do you want to

1361:18

do we just want to create yet another

1361:20

div with the class of flex and items

1361:22

will be set to Center and inside there

1361:24

let's just create our input feeld with a

1361:25

type of check box and also provide our

1361:28

check and check will be equals to the

1361:30

include numbers include numbers which is

1361:33

coming from our store and then when

1361:35

somebody change them we're going to be

1361:37

firing this toggle numbers underneath

1361:39

then we also have to create a label with

1361:41

the class of margin for the left will be

1361:42

two text will be set to small and I'll

1361:45

just right not provide HTML for God damn

1361:47

it and for the label we will just say

1361:49

like include numbers and that's going to

1361:52

be it there we go and here you can see

1361:55

we are now getting our checkbox and we

1361:57

are now getting our include number which

1361:59

is looking cool now we also have to

1362:01

duplicate there like a few times so I'm

1362:02

going to just select this first one

1362:04

we're going to be duplicating there for

1362:06

the sbls you also need to duplicate the

1362:09

for the upper case also for the lower

1362:11

case and generate password so yeah here

1362:14

I'm going to go to the top one that's

1362:17

already done okay so instead of

1362:18

providing this include number I'm going

1362:19

to change that to include symol come on

1362:21

include symol s y m b o LS and then

1362:26

toggle uh sbls and here also change this

1362:29

label to symbols like so change this one

1362:33

to include uppercase this one and also

1362:37

change this toggle one to toggle

1362:39

uppercase and also change this include

1362:42

to include uppercase and then letters

1362:46

like so now let me change this value

1362:48

instead of writing include numbers I'll

1362:50

write like include lower case and then

1362:53

toggle lower case change this one to

1362:57

include lower case

1362:59

letters like so and we don't need this

1363:02

one so I'm going to just remove that and

1363:04

I'm going to also remove this label and

1363:05

you know what we also don't need this so

1363:07

I'll just also remove that create a

1363:09

button and yeah it's going to say like

1363:12

generate password when somebody clicks

1363:15

on this button we're going to be fting

1363:16

this handle generate come on handle

1363:20

generate password function which is

1363:22

going to be just a oneliner function

1363:24

which we're going to be creating right

1363:25

now and provide a classes to this one

1363:27

right here I'm going to copy the name of

1363:28

this and go to the top and create this

1363:31

function right here which is going to be

1363:33

just a one lineer function okay so let's

1363:35

just create our cons handle generate

1363:37

password that's going to be equals to

1363:38

this Arrow function now we are going to

1363:40

be only firing this generate password

1363:43

function from our store and that's done

1363:45

okay and finally we have to render our

1363:47

password somewhere so that we can see

1363:49

what we got okay so we going to be

1363:50

rendering there underneath this button

1363:52

and I'll just say like if we have the

1363:54

generated password then we want to show

1363:56

this UI so I'll use the end operator and

1363:59

then we want to show this D with the

1364:00

class of margin for the top of four and

1364:02

piring for yeah ping all around will be

1364:05

set to four background will be set to

1364:08

gray 100 and totally rounded large

1364:12

inside this Dev create our paragraph

1364:14

with the class of text totally large and

1364:16

break will be set to all and here we

1364:18

have to set like generate or generate

1364:22

pass C generated password there we go

1364:26

now let me save my file this should also

1364:28

be a generated password and here you can

1364:32

see we are now getting our password

1364:33

generator which is looking cool so if I

1364:36

just remove the include numbers include

1364:38

samps and everything and if I just set

1364:40

that to the include numbers and click on

1364:42

the generate password so it's going to

1364:44

gives us only the numbers if I also want

1364:46

to get like the sambols so I'm going to

1364:48

just provide a symbols and remove this

1364:50

number so I'm going to click on the

1364:51

generate so it's going to only give the

1364:53

state symbols if I only want to get the

1364:55

uppercase letter so I can just put

1364:56

uppercase letter and for that we also

1364:59

have to provide some sort of yeah I'll

1365:01

just provideed uppercase letter so it's

1365:03

going to only giv us uppercase letters

1365:04

and now if you want to get like the

1365:06

lowercase letters so now if I click on

1365:07

this it's going to gives us a lower case

1365:09

one and if I want to get like all of

1365:11

them so I can just check all of them and

1365:13

generate the password now it's going to

1365:15

give us only 12 characters but now you

1365:17

want to change that to like I don't know

1365:19

maybe 100 maybe and then I can click on

1365:21

this generate password so now it's going

1365:23

to give us all of that generate password

1365:25

and if I want to only get just a numbers

1365:28

and here if click on that so it's going

1365:29

to only giv us us a number and that's

1365:32

going to be a very strong password to

1365:33

remember so yeah that was our password

1365:36

generator by using reactj Zeus

1365:39

typescript and tailin CSS Oracle I want

1365:41

you to give me update about the

1365:42

Scarecrow I mean the penguin I mean the

1365:45

kitten I mean the penguin yeah okay so

1365:48

let's just make a setup so I'm going to

1365:50

go into my terminal and I'll use npm

1365:54

create weed at latest now we are going

1365:57

to be building a meal

1366:00

Ms and I'm going to choose reactjs with

1366:03

typescript go into the mees and use npmi

1366:06

to install every single thing inside

1366:08

there also install zeust so use npmi

1366:12

zeust it's going to install in my

1366:14

project I'm going to open that in my vs

1366:16

code now I'll also go to my TN CSS go to

1366:19

framework guides we and copy there place

1366:24

here hit enter to initialize there and

1366:26

I'm going to also copy this cont content

1366:29

go into my yeah twiin there we go and

1366:33

then I'm going to replace this content

1366:35

with this new one I'm going to also copy

1366:37

these components and go into my index.

1366:40

CSS and replace that with this new

1366:43

components now let me just make a bit of

1366:45

cleanup so we don't need the public

1366:46

folder SS folder ab. CSS folder now let

1366:50

me go into the app. TSX file and replace

1366:53

it with this AB dot yeah just would be

1366:55

fine and finally let me test this out so

1366:57

I'm going to copy this H1 and place it

1367:01

here and use my npm rund de to run my

1367:05

server and open that server right here

1367:08

but God Local Host 3000 3,000 we are not

1367:12

using Create react app and yep that's

1367:14

working totally fine now let me go ahead

1367:16

and Define my store. ts and first of all

1367:19

we would need the create function from

1367:22

the zeust library I'm going to save this

1367:24

file now we have to export our use tour

1367:28

you can give it any name that you like

1367:29

and let's just create our store it's

1367:31

going to take the call back function of

1367:33

stad and inside there we are going to be

1367:36

also providing our St with the name of

1367:37

meals and here we just have to store the

1367:40

inside this array we would also need our

1367:42

search query and search query will be

1367:45

set to empty string I'm going to also

1367:47

put the set meals function and here we

1367:49

have to specify the meals and now let's

1367:52

just use our set method and provide my

1367:55

meals inside my meals what the hell am I

1367:58

saying

1367:59

and then write a set search query and

1368:03

provide my query there and it's going to

1368:05

take a set as a preter and here we also

1368:07

have to provide our search query search

1368:10

query and that's going to be equals to

1368:12

this query so now let me just add a bit

1368:14

of typescript to there so first of all

1368:16

let's just create an interface for the

1368:17

Mals so I'll write like interface and

1368:20

then Mees and inside there the ID of the

1368:23

meal and this can be set to string then

1368:25

we have a stir meal the name so this can

1368:28

to be also set to string and then we

1368:30

have a stir M thumb like for the image

1368:33

and this can be also set to a string

1368:35

underneath that we also have to Define

1368:37

an interface for our store all right

1368:39

like store dot not dot but just a store

1368:42

State Prov our meals inside there that's

1368:44

going to take a meal of array and we

1368:46

also have to specify our search query

1368:49

which will be set to a string not a

1368:51

comma but closing tag and now let's just

1368:54

use our set meals and here we are going

1368:56

to be defining our meals and it's going

1368:57

to take a meal is our array and finally

1369:01

we have to return the white from the so

1369:03

I'll use a white and then SE search

1369:06

query it's going to be taking a query as

1369:09

a perimeter like query that's going to

1369:11

be a string and here we also have to

1369:13

return white from there okay this should

1369:16

be meal so I'm going to copy there and

1369:18

place that there and also there now let

1369:21

me inate the with or store start and

1369:25

close them now that's done but I'm going

1369:27

to also provide my me me right here all

1369:29

use like meals and annotate that with

1369:32

this one and this one should be a string

1369:34

to that's to done and we are now to done

1369:37

with our store and also or state now let

1369:40

me use the inside our component so I'll

1369:42

just create a file or folder with the

1369:44

name of components and inside there

1369:46

we're going to be defining our m. TSX

1369:48

this is use our RFC inside there go to

1369:51

my app and remove this H1 just create a

1369:54

section and inside this section Define

1369:56

or render or Mees inside them sa my file

1370:00

and check this out yep we are getting

1370:02

our meals remove them now the first

1370:04

thing that I want to do is that I want

1370:06

to get my store so use like use store

1370:09

from where not from zeust but from our

1370:12

store there we go we also need the use

1370:15

effect so I'll just import the right

1370:17

here because we're going to be fetching

1370:18

our data and which means like we're

1370:20

going to be doing some sort of a side

1370:21

effect so for that we going to be using

1370:23

the use effect so I'll just use like use

1370:25

store and from this use store we're

1370:28

going to be destructuring a few things

1370:30

so now let's just destructure first of

1370:32

all the meals then the god meals in low

1370:36

case then search query and then set Mees

1370:41

and set search query like so and this

1370:45

should be a constant now let me fetch my

1370:47

data so to fetch the data we're going to

1370:49

be using the use effect so now let me go

1370:51

back and inside this use effect we're

1370:53

going to be providing our call back

1370:54

function and just provide our empty

1370:56

dependency or you know what that's it's

1370:58

not going to be empty dependency array

1371:00

here we have to specify the set meals

1371:02

and now here we're going to be rendering

1371:04

our data so I'll just use like fetch M

1371:07

since can be equals to the asynchronous

1371:09

function and inside this ASN function

1371:11

we're going to be using our try and

1371:12

catch block so for the catch I'll just

1371:14

log to the console but you know let me

1371:16

just use like console. error if you got

1371:18

some sort of error so we're going to be

1371:19

logging there we use like error fetching

1371:22

data or something and here we are going

1371:24

to be rendering our error inside there

1371:27

now for the tri block what you wanted do

1371:28

we just want to use our a and then fetch

1371:31

our data from this URL okay and I'm

1371:34

going to also store them in the response

1371:35

variable like so and now underneath

1371:38

there what do you want to do you want to

1371:40

convert the data to the Json and I'm

1371:43

going to also store there inside the

1371:45

data variable and now we have to set

1371:47

that to our meals so now here we have to

1371:50

specify our data do meals and that's

1371:52

going to be it for fetching or data but

1371:54

now let me call that function right here

1371:57

like so and then I'm going to hide this

1372:00

use effect from here now we are fetching

1372:02

our data totally successfully so now we

1372:04

have to render that data inside our down

1372:06

I'm going to provide these class names

1372:08

to this first div and now inside this

1372:10

div what you want to do we just want to

1372:12

create our H1 which will say like C food

1372:15

and recipes I'm going to provide these

1372:17

classes to this one let me just sve my

1372:19

file and here you can see we're now

1372:21

getting our c food recipes which is

1372:23

looking cool now underneath there we

1372:25

going to be creating an input field for

1372:27

our search so just input field with the

1372:29

type of text the placeholder will just

1372:31

say like search for a meal and you know

1372:35

what do do dot would be fine for the

1372:37

value I'll provide the search query and

1372:40

also whenever someone try to type

1372:41

something inside there so we're going to

1372:43

be firing this function which will say

1372:45

like uh search query and it's going to

1372:47

take the event. target. value and now

1372:49

let me just save there and we also have

1372:51

to specify these classes to so let's

1372:54

just test this out so here you can see

1372:55

we are now getting what input field I

1372:57

know this is looking not that cool but

1372:59

yeah we are getting there so then stly

1373:01

done so now I'm going to go to the top

1373:03

and filter my meal okay so what I'm

1373:07

going to do is that I'm going to just

1373:08

create a function with the name of like

1373:10

filtered meals and it's going to be

1373:12

equals to this meals. filter method and

1373:15

here we have to specify our meal inside

1373:17

there and what I'm going to do is that

1373:19

I'm going to just write like if meal. St

1373:21

Meal which will be the name of that we

1373:23

also have to make that as a lower case

1373:26

and then we're going to be checking if

1373:27

that includ ludes the search query and

1373:30

I'm going to also make this search query

1373:32

to lower case I'll just write like uh to

1373:35

lower case like so and I'm going to also

1373:38

execute them now we're going to be

1373:39

trading over through this filter

1373:41

products and if you have some sort of a

1373:42

filter product we're going to be

1373:44

rendering there but if you don't have

1373:45

any filter products then we're going to

1373:48

be rendering all of the products so what

1373:49

I'm going to do is then now underneath

1373:51

this input field we're going to be

1373:53

creating a div and inside there let's

1373:55

just check if we have the filtered meal

1373:58

and then let's just use our length. Z

1374:00

like if we have some sort of a filter

1374:02

meal in this situation we are going to

1374:04

be rendering one UI but if that's not

1374:06

the case then we're going to be

1374:07

rendering another UI let me just take

1374:10

care of this else class then we're going

1374:11

to be taking care of the first one so

1374:13

I'll just create a paragraph and I'm

1374:15

going to also close them manually and

1374:18

here what do you want to do we just want

1374:19

to write like no Mals found or something

1374:22

like that now we have to over through

1374:24

that mail so we going to be using like

1374:26

filtered meal and let's just use map

1374:28

method on there and here we have to

1374:30

specify our meal and now inside there

1374:32

we're going to be creating a DA and

1374:34

inside this D let's just close this D

1374:36

right here just like there we're going

1374:38

to be providing a key which will be a

1374:39

mail. ID mail and also we have to

1374:43

specify a classes today so let's just

1374:45

proide these classes we're going to be

1374:46

first of all rendering the image so I'll

1374:48

use like IMG tag for there and close

1374:51

there for the source I'll provide like

1374:53

me. St me thumb which will be the

1374:56

thumbnail of their specific meal I'm

1374:59

going to also provide the alternative

1375:00

text and alternative text will be a meal

1375:03

meal and I'm going to also provide a bit

1375:05

of classes today which will be these

1375:07

classes now let me just save my file and

1375:09

we are not getting anything so you know

1375:11

what let's just go to my inspect element

1375:13

go to the console and cannot read the

1375:16

property of undefined using filter so we

1375:20

did me something wrong and I found out

1375:22

that bug here I'm using data. meal but

1375:26

it should be meals with s so now if I

1375:29

just save my file and refresh there and

1375:31

here you can see we now getting all of

1375:32

that images right here you can provide

1375:34

more styling to there if you wanted to

1375:36

but I'm not going to so what I'm going

1375:37

to do is I'm going to go to the bottom

1375:39

and let me take care of the rest of the

1375:40

UI so I'll just create a H2 with the

1375:43

class of AUD this is word H2 which will

1375:47

take like meal. meal and I'm going to

1375:50

also provide these classes to it you

1375:51

should also provide these classes and

1375:53

underneath there let's is s a paragraph

1375:55

with the classes of text great

1375:58

600 and also text will be set to totally

1376:01

small it's going to say like delicious

1376:04

Seafood meal dot there we go and that's

1376:07

everything that we have to do and now I

1376:09

can filter something so let's suppose if

1376:11

I want to like filter this specific meal

1376:14

I can totally proide there and now it's

1376:15

going to only giv us their specific meal

1376:18

I can also search for something else

1376:19

like fish pie yeah copy that and place

1376:24

it here and now we getting fish pie like

1376:26

twice and yeah there was how we going to

1376:29

be fetching our data and how we can

1376:31

store that data by using zeen and how we

1376:34

can do a filtering by also using zustand

1376:37

forgiveness can be powerful even for the

1376:40

Unworthy my wife F taught me the

1376:43

cratos God damn it that was a huge voice

1376:46

for a Creator so you know what let's

1376:48

just make a setup I'm going to open my

1376:50

terminal right here let me zoom in a bit

1376:53

and use npm create create with at latest

1376:58

I'm going to choose reactj but first of

1377:00

all I will give it the name of like form

1377:03

Builder and I'm going to choose reactj

1377:05

with tcri let's just go into the form

1377:07

Builder and install every single thing

1377:09

inside there that's done I'm going to

1377:11

also install zeen so let's just write

1377:13

npmi and zust so it's going to install

1377:16

that in project so that's also done now

1377:18

let me open that in my vs code next we

1377:20

will also install T CSS I'm going to

1377:22

click on this getting started go to the

1377:24

framework and guides go to the weed copy

1377:26

this command and play right here inside

1377:29

our terminal like so I'm going to hit

1377:31

enter so it's going to initialize my T

1377:33

CSS and while this doing that I'm going

1377:35

to copy this content go into my tailing

1377:37

config file and replace it with this new

1377:40

content I'm going to also go into my

1377:42

index. CSS so let's just go into index.

1377:44

CSS and replace it with this new one

1377:46

finally I'm going to copy this line of

1377:48

code go to my app. TSX remove every

1377:50

single thing from there and I'm going to

1377:52

be using rfn and replace there with this

1377:55

with this H1 so now let me open my

1377:57

terminal and use PM run Dev and then I'm

1378:00

going to write my Local Host right here

1378:02

and yep everything is working the way

1378:04

exp to work I'm going to also do a bit

1378:06

of cleanup so I'll just remove this

1378:08

public folder from there also the SS

1378:10

folder app. CSS and then I'm going to go

1378:14

into yeah I guess that's going to be

1378:16

fine okay so now let's just Define our

1378:18

store. TS I'll import my zust my create

1378:23

function from the zoo and then we are

1378:25

going to be creating our custom hook so

1378:27

I'll just create a constant with the

1378:28

name of like use form store it's going

1378:31

to be equals to the create function and

1378:33

here we just have to specify our set

1378:35

method and also our aror function like

1378:37

so and inside this aror function what do

1378:40

you want to do first of all we have to

1378:41

Define our initial STS I'll use like uh

1378:43

form fields and that's going to be

1378:46

equals to this empty array so now let me

1378:47

Define my interface right here with the

1378:49

name of uh what do we call it form and

1378:52

then Fields like so and what I'm going

1378:55

to do is that I'm going to provide my

1378:56

label and label will be string and the

1378:59

type will be a few types so we can

1379:00

accept the type of text we can also

1379:03

accept the type of number we can also

1379:05

accept the type of password and also the

1379:08

text area and the date come on date and

1379:12

also finally we can also accept the

1379:14

files okay like so and now underneath

1379:17

there we're going to be also providing

1379:19

the value and the value will be set to

1379:20

string now that's done now the next

1379:22

thing that we have to do is that we have

1379:23

to Define our interface once again and

1379:25

the interface name will be form store

1379:28

stad and inside there first of all we

1379:29

have to Define our form fields and which

1379:32

will be coming from the form field which

1379:34

we just defined up above and that's

1379:35

going to be array now I'm going to also

1379:37

provide a function which will be add

1379:39

field which we are going to be defining

1379:41

in a few seconds so it's going to take a

1379:42

field as a perimeter and this can be

1379:44

equals to this form fields and now we

1379:46

are going to be returning the white from

1379:48

there we will also create the remove

1379:50

field function and can also take the

1379:52

index and index will be a number and we

1379:54

have to just return white from there

1379:57

I'll just use like a update field and

1379:59

it's going to also take the index and

1380:00

index will be a number it's going to

1380:02

also take the updated field and the

1380:04

updated field will be a form field which

1380:06

we just defined up above and we're going

1380:08

to be returning a white from the finally

1380:11

we just have to write a reset form and

1380:13

that's going to be my arrow function

1380:15

which will only return the white from

1380:18

there so now our interfaces are totally

1380:19

done so I'm going to copy the name of

1380:21

there and put there and annotate there

1380:23

right here just like that we already

1380:25

specify our state the next that we have

1380:28

to do is that we have to create our add

1380:30

field and it's going to take a field as

1380:32

a perimeter and now let me just create

1380:34

my function with the with the state

1380:36

property and here and here we have to

1380:38

specify our state like so and we are

1380:41

going to be returning the form fields

1380:43

from there and first of all we have to

1380:45

make a clone of our St form fields which

1380:47

we have to find up above and then we are

1380:49

going to be adding that new field which

1380:51

we now taking as a perimeter for this

1380:53

function so that's also done next we

1380:56

have to take care of the remove field so

1380:58

write like remove field and here we have

1381:00

to specify our index and inside that we

1381:03

going to be using our set method so it's

1381:04

going to take a St as a perimeter and we

1381:06

are going to be using let's just right

1381:09

there and we are going to be using the

1381:11

form fields and form field will be

1381:13

coming from st. form fields. filter

1381:16

method we have to provide our underscore

1381:19

let's just write our underscore and also

1381:21

we need the index which means like we

1381:23

don't need the value like the filtered

1381:25

value but we only need this index right

1381:28

here okay so that's why I'm providing

1381:30

that there and here we only have to

1381:32

check if our index does not equals to

1381:34

the perimeter of that index which you

1381:36

are now taking there as a perimeter so

1381:39

then we just want to remove that

1381:40

specific field I'll also provide the

1381:43

update field so it's going to allows us

1381:44

to update our field by providing the

1381:47

index and also the updated field as well

1381:50

okay so it's going to take the set and

1381:52

here inside this set we're going to be

1381:53

providing our call back function by

1381:55

providing our state as a perimeter and

1381:57

inside then we are going to be providing

1381:59

first of all our form field so if you

1382:01

want to get them we going to be using

1382:02

state. form fields and then we are going

1382:05

to be trading over through all of that

1382:06

by using our map method here we have to

1382:08

specify our field and also our index

1382:11

okay then we have to check if our index

1382:13

is triple equals to which means like

1382:15

equals to or index in this situation

1382:18

we're going to be returning our updated

1382:20

field but if that's not the case we

1382:21

going to be only returning or simple

1382:24

field like that now underneath this one

1382:26

I'm going to also put a comea there

1382:28

finally we have to write our reset form

1382:30

and then we have to specify our set

1382:33

function and from this set function

1382:35

we're going to be only returning our

1382:36

form field and this can be equals to

1382:38

this array and what am I doing wrong uh

1382:42

yep here we have to specify this comma

1382:44

and that's toally done finally we have

1382:46

to export them so we can use in other

1382:48

file so I'll use like export default and

1382:50

then use forms store like that so yeah

1382:54

the store is not tot done next we have

1382:56

to jump into our component and use them

1382:58

okay so now let's define our form

1383:00

Builder I'm going to go ahead and create

1383:02

my components folder and inside there

1383:04

we're going to be defining our form

1383:06

builder. TSX and let's just use our RFC

1383:10

inside there go to our app. TSX and

1383:13

registered there right here I'm going to

1383:15

remove there and provide my form Builder

1383:18

and import it right here let me check

1383:20

this out and yep we are getting our form

1383:22

Builder which is looking cool first

1383:24

thing first let me go into this

1383:25

component first of all we have to import

1383:27

a lot of thing from our use form store

1383:30

and we have to execute there so what I'm

1383:32

going to do is that I'm going to be

1383:33

restructuring a lot of things like for

1383:36

instance we're going to be destructuring

1383:37

the form Fields also the end field and

1383:41

remove field update field and reset

1383:44

field okay reset form to be precise not

1383:47

a field and now underneath there what we

1383:49

have to do we have to Define our initial

1383:51

State con New Field and then set new

1383:55

field it's going to be equals to the

1383:57

used it and now inside there we going to

1384:00

be providing a label and which will be

1384:01

set to empty string we're going to be

1384:03

also providing a type and the initial

1384:05

value will be set to text I'm going to

1384:06

also provide the value and the value

1384:08

will be set to this empty string so what

1384:10

I'm going to do is that I'm going to

1384:11

also Define an interface for the or type

1384:13

whatever you want to call there and I'll

1384:15

just give it the name of like new field

1384:17

and inside there we're going to be

1384:19

defining what label l a l yeah and then

1384:22

that's going to be equals to A String

1384:24

we're going to be also providing the

1384:25

type so you know what let me go ahead

1384:26

and copy all of their type from here I'm

1384:29

going to copy this entire line and place

1384:32

it right here and next we also have to

1384:34

provide our value and value will be set

1384:35

to string okay so that's totally done

1384:37

and I'm going to annotate my state by

1384:39

using that new field right here and I'm

1384:42

going to close that next I'm going to go

1384:44

into the UI and start working on my UI

1384:47

I'll Place The Styling so you can

1384:49

totally pause the video and provide the

1384:50

styling by yourself I'm going to also

1384:52

write H1 and inside they I'll just use

1384:54

like form Builder and also provide a

1384:56

classes to this one and now underneath

1384:58

there we have to create our form or you

1385:00

know what not a form let's just remove

1385:02

there we have to create a d with a class

1385:04

of flex and also Flex will be set to

1385:05

column margin for the bottom will be set

1385:08

to uh six like so and inside this D

1385:11

we're going to be defining our input

1385:13

field so right like input with a type of

1385:15

text and we're going to be providing a

1385:17

name of label today I'm going to also

1385:19

provide the placeholder which will say

1385:20

like field label and also provide the

1385:22

value which will be coming from the new

1385:24

field. level and when somebody try to

1385:26

type something ins there we're going to

1385:28

be firing this function which is a

1385:29

handle field change and I'm going to

1385:32

save my file right now so this is how it

1385:34

looks like I'll also provide a classes

1385:36

to this one and I'm going to comment

1385:38

this line out for a few seconds check

1385:40

this out and Yep this is how it looks

1385:42

like right here I know it is looking

1385:44

awful but we are now getting there now

1385:46

underneath this input field let me just

1385:48

go back we're going to be defining our

1385:50

select area I'll use like select and we

1385:52

are not going to be providing any names

1385:54

and IDs to them so let's just remove

1385:55

that from here and what I want to do is

1385:57

that I want to just put a name of type

1385:59

and also the value will be coming from

1386:01

the new field let me just write a new

1386:03

field. type and here we have to write on

1386:06

change when when somebody tried to write

1386:08

something inside there still we're going

1386:09

to be firing this handle change function

1386:11

once again and we have to provide that

1386:13

same styling right here to this

1386:15

component as well so now let me just hit

1386:17

enter and inside there we're going to be

1386:18

providing a few options so I'll just

1386:20

write like option and for the first one

1386:22

I'm going to set there to text and let

1386:23

me just write a text and I'm going to

1386:25

duplicate there a few times so that's

1386:27

going to be the first one so now let me

1386:28

just change there to a number and also

1386:31

change these one to the text in lower

1386:35

case text area and this one to the DAT

1386:38

and finally these last one to the file

1386:41

okay so I'm going to just make as

1386:43

uppercase so this one will be uppercase

1386:45

n uppercase t and uppercase D and

1386:49

finally uppercase F now need this select

1386:52

statement what do you want to do we just

1386:53

want to create a DAT with the class of

1386:55

flex and justify will be set to be wi

1386:58

and inside there let's just create our

1386:59

button and the type will be a button as

1387:03

well and let's just put our own click

1387:05

event handler when somebody clicks on

1387:06

there we're going to be firing this

1387:08

function which is a handle add field and

1387:11

it's going to say like add field right

1387:14

here I'm going to also provide a classes

1387:15

to this one save my file now you need

1387:18

this button what you want to do we just

1387:19

want to create yet another button with

1387:22

uh classes a lot of classes but it's

1387:24

going to say like reset form or it

1387:27

should be a reset like so the type will

1387:29

be set to button in this case and when

1387:31

somebody clicks on there we are going to

1387:33

be firing like reset form function and

1387:36

provide a classes to this one let's just

1387:38

proide these classes I'm going to save

1387:40

my file so obviously it's going to gives

1387:41

us an error I'm going to comment this

1387:43

line out I'm going to also comment this

1387:44

line out and comment that line out okay

1387:48

so now if I save my file I know they're

1387:50

not looking that great but yeah we can

1387:52

totally work with that if you wanted to

1387:54

so we can totally change the styling of

1387:56

there and by the way if you are grabbing

1387:57

this code from my GitHub repository the

1387:59

UI will be completely changed I'm now

1388:02

recording this course and I am in a

1388:04

super hurry so that's why I don't have a

1388:06

lot of time to provide a cool looking UI

1388:09

but when you grab this score from my

1388:10

giab repository you will see a lot of

1388:13

cool uis so I'll just uh iterate over

1388:15

through all of the form field and

1388:17

provide my field and also the index

1388:18

inside there and here what do you want

1388:21

to do we just want to render our form

1388:23

field component which we going to be

1388:25

creating in a few seconds and we have

1388:27

have to specify the key as a prop and

1388:29

it's going to take the index and we also

1388:31

have to provide the field and it's going

1388:33

to take the as a prop we're going to be

1388:35

also providing the own update and when

1388:37

somebody update that we're going to be

1388:39

firing this handle field update function

1388:42

and when somebody tried to remove them

1388:44

we're going to be firing this handle

1388:46

field remove function so now I'm going

1388:48

to sve my file and first of all we have

1388:50

to comment these line out now that's

1388:52

looking cool but first of all we have to

1388:54

take care of like how we're going to be

1388:56

adding the form how we going to be

1388:57

changing the form and so on and so forth

1388:59

so now let me just uncomment all of

1389:01

these uh functions so I'll will just

1389:03

uncomment that one uncomment this handle

1389:06

change function and also handle add

1389:09

field that's going to be my first

1389:11

function and then hand reset form and

1389:15

we're going to be taking care of the

1389:16

rest of them in a few seconds so you

1389:18

know what let's just Define our

1389:19

functions right here so first thing

1389:21

first how we are going to be defining

1389:23

our handle add field function like how

1389:25

we are going to be adding our new field

1389:27

so to do that we're going to be finding

1389:29

this handle add field function it's

1389:31

going to take a arrow function and

1389:32

inside that we have to use our add field

1389:35

and here we have to specify our new

1389:36

field and that new field is coming from

1389:39

this St next we also have to provide our

1389:42

set new field and inside that we're

1389:44

going to be providing a label come on

1389:46

let's just write a label and label will

1389:48

be empty string we're going to be also

1389:49

providing a type and type will be set to

1389:51

empty string or you know what not empty

1389:54

string but we have to specify text

1389:55

inside there and also so the value will

1389:58

be set to empty string like so so this

1390:00

how we going to be adding our field and

1390:02

now let's talk about how we going to be

1390:04

changing our field like when somebody

1390:05

try to type something inside that input

1390:08

field we're going to be firing that

1390:09

function which is a handle field change

1390:12

and it's going to be equals to this

1390:13

function so it's going to take event as

1390:15

a perimeter and also what do you want to

1390:18

do we're going to be doing a lot of

1390:19

things but now let me just annotate the

1390:21

first of all we're going to be first of

1390:22

all annotating there by change event and

1390:25

then we have to explicitly tell it like

1390:27

we can either use the inside our HTML

1390:30

input element or we can use the inside

1390:32

our HTML select element or we can use

1390:35

the HTML text element text area element

1390:38

to be precise so that's the first thing

1390:40

that we have to do now we are totally

1390:42

able to use this so what I'm going to do

1390:44

is that from this event Target I'm going

1390:47

to be destructuring a few things so you

1390:49

know let's just destructure the name and

1390:51

also the value out of this uh event so

1390:55

let's just write our con right here just

1390:57

write a con God damn it and I'm going to

1390:59

just use like set new field and here

1391:01

inside then we have to specify our

1391:03

previous field and then we have to make

1391:05

the clone of our previous field and then

1391:07

we have to just use our name and provide

1391:09

the value which we are now grabbing from

1391:11

this event. target. value okay so that's

1391:14

done identify expected oh here we have

1391:18

to use triple dots like so now let me

1391:20

just save my file and this how we are

1391:22

going to be defining our handle field

1391:24

function next we also have to take care

1391:26

of the handle field update so I'll just

1391:28

create a function with the name of

1391:30

handle field update and inside this it's

1391:33

going to take a index as a perimeter and

1391:35

I'm going to just annotate that with a

1391:36

number like so as a number and I'm going

1391:39

to provide a comma there let's just also

1391:41

write like updated field and it's going

1391:43

to take a new new field which we've

1391:46

already defined up above okay so I'll

1391:48

use like update field and here we have

1391:50

to specify the index and also the update

1391:53

field right here now let me just save my

1391:55

file and we're going to be ping the this

1391:57

function as a prop to this function like

1392:00

handle field update

1392:03

oh that was handle field update and I'm

1392:07

giving it the name of yeah the name is

1392:09

totally correct now let me also take

1392:11

care of the handle field remove so I'll

1392:13

just use like handle field uh not change

1392:16

but remove like so and it's going to

1392:18

take an index as a perimeter and we have

1392:20

to annotate there with a number okay and

1392:23

I'm going to use like remove field and

1392:24

provide my index inside there which we

1392:27

taking as a perimeter so now let me just

1392:28

save my file and that's tot done now we

1392:31

have to provide there as a value for our

1392:33

component so I'll just uncomment there

1392:35

now let me go ahead and create this form

1392:37

field component inside my component

1392:39

folder so I'll use like form field. TSX

1392:42

and let's just use our rafc inside them

1392:45

and import my form field component right

1392:48

here okay so I'm just going to take a

1392:50

key the field and also these two

1392:52

functions so now let's just destructure

1392:54

them I'm going to zoom in a bit and the

1392:56

first thing that we have to do is that

1392:58

we have to restructure a lot of things

1393:00

like the field the index and also the

1393:02

own update function and the own remove

1393:05

function from there now let me just save

1393:07

my file so obviously my typescript

1393:09

compiler will freak out and what I'm

1393:11

going to do is that I'm going to just

1393:13

place this interface right here and this

1393:15

interface is huge like form field

1393:17

interface so now inside there we're now

1393:19

defining our field which will have a

1393:21

label and that's going to be a string

1393:22

it's going to also have a type and type

1393:24

can either be a text number password

1393:26

text area dat or file we are also

1393:28

providing a value which is now set to

1393:30

string we are also providing a index

1393:31

which is now set to number and when

1393:33

somebody try to update the or use that

1393:36

update function so it's going to take a

1393:37

index as a perimeter and we are now

1393:39

providing a number as a type to there

1393:41

and then on the updated field it's going

1393:43

to take that same property which you are

1393:45

now defining right here and finally it's

1393:47

going to just return the white and when

1393:49

somebody try to remove something so it's

1393:51

going to take a index as a perimeter and

1393:53

that's going to be a number and we're

1393:54

going to be returning the wi from there

1393:56

okay so now let me just side there I'm

1393:57

going to copy the name of there and

1393:59

annotate my component like so so I'll

1394:01

use like react. FC for the functional

1394:04

component and here we have to provide

1394:06

our home field props right here so now

1394:08

if I save my file so this is how my

1394:09

component looks like and now let me go

1394:11

into the UI and implement this UI so

1394:14

I'll just hit enter right here and

1394:15

provide a styling to the first div now

1394:18

inside this div we are going to be using

1394:19

our label and for this label let's just

1394:22

remove our HTML form and here we are

1394:24

going to be rendering our field. label

1394:27

so let's just use our field. label like

1394:29

so I'm going to also provide a classes

1394:30

to this one to style and now if I save

1394:33

my file and obviously we're going to be

1394:34

getting some sort of error because we

1394:36

have to use all of that stuff and

1394:38

provide this on update and also that

1394:40

functions why in the world are we

1394:41

getting these errors are we not

1394:43

providing a handle change function

1394:44

that's why we getting that error I'm not

1394:46

quite sure about that oh here you can

1394:48

see this is my mistake instead of

1394:49

providing a handle update not update but

1394:52

this function you know what uh this

1394:54

handle field change I'm only providing

1394:56

this handle change so now let me just

1394:58

replace that and now if I save my file

1395:00

and test this out so I can now provide

1395:02

anything I want I can choose the number

1395:04

and I can add there so it's going to add

1395:06

there right here but now let me just

1395:07

take care of the rest of their stuff so

1395:09

now let's just go into our field

1395:10

component and render all of that stuff

1395:12

so not need this label I'm going to

1395:14

first of all use my field. type not file

1395:18

but field card if i e there we go field.

1395:22

type if there is triple equals to the

1395:24

text area so in this situation we're

1395:27

going to be rendering the text area like

1395:29

so but if that's not equal to the text

1395:31

area then we're going to be using like

1395:33

field. type f i l d field oh my goodness

1395:38

what the hell is going on with my ID

1395:40

today so I'm going to copy them and

1395:42

place it right here if that is equals to

1395:45

the file then we're going to be

1395:46

rendering another UI then once again we

1395:48

have to provide another expression and

1395:50

inside this expression we're going to be

1395:53

providing another UI so you know what

1395:55

let me just take care of this first one

1395:56

if the field. type is equal to text area

1395:59

so in this situation what do we want to

1396:01

do we only want to return our text area

1396:04

like so and I'm going to close there and

1396:06

inside this text area we're going to be

1396:08

providing our value and value will be

1396:10

coming from the field. value do value

1396:13

like so and we are going to be also

1396:15

providing the own change Handler and

1396:16

when somebody tried to type something

1396:18

inside there we're going to be firing

1396:20

this handle change function which we are

1396:22

going to be creating in a few seconds

1396:23

next we're going to be also providing a

1396:25

UI to the for The Styling

1396:27

and now for this second one if the

1396:29

field. type is equal to the file so in

1396:32

this situation we're going to be

1396:33

creating our input field and inside this

1396:35

input field we have to provide the type

1396:37

and the type will be set to file and

1396:39

when somebody tried to type something

1396:41

inside they were going to be firing this

1396:43

handle file change function which we are

1396:45

going to be creating in a few seconds

1396:47

and for the UI I'll just put a border

1396:49

and also the Border will be set to to

1396:50

pray of 300 and also totally rounded

1396:53

large and now for the final one we going

1396:56

to be Crea an input field with the type

1396:58

of uh the Ty type should be dynamic so

1397:01

I'll just use like field. type if I El D

1397:06

like so field. type and here we also

1397:09

have to specify the value I don't know

1397:11

why I'm getting an error so I'm going to

1397:12

copy and place it right here and for the

1397:15

value we're going to be checking field.

1397:18

type triple equals to the file so if

1397:20

that's the case then we have to just

1397:22

provide empty string but if that's not

1397:24

the case so we're going to be just

1397:25

getting the field value

1397:27

radio like so and this should be a field

1397:31

so now let me just place that there now

1397:32

outside from there if somebody type

1397:35

something inside this input field so we

1397:36

are going to be firing this handle

1397:38

change function once again and for this

1397:40

UI we are going to be providing these

1397:42

styling so now if I save my file so this

1397:44

is what we are doing first of all we are

1397:46

checking the type if the type is set to

1397:47

text area we're going to be rendering

1397:49

the text area and also the content will

1397:52

be coming from the field. value and

1397:54

we're going to be also attaching this on

1397:55

change event handler then if the type is

1397:57

set to file so we're going to be

1397:59

providing a file as a type if the type

1398:01

is not the file and also not the text

1398:04

area then we're going to be grabbing all

1398:05

of that uh stuff you know let me just

1398:07

show you there then we're going to be

1398:08

working with the text number password

1398:11

and that okay now everything is cool but

1398:14

finally let me just create a button

1398:16

which will allows us to remove all of

1398:17

that stuff so I'll just use a remove

1398:20

button it's going to take the type of

1398:21

button and now outside from there when

1398:23

somebody clicks on there we're going to

1398:25

be firing this function which is the

1398:27

remove or just uh God damn it on remove

1398:32

there we go it's going to also take

1398:33

index as a perimeter and provide a

1398:35

classes to it okay so that's totally

1398:37

done so now let me just take care of

1398:39

this function like we have a handle file

1398:41

change and we also have a handle change

1398:43

so let's just go ahead and go to the top

1398:45

and here we're going to be defining our

1398:47

function so first of all we're going to

1398:49

be defining our handle change function

1398:51

and somebody triy to type something

1398:53

inside that input field so we just going

1398:54

to take a event as a object and and here

1398:57

we only have to use our uh own update

1398:59

function it's going to take a index and

1399:01

it's going to also first of all make a

1399:03

clown of all of the field f i e l d

1399:05

there we go and then we're going to be

1399:06

providing a new value and the new value

1399:08

will be coming from the event. target.

1399:11

value and we are only allowed to do them

1399:13

on the react. change event like so and

1399:18

we can use that on the HTML input

1399:20

element or we can use the on the HTML

1399:22

text area element and now let me just

1399:25

close there so that's the first function

1399:27

that we have to write now for the second

1399:29

function which is a handle file change

1399:31

I'm going to create T right here so cons

1399:33

handle file uh yeah file change and it's

1399:36

going to be equals to this function once

1399:38

again and it's going to also take event

1399:40

as object and now here we're going to be

1399:42

updating this so now let's just use like

1399:44

one update and provide my index to them

1399:46

and here first of all we have to make a

1399:48

clone of all of the fields and then we

1399:50

have to provide a new value today and

1399:51

the new value will be coming from the

1399:53

event. target. files in this case

1399:56

because we now working with the files

1399:57

and once again we have to provide a

1399:59

types for this one so I'll use like

1400:00

react. uh change event and then we are

1400:04

going to be only allowed to use the on

1400:06

the HTML input elements now this is

1400:08

going to be the expression so if we have

1400:10

the event. type. files so in this

1400:12

situation we're going to be using the

1400:14

array. from and here we have to specify

1400:16

like event. target. files but if that's

1400:20

not the case so we only want to provide

1400:22

the empty string okay so now let's just

1400:24

iterate over through there so let's just

1400:25

go back and I'm going to provide a file

1400:27

as a name and let's just use our file.

1400:30

name and now from this one we're going

1400:32

to be getting a join method and you want

1400:33

to join there by only providing a comma

1400:35

in space okay so that's only done and

1400:38

this shouldn't be a recording start this

1400:40

should be a react there we go reacted

1400:43

now that is looking cool and everything

1400:46

should be working the way we expect him

1400:48

to work and I just realized that I made

1400:50

a few mistak so let's just go ahead and

1400:51

go to the form component and here we

1400:53

have to specify our index so I'll just

1400:55

write like index come on index and that

1400:58

index will be coming from this index

1401:00

which we now providing as a function or

1401:02

perimeter to that and also here you can

1401:05

see I'm using a flex twice so it

1401:07

shouldn't be a flex I'll just provide a

1401:09

separator or Dash to it now let me just

1401:11

save this file and let's just try this

1401:14

out I'm going to just refresh there and

1401:16

I'll give it some sort of a name like um

1401:20

text input or or my text input would be

1401:23

fine and I'm going to only choose the

1401:25

text one so now let me just click on

1401:26

this add field and it's going to add

1401:28

there right here now I can totally write

1401:30

whatever I want to write I can also

1401:31

totally remove there if I wanted to now

1401:34

I can also select the number and I'll

1401:36

write like um bank account numbers only

1401:41

or something like that and now if I hit

1401:42

enter so it's going to gives us this

1401:44

input and now we are not allowed to type

1401:46

anything else except numbers okay so we

1401:49

can totally add them I can also click on

1401:51

the reset form so it's going to reset my

1401:53

entire form right here okay so I'll just

1401:55

write a gibberish right here and provide

1401:57

a text area or change that to some sort

1402:00

of a description area or something I'm

1402:03

going to click on this add field and

1402:04

it's going to gives us this text area

1402:06

right here I can also add like some sort

1402:08

of dead and my birth or enter your birth

1402:15

day or something like that now if I

1402:17

click on this one so it's going to gives

1402:18

us this field right here where I can

1402:20

choose my birthday or something now I

1402:23

can also select this field I proide a

1402:25

custom field so I can just click on ADD

1402:27

there and here you can see it's going to

1402:28

add there right here so I can click on

1402:30

this reset form so it's going to reset

1402:32

all of the form so yeah that was it

1402:33

about four or custom form Builder you

1402:36

can't fight who you are K you lose Agent

1402:40

47 tickets on sale now let's just open

1402:43

our terminal and make a setup I'm going

1402:46

to zoom in a bit and the first thing

1402:48

that I want to do is that I want to use

1402:50

like npm create we at latest and then

1402:54

the name will be to do let's I know a

1402:56

lot of people will think huz like to-do

1402:59

list is just a simple application but

1403:01

yeah let me show you how simple it is so

1403:03

I'm going to go into the reactjs and

1403:05

choose typescript go into the to-do list

1403:07

and use npmi to install every single

1403:09

thing that's done I'm going to use npmi

1403:12

and then zeust turn to install zean

1403:15

inside this project that's also done and

1403:17

now let me open that in my vs code and

1403:20

search for the TN CSS go to the getting

1403:23

started and go into the framework and

1403:25

guides choose we copy this command place

1403:29

it right here inside our terminal it's

1403:31

going to take a bit of time to install T

1403:33

CSS inside this project hit enter on the

1403:35

npx create or npx t CSS n-p and now I'm

1403:41

going to copy this content from there go

1403:43

into my tment CSS and replace it with

1403:46

this new content copy this index file so

1403:49

I'll go into the index. CSS and replace

1403:51

it with this new one okay and let's just

1403:54

test this out by going into our app do

1403:56

TSX file remove every single thing from

1403:59

there and replace there with this new H1

1404:02

I'm going to also remove this public

1404:03

folder SS folder ab. CSS folder and the

1404:07

rest of them will be totally fine so

1404:08

let's just test this out I'm going to

1404:10

use npm run Dev or what you call it

1404:12

Local Host yep it is working the way we

1404:15

expect him to work okay keyboard lower

1404:17

so let's just create our store. TS file

1404:20

and import create function create

1404:23

function from the zoo so this now we

1404:26

have to Define our use store and that's

1404:30

going to be equals to the create

1404:31

function which will take a call back

1404:33

function they're going be also providing

1404:35

this Arrow function and create our todos

1404:38

as our initial value and Define our

1404:41

interfaces so I'll just go ahead and

1404:43

Define my interface for the too and

1404:47

inside they provide the ID and ID will

1404:48

be set to number text will be set to

1404:50

string and also completed will be a

1404:53

Boolean flag okay that's also done I'm

1404:57

going to also Define the interface of

1404:59

to-do store and inside there let's just

1405:01

Define our to-dos which will be equals

1405:04

to their to-do which we just created up

1405:05

above and also Define our add too and

1405:09

then too will be coming from this to-do

1405:13

and now this going to be equals to this

1405:14

eror function and also provide our

1405:17

remove to-do which allows us to remove

1405:19

or to-do by using this ID I'll also

1405:22

return the white from there and provide

1405:24

our toggle to do and okay and here we

1405:26

also have to specify the ID and ID will

1405:28

be set to a number and return white from

1405:31

there now what I'm going to do is that

1405:34

I'm going to provide my air to-do right

1405:36

here so I'll use like air too and here

1405:38

we have to specify our to-do inside

1405:40

there and let's just use our set

1405:42

function and for this set function we're

1405:44

going to be providing our state and then

1405:46

inside the St first of all we have to

1405:48

grab our to-dos and make the clone of

1405:50

what existing to do by using state.

1405:53

todos and then I'm going to provide a

1405:55

comma here add this new to-do which we

1405:57

are now taking as a perimeter okay

1406:00

that's also done now underneath this add

1406:01

to-do we going to be also defining a

1406:03

remove Todo function which will take ID

1406:05

as a perimeter and also let's just use

1406:07

our set method and provide our St them

1406:11

and use our Todo first of all let's just

1406:13

provide this syntax and then we have to

1406:15

use our to-dos grab our todos by using

1406:17

state. todos do filter and once again we

1406:21

are going to be using the filter method

1406:23

to provide our ID to this all just us

1406:25

like to do and here we just have to use

1406:27

to-do do ID if that to-do do ID does not

1406:30

equal to that ID which we are now taking

1406:32

as a perimeter for this function that

1406:34

function will only remove that specific

1406:36

to-do next we also have to just toggle

1406:39

or to-do so I'll use like toggle to-do

1406:41

and provide my ID to them and now we

1406:43

have to use our function okay so inside

1406:46

this function we have to use our set

1406:47

method and provide my state to them and

1406:50

now what do you want to do we just want

1406:52

to get our todos like our entire todos

1406:55

and you want to get there by using using

1406:56

state. todos and itate over through all

1406:58

of them so I'll provide my to-do as a

1407:00

perimeter and let's just use if for too.

1407:03

ID is triple equals to this specific ID

1407:06

then you just want to make first of all

1407:08

the clown offer to do and we have to

1407:10

provide our completed flag to it okay so

1407:13

completed flag will be equals to not to

1407:15

do which means like not to do. complete

1407:17

which means like let me just what the

1407:19

hell am I saying today okay so I'm going

1407:22

to explain this code in a few seconds

1407:24

but now we have to just provide the

1407:26

class and for the El class let me just

1407:27

put it to do okay that's a lot of JB so

1407:30

now let me just cut that from here we

1407:32

don't need to provide all of that

1407:33

nonsense so let's just remove that and

1407:36

also remove these ones and then we have

1407:39

to provide this expression once again

1407:41

now I sa there so this is how it looks

1407:43

like right here and we also have to

1407:45

annotate there so that we can remove all

1407:46

of that errors I'll use like to do store

1407:49

and annotate there with this new one so

1407:51

this is how it looks like let me just

1407:52

say that here you can see we're now

1407:53

providing a set method which will take a

1407:55

arrow function and here we are also

1407:57

taking our Str first of all we are just

1407:59

mapping over through all of our to-dos

1408:01

and then we are checking if our to-do do

1408:03

ID is equal to that ID which we are now

1408:06

taking as a perimeter for this function

1408:08

so in that situation we're going to be

1408:10

first of all making a list or a clown of

1408:12

for existing to-do and we have to

1408:14

provide this completed flag to it like

1408:16

we are not interested in any of the

1408:17

to-do we are only interested in this

1408:20

specific completed flag so if that

1408:22

statement is true we're going to be

1408:24

converting that to false but but if

1408:26

their statement is set to false we're

1408:27

going to be converting there to true if

1408:29

there is not the case then we're going

1408:31

to be only returning or to-do that's it

1408:34

okay so finally we have to export this

1408:36

so we can use the inside our file and

1408:38

I'm going to export that by using

1408:40

default so let's just use our export

1408:42

default and then use store like so so

1408:45

our store content is now completely done

1408:47

time to use the store inside our

1408:49

component so I'll create a file with the

1408:51

name of

1408:52

components and then to do list. TSX use

1408:56

my RFC inside there go to my app and

1408:59

remove this H1 and render my to-do list

1409:02

component right here so the first thing

1409:04

that I want to do is that I want to grab

1409:06

every single thing from my store so

1409:08

let's just zoom in a bit and let's just

1409:10

use or use store right here and what I'm

1409:13

going to do is that I'm going to just

1409:14

grab a few things from my store I'll

1409:16

change that to const and use my to-dos

1409:19

and then add too and also remove to-do

1409:23

toggle to-do we only want to grab all of

1409:25

them now underneath we're going to be

1409:27

also defining our set for our input so

1409:29

I'll use like input uh or input value

1409:32

rather and then set input value in value

1409:36

and going be equals to this uh use State

1409:38

function not store but use State

1409:41

function and inside this Us St function

1409:43

the initial value will be set to empty

1409:44

string now for the UI I'm going to

1409:47

remove this uh to-do and provide this

1409:49

classes to it and now here we're going

1409:51

to be creating yet another de with the

1409:53

class of these amazing classes so now

1409:55

let me just go back and inside this div

1409:58

we going to be defining our H1 and I

1410:00

just say like to do or you know what to

1410:02

do like so and list I'll also provide a

1410:05

classes to it now let me just save my

1410:07

file T this out let's just refresh there

1410:10

and we are getting some sort of error

1410:11

and that eror is coming from the subscri

1410:14

oh that is coming from the Subscribe

1410:17

we're getting there from The Zo and

1410:19

there is not what we want so we have to

1410:20

use our use store we have to grab that

1410:23

from our store now let me just save my

1410:25

file and and refresh there and here you

1410:27

can see we are now getting or to-do list

1410:29

which is looking cool now underneath

1410:30

this H1 what do you want to do we want

1410:32

to Define another D with the class of

1410:34

legs and then items will be set to

1410:37

totally Center and margin for the bottom

1410:39

will be set to four and inside this

1410:41

table let's just Define our input field

1410:43

with the type of text and the value will

1410:45

be coming from the input value which we

1410:47

just Define right here there we go and

1410:50

when somebody try to type something

1410:51

inside there we're going to be firing

1410:53

this function which is a set input value

1410:55

and here we have to specify event.

1410:57

target. value inside there okay and I'm

1411:01

going to also provide a placeholder

1411:02

which will say like add um a new too or

1411:07

to do there we go and provide these

1411:09

classes to it so that it looks a bit

1411:11

cool and this is how it looks like right

1411:13

here which is not that impressive to be

1411:16

honest but yeah it is looking cool now

1411:18

underneath this input field we're going

1411:20

to be defining a button which allows us

1411:21

to do this I'll just use like add and

1411:24

here I'm going to provide the on click

1411:26

event handler when somebody clicks on

1411:28

this button we going to be firing this

1411:30

handle add Todo function and we also

1411:32

have to provide these classes to it now

1411:34

let me copy the name of the and Define

1411:36

this function right here so let's just

1411:38

use our cons handle a to do and this

1411:41

function first of all we have to check

1411:43

if we input value. Rim like if we don't

1411:46

have any spaces inside our input field

1411:48

we want to check that if that is equal

1411:50

to empty string if the user did not

1411:52

specify nothing then we only want to

1411:54

return like we don't want to do anything

1411:56

else in there and now we have to add

1411:58

what to do and if you want to add what

1412:00

to do we are going to be first of all

1412:02

providing the ID and the ID will be

1412:03

coming from dat. now we're going to be

1412:05

also providing a text and the text will

1412:07

be coming from this input value so I'm

1412:09

going to copy that and place it right

1412:11

here and provide my comma and also for

1412:13

the completed flag we're going to be

1412:15

setting there to false and now need this

1412:17

a to do we're going to be also setting

1412:19

or input value to empty string like we

1412:22

just want to clear this out now let me

1412:23

save my file and that's done so we are

1412:25

not only able to add or to-do like

1412:28

whenever I click on this it's going to

1412:29

empty out our input field but we cannot

1412:31

see their to-dos so to see there we have

1412:34

to go ahead and render there right here

1412:36

I'll use a UL with the class of space on

1412:39

the y- axis will be set to three and now

1412:41

it read over to all of the todos by

1412:43

using the map method and provide a too

1412:45

as a perimeter inside the let's just use

1412:47

our lii and here we have to specify the

1412:50

key and the key will be coming from the

1412:52

too. ID and also provide these classes

1412:54

to it so now inside this lii what do you

1412:56

want to do we just want to create a div

1412:58

with the class of flex and items will be

1412:59

set to Center and inside this div we're

1413:01

going to be creating our input field

1413:03

with a type of checkbox and then we also

1413:06

want to provide the check St it's going

1413:08

to be check if you have to do do

1413:09

completed so it's going to either gives

1413:11

us true so if it gives us true that will

1413:14

be checked but if it gives us false so

1413:16

that's not going to be checked so now

1413:17

let's just also provide the own change

1413:19

Handler and here whenever somebody try

1413:21

to type something inside there we're

1413:23

going to be firing this toggle to do fun

1413:26

and it's going to take a TOD do. ID and

1413:28

now outside from there I'm going to also

1413:30

provide these classes St so now if I

1413:31

save my file and here you can see this

1413:33

is how our checkbox looks like if I add

1413:36

another item so it's going to also give

1413:37

us that checkbox once again and now

1413:39

underne this checkbox we want to show

1413:41

our label okay so I'll use like span and

1413:44

this span will only render the Tod do.

1413:46

text so now if I save my file and here

1413:48

you can see it's going to gives us their

1413:49

text but now let me just format the B

1413:52

okay so I'm going to go ahead and put a

1413:53

classes to it and that classes will be

1413:55

done Dynamic so for that we have to use

1413:57

our template literal and here we have to

1413:59

render or too. completed flag totally

1414:01

dynamically so if you have a completed

1414:04

flx so in that situation we're going to

1414:05

be using this uh styling like line three

1414:09

and also text will be set to gray of 400

1414:12

like if our state is completed so then

1414:14

we're going to be using that styling but

1414:16

if that's not the case so we're going to

1414:18

be setting that to text to gray of 700

1414:21

like so so now if I save my file and

1414:24

here you can see both of them are now

1414:25

set to this line through but if I

1414:27

uncheck one of them it's going to remove

1414:29

that line and also that styling okay so

1414:32

that's what this line of code means now

1414:34

underneath that we also want to create

1414:36

our button which allows us to remove

1414:37

that specific to-do so I'll just use a

1414:40

button with the level of delete and

1414:42

whenever somebody clicks on there we

1414:44

going to be firing this function which

1414:45

will take like remove to-do and here we

1414:47

have to specify the to-do do ID to it

1414:50

okay so now outside from there we're

1414:51

going to be also providing these classes

1414:53

to it so now let me just save there and

1414:55

this is how it looks like right here

1414:57

let's suppose if I want to delete this

1414:58

one I can click on there so it's going

1415:00

to delete there if I want to remove this

1415:01

one as well so it's going to also remove

1415:03

there I can also add like walk the dog

1415:06

click on the add so it's going to add

1415:08

there I can mark the S check I can also

1415:11

totally delete if I wanted to I can also

1415:13

say like walk the fish in this case and

1415:15

click on the ADD and it's going to add

1415:17

there and and I can say like record the

1415:20

uh react native course and now if I

1415:24

click on this one so it's going to also

1415:26

gives us there I can also totally remove

1415:28

there check and remove there so yeah

1415:30

that was our basic to-do list

1415:32

application by using reactjs typescript

1415:34

Ze and also T CSS what happened Rick I

1415:37

thought we ain't the good guys anymore

1415:39

huh I'm a better father than you Rick

1415:42

I'm better for Lori than you man cuz I'm

1415:44

a better man than you Rick and that was

1415:49

The Walking Dead dialogue and I hope you

1415:51

guys appreciate that because I put a lot

1415:54

of efforts into it so now let me open my

1415:56

terminal and make a set of four or

1415:59

amazing amazing amazing projects now let

1416:02

me zoom in a bit and use npm create we

1416:05

at latest the name will be notes I'm

1416:08

going to choose reactjs with typescript

1416:10

go into the notes folder and use not NES

1416:13

but just a nodes folder and install uh

1416:16

every single thing which needs to be

1416:17

installed for the rejs now that's done

1416:20

you're going to be also installing a zoo

1416:22

stand inside your project that's also

1416:24

done so now let me open there in my vs

1416:26

code let me zoom in a bit and the first

1416:28

thing that I want to do is I want to go

1416:30

into the tailin CSS and go into the

1416:33

framework guides choose we and copy

1416:35

there from there and put it right here

1416:37

inside the terminal so it's can install

1416:39

the inside my machine so that's done and

1416:42

copy the content from here go into the T

1416:46

CSS and replace it with this new content

1416:49

like so save my file let me also copy

1416:51

the go into the index. CSS and replace

1416:54

it with this new one I guess the rest of

1416:56

them will be fine but I'm going to also

1416:57

remove this public folder s this folder

1416:59

f. CSS folder and I'm going to also

1417:02

remove every single thing from this f.

1417:04

TSX and replace them with this new H1 so

1417:07

I'm going to copy them and place it here

1417:10

then s my file and open my terminal use

1417:12

npm run Dev to run there okay so let's

1417:15

just use our local host or whatever and

1417:18

now here you can see everything is

1417:19

working the way we exp to work but we

1417:22

would also need something called the

1417:23

react Quil or or Quil whatever you want

1417:26

to call this so this is going to be the

1417:28

main website so if I click on there here

1417:31

let me just click on there here is the

1417:33

main website basically we're going to be

1417:35

using this qu to Tender or editor so

1417:37

here you can see we can totally change

1417:39

that to Bard we can also change that to

1417:41

italic or underline and we can also make

1417:44

it as a link if you wanted to we can

1417:46

make the as what do we call it as a

1417:48

order list unorder list lots of stuff

1417:51

with there so we are going to be using

1417:52

the re Quil which will gives us this

1417:54

editor totally for free so how are we

1417:56

going to be installing there let me go

1417:58

back and go to this react Quil once

1418:00

again here I'm going to go to the bottom

1418:02

this is how we going to be installing

1418:03

this I'm going to copy this line of code

1418:05

and stop my server once again and place

1418:08

this react quill right here there we go

1418:10

and I'm going to hit enter so it's going

1418:11

to install inside my so that's done now

1418:13

I'm going to go ahead and create my

1418:15

component right here or you know what

1418:17

we're not going to be creating any

1418:18

component but I'm going to just remove

1418:20

this H1 and replace it with this div sem

1418:22

my file and I'm going to copy these two

1418:25

line of code this just copy them and put

1418:29

them right here on the top so this how

1418:31

we're going to be importing and using

1418:32

the re Quil inside our project okay so

1418:35

now let me go ahead and create my

1418:37

store. and first of all we would need

1418:40

the create function from the Ze turn now

1418:43

underneath that we have to create our

1418:46

use noes tool and it's going to be

1418:48

equals to this create function create

1418:51

function and inside this create function

1418:53

we have to specify our callback function

1418:55

and now inside this callback function uh

1418:58

we're going to be doing a lot of stuff

1418:59

but first of all image Square interface

1419:01

so what I'm going to do is that I'm

1419:03

going to Define my nodes and notes will

1419:05

be equals to this empty array we're

1419:06

going to be also providing a search

1419:08

field because we're going to be also

1419:10

searching for nodes and we would also

1419:12

need the editor content which will be

1419:14

set to empty string we're going to be

1419:16

also keeping track of the note color and

1419:19

that's going to be equals to totally

1419:21

white color we also need the current

1419:23

note index and the current node index

1419:25

will be set to know okay so I'm going to

1419:28

go ahead and create a type for there so

1419:30

let's just use like interface with the

1419:31

name of node and inside there let's just

1419:34

use our text with the type of string and

1419:36

color with the type of string as well

1419:39

now underneath that I'm going to be

1419:40

placing a huge interface and now let me

1419:43

explain that here you can see we have

1419:45

one not State interface and inside there

1419:47

we have one notes which will be coming

1419:49

from this note right here like we have a

1419:52

text and also the color which are both

1419:53

set to string and we also have a search

1419:55

field which is set to string editor

1419:58

string note color string current note

1420:00

index which will either be a number or a

1420:02

no and the initial value that to now and

1420:05

we have a set noes function which will

1420:07

take update notes as a perimeter and

1420:09

return white and then we have a set

1420:11

search function which will take search

1420:13

value as a perimeter and return white

1420:15

and then we have a set editor content

1420:17

set note color Set current node index

1420:20

and add over update node and we also

1420:23

have the select node Okay so so this is

1420:25

how my interface looks like now I'm

1420:27

going to copy the name of there and

1420:29

annotate my create function with this uh

1420:32

what do we call it no ST now underneath

1420:35

that we have to Define our set nodes and

1420:37

this can be equals to the updated up d a

1420:40

t updated noes and here we have to use

1420:43

our set method and for this set method

1420:46

we are going to be first of all

1420:47

providing our notes so I'll use like

1420:49

notes and notes will be coming from this

1420:51

updated notes from up above and now

1420:53

underneath them we're going to be also

1420:54

providing set search field and it's

1420:57

going to take a search value as a

1420:58

parameter and now inside this one we're

1421:01

going to be using the set method and

1421:03

here we have to just use search and the

1421:06

search will be coming from the search

1421:08

value which we also Define up above and

1421:10

now let's just use our set editor

1421:12

content it's going to take a Content as

1421:15

a perimeter and we're going to be using

1421:17

the set method one more time and here

1421:19

inside then we have to use what do we

1421:21

call it editor content and that's going

1421:24

to be equals to this content

1421:25

and now underneath there we're going to

1421:27

be using the set note color and this

1421:30

going to be equals to the color and here

1421:32

we have Ed the set and inside this set

1421:35

first of all we have to get the node

1421:37

color so we're going to be getting there

1421:38

by using this node color and we have to

1421:40

Define this color with the that's also

1421:42

done now underneath this one we have to

1421:44

also provide the Set current node index

1421:47

it's going to take an index as a

1421:48

perimeter and we have to use our set

1421:50

function inside there and here we also

1421:53

have to Define our c current node index

1421:56

and that current node index will be set

1421:58

to newly added index now let me just

1422:00

save my file and that's going to be

1422:02

every single thing for the functions and

1422:04

now we are only left with two other

1422:06

functions so now let's just go back and

1422:08

create the nend or note update and or of

1422:12

De no to be precise and we are going to

1422:14

be creating a b of there but now let me

1422:17

also Define the select note function as

1422:20

well so it's going to take a index and

1422:22

also I'm going to create a body of them

1422:25

in a few seconds okay so let's just sa

1422:27

our file okay here we are making two

1422:29

mistakes let me remove this in and here

1422:32

we also have to provide the separator

1422:34

and that's going to be fine now let me

1422:36

take care of this end or update function

1422:38

so inside the or you know we're going to

1422:40

removing this curly braces from there

1422:42

and let's just use our set method and

1422:44

provide our state today first of all we

1422:46

have to restructure a lot of things from

1422:48

this state so to destructure then we're

1422:50

going to be using the con resert keyword

1422:52

and we're going to be destructuring the

1422:53

editor content the node come on the Node

1422:56

color and also the current node index

1422:59

and also all of the nodes from the St

1423:02

now we also have to check let me just go

1423:04

back and we also have to check uh and

1423:06

we're going to be checking if the editor

1423:08

content. trim which means like if we

1423:10

have some sort of a spaces inside there

1423:12

then we're going to be also checking

1423:14

once again the editor uh note index if

1423:17

there is not come on if there is not

1423:21

equals to no so what we want to do in

1423:23

that case we want to update the existing

1423:25

node so how are we going to be doing

1423:26

there first of all we need the clown all

1423:28

for existing nodes and I will just clown

1423:31

there and I'm going to sore that clown

1423:33

value inside the updated nodes variable

1423:36

like so and next we can modify this so

1423:38

to modify them we going to be using our

1423:40

updated noes once again and we have to

1423:42

specify our current node index and

1423:45

that's going to be equals to this newly

1423:47

created object and inside then we have

1423:49

to specify our text and the text will be

1423:51

set to editor content and we also have

1423:53

to provide the color and the color will

1423:55

be set to note color like so and now

1423:58

underneath this if statement we only

1424:00

have to return this object which will

1424:01

have the notes this is right in notes

1424:03

and notes will be equals to this updated

1424:05

notes and also underneath there we have

1424:07

to specify our editor content and our

1424:10

editor content will be set to empty

1424:12

string and we also have a note color and

1424:14

I'm going to just proide there like

1424:16

totally empty not empty string but

1424:18

totally white color now I will also use

1424:20

the current node index and set there to

1424:23

now I'm going to send my file so that's

1424:25

going to be the first if statement now

1424:27

outside from there you know what let me

1424:29

just highlight this one so here you can

1424:32

see we have our highlight R all just

1424:34

proide else class but if that's not the

1424:37

case what do we want to do in that

1424:38

situation we only want to add a new

1424:40

to-do so to add a new to-do we're going

1424:42

to be just returning an object and we're

1424:44

going to be using our notes and first of

1424:46

all we have to make a copy of our

1424:48

existing notes and then we're going to

1424:50

be providing a text and that text will

1424:52

be set to edit her content and also we

1424:55

have to change the color and the color

1424:57

will be set to new color okay from up

1424:59

above and also we have to use our editor

1425:03

content and set that to empty string and

1425:05

provide a note color which once again

1425:08

will be set to totally white color and

1425:10

the current node index will be set to

1425:13

null like so this function is totally

1425:15

done I'm going to go into this select

1425:17

nodes function and remove this curly

1425:19

braces from there and now I'll use the

1425:22

set function it's going to take a St as

1425:23

a perimeter and inside there what do you

1425:26

want to do we want to use our current

1425:28

node index and the current node index

1425:30

will be equals to that index which we

1425:32

are now taking as a perimeter for this

1425:34

function and we're going to be also

1425:36

providing the what do we call it the

1425:37

editor and the editor content will be

1425:39

equals to the state. nodes not color but

1425:42

nodes there we go and here we have to

1425:45

specify the index and then we want to

1425:46

get the text out of there now I'll also

1425:49

take care of the note color and the note

1425:51

color will be equals to state. nodes and

1425:54

here we want to get the index of that

1425:57

specific color and that's going to be it

1426:00

finally we have to export this so we can

1426:02

use the other files we going to be using

1426:04

like export default and then use node

1426:06

store and that was our entire store so

1426:09

you know what let's just use the inside

1426:11

our component so now inside the app

1426:12

component I'm going to use the use node

1426:15

store to import there and we're going to

1426:16

be restructuring a few things from there

1426:18

or you know what every single thing that

1426:20

we've defined inside our store I'll use

1426:22

like editor content also the the note

1426:25

color the current note index like so and

1426:29

the set editor content set Noe color and

1426:32

the add or update function from there so

1426:34

now that's stly done the next thing that

1426:36

we have to do is that we have to go to

1426:38

the UI and I'm going to style there a

1426:40

bit so I'll just Pro a classes of height

1426:42

will be set to tot the screen and flex

1426:44

so now inside this D we're going to be

1426:46

rendering our what do we call it our

1426:48

side bar component in a few second which

1426:50

we going to be creating there but now

1426:52

let me just take care of the main are

1426:54

area so now let's just save this file

1426:56

and take care of the main area so I'll

1426:58

just create a div with a class of with

1427:01

will be set to 2 out of three and then

1427:03

pairing will be set to add and inside

1427:05

this div we have to specify our text

1427:08

editor which means like we have to use

1427:10

our react Quil so now underneath that we

1427:12

have to just call or react Quil which we

1427:14

are also importing right here we have to

1427:16

call that and we're going to be

1427:18

providing a few props St okay so what

1427:20

I'm going to do is that I'm going to

1427:21

provide the placeholder which will say

1427:22

like write your note here dot dot dot

1427:25

I'm going to also provide like some sort

1427:27

of a theme to this so the theme will be

1427:28

set to snow and also I'm going to style

1427:31

this I'll just write like height will be

1427:32

set to 96 background will be set to

1427:34

totally white margin for the bottom will

1427:36

be set to Two Rim and close them and

1427:38

here you can see we are now getting our

1427:40

text editor I can also write something I

1427:42

can totally format there if I want to

1427:45

like I can make the italic I can make

1427:46

that ball or just a normal or something

1427:49

like that I can also make it as a link

1427:50

if I wanted to so let's just select them

1427:52

and I can also yeah the this one yes we

1427:55

can also specify our link and so on and

1427:57

so forth so now our reu is working the

1428:00

way we expand him to work so now

1428:01

underneath there what we have to do we

1428:03

have to provide our color selector so

1428:06

let me also create a color selector

1428:07

right here so I'm going to create a with

1428:08

the class of flex and also margin for

1428:10

the left will be set to arbitrary value

1428:13

like one rim and I'm going to also Pro

1428:15

like items will be set to Center margin

1428:18

for the top will be set to four and

1428:20

space on the xaxis will be set to four

1428:22

as well okay so now inside this D we're

1428:24

going to be creating our input field

1428:26

with a type of uh color in this case

1428:28

because we're going to be providing a

1428:29

color not text or numbers or something

1428:31

like that and I'm going to also provide

1428:33

the value and the value will be that

1428:34

node color from up above okay and when

1428:37

somebody try to type something inside

1428:39

that then we're going to be firing this

1428:40

function which is a set Noe color and

1428:42

then we have to use our event. Target uh

1428:46

target. value right here and also I'm

1428:48

going to provide a class name and the

1428:50

class name will take like with will be

1428:51

set to Two Rim or not Two Rim but 10

1428:54

would be fine height will be also set to

1428:55

10 and padding for all around will be

1428:58

set to one for a border and round it set

1429:00

to four I'm going to save this file now

1429:02

underneath this input we are going to be

1429:04

also creating a paragraph which will say

1429:06

like choose a note color or something

1429:08

like that so now let me test this out so

1429:10

here you can see we have our input field

1429:12

and now we can choose different kind of

1429:14

colors from there so which is also

1429:15

looking cool now finally we have to

1429:17

create a button which will allows us to

1429:19

save our changes so use like save button

1429:21

and now underneath there we're going to

1429:23

be creating a button which will first of

1429:25

all check if the curent node index is

1429:28

not equal to no so in this situation we

1429:30

going to be saying like update the node

1429:33

but if that's not the case we will just

1429:34

say like save the node like so and when

1429:37

somebody click on this button we are

1429:39

going to be firing this add or update

1429:40

function right here I'll also provide

1429:42

these classes to it and yeah you can

1429:45

also provide then so now let me just

1429:46

save my file and I will also render this

1429:49

AI outline plus come on AI I guess I

1429:53

didn't install the react icons so you

1429:55

know let me just install the npmi and

1429:57

then react uh react icons like so that's

1430:01

toally done let's just use our npm run

1430:02

there one more time and now we have to

1430:04

render there right here so I'll use like

1430:06

AI outline and then plus come on Yep

1430:10

this one so I'm going to hit enter and

1430:12

I'm going to also provide a classes to

1430:13

it so I'll just write like margin for

1430:15

the right will be set to two so now if I

1430:17

save my file and here you can see I know

1430:19

the UI is not looking that cool the UI

1430:21

is looking a bit weird because we're

1430:23

using a flex right here and we are not

1430:25

providing any sidebar to this so if I

1430:27

just remove this Flex sa my file and now

1430:29

this is how it looks like right here I'm

1430:31

going to provide my Flex box or Flex

1430:32

once again now for this react Quil I'll

1430:35

also provide the value and the value

1430:37

will be coming from the editor content

1430:39

and also on the on change event handler

1430:42

we're going to be fting this set editor

1430:43

content I can write whatever I want to

1430:45

write I can also totally edit if I

1430:47

wanted to and I can also choose a

1430:49

different color and I can save there

1430:51

okay so once I save there like

1430:52

everything is working the way we expect

1430:53

him to work but finally we have to just

1430:55

create the sidebar component and that's

1430:57

going to be it so I'll just create a

1430:58

file or even a component folder and

1431:01

inside that I'll have like sidebar. TSX

1431:03

I'll use my uh RFC inside this save my

1431:07

file and render my sidebar component uh

1431:10

right in here yeah save my file test

1431:13

this out so here you can see we are now

1431:15

getting our sidebar which is looking

1431:16

cool and now let's just zoom in a bit

1431:19

the first thing that I want to use that

1431:20

I want to use like use node store and

1431:23

I'm going to execute there okay next we

1431:25

will also destructure a few things like

1431:27

the nodes also not a note color let's

1431:30

just go back the nodes and also the

1431:32

search and also the select node and set

1431:36

search now underneath them we're going

1431:38

to be defining our filtered node so I'll

1431:39

use like filtered nodes and that's going

1431:42

to be equals to the nodes and now we're

1431:43

going to be filtering there and to

1431:45

filter there we will provide a call

1431:47

function of node to there and now inside

1431:49

this one what do we have to do you know

1431:51

we don't even have to put that

1431:52

parenthesis we can just use like do

1431:55

text. to lower case we have to first of

1431:57

all change that to lower case like so

1432:00

and then we have to check if that

1432:02

includes the search. to lower case we

1432:04

also have to change that to lower case

1432:06

methods now I'm going to save my file so

1432:08

it's going to giv us that filter data

1432:10

and you know what let me just render

1432:11

that right here so what I'm going to do

1432:13

is that I'm going to just remove this

1432:14

sidebar from there and I'll will provide

1432:16

a classes of with will be set to one out

1432:18

of three background will be set to

1432:19

totally white pairing for all around

1432:21

will be set to four and Shadow not SM

1432:24

small but large now inside this div you

1432:26

want to create our div once again with

1432:28

the class of flex and items uh items

1432:31

will be set to Center and margin for the

1432:33

bottom will be set to four okay so I'll

1432:35

also use the fa or you know fi search

1432:38

right here for a search uh icon I'll

1432:41

also proide the classes of text will be

1432:42

set to totally extra large margin for

1432:44

the right will be set to two and now

1432:46

underneath there we're going to be

1432:47

defining what input field with the type

1432:49

of text and I'll also provide the

1432:51

placeholder which will say like search

1432:53

nodes dot dot dot and also I'll provide

1432:56

the value and value will be a search

1432:57

value which is coming from our store we

1432:59

can also provide the own change event

1433:01

hander and it's going to take a callback

1433:03

function and let's just use our set

1433:05

search right here and for this set

1433:07

search we're going to be providing our

1433:08

event. target. value and now let's just

1433:10

s there and a bit of styling to it so I

1433:13

guess that's going to be fine now let me

1433:15

check this out so here you can see we're

1433:16

now getting more search field but I

1433:18

don't know why this is looking super

1433:20

weird let me just take care of that and

1433:22

I just realized that I made a mistake

1433:24

I'm going to cut this div from here and

1433:26

I'm going to put there right here at the

1433:28

bottom like so so now if I save my file

1433:31

and test this out so now that's looking

1433:32

better now let me also take care of the

1433:34

notes so I'll go to the sidebar once

1433:36

again and finally we have to render all

1433:39

of our list so for them I'm going to be

1433:40

using like noes list and render all of

1433:43

my list right here okay so I'll use a

1433:45

div inside this div I'll first of all

1433:47

check if you have the filter nodes.

1433:49

length if that is equal to or greater

1433:51

than zero so in this situation we going

1433:53

to be rendering one one UI if that's not

1433:55

the case then we're going to be

1433:56

rendering another UI and I'll just

1433:58

create a paragraph which will say like

1434:00

no new nodes and I'll just close this

1434:03

paragraph right here just like that and

1434:05

now for this one we have to render our

1434:07

first UI so first of all we have to

1434:09

iterate over through all of four filters

1434:11

so I'll use a map method for that so

1434:12

it's going to take a note and also the

1434:14

index and here we have to specify our

1434:16

div so I'll just write a div and I'm

1434:18

going to close them and close this D

1434:21

like so okay so inside this D what we

1434:24

have to do well you know what first of

1434:26

all we have to provide a few things

1434:27

today so I'll provide a key and and key

1434:29

it will take as a index and we're going

1434:31

to be also providing the own click event

1434:33

handler when somebody try to click on

1434:34

them then we are going to be firing this

1434:36

select note function and here we have to

1434:39

specify our index so now if I save my

1434:41

file next we have to also provide a

1434:43

classes to it and now inside this D we

1434:46

have to provide our content the first

1434:48

thing that we have to do is we have to

1434:49

create the color circle and to create

1434:52

them first of all we going to be

1434:53

creating a d

1434:54

and that we're not going to be closing

1434:57

there like this we're going to be

1434:58

closing there as a oneliner I'm going to

1435:00

put a class name and a class name will

1435:01

take like width of four and height will

1435:04

also be set to four because we're just

1435:06

creating a small circle and that's going

1435:07

to be totally rounded and also margin

1435:09

for the right will be set to and let's

1435:11

just also put a classes to it so I'll

1435:13

just write like classes and here inside

1435:15

the we will first of all change the

1435:17

background color background color like

1435:19

so and that's going to be coming from

1435:20

the node do color and I'm going to also

1435:22

provide the border and border will be

1435:24

set to one pixel not two but one pixel

1435:27

solid and totally black color and now

1435:31

what I want to do is I want to just

1435:32

write some sort of a note I'll also

1435:33

choose the color of there and I'm going

1435:35

to just choose some sort of a pinkish

1435:37

not a pink color but purple color now

1435:39

I'm going to save there and once I save

1435:41

that here you can see that color right

1435:42

here or that Circle to be precise now

1435:44

underneath we're going to be creating

1435:46

yet another div and which will have the

1435:48

class of trunk head and also it will

1435:50

have a property which is a dangerously

1435:52

inner HTML property and here we have to

1435:55

just specify Das Dash HTML and for this

1435:58

HTML we're going to be providing our

1435:59

not. text Casi here we also have to

1436:03

specify these curly braces once again

1436:05

and now that's totally looking better so

1436:07

now let me explain what in the world is

1436:09

this dangerously set inner HTML so in

1436:11

reactjs this dangerously set inner HTML

1436:14

is a property that allow you to set HTML

1436:17

content directly within a component it

1436:19

is also named this way to highlight the

1436:21

potential risk associated with injecting

1436:23

the HTML cont such as like cross side

1436:25

scripting XS attex if the HTML content

1436:28

is not properly sanitized you're not

1436:30

going to be using the in the production

1436:32

but we are just creating this simple

1436:34

application so that's why I use that so

1436:36

I want you to keep that in mind and what

1436:38

I'm going to do is that I'm going to

1436:40

just test this out so I'll just write

1436:42

like I don't know uh

1436:44

walk the dog or something like that I'm

1436:47

going to choose a red color for them and

1436:49

save that as a node I'll also write like

1436:52

something cool and now I'm going to just

1436:54

highlight this cool and bold there and

1436:57

change the color of there to something I

1436:59

don't know kind of a greenish color

1437:00

would be fine and now I'm going to also

1437:02

save this note and here you can see we

1437:04

are also getting that styling we can

1437:06

also write like um amazing stuff as a

1437:09

note and I'll just select this first one

1437:12

and underline there I'll also choose a

1437:14

color for there like kind of a orangish

1437:17

or yellowish color and now if I click on

1437:19

the save not so it's can also save there

1437:21

now I can also search for a specific uh

1437:23

not so let's suppose if I want to search

1437:25

for like something it's going to give us

1437:27

that something cool if I want to search

1437:29

for the amazing so it's going to give us

1437:30

that amazing stuff if I want to search

1437:32

for like walk the dog so it's can also

1437:34

give us there and that was our n project

1437:37

in reactjs do you know what insanity is

1437:40

insanity is doing exact same

1437:43

thing over and over again and expecting

1437:45

to change says who says my grandma

1437:49

God Rest her soul she is the most

1437:51

wonderful woman in this entire the

1437:54

universe okay so the first thing that we

1437:57

have to do is that we have to make a set

1437:58

of four or amazing and advanced level

1438:01

project so what I'm going to do is that

1438:03

I'm going to make a setup so let me just

1438:05

zoom in a bit so you guys can see

1438:06

everything a bit better and I'm going to

1438:08

be using npm Create we at latest and

1438:12

then I'm going to give it the name of

1438:13

like Advance task list I'll choose

1438:17

reactjs and typescript let's just go

1438:19

ahead and go to the advanced level uh

1438:22

task this and I'm going to be using npm

1438:24

Mi to install all of the packages now

1438:26

that successfully done I'm going to also

1438:28

install Ze so I'll use like npmi and

1438:30

then Z it's it's going to install them

1438:32

in my machine I'll also install the

1438:35

react icons and then I'm going to open

1438:38

the inside my vs code so I'll use like

1438:40

open Dot and this is how things looks

1438:42

like so I'll just go ahead and remove

1438:43

the public folder SS folder app. CSS and

1438:47

remove every single thing from the app.

1438:49

TSS or TSX I'm going to go into the app

1438:52

and remove every single thing from there

1438:54

I'll also go ahead and use the npm Run

1438:56

Dev to start my server so I'll use like

1438:58

npm run Dev and then I'm going to use

1439:01

the Local Host it's going to run there

1439:03

I'm going to also go ahead and go to the

1439:05

tailin CSS and install tailin CSS inside

1439:08

my project so let's just go ahead and

1439:11

copy this command open the terminal and

1439:14

place it right here I'll just place

1439:17

there I'll also hit enter so this can

1439:19

initialize the tment CSS inside my

1439:21

project so I'll just copy this content

1439:24

now let me go ahead and go to our tailin

1439:26

config file and replace them with this

1439:28

new content I'm going to copy this

1439:30

tailin I mean like index. CSS components

1439:33

and I'm going to place that there

1439:34

finally let's just test this out so I'll

1439:36

go ahead and go to my app and replace

1439:39

the with this Dev like so now let me use

1439:43

mpm run Dev so it's going to start my

1439:45

server I'm going to go there and here

1439:47

you can see everything is working the

1439:48

way we expect him to work so that was

1439:50

our basic setup of our project okay so

1439:52

now first thing first we have to Define

1439:54

our store so I'll use like store. TS and

1439:57

now inside there we are going to be

1439:59

doing craziness we are going to be

1440:01

writing a lot of code so we use first of

1440:04

all import the create function uh create

1440:07

function from where from the Zain

1440:09

library and now we have to Define our

1440:12

store so I'll use like export and then

1440:14

cons use store it's going to be equals

1440:16

to the create function which we now

1440:18

importing it's going to take a set

1440:20

object and inside this set object we're

1440:22

going to be performing a lot of

1440:24

craziness but I want you to bear with me

1440:26

for a few seconds because first of all

1440:28

we going to be defining a lot of

1440:29

interfaces and then we're going to be

1440:31

writing a data based on those interfaces

1440:34

so now let's just start from the first

1440:35

thing first of all we're going to be

1440:36

creating an interface for the list and

1440:38

inside there we going to be providing a

1440:40

name and the name will be totally a

1440:42

string we're going to be also setting

1440:43

there for the Emoji and Emoji will be

1440:45

set to a string and that's done we also

1440:47

have to create an interface for the

1440:49

workspace we use like interface and

1440:51

let's just create a workpace and here

1440:54

inside there we have to define the name

1440:55

and the name will be set to string and

1440:57

the Emoji will also be set to a string

1441:00

okay now underneath there we have to

1441:02

take care of the to-do so I'll just go

1441:04

ahead and uh create an interface for for

1441:06

the I'm going toate with a text and text

1441:08

will be a string I'm going to also

1441:10

provide a list and this will be a string

1441:12

the workspace come on workspace will be

1441:15

a string as well and sa my file now we

1441:19

have to Define one of the biggest

1441:20

interface in this entire course so we

1441:23

are going to defining the interface for

1441:25

word for or App State and this app state

1441:28

will have a lot of state and a lot of

1441:30

data inside there so let's just start

1441:32

from the first one first of all we're

1441:33

going to be writing our list and then

1441:35

list will be coming from this list which

1441:37

we just defined right here okay so

1441:40

that's going to be our list I'm going to

1441:41

also provide the workspace so let's just

1441:43

use our workspace and we are going to be

1441:45

annotating that with our workspace which

1441:47

we just a few seconds ago I'm going to

1441:49

also write the to-dos and here we have

1441:51

to anate the with or to-do interface and

1441:54

then we have to write the edit index

1441:55

it's going to be either a number or a

1441:57

null value now we have to also write the

1442:00

drop down index it's going to be either

1442:03

a number or a null value and then we

1442:06

have to take care of is list model open

1442:10

that's going to be a Boolean value so we

1442:12

have to annotate the is workpace model

1442:16

open and here we also have to inate with

1442:18

a Boolean and then selected list and we

1442:21

have to inate with a string then

1442:23

selected workpace and also annotate with

1442:27

the string one more time then we have to

1442:29

create our to-do text and that's going

1442:31

to be a string also have to create our

1442:33

model name a string and then the model

1442:37

Emoji come on model Emoji that's going

1442:40

to be a string as well it should be 1D

1442:43

then the model type and model type will

1442:45

either be a list or it's going to be uh

1442:50

come on a workspace so let's just write

1442:51

or workspace or it's going to be a null

1442:54

value I'm going to also write the add

1442:56

list and for this ad list we're going to

1442:58

be using a name and that name will be a

1443:00

string we also have to provide the Emoji

1443:02

I'm going to provide a comma there and

1443:03

the Emoji it will take as a string and

1443:06

here we have to return wide from there

1443:08

I'm going to also write the ADD workpace

1443:10

and for this add work space we're going

1443:11

to be providing a name name will be a

1443:13

string and also the Emoji will be come

1443:16

on emoji will be a string as well and

1443:19

we're going to be returning a white from

1443:21

there I'm going to also attach the a to

1443:23

do and here a to-do will be taking a

1443:25

to-do and now we have to annotate the

1443:27

with or to-do interface which we just

1443:29

defined up above and return white from

1443:31

the update to do and then uh it's going

1443:35

to take the index and index will be a

1443:36

number and then updated uh to do and B

1443:41

at to do which we just Define up above

1443:43

and we are going to be returning a white

1443:45

from there now let me take care of the

1443:47

delete come on delete uh or delete to do

1443:50

it's going to take the index and index

1443:52

will be a number and we are going to be

1443:54

returning a wi from the this just take

1443:57

care of the handle edit and handle edit

1443:59

will take the index and that index will

1444:01

be a number and we're going to be

1444:02

returning a white from the handle update

1444:05

and same exact thing like it's going to

1444:07

take a index and index will be a number

1444:09

and we are going to be returning a wi

1444:11

from there then handle drop down click

1444:14

when somebody clicks on there it's going

1444:15

to take an index and index will be a

1444:17

number and we are going to be returning

1444:19

a white from there now we also have to

1444:22

create for the set edit text and here

1444:25

it's going to take a text as a perimeter

1444:27

and text will be a string and return wi

1444:30

from there and then set edit index and

1444:33

then it's going to take index as a

1444:35

perimeter we're going to be annotating

1444:37

there as a number or it should be come

1444:39

on what the hell did I just do it should

1444:41

be a null value so either a number or a

1444:43

null value and we're going to be

1444:45

returning a wide from there and now let

1444:47

me Define a few more and then I promise

1444:49

that's going to be it okay so I'm going

1444:51

to define the open list model and this

1444:53

open list model will take nothing it's

1444:56

going to only return the white then Clos

1444:58

list model also not going to take

1445:01

anything and we're going to be returning

1445:02

white from there and then we have the

1445:04

close workspace model and it's not going

1445:07

to take anything once again it's going

1445:10

to return the wi from there also set

1445:12

selected list and here we have to

1445:15

provide a list and list will be set to a

1445:17

string and we have to return the white

1445:19

from there and then the set selected

1445:22

workspace going to take the workspace as

1445:24

a perimeter we have inverted as a string

1445:27

and return the white from there close

1445:29

there we're going to be also using a set

1445:31

to do text and now we have Prov a text

1445:34

inside there and return we like annotate

1445:37

the with a string and it's going to

1445:38

return a white now let's just create

1445:40

handle a to do and then we are going to

1445:43

be just returning this white function

1445:46

and now we also have to get the set

1445:48

model name and here we have to provide a

1445:50

name and annotate with the string and

1445:53

going to return wide then set model

1445:56

Emoji it's going to take the Emoji and

1445:59

that emoji we're going to be annotating

1446:01

as a string and return white from there

1446:04

let's just use a white and now we're

1446:06

going to be using set model type and for

1446:09

this set model type uh we going to be

1446:11

providing a type so type will either be

1446:13

a list on let's just write a list or it

1446:16

can be a workpace okay and finally we

1446:19

going to be uh returning the white from

1446:22

there and then we going to be using the

1446:24

handle save model and we have to return

1446:27

nothing from there just a wide okay wide

1446:30

there we go now let me S my file and

1446:33

that was our

1446:34

basic basic interfaces so first of all

1446:37

we create interface for the list then

1446:38

for the workspace then for the to do and

1446:40

finally we created there for the ab

1446:42

state so now let me just copy the name

1446:44

of there and annotate my create function

1446:47

with this AB Strate so I'll just use

1446:49

like f Strate and close there and now we

1446:51

have to specify a values for then so

1446:54

what I'm going to do is that first of

1446:55

all I'm going to be defining my list so

1446:58

it's going to be set to just an empty

1446:59

list or array I'm going to also specify

1447:02

the workspace and workspace will be once

1447:03

again list and then to do we have to

1447:06

provide that array once again then for

1447:09

the edit index we're going to be setting

1447:11

the initial value to no and then the

1447:13

error text and we're going to be setting

1447:15

the initial value to empty string then

1447:17

for the drop- down index uh we are going

1447:19

to be setting that to initial value of

1447:21

now then is list model open open initial

1447:24

value will be set to false and then is

1447:26

workspace model open the initial value

1447:28

will be set to false and then for the

1447:30

selected list come on let's just WR a

1447:32

selected list and we're going to be sing

1447:34

there to empty string and then set I

1447:36

mean like

1447:37

selected workspace and we're going to

1447:39

Beering there to empty string now

1447:41

underneath there we have to write a to-

1447:42

do text and annotate with empty string

1447:45

and also the model name will be set to

1447:47

empty string the model Emoji will be set

1447:51

to this string and the model hi will

1447:54

also be set to no now we have to Define

1447:56

our functions like how we're going to be

1447:58

changing our states so let's start from

1448:00

the first one which is a add list like

1448:02

how we are going to be adding our new

1448:03

list uh it's going to take a name and

1448:05

it's going to also take the Emoji we

1448:07

already annotated there and now we just

1448:09

have to use the set method in this set

1448:11

method we'll take the state and here we

1448:13

have to use that state so we're going to

1448:15

be using like list now we have to otate

1448:17

with dot dot dot State first of all and

1448:20

I mean like state do list and then we

1448:23

have to use the name come on name and

1448:25

also the Emoji I'm going to save this

1448:27

file but we are getting some sort of an

1448:30

error I know these errors are coming

1448:31

from the typescript but where in the

1448:33

word is this error coming from oh that's

1448:35

because we have to write a curly Braes

1448:38

there I'm going to cut that and place it

1448:40

right here and that's done this is how

1448:41

we going to be adding our new list now

1448:44

let's talk about the workspace like how

1448:45

we are going to be adding a workspace

1448:47

all use like add work come on it is

1448:50

doing that for me now I'll write like

1448:52

the name and also the Emoji and here we

1448:54

have to use the set method I'm going to

1448:56

be using a state and inside there we

1448:59

have to Define our workspace and here

1449:02

inside this workspace we're going to be

1449:03

getting there from the St

1449:05

workspaces uh or spaces was there a

1449:08

space or a spaces let me just check this

1449:10

out okay it was a workspace so yeah we

1449:14

also have to write a workspace right

1449:16

here I'll remove them and for a comma

1449:19

it's going to take a name and it's going

1449:20

to also take the Emoji I'm going to save

1449:22

this file now I'm going to go ahead and

1449:24

Define how we're going to be adding a

1449:25

to-do so I'll use like add to-do and now

1449:28

it's going to take a to-do inside there

1449:30

now we use the set method once again

1449:32

it's going to take the state and for

1449:34

this state we're going to be getting our

1449:35

to-dos from where from dot dot dot the

1449:38

state do too or to-dos rather and now we

1449:41

have to just specify or new to-do to

1449:43

there which we are now taking as a

1449:44

perimeter and we are now passing that

1449:45

right here okay so that's or a to-do now

1449:48

let me just take care of updating the

1449:50

to-do so I'll use like update too and

1449:53

here we have to take the index and also

1449:55

the updated to do and now uh we have to

1449:58

use the set method it's going to take a

1450:00

state and for this St I'm going to go

1450:02

ahead and first of all Define my new

1450:05

to-do so I'll use like cons new to-do or

1450:07

to-dos rather and first of all we have

1450:09

to make a clone off or existing one if

1450:12

we have something so we're going to be

1450:13

using state. toos so it's going to

1450:15

allows us to make a clone off or

1450:17

existing to and this should be const

1450:20

we're getting a lot of these curly Braes

1450:22

but you know what let me just remove

1450:24

this annotation from here so that we can

1450:26

remove all of that errors and I'm going

1450:27

to add it back in a few seconds so this

1450:29

how we going to be adding a new to-do

1450:31

then we have to get that new to-do and

1450:33

I'm going to place that right here and

1450:35

provide that index which we now taking

1450:37

as a perimeter and we have to provide

1450:39

there and then we have to set that to

1450:41

this updated to-do so I'll use like this

1450:43

updated to-do copy the name of that and

1450:45

place it right here that's done and

1450:47

finally we have to return some sort of a

1450:49

data from there so I'm going to be using

1450:51

uh what the hell is wrong oh we have to

1450:54

remove this parenthesis and also that

1450:58

parenthesis from there now we have to

1451:00

return a data so I'll just use like for

1451:02

the to-dos we're going to be adding a

1451:03

new to-do for there and also for the ER

1451:06

index uh we are going to be attaching a

1451:08

n value initially and also for the edit

1451:11

text we're going to be setting that to

1451:13

empty string so now let me just save my

1451:14

file and that's going to be it for

1451:16

updating the Tod so just collapse them

1451:19

underneath this updating to do we have

1451:20

to Define yet another function which

1451:22

will allows us to delete the to-do okay

1451:24

so let's just use like the index and

1451:26

here inside there we're going to be

1451:28

using our set method it's going to take

1451:30

a state as a perimeter and here inside

1451:33

there we have to first of all get all of

1451:34

the todos from where from the state.

1451:37

todos and then we have to use the filter

1451:39

so let's just go ahead and use a

1451:41

produce. filter filter we are not

1451:43

interested in anything but we are

1451:45

interested in the index so I'll just go

1451:47

ahead and use like if our index does not

1451:50

equal to that index which we are now

1451:51

taking as a perimeter so in that

1451:53

situation we only want to remove that

1451:56

specific Todo and we also want to make a

1451:58

drop down index come on uh what the hell

1452:01

did I just do God damn it okay so I'll

1452:04

just use like drop down index it's going

1452:07

to be set to the initial value op n I'm

1452:09

going to provide a comma there now

1452:11

that's looking better so this is how we

1452:13

are going to be removing our to-do or

1452:14

deleting or to-do now underneath this

1452:17

delete to do we have to also create a

1452:19

function for handling the edit so I'll

1452:21

use like the handle edit and it's going

1452:23

to take an index as a perimeter and

1452:25

inside that we have to use a set method

1452:27

it's going to take a state and for this

1452:28

St what we have to do we have to first

1452:31

of all Define our edit index and we have

1452:33

to provide the index value which we are

1452:35

now taking as a perimeter from there now

1452:37

we have to use the edor text and now I'm

1452:40

going to inate with the state DOT and

1452:42

now let me just put index inside there

1452:44

do text now we have to use the drop-

1452:46

down index and now we have to set that

1452:49

to totally null value like this I'm

1452:52

going to also collapse there and now we

1452:54

have to create for the handle update so

1452:56

it's going to take a index and now

1452:58

inside there we have to use a set method

1453:00

once again and provide our state and now

1453:03

for this one we're going to be first of

1453:04

all defining our updated to do and how

1453:07

are we going to be doing them this is

1453:09

how we are going to be doing this so

1453:10

first of all we have to make a clown of

1453:11

our existing state. toos and provide our

1453:14

index inside there which we now taking

1453:16

as a perimeter from there okay I'm going

1453:18

to also provide a text and the text will

1453:20

be set to state. edit text come on and

1453:23

edit text and that's going to be done so

1453:26

now underneath this update to do what

1453:28

the hell am I doing this should be

1453:30

updated too now underneath this updated

1453:33

Todo we have to Define our new too so

1453:35

I'll use like cons new too and it's

1453:37

going to be equals to this object like

1453:39

this array and we have to make a clone

1453:41

of our existing set. toos like so and

1453:44

then we have to use our new todos inside

1453:46

there and pass our index which we now

1453:47

taking as a perimeter and set that to

1453:50

this updated to- do underneath that we

1453:52

are going to be turning the todos and

1453:54

also we are going to be setting the

1453:55

value of there to new todos and then a

1453:58

index will be set to this now yes I'll

1454:00

use like edit index and set there to no

1454:04

I'm going to also provide the edit text

1454:06

and set there to empty string okay so

1454:09

yeah that's going to be it so I'm going

1454:10

to comment or collapse that next we have

1454:13

to Define our handle drop- down click so

1454:16

let's just use a handle drop down click

1454:19

and then it's going to take index as a

1454:21

perimeter now we can use a set method

1454:23

and for this set method we have to

1454:25

specify a state index now inside they

1454:27

we're going to be using a drop down

1454:29

index if the index is equal to the

1454:31

state. dropdown index so in this

1454:34

situation we are going to be setting the

1454:36

value to null but if that's not the case

1454:38

we going to be setting the to this index

1454:40

which you're now taking as a perimeter

1454:42

that's going to be it for the handle

1454:43

drop down click now let me take care of

1454:45

the set Ed text so I'll use like set

1454:47

edit text and annotate there with a I

1454:50

mean like not annotate but it's going to

1454:51

take a text as a PR and now I'm going to

1454:53

be using a set method once again and

1454:55

here inside there we have to use the Ed

1454:57

text and provide the text value which we

1454:59

are now taking as a perimeter right here

1455:02

I'm going to provide a comma Now let me

1455:03

also take care of the set edit index and

1455:06

here it's going to take the index as a

1455:07

perimeter and now we are going to be

1455:09

using the set method and provide our

1455:10

edit index and change that to index

1455:13

which we are now taking as a perimeter a

1455:16

comma there now we are going to be also

1455:18

taking care of the open list model it's

1455:21

not going to take anything as a

1455:22

perimeter and now we are going to be

1455:24

using a set method and for this set

1455:26

method we're going to be checking is is

1455:29

list model open we're going to be

1455:31

setting that to true and also the model

1455:33

type will be set to a list in lower case

1455:36

or you know in upper case l in the rest

1455:39

of them will be in lower case that's

1455:41

done we also have to create one more for

1455:44

uh what we call it close list model and

1455:47

now it's not going to take any perimet

1455:49

but now we are going to be using a set

1455:50

method inside there and here we have to

1455:52

provide like is list model open so we

1455:55

use like is list model open and change

1455:58

that to false and the model name will be

1456:00

set to this empty string and also the

1456:03

model Emoji will be set to this empty

1456:06

string that's done now let's create our

1456:08

open workspace model like so it's not

1456:11

going to take any perimeter but once

1456:13

again uh you know we're going to be

1456:15

copying this entire line and now let me

1456:16

just place there so instead of providing

1456:18

this is list open I'm going to change

1456:21

there to uh is workspace model open okay

1456:25

and now we are going to be setting that

1456:26

to true and for the model type I'm going

1456:29

to remove that and change there to the

1456:31

model type and it's going to be set to

1456:32

the workspace so upper case W and then

1456:35

space in lower case like that now we're

1456:38

going to be using a closed workspace

1456:40

model and here we have to provide our

1456:43

Arrow function now let's just use a set

1456:45

method and inside there we're going to

1456:47

be checking is our workspace model open

1456:50

and we're going to be setting that to

1456:51

false then the model name will be set to

1456:54

empty string I'm going to also provide

1456:55

the model emoji and change that to empty

1456:58

string once again underneath that we

1457:00

have to Define our Set uh selected list

1457:04

and now it's going to take a list as a

1457:06

perimeter now we going to be defining

1457:08

our set and here we have to write like

1457:10

selected on selected list and change

1457:14

that to the list which we have created

1457:15

well it is taking as a perimeter and now

1457:18

underneath that we have to also Define

1457:20

the uh set selected workspace and for

1457:23

this set selected workspace let me just

1457:25

remove that dot from there it's going to

1457:27

take a workspace as a perimeter and now

1457:29

we're going to be using a set method and

1457:31

now we have to write a selected

1457:33

workspace and set that to the workspace

1457:35

which we are now providing as a

1457:36

perimeter okay that's done now

1457:39

underneath there we're going to be

1457:40

defining the set to do text and provide

1457:43

our text inside there now we're going to

1457:46

be using our set method once again and

1457:48

proide our to-do text and there to-do

1457:51

text will be set to this text now need

1457:53

there we also have to provide our handle

1457:55

a too and now inside this handle a too

1457:59

we're going to be using our set method

1458:01

not like this but this is remove there

1458:04

we are going to be using our set method

1458:05

like this it's going to take a state as

1458:07

a perimeter and inside there what we

1458:09

have to do we have to destructure a few

1458:11

things from or stad so what are the

1458:13

things which we are going to be

1458:14

destructuring from or stad these are all

1458:17

the things that we have to D structure

1458:18

from the St so I'll just write like to

1458:20

do text and then select

1458:23

yeah selected list rather then selected

1458:25

workpace okay so we have to destructure

1458:28

that and now we can check if text. trim

1458:32

method so if that's the case like if

1458:34

that is equal to empty string so in this

1458:35

situation but if that's not the case we

1458:38

are going to be creating a new to-do so

1458:40

I'll use like cons new to-do and here

1458:42

it's going to be an object so we have to

1458:44

specify the list and the list will be

1458:45

set to selected list then provide my

1458:48

comma and then workspace and workspace

1458:50

will be set to selected workspace which

1458:52

we are now destructuring from our state

1458:55

right here that's done finally we have

1458:56

to return those values so we're going to

1458:58

be using like return and now let's just

1459:00

use the to-dos and change the to dot dot

1459:02

dot and then state DOT to-dos like we

1459:04

want to make a clone of there and then

1459:06

we want to add one new to-do inside

1459:08

there if that's the case we're going to

1459:10

be also setting the to-do text to

1459:12

totally empty string and also the

1459:14

selected text to be also come on

1459:17

selected selected text it's going to be

1459:20

also set to empty string in the selected

1459:23

uh yeah selected list will be also set

1459:25

to empty string and finally the selected

1459:28

uh workspace will also be set to empty

1459:30

string so that's or uh handle air too or

1459:33

hide there now underneath there we have

1459:35

to Define another function or method

1459:37

whatever you want to call there so we're

1459:39

going to be using like set model name

1459:41

it's going to take a name as a perimeter

1459:43

and now we have to use the set method

1459:44

and now we have to provide the model

1459:46

name inside there and that's going to be

1459:47

set to this name I'm going to provide a

1459:49

comma now let's take care of the set

1459:51

model emoji

1459:53

and here we have to provide our emoji

1459:55

and now we have to use the set function

1459:57

and let's just use the model emoji and

1460:00

change that to the Emoji like so I'm

1460:02

going to also use the set model type and

1460:04

it's going to be taking a type now we

1460:06

have to use a set method and provide my

1460:09

model type and that's going to be set to

1460:11

this type like so now underneath that we

1460:14

have to use the handle s and then we are

1460:17

going to be using this function now let

1460:19

me just provide my State method inside

1460:21

there and provide my state just like

1460:23

this and here inside there let's just

1460:25

destructure a few things from our stad

1460:27

so what are the things that we are going

1460:28

to be destructuring we are going to be

1460:30

destructuring the model name from where

1460:32

from the state and also the model emoji

1460:35

and also the model type okay so now need

1460:38

let's just save our file okay what the

1460:40

hell is going on where the hell oh we

1460:43

have to proide a comma there so now let

1460:44

me just save my file and now it will

1460:46

work okay next we have to check if our

1460:49

model name. TR method equals to to empty

1460:53

strings in this situation we're going to

1460:54

be only returning the St okay let's just

1460:57

put T above and now we have to check if

1461:00

our model type is equal to the list so

1461:03

in this situation we're going to be

1461:05

using state. add list and now we have to

1461:07

add our model name model name and also

1461:11

our model Emoji like that and if that's

1461:14

not the case we're going to be using the

1461:16

model type and if the model type is

1461:18

equal to the workspace so in this

1461:20

situation we're going to be using that

1461:22

once again and we're going to be

1461:23

attaching the add workspace and then uh

1461:26

we have to provide the model name and

1461:28

also the model uh Emoji like so finally

1461:33

we have to return all of that values and

1461:35

that's done so I'll just use like the

1461:37

model name we have to inate with empty

1461:40

string and also the model Emoji we have

1461:42

to use the initial value of empty string

1461:44

and then the model type and use the null

1461:47

value to there and then is list model

1461:50

open we have to set there to p and also

1461:53

is workspace model open and set there

1461:56

two FS oh my God that was a lot and I

1462:01

mean a lot of typing okay so still I'm

1462:04

going to go ahead and go to the top and

1462:06

I'm going to copy this Abate from there

1462:09

and here I'm going to annotate my

1462:11

Creator function with this ab and now

1462:14

let me just save my file and yeah that

1462:17

was our store and now let's just start

1462:19

working on our UI so that was it about

1462:21

for the store now let's start working

1462:22

working on our UI so I'm going to go

1462:24

ahead and Define my components folder

1462:26

and inside that I'm going to be defining

1462:27

my sidebar. TSX and also my main area.

1462:31

TSX let's just go to the sidebar and use

1462:33

the RFC and also inside the main area

1462:37

use the RFC now let me go ahead and go

1462:39

to my UI and provide my Flex classes to

1462:42

this so I'll use like the class names

1462:44

and it's going to be set to flex and

1462:46

height will be set to toly screen inside

1462:48

this D we have to render our sidebar

1462:50

which we are now getting and we have

1462:52

have to close there underneath there we

1462:54

have to create a d with the class of

1462:55

flex of only one ping all around will be

1462:57

set to six and now I'm going to select

1462:59

main area and render there right here if

1463:03

I check this out so we are now getting a

1463:04

sidebar and we are also getting this

1463:06

main area so we're going to be taking

1463:08

care of the sidebar in a few seconds but

1463:10

first of all we have to take care of the

1463:11

main area so you know what I'm going to

1463:14

comment this line out sem my file and

1463:15

now we are getting this main area and

1463:17

now let's just start working on our main

1463:19

area so what I'm going to do is that I'm

1463:21

going to grab something the use store

1463:24

from where from let's just go ahead and

1463:25

go to our store and now inside there we

1463:28

have to destructure a few things so I'll

1463:29

just destructure uh what do we call it

1463:31

we're going to be restructuring all of

1463:32

that from the use store so we would need

1463:34

the lists and also the

1463:36

workspaces and also uh the selected list

1463:40

selected workspaces and to- do text

1463:43

selected to-do list or set selected list

1463:47

and then set selected workspace set to

1463:50

do text and finally we have to do

1463:52

restructure the handle air to do I'm

1463:54

going to save this file right now now

1463:55

let me go ahead and go to my UI and

1463:58

provide a class name so I'll use like

1463:59

the flex will be set to one and pairing

1464:01

all around will be set to six inside

1464:03

this T you have to Define margin for the

1464:05

bottom of and not five but just a four

1464:08

inside there we have to create our input

1464:09

field and this input field will have the

1464:11

type of text I'm going to also specify

1464:13

the value and that value will be coming

1464:15

from this add to-do I me like to-do text

1464:18

to be precise and now let me just place

1464:19

it right here and when somebody Tred to

1464:21

type something in inside this so we're

1464:23

going to be firing this function which

1464:24

will be a set to do text and provide my

1464:27

event. target. value inside there let me

1464:30

just s my file and that's going to be

1464:31

done we also have to specify the place

1464:33

holder which will say like add a new too

1464:36

or something like that and also specify

1464:38

my class name so so I'll say like border

1464:40

and Border will be set to gray of 300

1464:42

pairing all around will be set to two

1464:44

hold rounded rounded large and the WID

1464:47

will be set to totally full now let me

1464:49

save my file and check this out so we

1464:51

are now getting this amazing huge input

1464:54

field we will change that in a few

1464:56

seconds but yeah let's just proceed to

1464:58

the next one so the next thing that we

1464:59

have to do is that we have to create a d

1465:00

with a class of margin for a top of two

1465:02

flex and also items will be set to to

1465:05

Center and inside there we have to

1465:06

Define our select field we not going to

1465:08

be attaching any name to this so I'll

1465:10

just remove the name and also the ID

1465:11

from there and I'm going to specify the

1465:13

value and for this value we're going to

1465:15

be providing our selected list and

1465:17

that's going to be it and when somebody

1465:18

try to change something inside there

1465:20

we're going to be firing this function

1465:21

and we're going to be changing the

1465:23

selected list value and we are going to

1465:25

be providing the event. target. value

1465:28

inside there I'm going to also specify a

1465:29

bit of classes to this so I'll use like

1465:31

border and Border will be set to gray of

1465:34

300 and also pairing all around will be

1465:36

set to two rounded large and margin for

1465:39

the right will be set to two inside this

1465:42

select statement we're going to be

1465:43

defining our option and for this option

1465:45

we're not going to be providing any

1465:46

value today and let's just make their

1465:48

disable and here I just say like select

1465:51

list and underneath this option uh we're

1465:54

going to be trading over through all of

1465:55

our list now use the map method and

1465:57

proide my list inside there and the

1465:59

index okay so what I'm going to do is

1466:01

that I'm going to specify my option and

1466:03

close there and for this option we're

1466:05

going to be providing a key and the key

1466:07

will be set to this index and I'm going

1466:08

to also specify the value and value will

1466:10

be coming from the list. name and here

1466:13

inside there we have to render our Emoji

1466:14

so I'll use like list. emoji and then

1466:17

list. name I'm going to save this file

1466:20

right now and yeah we are getting this

1466:22

select statement but we did not specify

1466:24

nothing inside our sidebar so that's why

1466:26

we cannot select something from there so

1466:29

yeah that's cool and everything now

1466:30

underneath the select statement we have

1466:32

to Define yet another select statement

1466:34

so we are not going to be providing any

1466:36

name and ID to there so let's just

1466:37

remove that from here and we're going to

1466:39

be providing a value so let's just use

1466:41

the value and the value will be set to

1466:43

selected workspace like so and when

1466:46

somebody try to change something inside

1466:48

this so let's just use the own change EV

1466:49

Handler we are going to be firing this

1466:51

function which which is a set selected

1466:53

workspace not list but change that to

1466:55

workspace and provide my event. target.

1466:58

value inside there underneath then we

1467:01

also have to specify the classes all

1467:02

used like the border and Border will be

1467:04

set to gray of 300 ping all around will

1467:07

be set to two rounded toally large and

1467:10

inside this select statement we're going

1467:12

to be defining our option and for each

1467:14

of this option we're not going to be

1467:15

providing any value today and I'm going

1467:17

to make it totally disable and I'll just

1467:19

select select workspaces right here our

1467:22

workspace rather underneath this option

1467:24

we're going to be rendering our

1467:26

workspaces if we have some so if you

1467:28

have the workspaces then we want to

1467:30

right over through them so I'll use like

1467:31

the workspace and just a workspace

1467:34

rather and I'm going to also paste the

1467:35

index inside there okay so what I'm

1467:38

going to do is that I'm going to provide

1467:39

my option once again and here for this

1467:41

option we're going to be providing the

1467:42

key and the key will be set to this

1467:44

index and the value will also be set to

1467:46

workspace do name so for this option

1467:49

we're going to be rendering our

1467:50

workspace do emoji and then workspace do

1467:54

name now let me just save my file here

1467:56

we have a selected workspaces but we

1467:58

cannot select any workspace from there

1468:00

and also any list because we did not

1468:02

create them so once we create them then

1468:05

we would be able to see all of them so

1468:07

what I'm going to do is that underneath

1468:08

this select statement we're going to be

1468:10

defining our button and for this button

1468:12

I'm going to also attach a few classes

1468:13

to this so I'll use like background holy

1468:15

black text will be set to totally wide

1468:17

pairing for the x-axis will be set to

1468:19

four pairing for the y axis will be set

1468:21

to two totally rounded large and also

1468:23

margin for the left will be set to four

1468:26

flex and this is make it items totly

1468:29

Center like so and it's going to say

1468:32

like add to do and here we also have to

1468:35

render our icons so I'm going to be

1468:37

using like fa plus icon so it's going to

1468:39

allows us to add work to do I'm going to

1468:41

save my file and also when somebody

1468:43

clicks on there we going to be adding

1468:45

work to do so I'll use like the on click

1468:47

event handler and when somebody clicks

1468:49

on them we're going to be firing this

1468:50

handle add too function and yep we are

1468:52

now getting there so if I type something

1468:54

inside there and click on this air to do

1468:56

it's going to add there but we cannot

1468:58

see there and why is there because we

1469:00

did not render any content on our

1469:02

screens so that's why we would not be

1469:04

able to see anything so yeah that was

1469:06

just the main area and now let's just

1469:08

take care of the sidebar and also the

1469:10

other stuff that's done so let's just go

1469:12

ahead and go to our app and render all

1469:15

of our content right here so all of our

1469:17

to-dos and stuff so what I'm going to do

1469:19

is that underneath this main area I'm

1469:21

going to Define another D with the class

1469:23

of margin for top of six and inside

1469:25

there let's just use R2 with the classes

1469:27

of text totally extra large font will be

1469:30

set to semi bolt andb like margin for

1469:32

the bottom will be set to four and

1469:34

margin for the left will be arbitrary

1469:36

value so I'm going to be using like uh

1469:37

to RM I'll specify my to-do list inside

1469:40

there let's say say our file check this

1469:42

out so we are now getting our to-do list

1469:44

and now finally we have to it over

1469:45

through all our todos so we can see them

1469:48

so I'm going to be using like ul and for

1469:50

this UL we're going to be passing the

1469:51

class of list DC and also padding for

1469:54

the left will be set to five oh I forgot

1469:56

to destructure them so I'm going to go

1469:58

to the top and first of all we would

1469:59

need let's just import the use store

1470:02

from where from let's just go ahead and

1470:03

go to the top and import that store from

1470:06

the store I mean like that use store

1470:08

from the store so for now I'm going to

1470:10

be destructuring a few things so I'll

1470:11

just uh use this destructuring syntax

1470:14

and we're going to be destructuring

1470:15

there from this use store so what do we

1470:17

need from there we need the to-dos

1470:19

obviously and also we need the edit

1470:21

index and edit we would also need the

1470:23

edit text and the drop- down index

1470:26

handle edit handle update not add word

1470:30

handle come on handle update drop down

1470:32

click delete too set edit text yeah

1470:36

index would be fine and also we need the

1470:37

set edit text I'm going to save this

1470:40

file and now let's just go ahead and

1470:41

itate over through all of the to which

1470:43

we just imported from our store okay so

1470:46

I'm going to go ahead and use there I'll

1470:48

pass my and now let's just itate over

1470:50

through there by using the map method

1470:52

and then I'm going to be placing a to-do

1470:53

and also the index inside there okay so

1470:56

let's just close there and I'm going to

1470:57

be using a lii close this one we have to

1471:00

also specify the key and the key will be

1471:01

set to our index and for the class name

1471:04

margin for a bottom will be set to two

1471:05

margin for the left will be set to to

1471:08

rim and close there like so I'm going to

1471:10

be also checking like if the edit index

1471:13

is equal to this index which we're now

1471:15

getting by it rading over through our

1471:16

items so if that's the case we're going

1471:18

to be rendering one UI if that's not the

1471:21

case we're going to be rendering another

1471:22

UI I'm going to take care of the else

1471:24

CLA in a few seconds so I'll just close

1471:26

it like this and now we have to take

1471:28

care of this first one so I'll just

1471:30

Define first of all my div with the

1471:32

class of flex and also the items will be

1471:34

set to all the center I'm going to save

1471:35

my file inside this div we have to

1471:37

Define our input field with the type of

1471:39

text I'm going to also past the value

1471:41

and the value will be set to edit and

1471:43

when somebody try to change something

1471:44

inside there or type something inside

1471:46

there we're going to be setting the edit

1471:48

text to this event. target. value like

1471:51

whatever the user type inside there you

1471:53

want to get there now this just also

1471:55

provide a bit of classes to this we use

1471:57

like border and Border will be set to

1471:59

gray of 300 and pairing all around will

1472:01

be set to one poly around it large

1472:03

margin for the right will be set to two

1472:05

here we are now getting this UL but also

1472:07

we have to render that content which we

1472:09

type inside there I'm going to be first

1472:11

of all using my button so I'll use like

1472:13

button and the classes will be set to

1472:15

background totally green 500 TT off

1472:18

totally white pairing for the xaxis of

1472:20

two ping for the Y AIS of one totally

1472:22

rounded large and margin for the right

1472:25

will be set to two inside this button

1472:27

what do we have to do uh we have to past

1472:29

the update label inside there and when

1472:32

somebody clicks on this button we're

1472:33

going to be firing this function so I'll

1472:35

just say like uh handle update which we

1472:38

are now getting from our store and we're

1472:40

going to be placing our index inside

1472:42

there so it's going to update our item

1472:43

based on this index now underneath this

1472:46

update button we're going to be passing

1472:47

our delete button so I'll use like

1472:49

button and the classes will be set to

1472:51

background gray of 500 and also takes

1472:54

off totally white pairing for the xaxis

1472:56

of two pairing for the y axis of one

1472:58

totally rounded large and inside them

1473:00

I'm going to past like cancel save this

1473:03

file and here we also have to attach the

1473:05

event handler so when somebody try to

1473:06

click on there then we're going to be

1473:08

firing this function like set edit index

1473:10

and P null value to there that's done so

1473:13

I'm going to go ahead and go to the else

1473:14

class and remove that from here and

1473:16

Define my D with a class of relative and

1473:19

also we have to make the as a flex

1473:20

justify with be set to between and the

1473:23

items will be set to totally Center

1473:26

inside there let's just Define our D

1473:27

inside this D we have to Define our

1473:29

spend margin for the right field be set

1473:30

to four now finally we have to render

1473:32

our level or whatever we type inside

1473:35

this input field so I'll just use like

1473:36

the strong tag for there and now we have

1473:39

to use like too. text and here outside

1473:42

from there we're going to be also

1473:43

rendering like the list just just a

1473:46

level of list and now we have to use or

1473:48

Tod do. list inside there underneath

1473:50

there we are going to be also specifying

1473:52

the workspaces or just a workspace and

1473:54

now we can use that to do. workspace s

1473:57

file and here you can see we're now

1473:58

getting the text which we specify inside

1474:01

our input field we are not getting the

1474:02

list because we did not select any list

1474:04

we are also not getting any workspace

1474:06

because we did not select any workspace

1474:08

so that's why we are not getting there

1474:10

but other than that we are now getting

1474:11

our content so you know what let me just

1474:12

add uh something else and if I click on

1474:15

this add button it's going to add that

1474:17

right here so that's cool underneath

1474:19

this div we have to Define another D

1474:21

with the close so flex and items will be

1474:22

sub all this Center I'm going to render

1474:25

the icons all use like MD more just CP

1474:27

that from the react icons now we can

1474:29

specify your class name so let's just P

1474:31

like the cursor uh cursor come on q s o

1474:35

r and cursor will be set to pointer and

1474:37

the size will be set to 24 and when

1474:40

somebody clicks on there we're going to

1474:41

be firing this function so I'll use like

1474:43

the handle drop down come on handle drop

1474:46

down click and when somebody clicks on

1474:48

there we're going to be passing this

1474:49

index inside there now let me add

1474:51

something if I click on the add to do we

1474:52

are now getting these three dots if I

1474:54

click on there nothing will happen and

1474:57

why because we did not specify any

1474:59

content inside there so now let's just

1475:01

do this so I'll use like if the drop

1475:02

down index is triple equals to that

1475:05

specific index so in this situation

1475:07

we're going to be rendering this UI so

1475:09

I'll use like the div and this div will

1475:10

have the classes of absolute and also

1475:13

the right P will be set to zero margin

1475:15

for the top will be set to two

1475:16

background holy white and also border

1475:19

and make that Holy rounded Shadow will

1475:22

be set to totally large inside there we

1475:24

have to Define our button so this button

1475:26

will have a few classes like block and

1475:29

pairing for the xaxis will be set to

1475:30

four pairing for the y axis will be set

1475:32

to two t of to gray of

1475:35

700 and I'm going to also provide the

1475:37

Howard St so we are going to be doing

1475:38

that in a few seconds so let's just do

1475:40

that I'm going to use the how set and we

1475:42

are going to be only changing the

1475:44

background color to 100 when somebody H

1475:47

over this button and we also want to

1475:48

provide the width of tot full text will

1475:50

be set to totally left and for this

1475:52

button I'm going to say like update and

1475:53

now let me just save there I'm going to

1475:55

go back because I feel like there's a

1475:58

lot of text underneath this button we're

1476:00

going to be defining yet another button

1476:02

or you know what we have yeah we have to

1476:04

Define another button separately so I'll

1476:06

just Define a button and it's going to

1476:08

say delete I'm going to also style that

1476:10

bit so I'll use like the block pairing

1476:11

for the xais of four pairing for the Y

1476:13

AIS of two text Gray of

1476:16

700 and when somebody how over there we

1476:19

going to be changing the background to

1476:21

toally one 100 and with will be set to

1476:23

full and text will be set to left that's

1476:25

done I'm going to also attach the event

1476:27

handlers on them so when somebody try to

1476:29

click on there then you want to F this

1476:31

function so I'll use like the handle

1476:33

edit and paste my index inside there sa

1476:35

this file I'm going to also put the

1476:37

event handler on this delete button so

1476:39

when somebody clicks on there we're

1476:41

going to be firing this function and use

1476:42

the delete to do and P our index inside

1476:45

there I'm going to go ahead and add some

1476:47

to-do so I'll use like something and

1476:49

click on the add to-do so here you can

1476:51

see we are now getting the text and we

1476:53

are not getting any list because we did

1476:54

not add any of them we also not getting

1476:57

any workspaces because we also did not

1476:59

add them I'm going to click on these

1477:00

three dots and here you can see we can

1477:02

now update there if I click on the

1477:04

update so I can change the or learn

1477:06

primer motion or something like this

1477:08

I'll use like learn frame and motion

1477:10

click on the update and here you can see

1477:11

it's going to update there if I want to

1477:13

delete this so I can click on these

1477:14

three dots and I can click on this

1477:16

delete so it's going to remove them from

1477:17

the UI I can also add something else

1477:20

like learn Zeus stand with projects or

1477:23

something like that and now I can click

1477:24

on this add to do and it's going to add

1477:26

there right here I can once again click

1477:28

on there and change that to frame motion

1477:31

or something like that and click on here

1477:33

so this can also update there and we can

1477:35

also delete that so they to done then St

1477:38

done now let's start working on the

1477:39

final touches so we are going to be

1477:41

working with the sidebar right now and

1477:43

the first thing that we would need is

1477:45

the use store from where from our store

1477:49

file so I'm going to go ahead and go to

1477:51

the top and get the store from there

1477:53

next we're going to be restructuring a

1477:55

few things from where from our use store

1477:57

which we just imported so what are the

1477:59

things that we would need we would need

1478:00

the list you would also need the

1478:02

workspaces the open list model and the

1478:06

open workspace model like so I'm going

1478:09

to go to the UI and remove there and add

1478:11

a few class names so I'll just use like

1478:13

with will be set to 60 background will

1478:15

be set to this F9 F9 and close there I'm

1478:18

going to also specify the flex and flex

1478:20

will be set to to column inside there we

1478:22

have to Define our Flex of one and

1478:24

overflow come on overflow will be set on

1478:27

the y- axis will be set to totally Arrow

1478:29

Auto like so pairing all around will be

1478:32

set to four not five but pairing all

1478:35

around will be set to totally four

1478:37

inside there we have to Define our H3

1478:39

with the classes of text to large point

1478:41

of semi bold semi Comm on semi bold and

1478:45

flex items will be items will be to

1478:48

Center I'm going to just render my list

1478:50

inside there now let me just say my file

1478:52

and here you can see we're now getting

1478:53

this amazing sidebar and also this list

1478:55

right here that's toally done and now

1478:57

here we are going to be rendering over

1478:59

list of items but we are going to be

1479:01

doing there once we are totally done

1479:03

with the model which we are going to be

1479:04

creating in a few seconds so I'll just

1479:06

Define a button right here and it's

1479:08

going to take like the class of flex and

1479:10

justy will be set to toly center items

1479:12

will also be set to toly Center and

1479:14

margin for top will be this arbitrary

1479:16

value which will be set to one Rim it's

1479:18

going to say like um this fa a class and

1479:22

we have to import that and close the

1479:23

right here I'm going to also specify the

1479:25

classes margin for the right will be set

1479:27

to two and it's going to say list or

1479:29

just a list singular here you can see

1479:31

we're now getting there which is looking

1479:32

cool and now the next thing that we have

1479:34

to do is that we have to go ahead and go

1479:36

to the bottom and create our workspaces

1479:38

all just use like pairing for all around

1479:41

will be set to toally four inside there

1479:44

we have to render or you know what I'm

1479:45

going to copy this exact same thing from

1479:48

there place it right here and change

1479:50

that to workspaces and now underneath

1479:52

this H3 what we have to do we have to

1479:54

render our workspaces which we are going

1479:57

to be doing in a few seconds but not

1479:59

right now this is cre for B with the

1480:01

class of flex and justify justify will

1480:04

be set to to Cent and items will be to

1480:07

set to Center margin for top will be set

1480:09

to this arbitrary value which we're

1480:11

going to be providing right here like uh

1480:13

one rim and now it's going to say that

1480:16

render the workspaces and you would also

1480:19

need to render our fa plus icon once

1480:21

once again and close them and I'm going

1480:23

to also specify margin for the right of

1480:25

two I'm going to save this files so now

1480:27

we are getting the list and also the

1480:29

workspaces so now the next thing that we

1480:30

have to do is that we have to introduce

1480:32

another component which is a model. TSX

1480:35

and now I'm going to just say like RFC

1480:37

inside there save my file and go to my

1480:39

app go to the bottom and here we have to

1480:42

render our model component okay I'm

1480:45

going to call that s my file now let me

1480:47

go ahead and go to my model and the

1480:49

first thing that we would need is that

1480:50

we would need the use store from where

1480:52

from our store so let's just go ahead

1480:54

and go to our store pile that's done now

1480:57

inside this model we're going to be

1480:58

destructuring a few things from where

1481:00

from our use store and now what are the

1481:02

things that we would need we will need

1481:04

the is list model open and also the is

1481:07

workspace model open and the model name

1481:10

model Emoji model type set model name

1481:13

not Emoji but just set a model name set

1481:16

model Emoji right now and I'll save

1481:19

model Clos this model close workspace

1481:22

model and now let me just save there now

1481:23

I'm going to go to the UI and remove

1481:25

that from here and attach my classes all

1481:27

used like it's going to be set to

1481:29

totally fixed and insert will be set to

1481:30

zero legs and items will be totally set

1481:33

to Center justify will be also set to

1481:35

center background of gray 900 background

1481:38

opacity will be set to 50 and the Z

1481:41

index will be set to 50 inside then we

1481:43

have to Define yet another D with the

1481:45

class of background holy white padding

1481:47

all around will be set to six fly

1481:49

rounded large and the width will will be

1481:51

set to 80 and we also have to provide

1481:53

the flex and justify will be in this

1481:55

case set to between and items to Center

1481:58

mb4 inside then we have to render our H2

1482:02

it's going to have the text of extra

1482:03

large P of totally Bol P of totally Bol

1482:06

and we have to render our content right

1482:08

here so I'm going to be using like

1482:10

create new and then model type like what

1482:13

you want to build and here you can see

1482:14

we now getting this model and we are

1482:16

also getting this create new list right

1482:18

here which is this create new list so

1482:20

yeah then also done now underneath we

1482:22

have to Define our button so I'll use

1482:24

like the button and the classes will be

1482:26

set to like text of Po 600 and when

1482:29

somebody have over this we are going to

1482:30

be taking care of there right now so

1482:33

when somebody have over there we are

1482:34

going to be changing the text to gray

1482:36

900 and the label will be set to this

1482:38

icon so I'll use like fa times and now

1482:41

let's just grab there from our react

1482:42

icons and now let me just save there as

1482:44

soon as I sa there we are now getting

1482:46

this x icon which is looking cool

1482:48

underneath both of them we have to

1482:50

Define our input field so I'll use like

1482:52

the input field and the type will be set

1482:53

to text and here we also have to provide

1482:56

the value and the value will be set to

1482:57

model name I'm going to also provide the

1482:59

own change event handler so when

1483:00

somebody types something inside there

1483:02

we're going to be fighting this function

1483:04

it's going to have like set model name

1483:06

and now we have to provide the event.

1483:08

target. value inside there let me just

1483:10

save my file and the placeholder will be

1483:12

set to this random placeholders so we're

1483:14

going to be saying like enter and then

1483:16

the model name like what you want to

1483:18

build so I'll write like the model type

1483:20

and then the the name okay so now let me

1483:22

just save my file and here you can see

1483:23

we're now getting like enter the list

1483:25

name and now underneath we are going to

1483:28

be also styling this all use like the

1483:29

class name make the border and border to

1483:32

gray of 300 ping all around of two to

1483:35

rounded large with will be set to

1483:37

totally full m b will be set to four or

1483:39

margin for the bottom will be set to

1483:41

four we're getting this cool looking

1483:43

model and now underneath we're going to

1483:45

be also defining yet another input so

1483:47

I'll use the input with the type of text

1483:49

I'm going to also provide the value the

1483:50

value is going to take the model emoji

1483:52

and somebody try to type something

1483:54

inside this we are going to be firing

1483:55

this function which is a set model emoji

1483:57

and let's just proide our event. target.

1483:59

value inside there I'm going to save

1484:01

this file and for my placeholder and

1484:03

here I'm going to say like enter emoji

1484:05

and this is going to be totally optional

1484:07

if you want to provide that you totally

1484:09

can but you don't have to I'm going to

1484:10

also provide the class names and let's

1484:12

just set the two that exact class names

1484:14

I'm going to go ahead and copy that and

1484:16

place it right here save my file and we

1484:18

are also getting this Emoji picker or

1484:21

not Emoji picker but we are also getting

1484:22

this Emoji input field finally we have

1484:24

to Define our button so I'll select

1484:26

button and when somebody clicks on this

1484:28

button we are going to beiring this

1484:29

function which is a handle save not

1484:31

model but just a handle save function

1484:33

and now I'm going to also put a bit of

1484:35

classes to this I'll use like background

1484:37

totally black T of totally white pairing

1484:40

for the xaxis of four pairing for the y

1484:42

axis of two totally rounded large I'm

1484:44

going to save this file right now and

1484:46

provide the label as a save first of all

1484:48

I'm going to go to the top and provide

1484:50

my event handler on this one and

1484:52

somebody click on that X icon there is

1484:55

St disappear because we have to create

1484:57

that function so what we have to do we

1484:59

have to uh F this function which is a

1485:01

handle close function and now let me

1485:03

just copy the name of that and Define

1485:05

this function right here so I'll use

1485:07

like cons handle CLA and this function

1485:10

will not take any perimeter if for model

1485:12

type is equals to this list in this

1485:15

situation we're going to be using Clos

1485:16

list model and execute there if that's

1485:19

not the case we're going to be also

1485:21

checking like if the model type is equal

1485:22

to the workspace so in this situation

1485:25

what do we have to do oh my goodness

1485:26

let's just remove that in that situation

1485:28

we have to just close the workspace

1485:31

close the workspace model and execute

1485:34

there now let me just save my file we

1485:36

would still not be able to see anything

1485:38

next we have to go ahead and Define this

1485:40

function so I'll just go to the top and

1485:42

Define there right in here so I'll use

1485:45

like const handle or handle save I

1485:48

already copied there to my clipboard and

1485:51

we are not going to be doing anything

1485:52

crazy but we only have to apply this

1485:53

handle save model function and execute

1485:56

there and here you can see we're now

1485:57

getting this model and which is looking

1485:59

cool and now underneath there we have to

1486:00

provide a bit of check like return null

1486:03

if the model is not open so I'll just

1486:05

use like if not is is list model open

1486:09

and not is workspace model open so we're

1486:13

going to be only returning null from

1486:14

there okay so here you can see we're not

1486:16

getting anything but now we have to just

1486:18

take care of these lists so that we can

1486:20

see them so what I'm going to do is that

1486:22

that's already done so now let me just

1486:24

go ahead and go to my list and attach my

1486:26

event handlers on them so when somebody

1486:28

click on this icon we want to show that

1486:30

model and when somebody click on this

1486:32

icon we also want to show that model so

1486:34

what I'm going to do is that I'm going

1486:35

to just write like when somebody clicks

1486:37

on there it's going to be firing this

1486:38

open list model and now let me just save

1486:41

my file and if I click on there here you

1486:43

can see it's going to gives us that

1486:44

model I can also click on this it's

1486:46

going to make it disappear but now if I

1486:47

click on this one nothing will happen so

1486:50

which means like we also have to attach

1486:51

the on click event handler on this

1486:53

button as well so what I'm going to do

1486:55

is that I'm going to just write like on

1486:56

click event handler and render my open

1486:58

workpace model right here we're still

1487:00

going to be getting this model if I

1487:02

click on there once again it will make

1487:03

it disappear so the final thing that we

1487:06

have to do is that we have to take care

1487:08

of I'm super excited about this one we

1487:11

have to take care of the rendering the

1487:12

list and also rendering the workspaces

1487:15

so now in this case I'm going to be

1487:16

using a ul and inside this UL now we

1487:18

have to trate over through all of that

1487:20

list that we are getting from this use

1487:22

store okay so let's just use the dot map

1487:25

method on there and here we have to past

1487:27

the list and also the index inside there

1487:29

and what I'm going to do is that come on

1487:32

I'm going to place my AI inside there

1487:34

and close there and first of all we're

1487:36

going to be passing the index as a key

1487:38

and also pass a few class so I'll just

1487:40

proide like pairing all around of two

1487:41

and somebody how over there so you want

1487:43

to change the background color to this

1487:44

totally CCC make it totally rounded

1487:47

large cursor will be set to totally

1487:49

pointer and the F and items will be

1487:52

totally set to Center inside there we

1487:54

have to render or Spin and Mar for the

1487:56

right will be set to two and render or

1487:58

list. Emoji inside there I'm going to be

1488:01

also rendering my list. name and knif I

1488:04

have there and if I click on this

1488:06

workspace and I'm going to just write

1488:07

like I don't know um coding or something

1488:11

like that and I'm going to also past the

1488:12

coding or uh computer or why am I

1488:16

getting a for a computer you know

1488:18

what I'm going to just write like coding

1488:21

C or D and choose this icon or emoji and

1488:25

now if I click on there here you can see

1488:27

we're now getting this Emoji right here

1488:29

and now if I click on here it's going to

1488:30

also gives us that coding right here so

1488:33

that's done I'm going to go to the

1488:34

bottom and now let's just take care of

1488:36

rendering the workspaces the process

1488:38

will be exactly the same as the previous

1488:40

one so we use like the UL and inside

1488:42

there let's just itate over through all

1488:44

workspaces and we're going to be

1488:45

iterating over through there by using

1488:46

the map method so let's just take care

1488:48

of the workspace and we're going to be

1488:50

also getting the index so what I'm going

1488:51

to do is I'm going to P my Ali and for

1488:54

this Ali we're going to be passing the

1488:55

index as a key and the class names will

1488:57

be exactly the same so when somebody

1488:59

have over there we want to change the

1489:01

background color to this CCC and close

1489:03

there it's going to be totally rounded

1489:05

large and the cursor will be set to

1489:07

pointer legs and items will be set to

1489:09

totally Center and inside there we have

1489:12

to use our spin once again margin for

1489:13

the right will be set to two and now we

1489:16

are going to be using the workspace do

1489:17

emoji and finally let's just use our

1489:20

works space. name and woof that was a

1489:24

lot of typing and a lot of explanation

1489:27

so I can click on there now I can just

1489:29

write like uh I don't know it or yeah it

1489:35

Department of or something like that

1489:38

I'll just write like it or I guess that

1489:41

that icon would be fine so if I click on

1489:42

this sell and here you can see we now

1489:44

getting this it department now I can

1489:46

also choose this it from there I'll just

1489:48

write like uh learn or record the the

1489:53

frame motion course or something like

1489:56

that and now if I click on this air to

1489:58

do it's going to add that to-do right

1490:00

here it's going to also show us the list

1490:02

and it's going to also gives us that

1490:03

workspace right here I can totally

1490:05

change that to like something cool and

1490:08

if I click on the update so it's going

1490:09

to update there and yeah we can totally

1490:11

delete there okay let me just try there

1490:13

once again if I click on this list you

1490:15

would be able to add a new list so I'll

1490:17

just write like my personal info and I'm

1490:20

going to write like me and this is me

1490:24

and click on the save click on the sa so

1490:26

it's going to save that right here and

1490:28

now I can also add a new workspace if I

1490:30

wanted to so I'll just write like um Pro

1490:35

programming or something like the or day

1490:37

in the life of programmer or or you can

1490:40

say day in the life of Huzan so I'll

1490:42

just write like this icon or this emoji

1490:46

and now if I click on there it's going

1490:47

to also add there right here I can also

1490:49

add more like let me just write

1490:51

something and add some random Emoji like

1490:53

this click on the save so it's going to

1490:55

add there right here I can also add a

1490:57

new stuff or workspace other and I'll

1491:01

just add some random Emoji like this

1491:03

click on the save and here you can see

1491:05

it's going to also add there right here

1491:07

and now I can definitely choose them let

1491:09

me just choose this something I'm going

1491:10

to also choose this new workspace and

1491:13

random craft and if I click on this add

1491:16

to do and here you can see it's going to

1491:18

add there right here you can definitely

1491:19

go ahead and update there and I can also

1491:23

totally delete there and that was our

1491:26

super long project of this course next

1491:28

we're going to be building a bit more

1491:30

complex project than this one so let's

1491:31

get into it be careful who you trust

1491:33

Sergeant people you know can Hur you the

1491:35

most ghost so let's start working on our

1491:39

project so I'm going to go ahead and

1491:40

open my terminal I'll zoom in a bit so

1491:42

you guys can see everything a bit better

1491:44

and now I'm going to be using npm Create

1491:46

we at latest and I'll give it the name

1491:49

of advance

1491:51

uh quiz app or something like that I'll

1491:53

choose reactj and also typescript and

1491:55

now let's just go into the advance quiz

1491:58

app and install every single thing

1491:59

inside there then successfully install

1492:01

so I'll also install the Zan by using

1492:04

npm install or I zust so that's also

1492:07

install I'm going to open that in my vs

1492:09

code and this is how it looks like so

1492:11

I'm going to go ahead and remove the

1492:12

public folder go to the SRC remove the

1492:15

SS folder the f. CSS remove every single

1492:18

thing from the f. TSX save this file and

1492:20

now I'm going to also go ahead and go to

1492:22

the index. CSS file remove every single

1492:24

thing from there and I'm going to be

1492:25

using npm run Dev I'm not going to uh

1492:29

first of all we have to make a set of

1492:31

fourward tailin CSS as well so let's

1492:33

just go to the tailan CSS choose

1492:35

framework and guides go to the weed and

1492:37

copy this command open my terminal once

1492:39

again and now we are going to be

1492:41

installing a Tailwind CSS inside our

1492:43

project I'm going to also hit enter so

1492:45

it's going to initialize tailin CSS

1492:46

inside my project now I'm going to go

1492:48

ahead and go to my tailin config and

1492:50

remove this content from there and

1492:52

replace it with this new one like so s

1492:54

file and I'm going to also go ahead and

1492:57

copy all of these CSS so I'll just go in

1492:59

there place this sem my file and now I'm

1493:02

going to also copy this H1 go to my app

1493:05

and place there right here save my file

1493:08

and let's just use the npm Run Dev I'm

1493:10

going to go back and run there now let

1493:12

me go ahead and go to my local host and

1493:15

Yep this is working a okay so which

1493:17

means like now we successfully created a

1493:19

set of four work coding Journey now

1493:21

let's start working on our store so I'm

1493:22

going to go ahead and create a folder

1493:24

with the name of uh store inside there

1493:26

we're going to be creating a file with

1493:27

the name of use squiz uh store. TS file

1493:31

and inside this one the first thing that

1493:33

we would do is that we going to be

1493:34

graving the create function from the

1493:36

zustan library now underneath that we

1493:39

have to Define our use quiz store it's

1493:41

going to be equal to this cre function

1493:43

which we now grabbing from The Zo and

1493:45

now we are going to be passing our

1493:47

callback function today and our callback

1493:49

function will take that set method okay

1493:51

so we're going to be doing a lot of

1493:52

stuff but first of all we have to create

1493:54

our interfaces so that we can annotate

1493:56

our create function on there so what I'm

1493:58

going to do is that I'm going to Define

1493:59

my type with the name of question and

1494:02

here for this question it's going to

1494:04

take a question and that's going to be a

1494:05

string it's going to also take the

1494:07

options and that's going to be a string

1494:08

of array and also we're going to be

1494:10

passing the correct come on the correct

1494:12

answers and here it's going to be set to

1494:14

a number now that's the first thing that

1494:16

we have to do next we have to Define our

1494:18

interface so I'll just use like

1494:19

interface I'm going to give it the name

1494:21

of like quiz St and here inside there

1494:24

we're going to be passing the current

1494:26

question first of all and this going to

1494:27

be set to a number we're going to be

1494:29

also passing answers it's going to be

1494:30

either a number or null value of array

1494:34

okay like that and now we should have to

1494:36

provide this comma now we have to

1494:38

provide the score so I'll use like the

1494:40

score and score will be set to a number

1494:42

then show score is going to be a Boolean

1494:44

value and then what I'm going to do is

1494:47

that I'm going to provide my question

1494:49

and then that question will be that

1494:50

interface which we just created right

1494:52

here okay that's done now underneath

1494:55

that we have to put the select and it's

1494:56

going to take the option index as a

1494:58

perimeter and we have to inate as a

1495:00

number now we are going to be returning

1495:02

the white from there now let's just

1495:04

right to our next question and here

1495:06

we're going to be only returning the

1495:08

white from there like so we also have to

1495:10

provide the previous question and for

1495:12

the previous question we're going to be

1495:14

returning the wi and also for the reset

1495:16

question quiz or other so I'll just

1495:18

write like reset quiz is and here it's

1495:21

going to be just a function which will

1495:22

just return the wi now let me just save

1495:24

my file and that's going to be it for

1495:26

requested so I'm going to copy the name

1495:28

of there and now I'll annotate my create

1495:30

function by using that quiz St so I'll

1495:33

just close there and now inside there

1495:36

first of all we're going to be defining

1495:37

our current question and it's going to

1495:38

be set to zero we're going to be also

1495:40

providing our answers and the answers

1495:42

will be array of three answers and we

1495:44

are going to be filling them with null

1495:46

value like so now we also have to

1495:49

provide the ini value for the score and

1495:51

it's going to be set to a zero you also

1495:53

have to write like show score and the

1495:54

initial value will be set to false I'm

1495:56

going to be placing a lot of questions

1495:58

right here and if you want to use my

1496:00

question you can definitely go ahead and

1496:01

go to my GitHub repository but if you

1496:03

want to use your own one so yeah you can

1496:06

definitely provide your own ones so here

1496:08

you can see I have this questions array

1496:10

and inside there I have a few object so

1496:12

inside each object I have a question

1496:14

like what does a CSS stand for and also

1496:16

we have a few options so you got to just

1496:18

figure out like what's going to be the

1496:19

correct option and in here you can see

1496:21

we're also providing the correct answer

1496:23

as well and the correct answer is two 0

1496:25

1 and two so cascading style sheet is

1496:29

the correct answer so yeah here you can

1496:30

see I have a lot of questions which I

1496:32

already set up so I'm going to just

1496:34

collapse that right here just like there

1496:37

now I'm going to work on my function so

1496:38

I'll use like select answer come on

1496:41

select answer and that's going to be

1496:43

just set to this function and I'm going

1496:45

to just close there like so I'm going to

1496:47

duplicate there like a few times and

1496:49

change the name of their like the next

1496:50

question and also this one to be the

1496:53

previous question and this one will be

1496:56

set to a reset question come on reset

1496:59

reset quiz rather I'll use like the

1497:02

reset quiz I'm going to save my file but

1497:04

we are still getting this error I don't

1497:06

know why you know what we're going to be

1497:07

taking care of this error in a few

1497:09

second but now let's just start working

1497:10

on our select answer function so for

1497:13

this select answer it's going to take a

1497:14

option index and now we have to provide

1497:17

them or you know what we're not going to

1497:18

be providing this curly Braes so just

1497:20

use my set method it's going to take a

1497:22

St and inside them we are going to be

1497:24

using a curly braces right here so first

1497:26

of all we have to make a clown of all of

1497:28

our answers so I'll use like dot dot dot

1497:30

and then state do answers and now we

1497:33

have to store them in some sort of a

1497:34

variable so I'll use like answers it's

1497:36

going to be equal to this clown next we

1497:38

have to save the selected answer for the

1497:39

current questions so I'll use like the

1497:41

answers and here we have to specify the

1497:43

state. current questions is going to be

1497:46

equals to this option index now

1497:48

underneath that we have to just return

1497:50

our answers and this is going to be it

1497:51

for the select answer that's done now

1497:53

let me take care of this next question

1497:55

so inside there we not going to be

1497:57

providing any curly braces today so I'll

1497:59

use the set method and here we have to

1498:01

specify the St and for this St uh we are

1498:03

going to be using the curly braces so

1498:05

first of all we have to get like uh cons

1498:07

is last question we have to check like

1498:09

whether it is a last question or not so

1498:12

we're going to be using like state.

1498:13

current question if that is equals to

1498:16

the state. questions. length and length

1498:20

minus one which means like this going of

1498:21

gives us the last question and now we

1498:23

need there we have to provide our checks

1498:25

so I don't know why I'm getting these

1498:27

errors so I'll just cut that from here

1498:30

and you know it's going to just remove a

1498:32

few errors and now we have to provide

1498:34

our check so I'll just use like if we

1498:36

have the last question so in this

1498:38

situation we're going to be setting the

1498:40

score to zero and now we have to Loop

1498:43

through the question and compare the

1498:44

answers so how are we going to be doing

1498:46

them we're going to be using a state.

1498:48

questions now for these questions we are

1498:50

going to be using the four each so that

1498:52

we can itate over through there so now

1498:54

I'm going to be passing a question as a

1498:56

perimeter and we are going to be also

1498:58

passing an index as a perimeter inside

1499:00

there I'm going to be checking if the

1499:03

st. answers and here we have to specify

1499:06

that index if that is equal to the

1499:08

questions do correct answer so in that

1499:10

situation we're going to be only

1499:12

incrementing the score but if that's not

1499:14

the case so now underneath that we have

1499:16

to show the score and stop the quiz so

1499:19

I'll just return the show score come on

1499:21

the show score oh my God show score and

1499:24

here we have to set there to true and

1499:26

also we have to return the score we have

1499:29

to move to the next question so we going

1499:31

to be returning the current question

1499:33

current come on current question and

1499:36

then that's going to be equals to the

1499:37

st. current question + one so now let me

1499:40

just save my file so this is how we

1499:42

going to be moving into the next

1499:44

question and now let me just hide there

1499:47

from here just like that now let's start

1499:49

working on this this previous question

1499:50

so I'm going to go ahead and remove them

1499:52

and use the set method and for this set

1499:55

method it's going to take a state as a

1499:57

perimeter and inside there we're going

1499:59

to be getting the current question God

1500:01

damn it what the hell was that we're

1500:02

going to be getting the current question

1500:05

and now for this current question we are

1500:06

going to be getting the maximum withd so

1500:08

I'll use like math. Max and here we have

1500:11

to use the state do current question

1500:14

minus one so this going of gives us the

1500:16

last question then we have to provide a

1500:18

zero for the accumulated variable

1500:20

so that's done and finally we have to

1500:21

create our reset quiz function it's

1500:23

going to just basically reset our entire

1500:25

quiz so I'm going to be using a set and

1500:28

here what do we have to do I'm going to

1500:30

just use this curly braces and the

1500:32

current question let's just write a

1500:34

current question and the current

1500:36

question will be set to zero the answers

1500:38

will be set to array dot I like array

1500:41

three and fill them with null values and

1500:44

also we're going to be providing a score

1500:45

and the score will be set to zero in the

1500:47

show score come on show score

1500:50

will be also set to false now this is

1500:52

how we are going to be creating our

1500:53

state I'm going to also go ahead and

1500:55

annotate with this quiz state so I'll

1500:58

just annotate that with this quate and

1501:00

finally we have to export this so we can

1501:02

use that in other file so I'm going to

1501:04

be using like export default then use

1501:06

quiz store this is s file but why in the

1501:09

word we are getting this error and I

1501:11

just realized that I only made this

1501:13

single mistake I have to provide this s

1501:16

and as soon as I do that here you can

1501:19

see all of that errors are now

1501:20

successfully gone so yeah you have to

1501:24

provide this s with this questions and

1501:26

this is how we're going to be defining

1501:28

or quiz store that's done I'm going to

1501:30

go ahead and go to my SRC and Define a

1501:33

components folder so I'll use like the

1501:35

components and inside there we have to

1501:37

define a few components so I'm going to

1501:39

be first of all creating a quiz layout.

1501:41

TSX I'm going to be also creating a

1501:43

sidebar. TSX and also the question come

1501:46

on question. or yeah question. TSX would

1501:50

be fine now let me go ahead and go to my

1501:52

quiz layout and I'm going to be using

1501:54

rafc inside rafc inside the sidebar and

1501:57

also RFC inside the question so you know

1502:01

what let's just start working on our

1502:02

quiz layout and I'm going to also go

1502:05

ahead and go to my app and registered

1502:06

that right here so I'll just remove that

1502:09

and render my quiz layout so let's just

1502:11

use our quiz layout and render there

1502:14

right here now let me go ahead and go to

1502:16

my quiz layout and the first thing that

1502:17

I would do is that I'm going to specify

1502:19

the classes so class will be set to flex

1502:21

and height will be set to to screen

1502:23

remove there and render my sidebar

1502:25

inside there and close there now

1502:27

underneath them we have to define a d

1502:29

with the class of flex of one and also

1502:32

flex and flex will be set to to the

1502:34

column items will be set to Center and

1502:36

justify come on justify will be set to

1502:39

Center and inside there we have to

1502:40

render our question and close there and

1502:42

now as soon as I do there here you can

1502:44

see we're now getting this layout where

1502:46

we have our question and also our

1502:48

sidebar let's just go ahead and go to

1502:50

our sidebar and start working on our

1502:52

sidebar so what we have to do first of

1502:54

all we have to import the use quiz or

1502:57

you know what we are going to be

1502:59

importing the use quiz tour this is how

1503:02

we're going to be doing them next we

1503:04

have to destructure a few things from

1503:05

there so we are going to be

1503:07

restructuring there from the use quiz

1503:09

store so what are the things that we

1503:10

would need we would need the questions

1503:12

and also the current question inside

1503:15

this component now let me go ahead and

1503:17

go to my UI and first of all we're going

1503:19

to be attaching the class and the class

1503:20

will be set to with 1 over four and also

1503:23

background gray of 100 adding all around

1503:26

will be set to four inside there we have

1503:28

to use our H2 and then the text will be

1503:30

set to extra large margin for the bottom

1503:32

will be set to four and we're going to

1503:34

be saying like quiz progress underneath

1503:37

that we have to create our ul and for

1503:39

this UL we're going to beting over

1503:41

through all of our questions which we

1503:42

are now getting from this store so you

1503:44

know let me just show you there we're

1503:46

going to be iterating over through all

1503:47

of their questions so what I'm going to

1503:49

do I'm going to be using the map method

1503:51

and on this map method we don't need the

1503:53

data but we only need the index so now

1503:56

inside there we have to use our Ali and

1503:58

for each Ali we're going to be

1504:00

specifying the key and the key will be

1504:01

set to this index and I'm going to be

1504:03

attaching the class name and margin for

1504:04

the bottom will be set to two F and

1504:06

items will be set to Center Center there

1504:09

we go inside there we have to render our

1504:12

react icon so I'm going to go ahead and

1504:14

uh install the npmi react icons so it's

1504:17

going to install the inside my project

1504:20

now that's successfully done so I'm

1504:21

going to be using npm run Dev once again

1504:23

now we can use the fa check circle come

1504:26

on so it's going to gives us that F

1504:27

check circle now we can specify our

1504:30

classes toly dynamically so margin for

1504:32

the right will be set to two and here we

1504:34

have to render our classes toally

1504:36

dynamically so if our index by which we

1504:38

are now iterating over through is less

1504:40

than or equal to the current question so

1504:43

in this situation we're going to be

1504:44

changing the text to totally green of

1504:46

500 but if that's not the case we are

1504:48

going to be setting that to text Gray of

1504:50

400 so now let me just save my file and

1504:53

now underneath there we have to Define

1504:54

our span so I'll use like question and

1504:57

here we have to just render our index +

1505:00

one and that's going to be it so now let

1505:02

me just save my file and here you can

1505:03

see we now getting all the four

1505:05

questions and we don't have any buttons

1505:07

so we can increment through there we

1505:09

will see that in a few second but there

1505:11

was there about four or quiz sidebar now

1505:14

let me go ahead and go to my questions

1505:16

and inside there we're going to be doing

1505:18

craziness so first of all we're going to

1505:20

be importing our use quiz store inside

1505:22

there we're going to be destructuring a

1505:24

lot of things so I'll just destructure

1505:25

there right away so I'll use like not

1505:28

the used St but the use Quest store and

1505:31

execute the and from this use quiz store

1505:33

we're going to be getting all of the

1505:34

questions the current question the

1505:36

select answer the answers and also the

1505:39

next question previous question and the

1505:43

show score and just a score and also the

1505:47

reset quiz that's done I'm going to semi

1505:50

file and now we have to use the inside

1505:51

our UI now let me go ahead and go to my

1505:54

UI and here I'm going to provide the

1505:56

class names and this is proide our with

1505:58

first of all and we're going to be also

1505:59

attaching the padding and ping will be

1506:02

set to six all around proide our H3 and

1506:05

it's going to say like text will be set

1506:06

to 2 XEL the font will be set to semi

1506:09

board and inside there we have to render

1506:10

our question question like so so this is

1506:13

use our question that's going to be it

1506:16

I'm going to also go ahead and go there

1506:18

and first of all we going to be making a

1506:20

question so how are we going to be doing

1506:22

there we're going to be getting all of

1506:23

our questions and from this question we

1506:25

want to get the current question out of

1506:27

there and I'm going to store that inside

1506:29

the question variable and that's going

1506:30

to be it I'm going to also get the

1506:32

current answer so I'm going to just use

1506:34

that same technique and provide my

1506:36

current question inside there and now we

1506:38

going to be storing the inside the

1506:39

current answer or yeah answer would be

1506:42

fine let me just save my file and go to

1506:45

my UI once again and here I'm going to

1506:47

be using H3 with the classes of text to

1506:49

Excel and the font will be set to semi

1506:52

bold and here we have to use our

1506:54

question. question which means like now

1506:57

we are getting this question and we are

1506:59

now getting a specific current question

1507:01

out of there and here you can see we're

1507:02

now getting there like what does CSS

1507:04

stand for now underneath there we have

1507:06

to provide our options so I'll just use

1507:08

like a d with the class of margin for

1507:09

top will be set to four and now here we

1507:12

have to use our question do options and

1507:15

now let's just iterate over through all

1507:16

of our options so I'm going to be using

1507:18

like import my index inside there and

1507:20

here inside there we have to use our D

1507:22

once again and provide my key and the

1507:24

key will be set to that index I'm going

1507:26

to also specify the class name and

1507:28

margin for the y axis will be set to two

1507:30

inside there we have to provide our

1507:31

label and for this label uh we're not

1507:33

going to be providing any HTML for to

1507:35

them so I'll just use like the class

1507:36

name and the class names will be set to

1507:38

flex and items will also be set to

1507:40

Center and inside this label we have to

1507:42

Define our input field with the type of

1507:44

radio and also uh we are going to be

1507:47

attaching the name so the name will be

1507:48

set to this random name okay so we're

1507:51

going to be attaching that to

1507:52

dynamically so I'll use like question

1507:55

and here we have to attach our current

1507:57

question not answer but current question

1508:00

inside there we also have to provide the

1508:02

check state so for the check State we're

1508:04

going to be checking like if the current

1508:06

answer is equal to this index which we

1508:08

are now getting from this iteration

1508:11

right here and then when somebody try to

1508:12

type something inside there or change

1508:14

something inside there we're going to be

1508:16

firing this function which is a handle

1508:18

select and here here we have to specify

1508:20

come on the handle select and here we

1508:22

have to specify our index inside there

1508:24

which we going to be creating in a few

1508:26

seconds and I'm going to also specify

1508:27

margin for the right of two now let me

1508:29

just sve my file and now underneath

1508:31

there we also have to render for each

1508:34

option so I'm going to be using like

1508:35

option and now let me just comment this

1508:38

line out and here you can see we're now

1508:39

getting like what does CSS stand for and

1508:41

you can now choose your answers from

1508:43

here so you know what let me just create

1508:45

this function right away so I'm going to

1508:47

copy the name of there and go to the top

1508:49

and and here we're going to be defining

1508:50

our function I'll use like const and

1508:53

then handle select and here it's going

1508:55

to take the option index and we have to

1508:58

annotate that with any because we don't

1508:59

know and now inside there we going to be

1509:02

using the select answer and put my

1509:04

option index inside there that's done I

1509:07

can choose like a scating style sheet

1509:09

but now allows us to select there

1509:10

underneath there we have to create our

1509:12

buttons so what am I going to do

1509:14

underneath this one uh I'm going to be

1509:16

refining yet another D so I'll just give

1509:18

it the class of margin for top of six

1509:21

inside there we have to get our current

1509:23

question not answer but current question

1509:26

and if that is greater than zero then we

1509:28

want to show this UI but if that's not

1509:30

greater than zero then we don't want to

1509:32

show this button or this UI so I'll just

1509:34

use a button and here it's going to say

1509:36

like previous and now we're going to be

1509:38

attaching these classes to it all use

1509:40

like margin for the right of ping for

1509:41

the xais of four pairing for the y axis

1509:44

of two background gray of 500 and we

1509:47

also have to provide a text of toly

1509:48

white to that rounded and when somebody

1509:51

have over there we want to change the

1509:52

background to gray of 600 and also when

1509:56

somebody clicks on there we're going to

1509:57

be firing this function so when somebody

1509:59

clicks on there this is create our

1510:01

previous question function right here so

1510:03

previous question there we go I'm going

1510:05

to save this file and we cannot see that

1510:08

button because we have to select some

1510:09

sort of answer then it will show us that

1510:12

UI so that's also done now underneath

1510:14

this de we're going to be also creating

1510:16

our next button so to do that we're

1510:19

going to be first of all checking like

1510:20

if we have the current question if our

1510:23

current question is less than the

1510:25

questions. length minus one come on L

1510:28

GTH minus one which means like it's

1510:30

going to gives us the last question so

1510:33

it should be questions rather than just

1510:35

a question singular okay so if that's

1510:38

the case so we're going to be using this

1510:39

UI but if that's not the case then we

1510:41

are going to be providing this UI so

1510:43

I'll just use like uh these react

1510:45

fragments and close them and now let's

1510:47

just take care of this first y so I'm

1510:49

going to go ahead and create my button

1510:51

and inside this button I'm going to

1510:53

select next and now let me just attach

1510:55

my classes to there so I'll just use

1510:57

like class names pairing for the xaxis

1510:59

will be set to four pairing for the Y

1511:01

AIS will be set to two background blue

1511:03

500 text white round it when somebody

1511:06

have over there so change the background

1511:08

to totally blue of 600 and when somebody

1511:11

clicks on there then fire this function

1511:13

so I'll just use like when somebody

1511:15

click on there we're going to be finding

1511:16

the next question function and here you

1511:18

can see we are now getting our next

1511:20

question I can choose like a scaring

1511:22

style sheet and click on there and here

1511:24

you can see it's going to brings us to

1511:25

the next question but this UI is looking

1511:28

awful yeah I got to give you that one UI

1511:31

is looking super awful but anyways now

1511:33

let's just take care of this uh fragment

1511:35

I'm going to just remove there and

1511:37

change there to this button be providing

1511:39

the submit and now let's just attach our

1511:41

on click event handler and let's just

1511:44

put our handle submit function to this

1511:46

so handle come on handle submit function

1511:50

which we are going to be creating in a

1511:51

few second and now let me just also

1511:52

providing our class names ping for the Y

1511:54

AIS will be set to two background green

1511:57

of 500 Tex totally white and round it

1512:01

when somebody H over this we want to

1512:02

change the background to totally green

1512:04

of 600 this is our file copy the name of

1512:08

there and Define our function at the top

1512:11

right here so I'll just create a simple

1512:13

function which will be a handle submit

1512:16

and inside there we going to be only

1512:18

using the next question like so and yeah

1512:21

we can now definitely go ahead and go to

1512:23

the next question I can choose the

1512:25

cascading style sheet and click on there

1512:26

it's going to brings us to this next

1512:28

question it's going to also gives us

1512:30

that question two right here so what

1512:32

does http stand for http stand for hyper

1512:36

text transfer protocol and now let me

1512:38

just choose the which language is

1512:40

primarily used for the web scrapping or

1512:42

scripting rather not scraping so I'm

1512:44

going to choose JavaScript and click on

1512:46

the next and what does SQL for so

1512:49

structure query language like so and

1512:53

finally what is the main function of the

1512:55

web server to serve the web pages to the

1512:57

client next and which company developed

1512:59

the Java programming language Sun micro

1513:02

system so now let me just click on the

1513:04

next one and what is the purpose of

1513:06

title tag in HTML you create a new

1513:08

section to define the title of the web

1513:10

page yep click on the next one what does

1513:12

API stand for so application programming

1513:15

interface there we go I'm going to

1513:17

choose the and what is the purpose of of

1513:19

database index create a backup and click

1513:21

on the next one finally uh which

1513:24

protocol is commonly used to secure

1513:26

communication or the internet https

1513:29

submit the oh we cannot see the result

1513:32

because okay we cannot see the result I

1513:34

don't know why but there might be

1513:36

something wrong and you know what the

1513:38

problem was the problem was super awful

1513:42

here we also have to create a separate

1513:44

page for there we're not going to be

1513:46

using a react router but we're going to

1513:48

be checking like if we have the show

1513:49

score so in this situation we are going

1513:51

to be returning this UI okay so first of

1513:54

all we're going to be returning our div

1513:56

and this div will have the same width so

1513:58

let's just s that three and four and

1514:01

pairing all around will be set to six

1514:03

inside them this's is use our H2 and

1514:05

here we're going to be providing like

1514:06

text of 2 XEL and the font will be set

1514:09

to semi bold it's going to say like your

1514:12

score now let me just save my file and

1514:14

here you can see we're now getting our

1514:16

Ur score and also now underneath that we

1514:18

have to create a paragraph which will

1514:20

have margin for top of four and TT of

1514:22

totally large and it's going to say like

1514:24

you scor this amount so let's just

1514:27

render our score out of these questions

1514:31

so I'll use like questions. length Okay

1514:34

so I'm going to S my file and here you

1514:35

can see it's going to give us like my

1514:37

score finally we can also restart our

1514:39

question all use like the button and

1514:41

here we can use our you know what let's

1514:43

just write or restart restart quiz there

1514:47

we go and we can also Al specify our

1514:49

classes so margin for top will be set to

1514:52

six pairing for the xaxis of four

1514:54

pairing for the y axis of two background

1514:56

toly blue of 500 and text will be set to

1515:00

totally white rounded and when somebody

1515:02

have over there so let's just change the

1515:03

background color to totally 600 and now

1515:06

let me just save my file and here you

1515:08

can see we're now getting this button

1515:10

and when somebody clicks on this button

1515:12

so I'll use like on click so we just

1515:14

want to reset the quiz like so so if I

1515:18

click on there here you can see it's

1515:19

going to gives us all of their questions

1515:21

back so I can choose different kind of

1515:23

questions like totally randomly it's

1515:25

going to gives us all of their questions

1515:27

right here okay and finally it's going

1515:30

to show us our score so I'm just

1515:33

choosing random ones right here so it's

1515:35

going to give us like I only score one

1515:37

out of 10 we can also restart our quiz

1515:40

yep that's cool and you know what I'm

1515:42

going to also make the as a flex so I'll

1515:45

use like you know if I hide there I'm

1515:47

going to cut there from here like this

1515:50

entire thing let me just cut that from

1515:52

here go to my margin top and now we have

1515:56

to provide there right in here say my

1515:59

file I click on that yeah that's looking

1516:01

better now we are getting our previous

1516:02

button and also our next button right

1516:05

here so finally let me just click on the

1516:07

submit and yeah this is how we're going

1516:09

to be creating our quiz app I will shred

1516:11

this universe down to its last arum and

1516:13

then with the stones that you've

1516:15

collected for me create a new one it is

1516:17

not what has been lost but but only what

1516:19

has been given a Greatful

1516:22

Universe yeah that was a small little

1516:24

Thanos wice I am going to do that like I

1516:28

am going to destroy this entire universe

1516:30

like shred them all and then I'm going

1516:32

to create a new universe there will be

1516:33

only react developers nobody else is

1516:35

allowed in my

1516:37

universe so now let's just make a setup

1516:39

forward final boss and here I'm going to

1516:43

be making it let me just make that a bit

1516:45

bigger so you guys can see everything a

1516:47

bit better and then I'm going to just

1516:48

use npm create and then we at latest

1516:52

watch store will be the name of my

1516:54

project I'm going to choose reactjs and

1516:56

typescript let's just go into the watch

1516:58

store and now let me just use npmi to

1517:01

install all of the packages that's done

1517:03

I'm going to also install zustan by

1517:05

using npm install

1517:07

Zeus and now let's just install them

1517:10

then successfully done now let me go

1517:11

ahead and search for the TN CSS and I'm

1517:15

going to click on there go to the

1517:17

framework and guides and I'm going to go

1517:19

to the weed and copy this command I'm

1517:22

going to open my vs code by using Code

1517:24

dot let me just zoom in a bit and the

1517:25

first thing that I want to do is that I

1517:27

want to install the tailin CSS inside my

1517:29

project so now let me just place this

1517:31

command I'm going to also hit enter so

1517:32

it's going to initialize my tailin CSS

1517:35

and now I'm going to remove the public

1517:36

folder let's just go ahead and go to the

1517:38

SRC and remove the SS folder the app.

1517:41

CSS folder and remove every single thing

1517:43

from the ab. TSX file I'm going to go

1517:46

into the index.css remove every single

1517:48

thing from there

1517:49

and I'm going to copy this content just

1517:51

a content and now let me go ahead and go

1517:53

to my tman config file and replace it

1517:56

with this new one I'm going to also copy

1517:58

there and place that right here and also

1518:01

let me just test this out so I'm going

1518:02

to copy that and replace it with this D

1518:06

I'm going to use npm run de so that's

1518:08

going to run there let's just test this

1518:09

out by going into our local host and

1518:12

yeah it is working the way we expect him

1518:13

to work there are also a few things that

1518:15

I want to add in this SRC folder okay so

1518:17

first of all we're going to be adding

1518:19

the DB file and then we're going to be

1518:21

also adding this assets file inside this

1518:23

assets folder we have a lot of images

1518:26

okay so which we are going to be using

1518:27

inside this project and if you want to

1518:29

use these same images you can definitely

1518:31

go ahead and go to my gab repository and

1518:33

copy all of the styles from there now

1518:35

let me show you this data.js file okay

1518:37

so here we are just importing all of our

1518:40

images right here and then we have our

1518:42

actual data so this data will be our

1518:44

array and inside this array we will have

1518:46

a few objects so inside each object is

1518:48

going to have the ID the image like the

1518:51

black image Brown image red image and

1518:53

also the white image and we would also

1518:55

provide some sort of a title to them and

1518:57

also the pricing company and the country

1519:00

okay so we have a lot of data and you

1519:01

are more than welcome to add more data

1519:03

to there if you wanted to so yeah now

1519:06

let me just close there and that was our

1519:08

entire setup now let's start working on

1519:10

our store so the first thing that I'm

1519:11

going to do is that I'm going to create

1519:13

a folder with the name of store and

1519:14

inside there we're going to be creating

1519:15

a file with the name of store. inside

1519:18

there we are going to be importing the

1519:19

create function from where from our

1519:21

zustan library that's going to be the

1519:23

first thing now I'm going to place a few

1519:25

interfaces right here and if you care

1519:27

about these interfaces you can

1519:28

definitely go ahead and go to my guub

1519:30

repository and copy these interfaces

1519:32

from there so basically we're just

1519:33

creating our product State and also

1519:35

setting the product image and when

1519:37

somebody H over the product and

1519:39

initializing the product then we are

1519:41

creating a filter State and for this

1519:43

filter set we're going to be providing

1519:44

the selected country the selected color

1519:47

selected price range and now we're just

1519:49

creating a functions for there that's

1519:50

done now let's just start working on our

1519:52

use product store uh hook so I'm going

1519:54

to go ahead and just export there right

1519:56

away and now let's just create our use

1519:58

product and then stor going to be equals

1520:00

to this create function and now we are

1520:02

going to be annotating there with our

1520:04

product State and close there now here

1520:06

we're going to be defining the set

1520:08

method and inside the set method let's

1520:10

just start working on there so I'm going

1520:12

to just provide like the product States

1520:14

and here for this product State we're

1520:16

going to be sing there to empty object

1520:17

now we are going to be also defining

1520:19

what function for setting the product

1520:20

image so I'm going to use like set

1520:22

product it's going to be taking the

1520:23

perimeter of product ID not this one but

1520:26

product ID and also the image itself now

1520:29

inside there we're going to be using the

1520:30

set method and this set method will take

1520:32

the state as object or not object but as

1520:34

a perimeter what the hell am I saying

1520:36

today so inside there first of all we

1520:38

are going to be using our product State

1520:40

and our product state will be coming

1520:41

from our state come on state. product

1520:44

State like so and now we are going to be

1520:47

adding our new product to this so I'll

1520:48

just use like product ID and that's

1520:51

going to be equals to this dot dot dot

1520:53

let's just clone our existing state do

1520:55

product States and here we're going to

1520:57

be providing our product ID to there we

1520:59

would also need to specify our current

1521:01

image yes so for this current image

1521:03

we're going to be providing our image to

1521:05

there which we are now taking as a

1521:06

perimeter and now we are passing that to

1521:09

our current image so that's going to be

1521:10

it for setting the product image so I'm

1521:12

going to collapse there now underneath

1521:14

there we're going to be creating a

1521:15

function for set product how so when how

1521:19

over our product so what do we want to

1521:20

do in this situation we just want to

1521:22

write like product ID and also the how

1521:24

so now inside there we going to be using

1521:26

our state once again set method and

1521:28

provide your state to them and here

1521:30

inside them we're going to be getting

1521:32

like the product State and that product

1521:34

state will have the object and now we

1521:36

are going to be getting there by using

1521:37

the state. product State and now once

1521:40

again we have to specify our product ID

1521:43

which we are now taking as a perimeter

1521:45

and now we have to set there to first of

1521:47

all we have to clone our existing

1521:49

product. state and here we have to

1521:51

specify that product ID and then we're

1521:53

going to be providing our how state to

1521:55

there which we are also taking as a

1521:57

perimeter and that's also done I'm going

1521:59

to also collapse that next we have to

1522:01

provide our initialized product okay so

1522:03

I'm going to use like initialize product

1522:05

and for that it's going to also take the

1522:07

product ID and also the initial image

1522:10

not Infinity work God damn it product ID

1522:13

and also the initial image and here we

1522:17

are going to be using that set method

1522:18

once again and provide our state to them

1522:20

and we're going to be using that same

1522:22

exact syntax and now let me just provide

1522:24

like first of all make a clone of our

1522:26

state and then product State God damn it

1522:28

product State and now here we are going

1522:30

to be also providing our product ID

1522:32

today which we are now taking as a

1522:34

preter and that's going to be set to our

1522:36

current image and our current image will

1522:38

be set to this initial image so I'm

1522:40

going to copy that and place it right

1522:41

here right a comma and for the how set

1522:44

we're going to be setting that to false

1522:46

that's toly done and now we have to

1522:48

lamps there the next thing that we have

1522:49

to do is that we have to create yet

1522:51

another hook so let's just use like

1522:53

export cons and then use filter store

1522:56

because we're going to be also filtering

1522:57

our products just provide the create

1522:59

function and we have to annotate there

1523:01

with our filter State and close there

1523:03

inside this one we going to be providing

1523:05

our state and here we're going to be

1523:07

first of all providing the selected

1523:09

country and the initial value will be

1523:10

set to empty string like uh just array

1523:13

and also we're going to be providing the

1523:14

selected color and it's going to be also

1523:16

set to not countries what theck now so

1523:19

here inside there we're going to be

1523:20

providing the selected country not color

1523:22

but countries like so and the initial

1523:25

value will be set to empty array we are

1523:27

going to be also providing the selected

1523:29

uh selected color it's going to be also

1523:32

set to this empty array and now for the

1523:34

selected price range the initial value

1523:37

will be set to now and now let's just

1523:39

provide our function to there so now

1523:40

underneath we are going to be using like

1523:42

set selected uh country so this going to

1523:45

allows us to select our country and

1523:46

filter there so here we we're going to

1523:48

be passing our countries like that and

1523:51

now we have to use the set method and

1523:52

for this set method we're going to be

1523:54

providing the selected countries we have

1523:57

to set there to this countries which we

1523:59

are now taking as a perimeter and now we

1524:01

have to specify them right here I'm

1524:03

going to also provide a comma there now

1524:05

we have to use the set selected colors

1524:07

in this case and now it's going to take

1524:10

a colors as a perimeter and inside there

1524:12

we are going to be once again using our

1524:13

set method and here we have to specify

1524:15

our selected colors and now we are going

1524:17

to be set there to this colors which we

1524:19

are now taking as a perimeter that's

1524:21

also done I'm going to also specify a

1524:22

comma there now let's just create a

1524:24

function for the select ice range and

1524:26

for this selected price price range is

1524:28

going to take a range as a perimet and

1524:30

now we are going to be using the set

1524:31

method once again and here we have to

1524:33

use the selected price range and provide

1524:36

the range which we are now taking as a

1524:38

perimeter right here I'm going to also

1524:40

provide a comma now we have to finally

1524:42

create a clear filters function and

1524:44

inside this clear filters function we're

1524:46

going to be using this set method once

1524:48

again and now we are going to be just

1524:49

clearing out every single thing so I'll

1524:51

use like uh clear countries countries

1524:54

and we have to set there to empty object

1524:56

we like empty array and also for the

1524:58

selected colors we have to set there to

1525:00

empty array and finally for the selected

1525:02

price range we have to set there to n

1525:05

that's also done so this is what we have

1525:06

to do right now and if you want to copy

1525:08

these interfaces you can definitely go

1525:10

ahead and go to my guub repository and

1525:12

yeah this is how we are going to be

1525:13

creating our hooks for our project and

1525:15

that's it okay so now let's get into our

1525:17

UI and that's going to be a lot of fun

1525:19

so what I'm going to do is that I'm

1525:20

going to create a folder for the

1525:22

components components like them and

1525:25

inside there we're going to be creating

1525:26

three component first of all we're going

1525:28

to be creating a component for the

1525:29

navigation n AIG g a o n. TSX and also

1525:33

the product card. TSX and also the

1525:37

sidebar. TSX I'm going to go ahead and

1525:40

just write the rafc inside this

1525:42

component rafc inside that component and

1525:44

also RFC inside the sidebar now let me

1525:47

just go ahead and go to my app and

1525:49

register my sidebar right here first of

1525:52

all we are going to be using the sidebar

1525:53

and close there and now inside this

1525:56

sidebar we're going to be calling our

1525:58

navigation component so I'll just use

1526:00

like navigation and close there and now

1526:03

let's get into the navigation component

1526:05

and start working on there so for this

1526:07

navigation component we're not going to

1526:08

be doing anything crazy I'm going to

1526:10

provide the class names and Marg pH top

1526:12

will be set to Two Rim and also it's

1526:14

going to be set to container withd will

1526:16

be set to 90%

1526:18

and I'm going to also provide margin for

1526:20

the left of five frames close there and

1526:22

it's going to be set to to flex and

1526:25

justify will be set to to between e WWE

1526:29

and and items will be also set to toly

1526:30

Center inside this D we have to Define

1526:33

our h14 or logo so I'll just provide a

1526:35

class of logo and inside this H1 we're

1526:37

going to be rendering our iio or you

1526:40

know what we first of all have to

1526:41

install our icons so I'll just stop

1526:44

there and I'm going to be using npmi and

1526:46

react icons so it's going to install

1526:48

there inside this project so that's done

1526:50

I'm going to use npm run there one more

1526:52

time so it's going to run there inside

1526:54

there we have to use our IO filter

1526:57

outline okay let's just grab that and

1526:59

close there and here we have to specify

1527:01

the size and the size will be set to 27

1527:04

and also we going to be providing the

1527:05

class names and the class name will be

1527:07

set to margin for the left off and

1527:09

cursor will be set will be set to

1527:11

pointer now let me just save my file

1527:13

that's also done now underneath this H1

1527:15

we are going to be defining our

1527:16

navigation so inside this navigation we

1527:17

have to our UL it's going to have the

1527:19

class of F and also the items will be

1527:21

set to our L Center and margin for the

1527:24

right will be an arbitrary value so I'll

1527:26

just write like two R and close the

1527:29

spaces on the xaxis will be set to four

1527:31

and inside this Ur we have for our Li

1527:34

and we have to write like search help

1527:36

and also my accounts like so or just

1527:40

account would be fine and now underneath

1527:42

this navigation we're going to be also

1527:44

rendering our iio back outline and here

1527:47

we have to close there and provide the

1527:50

size of 24 to there now let me just save

1527:52

my file and test this out so here you

1527:54

can see this is how our navigation looks

1527:56

like we're going to be also taking care

1527:58

of this icon in a few seconds but yeah

1528:01

that's looking cool now let's start

1528:02

working on our product card so first of

1528:04

all we have to go ahead and go to our

1528:06

app and grab all of the data so I'm

1528:08

going to go ahead and just import the

1528:09

data from where from let's just go into

1528:14

our DB file and inside there we have our

1528:16

data.js file okay so now if I log that

1528:19

to the console so I'll just use the data

1528:21

save my file and now I'm going to go

1528:23

ahead and go to my console and we are

1528:25

now getting this array and inside this

1528:27

array we have all of our data which is

1528:29

looking cool now what I'm going to do is

1528:31

that I'm going to cut this sidebar from

1528:33

here and I'll just use the react

1528:35

fragments and inside these react

1528:37

fragments uh I'm going to pass my

1528:39

sidebar and now underneath this sidebar

1528:41

we're going to be creating a de with the

1528:42

class of pairing all around will be set

1528:43

to four flex and the flex will be set to

1528:45

wrap and justify will be set to toly

1528:47

Center and items will also be set to

1528:50

totally Center inside there we have to

1528:52

render our product card okay so I'm

1528:55

going to just render that right here I'm

1528:56

going to put the product as a prop and

1528:58

their product will be all of their data

1529:00

so now let me go ahead and go to my

1529:02

product card and I'm going to

1529:04

destructure there right here so I'm

1529:06

going to use like product and the first

1529:07

thing that I want to do is that I want

1529:09

to log there to the console so I'll use

1529:10

like

1529:11

console.log and data coming from the

1529:15

product come on product card uh JS file

1529:19

or TSX file and I'm going to render all

1529:21

of that product right here save my file

1529:23

now let me just open my terminal and

1529:25

close the tment CSS going to the console

1529:28

now let me just refresh there and yeah

1529:29

we are now getting all of their data

1529:31

which is looking cool the next thing

1529:33

that I want to do is that I want to

1529:34

remove them and here you can see we're

1529:35

also getting our product card so what

1529:38

I'm going to do is that I'm going to

1529:39

Define an interface for there so I'll

1529:40

just go to the top and Define the

1529:42

interface so I'll just use like the

1529:44

interface and product and inside there

1529:46

we have to provide the ID and the ID

1529:47

will be set to string the title will

1529:49

also be set to string so let's just

1529:51

provide our string and also the price

1529:53

will be set to a number and also I'm

1529:55

going to provide the image and for this

1529:57

image it going to be providing a black

1529:59

and black will be a string and we have

1530:00

to just provide the as a property and

1530:03

here for the key the key will be set to

1530:05

a string and also outside from there

1530:07

it's going to be set to a string now I'm

1530:09

going to Define yet another interface so

1530:11

I'll just use like interface and I'm

1530:13

going to give it the name of like

1530:14

product card props or something like

1530:16

that and inside this interace we're

1530:18

going to be setting the product and that

1530:20

product which we just Define up above

1530:22

like this one so I'm going to copy the

1530:23

name of them and now let me just inate

1530:25

my products with this product right here

1530:28

not like this but this so now let me

1530:30

just save my file and this is what we

1530:32

have to do right now the next thing that

1530:33

we have to do that we have to go to the

1530:35

top and grab our store so I'm going to

1530:37

go ahead and go to the top and use the

1530:38

used product store grab there I'm going

1530:40

to copy a name up there now we are going

1530:42

to be destructuring a lot of things from

1530:44

there so I'll just use like cons and

1530:46

then the destructuring syntax

1530:48

now it's going to be equals to this use

1530:49

product store okay so inside there we

1530:51

are going to be first of all

1530:52

destructuring the product State and also

1530:55

the set product image uh not how but set

1530:58

product image like this one and I'm

1531:00

going to also destructure the set

1531:02

product how when somebody how over there

1531:04

and also the initialized product I'm

1531:06

going to save this file now we have to

1531:07

Define our Global variables which we are

1531:09

going to be using inside this component

1531:11

so I'll use like product State it's

1531:13

going to be equals to this uh product

1531:15

State once again which we now

1531:16

destructuring from from our store and

1531:19

here we have to specify this product. ID

1531:21

which we are going to be getting from

1531:23

this product from our entire database so

1531:25

it's going to be either set to this data

1531:27

or it's going to be set to empty object

1531:29

in some situation okay so I'll also grab

1531:32

the current image and it's going to be

1531:34

equals to the product State on product

1531:37

State and we going to be getting the

1531:38

current property from there the current

1531:40

image property if that's not the case

1531:43

we're going to be getting the product.

1531:44

image. black okay so now let me just

1531:47

save my file and now we going to be also

1531:48

creating a variable for the h so when

1531:51

somebody how over this we're going to be

1531:52

getting that from the product state. how

1531:55

if that's not the case we are going to

1531:56

be initially setting the to FS I'm going

1531:59

to also create a state for the images

1532:01

and it's going to be equals to the

1532:02

object do values and here we have to

1532:04

specify the product. image I'm going to

1532:07

save my file right now now underneath

1532:09

that we have to initialize the state

1532:11

when the component first renders so

1532:13

which means like we are going to be

1532:14

performing the side effect so I'm going

1532:16

to be using the use effect for there

1532:18

okay so what I'm going to do is that I'm

1532:19

going to provide a comma there and here

1532:21

we have to specify the product. ID and

1532:24

also the product. image black and also

1532:27

the initial product right here okay so

1532:30

what we have to do inside them we are

1532:31

going to be providing our initial

1532:33

product and now here we have to specify

1532:35

the product. ID and also the product.

1532:37

image. black I'm going to save my file

1532:40

right now like this now let's start

1532:42

working on Ori so first of all I'm going

1532:44

to go ahead and provide a classes today

1532:45

so I'll use like this going to be set to

1532:47

relative

1532:48

relative and width will be set to 20 rim

1532:51

and also margin all around will be set

1532:53

to one rim and Border will be set to

1532:56

this color which is a EC EC EC EC like

1532:59

this and I'm going to also close there

1533:01

margin for the left will be set to three

1533:03

rim and also close there weiring all

1533:05

around will be set to four and now

1533:07

inside this div uh what we have to do or

1533:09

you know what first of all we're going

1533:10

to be also attaching the event handler

1533:12

on there what you know we are going to

1533:13

be doing there in a few second but now

1533:15

let's just take care of the UI I'm going

1533:16

to Define another D with a class of

1533:18

relative and also background will be set

1533:20

to to gr of 200 pairing all around will

1533:22

be set to four and inside this div it

1533:25

going be working with our image so for

1533:26

the image which will be coming from the

1533:29

current come on the current image and

1533:31

here for the alternative text we going

1533:33

to be also providing the product. title

1533:36

like so and now let me just save there

1533:38

here we also have to specify the class

1533:39

names so I'm going to use like object

1533:41

cover and width will be set to 12 FR 12

1533:45

frame like this and height will also be

1533:46

set to 12 r

1533:48

and close there rounded hold medium and

1533:51

margin for the left will be set to one

1533:53

rim and close there and now if I just

1533:55

refresh there we are getting some sort

1533:56

of error so not this one we have to go

1533:59

ahead and go to our inspect element and

1534:01

guess what we are getting some sort of

1534:03

error like cannot read the property of

1534:04

undefined reading the black and I

1534:06

figured out the solution so here you can

1534:08

see I'm now logging to the console this

1534:09

product and now if I show you there if I

1534:12

go ahead and go to my console and here

1534:14

you can see we're now getting these

1534:15

errors and we are now getting our data

1534:17

but look at our data we are now working

1534:19

with the array and inside this array we

1534:20

have our objects and now what am I doing

1534:23

I'm just accessing that image directly

1534:26

from all of our images and that's not

1534:28

allowed which means like we have to

1534:29

iterate over through all of our data and

1534:32

then we would be able to access the

1534:33

image and also that black property from

1534:35

there so what do we have to do I'm going

1534:36

to go ahead and go to my app and here

1534:39

I'm going to itate over through all of

1534:40

our data and then we're going to be ping

1534:42

our data like so so I'll just use like

1534:44

first of all uh my data and did I give

1534:48

it the name of data yes I did and I'm

1534:50

going to be using a map method right

1534:51

here and for this map method it's going

1534:53

to take a and now inside there we have

1534:55

to render our product card now I'm going

1534:57

to copy the name of this product and

1534:58

place it right here and we're going to

1535:00

be also providing a key and that key

1535:02

will be set to product. ID I'm going to

1535:04

save my file right now and here you can

1535:06

see we are now getting all all of our

1535:08

products and now we are getting all of

1535:09

our amazing images which means like

1535:11

everything is working the way we expect

1535:12

him to work so when somebody have over

1535:14

our image so what do you want to do in

1535:16

this situation so right like how and

1535:19

inside there we're going to be creating

1535:20

a div it's going to be an absolute and

1535:22

also the insert will be set to zero flex

1535:25

and items will be set to tot C justify

1535:28

will be between and pairing for the xais

1535:30

will be set to four so inside this t let

1535:32

me just go back uh we are going to be

1535:34

creating a button and this button will

1535:36

have a few classes so first of all I'm

1535:37

going to render my icon which will be fa

1535:40

a this I don't even I can't even

1535:42

pronounce the name of this so shivon

1535:44

left or something like that f a s h e v

1535:48

n left and now let me just grab there

1535:51

and close there we are going to be also

1535:52

providing a class name background will

1535:54

be set to gray of 300 and totally round

1535:57

it full now let me just save my file and

1535:59

here we also have to provide a bit of

1536:01

classes today so I'll say like Carousel

1536:03

button and also T will be set to to Wi

1536:07

save this file and now if I have over

1536:09

there let me just refresh there if I

1536:10

have over there nothing will happen

1536:12

because we also have to provide the on

1536:14

click man Handler today and I'm going to

1536:15

also duplicate this button and change

1536:18

the name of that to the right so I'm

1536:20

going to change that to right and here

1536:23

ENT can also import there and everything

1536:25

else would be the same and now if I have

1536:27

over them nothing will happen now let me

1536:29

go ahead and go to my div and here on

1536:31

this div we have to provide our own

1536:33

Mouse uh Mouse enter and here we have to

1536:36

call this function which will be set

1536:37

product how and here we have to provide

1536:39

our product. ID and also true to there

1536:42

and when somebody leave the mouse so

1536:44

let's just proide like on Mouse leave

1536:46

they're going to be still calling this

1536:47

function like set product how and here

1536:49

we have to specify the product. ID and

1536:51

set there two false I'm going to save

1536:53

this file and now I how over there here

1536:55

you can see we are now getting these

1536:58

icons so now let me just zoom in a bit

1536:59

and here if God damn it and here if I

1537:02

have over there we now getting these

1537:04

icons which is looking cool so I'm going

1537:06

to go back and now let's just start

1537:08

working on the rest of the UI I'm going

1537:10

to also provide all of their titles and

1537:12

stuff so now underneath this D we're

1537:14

going to be creating another da with the

1537:16

class of mar for top and here for the

1537:19

top margin we're going to be providing

1537:21

one RIM today like so I'm going to be

1537:23

using H2 and here we have to render or

1537:25

product. title underneath there we also

1537:28

have to create a paragraph and this

1537:30

paragraph it allows us to render or

1537:32

price I'll use like par product. price

1537:35

and now let me just save my file and

1537:36

here you can see we're now getting the

1537:37

product image the product title and also

1537:40

its price so yeah that was our product

1537:43

card and now let's get into our sidebar

1537:46

not so fast not so first first of all we

1537:48

also have to attach the event handlers

1537:50

on this button and also on this one so

1537:53

what I'm going to do is that when

1537:54

somebody clicks on this button we want

1537:56

to fire this handle come on handle

1537:59

previous function and when somebody

1538:00

clicks on this button then we want to

1538:03

fire this handle next uh function so now

1538:06

let me just save this file and now let

1538:08

me go to the top like this and here we

1538:11

have to Define our function so first of

1538:13

all we're going to be starting from the

1538:14

handle previous function and inside this

1538:17

fun function what we have to do we have

1538:18

to get the images we have to get the

1538:20

current index so I'm going to go ahead

1538:21

and just grab the images and then let's

1538:23

just use the index index off and provide

1538:26

our current uh image inside and now we

1538:29

have to store the inside the current

1538:31

index uh variable as done we also have

1538:34

to get the previous one so I'm going to

1538:35

be using like the previous index and

1538:37

it's going to be equals to uh this

1538:39

current index I mean like not the

1538:41

current image but the current Uh current

1538:43

index which we are now getting now let

1538:44

me just copy that and place it right

1538:46

here and we are now going to be getting

1538:48

the last item then we are going to be

1538:49

attaching the images do length Okay so

1538:52

now we have to divide there so it's

1538:54

going to gives us the remainder as well

1538:56

and now we have to divide there by using

1538:58

images. length Okay so it's going to

1539:00

gives us the previous image and now

1539:01

underneath there what we have to do we

1539:03

have to get the set product image and

1539:05

now inside there we have to Define our

1539:07

product. ID and also the images and now

1539:10

for each images we going to be providing

1539:12

our previous index so now let me just

1539:13

save my file and this should be index

1539:16

off there we go now I'm going to also go

1539:18

to the bottom and now let's just start

1539:20

working on the handle next button so

1539:22

I'll just write like cons handle next

1539:24

and inside this function what do we have

1539:26

to do we have to get the current index

1539:28

and so on and so forth so I'm going to

1539:30

copy that and place it right here so

1539:32

it's going to use us basically the

1539:33

current index and now inside there we

1539:35

have to get the next index and here is

1539:37

going to be equals to this current index

1539:40

plus one then we have to divide there

1539:42

with the images dot come on uh images.

1539:46

length

1539:47

and also we have to use the set product

1539:49

image set product image uh not how God

1539:53

damn it set product image there we go

1539:56

and here we have to specify the product.

1539:58

ID and also on the images we're going to

1540:00

be providing the next index now let me

1540:02

just save my file and if I H over there

1540:04

and if I click on this button so it's

1540:05

going to gives us the next item and now

1540:07

if I click on this one so it's going to

1540:09

gives us the previous item right here

1540:11

okay so which means like it's going to

1540:12

work for all of these images and they

1540:14

are looking super amazing so yeah you

1540:17

can also change there and there's

1540:18

something which I want to show you now

1540:20

let me go ahead and go to the sidebar

1540:22

and start working on this sidebar so I'm

1540:24

going to go to the top and here I'm

1540:25

going to be placing these interfaces and

1540:27

inside this interface we're going to be

1540:28

providing the country image and also the

1540:31

price now inside this sidebar I'm going

1540:33

to go ahead and first of all create my

1540:34

States so I'll use like cons is open and

1540:37

then set is open and it's going to be

1540:39

equals to the use State and the initial

1540:41

value will be set to false and here we

1540:43

also have to enter as a Boolean value

1540:46

now underneath that we also we have to

1540:47

create one for the country drop down and

1540:49

it's going to be set to the set country

1540:52

and now I'm going to set that to the use

1540:54

State and the initial value will be set

1540:55

to false and here we have to provide

1540:57

like Boolean value as well underneath

1541:00

that we also have to create one for the

1541:02

color uh color drop down and set color

1541:06

drop down and it's going to be equals to

1541:08

the use State and the initial value will

1541:10

be set to false and I'm going to also

1541:12

inate as a Boolean like so I'm going to

1541:15

also create one for the price drop down

1541:17

and then set come on set price drop down

1541:21

it's going to be equals to the US St and

1541:23

here for the initial value we're going

1541:25

to be setting there to false and inate

1541:27

as a Boolean value I'm going to save my

1541:29

files so that's going to be at forward

1541:30

State and now underneath there we have

1541:32

to go ahead and first of all grab the uh

1541:35

what do we call it the use filter store

1541:37

I'm going to copy the name of there and

1541:39

now here from the store we're going to

1541:41

be destructuring a lot of things so I'm

1541:42

going to just use the destructuring

1541:44

syntax and we have to destructure the

1541:46

selected country not color but the

1541:48

selected countries and also this come on

1541:52

selected the selected price range set

1541:55

selected country and also set selected

1541:59

color set selected price range and

1542:02

finally we have to grab the clear

1542:04

filters from the I'm going to save this

1542:06

file and now we have to use that inside

1542:08

our UI but before I do that I'm going to

1542:10

also provide a prop for my navigation

1542:12

which will be set to toggle sidebar and

1542:14

here we are going to be passing this

1542:16

toggle side bar function I'm going to

1542:18

copy a name of there and register this

1542:20

function right here so I'm going to use

1542:21

like con toogle sidebar and here we're

1542:24

going to be only using oh my God we are

1542:26

going to be only using the set is open

1542:29

and change that to not is open which

1542:31

means like if this is true it's going to

1542:33

make it false if it is false it's going

1542:34

to make it true I'm going to go into my

1542:36

navigation and inside this navigation

1542:38

I'm going to destructure this I'm going

1542:40

to be using like toggle sidebar and here

1542:42

I'm going to create interface for this

1542:44

I'll use like interface and then

1542:45

navigation uh props would be fine and

1542:48

inside there we have to provide our

1542:50

Toggler sidebar or toggle sidebar and

1542:52

we're going to be only returning the

1542:54

white from there okay so let's just

1542:56

close there and we're going to be

1542:57

returning the white now I'm going to

1542:59

copy a name of there and annotate my

1543:00

component like so now we have to use

1543:02

this tole sidebar so I'm going to just

1543:04

use there right here so when somebody

1543:06

clicks on there we're going to be firing

1543:07

this toggle sidebar function now here if

1543:10

I click on there nothing will happen not

1543:12

right now because we also have to take

1543:14

care of our navigation God damn it side

1543:17

bar so let's just go ahead and go to our

1543:18

sidebar and start working on our sidebar

1543:21

first thing first we have to start from

1543:23

our sidebar okay so I'll just create a

1543:25

div with a class of a lot of classes so

1543:27

I'll just create a div and I'm going to

1543:29

put a few classes to it so the classes

1543:31

will be dynamic I'm going to provide a

1543:33

fix come on I'm going to provide a fix

1543:35

and also Top Value will be set to zero

1543:37

the left value will be set to zero and

1543:39

height will be set to totally full and

1543:41

width will be set to

1543:43

80% so let's just use 80 and background

1543:45

will be set with holy White Shadow will

1543:48

be also totally large okay and for the

1543:51

transform we going to be rendering our

1543:53

content dynamically so I'll just use

1543:55

like if this is open so in that

1543:56

situation we want to use the translate

1543:59

value on the x-axis and set that to zero

1544:01

but if that's not the case we have to

1544:03

use the minus translate value and set

1544:06

that to totally full I'm going to save

1544:08

my file right now this is how it looks

1544:10

like right here so now outside from

1544:11

there we're going to be providing a bit

1544:13

of transitions to there so I'll just use

1544:14

like uh transition on the transform okay

1544:18

so I'm going to also put a bit of

1544:19

duration today and the duration will be

1544:21

set to 300 is in and out and for the Z

1544:24

index it's going to be set to 50 I'm

1544:26

going to save my file right now and

1544:27

inside there first of all we have to

1544:29

define the header uh with close button

1544:32

okay so I'll just use a d with the class

1544:34

of flex and justify will be set to toly

1544:36

between items will be set to toly Center

1544:38

pairing all around will be set to four

1544:40

border on the bottom inside there let's

1544:42

just use our H2 and this H2 will have

1544:44

the classes of text only large and font

1544:47

of semi Bard and I'm going to pass a

1544:49

filters inside there and now let me just

1544:51

save my file and here you can see we are

1544:53

now getting this sidebar right here and

1544:55

now we are also getting that filters so

1544:57

now let me just take care of that so now

1544:59

underneath this filters we're going to

1545:01

be creating a button and this button

1545:02

will have um the fix so I'll just use

1545:05

like a fix and basically this is the

1545:07

icon from the react icons I'm going to

1545:09

also provide a bit of class name so I'll

1545:11

just use like Tex of toally extra large

1545:13

and when somebody clicks on there we're

1545:15

going to be firing that same top sidebar

1545:17

function okay so here you can see we're

1545:19

now getting there if I click on there

1545:20

it's going to show us our sidebar and

1545:22

now if I click on this one so it's going

1545:24

to hide there which means like

1545:25

everything is working the way we expect

1545:27

them to work and now to need this T we

1545:29

have to Define our filters and that's

1545:32

going to be a lot of fun so now

1545:34

underneath this comment we're going to

1545:36

be defining our day with the class of

1545:37

pairing all around of four and spaces on

1545:40

the y axis will be set to six inside

1545:42

that we have to first of all start from

1545:44

the country come on oh my God country

1545:47

filter and then we are going to be

1545:49

taking care of the rest of the stuff

1545:51

this I'll use a div inside this div we

1545:53

have to Define our button and for each

1545:55

button we're going to be attaching flex

1545:57

and justify will be set to between items

1545:59

will be set to Center and the width will

1546:01

be set to to full text to left inside

1546:04

this button uh I'm going to be creating

1546:05

a span which will have the font of

1546:07

medium and it's going to say country

1546:09

like that I'm going to save my file and

1546:12

now to need them we also have to render

1546:14

our fi and that same icon so this h v r

1546:18

n shiron down or something like that I

1546:20

can't even pronounce the name of this

1546:22

icon and now let me provide a bit of

1546:23

class names today and here we are going

1546:25

to be rendering our classes dynamically

1546:27

so let's just use our transform and if

1546:29

our country drop down so in that

1546:31

situation we're going to be using rotate

1546:33

on the

1546:35

180° but if that's not the case so we

1546:38

are going to be setting there to empty

1546:39

string so now let me just save my file

1546:41

and now if I click on there here you can

1546:42

see we're now getting this country but

1546:44

we don't have any content inside there

1546:46

and by the when somebody clicks on this

1546:48

button we're going to be firing this

1546:49

function so now let me just use like uh

1546:52

toggle country dropdown I'm going to

1546:53

save the file now let me go ahead and go

1546:55

to the top and Define this function

1546:57

right here I'll just give it the name of

1546:58

like cons country dropdown it's going to

1547:01

be equals to the set country drop down

1547:04

and not country drop down which we

1547:06

already defin right here so we have this

1547:08

country drop down and the initial value

1547:10

is specify false today so if that's true

1547:13

we're going to be making it false but if

1547:16

that's f FSE we're going to be making it

1547:18

true and now here you can see if I click

1547:19

on there and if I click on this icon

1547:21

here you can see it's going to rotate or

1547:23

yeah rotate on the

1547:25

180° so that's cool and now underneath

1547:28

this button we have to render our

1547:30

countries so I'll just use like country

1547:32

drop down if that is the case we want to

1547:34

show this UI I'll just create with a

1547:36

class of margin for a top of two and and

1547:38

spaces on the y axis will be set to two

1547:40

inside this D we have to render our

1547:42

unique countries so how in the world we

1547:44

are going to be even getting a unique

1547:46

countries now just go to the top and

1547:48

here we have to define a unique

1547:49

countries and that's not going to be a

1547:51

huge case so we just have to get the

1547:52

unique unu n IQ unique countries it's

1547:55

going to be set to AR rayar from and

1547:58

inside there we have to use the new set

1548:00

so it's going to only gives us the

1548:01

unique stuff and it's going to remove

1548:03

the duplication and now inside there we

1548:05

have to specify all our data which we

1548:07

are now getting from this data.js file

1548:10

so I'm going to go ahead and go to the

1548:11

top and import this I'm going to use

1548:13

like uh data from when from let's just

1548:15

go ahead and go to the top and from our

1548:18

DB and data I'm going to save my file

1548:20

and copy the name of there now let me go

1548:22

to the bottom and here we have to

1548:24

specify our data now we're going to be

1548:26

iterating over through our data so I'll

1548:28

use like the item and now we going to be

1548:29

annotating this item with this product

1548:31

and now here we have use like item.

1548:33

country God damn it item dot oh my God

1548:38

item. country there we go oh I'm doing

1548:41

it wrong so I'm going to cut that from

1548:42

here and we have to wrap that in another

1548:45

parenthesis and now we can use there so

1548:47

that's all you're done so now we are

1548:49

getting this unique countries so I'm

1548:50

going to copy a name of there and here

1548:52

we're going to be passing it so I'll use

1548:54

that unique countries like so and now we

1548:58

have to over through all of that unique

1548:59

countries so I'm going to get the

1549:01

country and also the index of the

1549:03

country so inside there what do we have

1549:06

to do uh I'm going to go ahead and just

1549:08

Define my div and close there like so

1549:10

and this D will take a key and here we

1549:12

have to specify index inside there and

1549:15

for the class names I'm going to specify

1549:16

flex and items will be set to toly

1549:18

Center and when somebody clicks on there

1549:20

we're going to be firing this function

1549:22

which is the handle country come on

1549:25

handle country handle country selection

1549:30

and now we have to specify our country

1549:31

inside there I'm going to save this file

1549:33

and we're going to be seeing the result

1549:35

of that in a few second and we're going

1549:36

to be even also creating this function

1549:38

in a few seconds so now let me just go

1549:40

inside this de and here we have to

1549:42

specify our input field and for this

1549:44

input field we're going to be setting

1549:45

there to check box here we have to

1549:47

provide our checked state so it's going

1549:49

to be check if we have the selected

1549:52

country not color but the selected

1549:54

country do include that specific country

1549:58

which we are now taking as a perimeter

1549:59

so I'm going to go ahead and copy a name

1550:01

of there and place it right here and

1550:03

that's going to be it now underneath

1550:05

this check we also have to provide the

1550:06

own change event handler like when

1550:08

somebody change there so in that

1550:10

situation we are going to be firing this

1550:11

handle country selection God damn it I'm

1550:14

going to copy the name of that and place

1550:16

them right here and provide our country

1550:19

inside there and I'm going to also

1550:21

specify the class names and the class

1550:22

name will be set to margin for the right

1550:24

of two now to need this input field we

1550:26

have to Define our span and here we have

1550:28

to render our country inside there now

1550:31

let me go ahead and copy a name of there

1550:33

and create this function at the top of

1550:35

our file so now underneath this unique

1550:38

countries we're going to be defining

1550:39

like const andle country selection and

1550:42

here we have to provide the country and

1550:44

the country will be a string inside this

1550:47

uh what we have to do we have to use our

1550:48

set selected countries and here we have

1550:51

to provide first of all the selected

1550:52

country selected countries now we have

1550:55

to provide the includes method if that

1550:57

includes the country so in that

1550:59

situation we're going to be using the

1551:00

selected country come on selected

1551:03

countries and we have to filter through

1551:05

there selected countries and now we have

1551:08

to filter through them and here we only

1551:11

have to specify each country if that

1551:13

each country does not equal to that

1551:16

country tree which we're now taking as a

1551:17

perimeter we only want to remove the

1551:20

like we we totally want to ignore that

1551:22

but if that's not the case we're going

1551:23

to be first of all making a clone of all

1551:25

of our selected countries and then we

1551:28

have to specify each country inside then

1551:30

now let me just save my file and that's

1551:32

done so now let me just refresh there

1551:34

and if I click on this icon so it's

1551:35

going to open this sidebar if I click on

1551:37

this country and it's going to gives us

1551:39

all of that unique country so it's going

1551:41

to gives us Japan USA China India and so

1551:43

on and so forth and yeah I can click on

1551:46

there and nothing will happen because we

1551:47

have to paste this filtering into our

1551:49

app component so we are going to be

1551:51

doing that in a few seconds but now let

1551:52

me also take care of the the rest of the

1551:54

filtering now that's done I'm going to

1551:56

collapse them and now underneath this

1551:58

div we are going to be defining yet

1551:59

another div and that div will be a color

1552:02

filter like so or colors filter rather

1552:06

so now underneath there we going to be

1552:08

defining a div and inside this div we

1552:09

have to Define our button and this

1552:11

button will take the classes of flex and

1552:13

justify between item toly Center and

1552:18

with toally full text to left inside

1552:21

there we're going to be defining a spin

1552:23

with a class of font medium and it's

1552:25

going to say color I'm going to also

1552:27

attach the event handler today so when

1552:28

somebody clicks on it we going to be

1552:30

firing this function which is a toggle

1552:32

color drop down color drop down there we

1552:35

go and now let me just save my file and

1552:37

underneath this pin we're going to be

1552:39

defining our icon so I'll use like not

1552:42

this f i sh drop down there we go and

1552:45

I'm going to also spef by the classes

1552:47

and here we have to render our classes

1552:49

totally dynamically so I'll use like the

1552:50

transform not a translate but just a

1552:53

transform and we going to be rotating

1552:55

there if our color drop down is set to

1552:58

true so if that's the case we're going

1553:00

to be rotating there 1008 degree but if

1553:03

that's not the case so we're going to be

1553:05

setting that to empty string now need

1553:07

this button what you want to do we just

1553:09

want to render all of our content so

1553:10

I'll use like if we have our color drop

1553:12

down if there is true then we want to

1553:14

show this UI so inside this UI we are

1553:17

going to beating over through all of our

1553:18

colors I'll use like black brown and

1553:21

also the red color and the white color

1553:24

and the golden color like there or you

1553:27

know what we're going to be doing there

1553:28

but first of all we have to create a

1553:30

with the class of margin for top of two

1553:32

spaces on the y- AIS of two and inside

1553:34

there let's just start working on there

1553:36

I'm going to use the map method to over

1553:38

through them and I'm going to pass a

1553:40

color inside there and now here we have

1553:42

to create a div and now for this div

1553:45

we're going to be passing a key and the

1553:46

key will be coming from this each color

1553:48

so I'm going to copy a name of there and

1553:50

place it right here I'm going to also

1553:51

proide the class names and the class

1553:53

name will be set to flex items will be

1553:55

set to totally Center I don't know why

1553:56

I'm getting this error but yeah we are

1553:58

getting this error I'm going to have to

1554:00

cut that From Here and Now inside there

1554:03

we have to paste it like so or you know

1554:05

what let me just paste the manually so

1554:07

I'm going to use like the map and here

1554:08

we have to paste the color and now

1554:10

inside that we have to define the div

1554:12

and this div will have the key and the

1554:14

key will be that specific color we're

1554:16

going to be also passing a classes like

1554:18

Flex and and IRS will be set to totally

1554:20

Center when somebody clicks on there

1554:22

we're going to be firing this function

1554:24

which is a handle color selection and we

1554:27

are going to be creating this function

1554:28

in a few seconds now inside this div

1554:30

let's just Define our input field with

1554:32

the type of checkbox and now here we're

1554:35

going to be checking that if that's

1554:36

checked or not so first of all we have

1554:38

to provide the selected color and if

1554:41

that includes the color there specific

1554:44

colors which means like that's checked

1554:46

okay so now let me just save my file and

1554:48

here we're going to be also passing this

1554:50

on change you hander like when somebody

1554:51

try to change them then we're going to

1554:53

be firing this function which is a

1554:55

handle color selection and here we're

1554:57

going to be passing that color inside

1554:59

there I'm going to also provide the

1555:00

class name of margin for the right of

1555:02

two now to need this input field we're

1555:04

going to be rendering our span so I'll

1555:06

use like the span and here we have to

1555:08

render our color inside there now first

1555:10

of all I'm going to go ahead and create

1555:11

this function and then we are going to

1555:13

be creating that another one so now here

1555:15

let's just just create them what I'm

1555:17

going to do is that I'm going to create

1555:18

a function with the name of toggle color

1555:20

drop down and it's not going to do

1555:21

anything crazy but here we're going to

1555:23

be only using the set color dropdown and

1555:26

we have to provide like not color

1555:28

dropdown now let me just save my file

1555:31

and now it's time to create this

1555:32

function which is um and I'm going to

1555:35

also paste that color right here and we

1555:38

have to make it as a arrow function like

1555:40

so now let me go ahead and go to the top

1555:43

and Define this function right here so

1555:45

what we have to do we have to create a

1555:47

function with the name of handle color

1555:49

selection and inside it's going to take

1555:51

a color as a perimeter and that's going

1555:53

to be a string and now inside this

1555:55

function what do we want to do we just

1555:56

want to get the set selected colors like

1555:59

so and here we have to pass our selected

1556:01

color and if that includes that specific

1556:04

color which we are now passing as a

1556:05

perimeter then what do we want to do we

1556:07

want to get the selected colors selected

1556:10

colors and we want to provide the filter

1556:12

method on there and we want to filter

1556:13

out that specific item so I'm going to p

1556:16

the C for the color and if C does not

1556:19

equal to that color which we are now

1556:20

taking as a perimeter then you want to

1556:22

get their specific color but if that's

1556:24

not the case you want to make a clone of

1556:26

our existing selected color so we'll use

1556:28

like the selected colors and then we

1556:30

have to specify our new color to there

1556:33

like so and now let me just save my file

1556:35

and that's already done now if I click

1556:37

on the sidebar and click on the color so

1556:39

I can now choose different kind of

1556:40

colors right here you can also specify

1556:42

your own one if you wanted to but in my

1556:44

case that's going to be add and and I'm

1556:46

making a mistake so I'm going to also

1556:48

cut the line of code now if I click on

1556:50

there here you can see we're now getting

1556:51

this result which is looking cool now

1556:53

that's done I'm going to hide them and

1556:55

now let's start working on our pricing

1556:57

filters we use like price and then

1556:59

filter and now here we're going to be

1557:02

defining that same thing like the D and

1557:04

then the button which will have the

1557:05

classes of flex and justify will be set

1557:07

to between the items will be set to to

1557:09

the center with uh totally full and text

1557:13

totally left inside then we have to

1557:15

Define what with the class of f medium

1557:18

and it's going to say the price and when

1557:19

somebody clicks on this button you want

1557:21

to F this function which is the toggle

1557:24

price drop down okay drop down like so

1557:27

now let me just save my file and now

1557:29

underneath this pen we have to Define

1557:31

that same icon so I'll use like fi and

1557:34

then shivon or something like that and

1557:36

we have to close that and now I'm going

1557:38

to provide the class names and that

1557:40

class name will be totally Dynamic so

1557:41

I'm going to P like transform and we're

1557:43

going to be rotating the if or price

1557:47

price drop down is set to true so in

1557:48

that situation we're going to be

1557:49

rotating there on the

1557:51

180° but if that's not the case uh what

1557:55

do you want to do you just want to set

1557:56

the two empty string now let me save

1557:58

there now underneath this button what do

1558:00

you want to do we just want to render if

1558:02

our price drop down state is true then

1558:05

we want to show this UI but if that's

1558:07

not the case then we're not going to be

1558:09

showing nothing at all I'm going to

1558:11

create a with the class of margin for

1558:12

top of two and spaces on the Y AIS of

1558:14

two inside there let's just create our

1558:17

data so I'm going to create a few levels

1558:19

so now inside this array we're going to

1558:21

be defining a few objects so I'm going

1558:23

to hit enter right here and also right

1558:24

here I'm going to first of all provide

1558:26

My Level and for this level I'll just

1558:28

write like below $300 and here we also

1558:31

have to provide the minimum and minimum

1558:33

will be set to zero and the maximum will

1558:35

be set to 300 I'm going to save this

1558:37

file and we are getting some sort of

1558:39

error is not assignable to the type

1558:41

react node know what we will take care

1558:43

of that in a few seconds but first of

1558:45

all I'm going to make a few of them so

1558:46

I'm going to duplicate there a few time

1558:48

and here we have to change the two

1558:50

instead of a three starting from a 300

1558:53

to 600 and also here we have to change

1558:56

that to uh 600 so I'll just change that

1558:59

to six and now I'm going to change the

1559:01

minimum value to like 300 and also the

1559:04

maximum value to 600 and for the maximum

1559:07

we have to change that to 600 and then

1559:10

here we have to provide the infinity now

1559:11

I'm going to itate over through all of

1559:13

these items so I'm going to use the map

1559:14

method and here we have to provide the

1559:16

range and now inside there now inside

1559:20

there what do we want to do we just want

1559:21

to create our div and this div will have

1559:23

the key and the key will be range. label

1559:26

I'm going to also provide the class

1559:27

names and the class name will be set to

1559:29

flex and items will be set to totly

1559:30

Center and when somebody clicks on there

1559:32

we want to fire this function so now

1559:34

let's just F the on click event handler

1559:36

we want to fire this specific function

1559:38

which is a handle price range selection

1559:41

and here we have to past the range

1559:43

inside there now inside this D what we

1559:46

want to do we just want to create our

1559:47

input field with a type of radio and

1559:49

then this can to be checked if we

1559:51

selected price range. label do Lael if I

1559:55

can type that today label is equals to

1559:59

the range. label so in this situation uh

1560:01

that's going to be checked but if that's

1560:03

not the case so it's not going to be

1560:04

checked and when somebody try to change

1560:06

them we're going to be firing this

1560:07

function which is a handle selection and

1560:10

here we have to provide the range inside

1560:12

there I'm going to also provide the

1560:13

class name and the class name will be

1560:14

set to margin for the right of two and

1560:16

now underneath this input field we have

1560:18

to create our span so I'll just write a

1560:19

span and here we have to render our

1560:21

range. label like so I'm going to sve my

1560:24

file right now and now if I just refresh

1560:26

there we are getting some sort of error

1560:28

obviously we would get some sort of

1560:29

error because we have to create these

1560:31

functions so now what I'm going to do is

1560:33

that I'm going to copy the name of there

1560:35

and create this function or you know

1560:36

first of all let's just create this

1560:38

function so I'll just go to the top in

1560:40

here I'm going to be creating that

1560:42

function so what I'm going to do is I'm

1560:44

going to just write like toggle price

1560:45

drop down and here I'm going to be using

1560:47

set price drop down and change that to

1560:50

not price drop down okay so that's done

1560:53

now I'm going to go to the bottom and

1560:55

create this function which is a handle

1560:56

price range I'm going to go to the top

1560:58

once again and here we're going to be

1561:00

creating that function which is a const

1561:02

handle price range selection and it's

1561:05

going to take the range and that range

1561:06

will be a lot of range okay so we are

1561:09

going to be placing the minimum value

1561:10

and the minimum value will be set to

1561:12

number the maximum value will be also

1561:13

set to number and the label will be set

1561:16

to a string you can also Define a

1561:18

different interface for them but in my

1561:20

case I'm not going to if that's not the

1561:22

case we're going to be placing a null

1561:23

value today and now what I'm going to do

1561:25

is that I'm going to only use the set

1561:27

selected price range not color but

1561:30

selected price range and here we have to

1561:32

specify that range inside there now let

1561:34

me just save my file and now if I click

1561:36

on there and here you can see we're now

1561:38

getting the prices so now I can choose

1561:39

the above 300 and starting from 300 to

1561:43

600 and also above the 600 so yeah you

1561:46

can also now filter these items by using

1561:48

the prices that's done so I'm going to

1561:50

hide there and now underneath this price

1561:52

filter we're going to be defining our

1561:54

footer right here okay so this going to

1561:56

only allows us to clear out the filter

1561:58

so I'm going to create a d with the

1561:59

class of pairing all around four and

1562:01

border on the top flex and justify will

1562:04

be set to between and inside there we

1562:06

have to create a button and it's going

1562:07

to say like clear all when somebody

1562:10

clicks on this button so we're going to

1562:11

be firing this clear filters function

1562:13

and also I'm going to be passing a class

1562:14

names or background totally black text

1562:17

toally white and pairing for the xaxis

1562:19

of four pairing for the Y AIS of two

1562:21

only rounded so now if I sa my file now

1562:23

let me just click on that and here you

1562:25

can see we're now getting this clear

1562:26

button and you know what I'm going to

1562:29

remove this ping on the x-axis not the

1562:32

pairing on the x-axis but I'm going to

1562:33

prob like margin for the right of two or

1562:37

margin for the left of two yeah I guess

1562:40

that's going to be fine that's also done

1562:41

so I'm going to hide there and now

1562:42

underne this putter we're going to be

1562:44

defining our back

1562:46

uh overlay right here so now underneath

1562:49

there we're going to be checking like if

1562:50

our sidebar is open so in that situation

1562:54

this overlay to there so I'm going to

1562:55

create a div and I'm going to put a bit

1562:57

of class name to there like it's going

1562:58

to be S totally fix and the insert will

1563:00

be zero background totally black and the

1563:02

opacity will be set to 50 and the Z

1563:05

index will be also set to 40 and when

1563:07

somebody clicks on there we're going to

1563:09

be using the toggle sidebar function

1563:11

it's going to just hide our sidebar and

1563:13

it should be outside from these divs so

1563:16

I'm going to place it right here save my

1563:18

file and here you can see this is how it

1563:20

looks like right here so I can now

1563:22

choose them and also so I can totally

1563:24

close there and here you can see it's

1563:26

going to hide there so if I click on the

1563:27

and if I click on the overlay it's going

1563:29

to also hide my sidebar so this is

1563:31

looking cool now finally let's just

1563:33

Implement those filters inside our app

1563:36

so first of all we are now getting these

1563:38

errors so I'm going to just annotate

1563:40

with the any because we already

1563:41

completed the product so now the next

1563:43

thing that we have to do is that we have

1563:45

to change this store to not a store but

1563:47

this data to instead of using a JS we

1563:50

have to convert the to the TS case no

1563:52

let me just close there and then St done

1563:54

so now first thing first what do you

1563:56

have to do first of all we're going to

1563:58

be importing what do we call it the use

1564:01

filter store I'm going to copy the name

1564:03

of there and we have to execute there

1564:05

right here and the next thing that we

1564:07

have to do that we have to restructure a

1564:08

few things from there so I'm going to be

1564:10

using like the selected country we would

1564:13

also have to destructure the selected

1564:14

color and we would also have to

1564:16

destructure the selected price and now

1564:18

let me just save my file the next thing

1564:20

that we have to do is that we have to

1564:21

define a filter based on the selected

1564:23

data so I'm going to use like data and

1564:25

then do filter and it's going to take

1564:27

the item and now we're going to be

1564:28

annotating there with this product and

1564:30

we're going to be defining this product

1564:31

in a few seconds so now I'm going to go

1564:34

ahead and just start working on there

1564:36

and you know what let's just Define this

1564:37

product okay so I'm going to define the

1564:39

right here so I'll create the interface

1564:40

and this interface will be set to this

1564:42

product it's going to take the ID and

1564:43

the ID will be a string the country will

1564:46

also be a string and I'm going to also

1564:48

specify the image and the image will be

1564:50

there and we have to import that and now

1564:51

we have to pass the string comma string

1564:54

inside there next we're going to be also

1564:57

providing the price and the price will

1564:58

be set to a number now we successfully

1565:00

annoted there now inside this filter

1565:03

what do we have to do I'm going to first

1565:04

of all check if the item matches so for

1565:06

that we are going to be using like the

1565:08

select colors and then do length if the

1565:10

selected colors. length is equals to

1565:13

zero or the object do keys and here we

1565:16

have to specify item. image then we can

1565:19

use the Su method on there and we also

1565:21

have to P the colors inside there and

1565:23

now we are going to be using the

1565:25

selected colors that includes that

1565:27

specific color so now I'm going to save

1565:29

there I'm going to also store there in

1565:30

some sort of a variable so I'll use like

1565:32

match color and it's going to be equals

1565:34

to this matches color right here that's

1565:36

the first thing that we have to do next

1565:37

we also have to check like if the item

1565:39

match is the selected price range so I'm

1565:41

going to just go ahead and just write

1565:42

like match price or matches price it's

1565:46

going to be equals to the selected price

1565:48

range come on SE selected price range so

1565:53

if this the case we are going to be

1565:54

checking once again so if item do come

1565:56

on I not items but just item. price is

1566:00

greater than or equal to the selected

1566:03

selected price range do minimum and the

1566:07

item dot not items but just item. price

1566:11

is less than or equal to the selected

1566:14

price range. Ma Max Max so that's going

1566:17

to be the case so that's not the case so

1566:19

we're going to be setting that to true

1566:20

and now finally we have to return all of

1566:22

that so I'll just use like return the

1566:24

matches color and matches price now I

1566:29

also forgot to include one more so what

1566:31

do we have to do we have to define the

1566:33

cons matches country it's going to be

1566:35

equals to the selected countries. length

1566:39

come on L GTH if that's equal to zero or

1566:43

the selected country do includes

1566:47

includes the item. country okay so

1566:50

that's going to be it for the matching

1566:52

matches country I'm going to copy the

1566:53

name of there and I'm going to also

1566:55

place it right here like so now I'm

1566:57

going to go ahead and store there in the

1566:59

filtered data variable so I'm going to

1567:02

copy a name of there right now let me

1567:04

just copy there go to the bottom and

1567:06

instead of using the data I'm going to

1567:08

paste the filter data right here okay so

1567:11

now it's going to filter our items based

1567:12

on this data and now if I click on the

1567:15

side bar now I can choose different kind

1567:16

of filters so if I click on the Japan

1567:18

it's going to only gives us all of that

1567:20

watches which are from the Japan I can

1567:22

also choose like United State China

1567:25

India and so on and so forth now I can

1567:27

also choose different colors so if I

1567:28

choose like the black it's going to

1567:30

gives us all of that colors like here

1567:32

you can see this one is black and this

1567:34

one will also have the black variant so

1567:36

now let me just show you that here you

1567:37

can see this one is black and also this

1567:39

one is black so which means like it's

1567:41

going to also gives us that specific

1567:43

color item if I choose like the white

1567:45

also gives us white because all of these

1567:47

watches have the white variant like if I

1567:49

show you there here you can see we have

1567:51

the white variant right here and so on

1567:53

and so forth so if I just show you this

1567:54

one here you can see this one also have

1567:56

the white variant so that's also the

1567:58

colors one now if I go ahead and click

1568:00

on the prices I can also choose like

1568:02

below the 300 and also I can choose the

1568:05

above 300 and also I can choose like

1568:08

above $600 now I can select different

1568:10

kind of watches and yeah that was our

1568:13

final project of this course he again Su

1568:15

and wer YouTube channel so in this video

1568:18

I'm going to be making you the redex

1568:19

toolkit and rtk query monsters so there

1568:23

are a lot of great resources out there

1568:25

which teaches the rtk query and also the

1568:27

redex toolkit so why you should spend

1568:30

your time watching this course so to

1568:32

convince you in the first part of the

1568:34

course we're going to be learning about

1568:36

the redex toolkit and then the rtk query

1568:38

but in the second part we are going to

1568:41

be building two amazing and I'm talking

1568:44

about a huge industry level projects so

1568:47

I already built and the first project is

1568:49

already on my YouTube channel but the

1568:51

second project will take I don't know

1568:53

maybe two or 3 days so by the time

1568:55

you're watching this video the second

1568:57

project will be already on my YouTube

1568:59

channel so now let me show you where you

1569:00

can find these projects and how to

1569:02

become a merch monster so you don't have

1569:05

to go any further you just have to

1569:07

search husan webd on YouTube and it's

1569:09

going to bring you to my YouTube channel

1569:10

right here and I have a lot of amazing

1569:13

courses if you wanted to check it out so

1569:15

here you can see we have this merag

1569:17

project course and this is the entire

1569:20

project and by the way if you want to

1569:21

become a merag developer here I already

1569:23

have a course on that now let me just

1569:25

show you that course so you can just

1569:26

watch this course and it's going to just

1569:27

make you a JavaScript monster okay so

1569:30

this course offers every single thing

1569:32

that you have to know about JavaScript

1569:34

but anyways back to our topic now we are

1569:36

talking about the mer stack project so

1569:38

if you click on this playlist it's going

1569:40

to bring you to this playlist right here

1569:41

which teaches every single thing about

1569:43

the Redux toolkit and artic queries so

1569:45

the first thing which you have to do is

1569:47

that you have to watch this video which

1569:49

you are currently watching and then you

1569:51

have to jump straight into this project

1569:53

right here so duration of this project

1569:54

is about 15 hours and it's going to make

1569:57

you a superstar in mer Tech and I'm

1570:00

already working on the mer stch movies

1570:02

application which will be launched I

1570:03

don't know maybe in two or 3 days so

1570:06

stay tuned and now let's learn what in

1570:08

the word is a Redux and then we are

1570:09

going to be jumping into the Redux

1570:11

toolkit so we are not going to be using

1570:15

using the redex score in this course but

1570:17

I just want to give you a quick overview

1570:19

of what a redex is so redex is an open

1570:22

source JavaScript library for managing

1570:24

the state and here the keyword is the St

1570:27

so if I ask you a question like what is

1570:29

a state in reactjs so your answer will

1570:31

probably be like a use reducer the use

1570:33

context the use State and all of that

1570:36

kind of stuff so redex is an open source

1570:38

JavaScript library which allows us or

1570:40

which help us to work with State

1570:42

Management in a predictable way and it

1570:45

is commonly used with libraries like

1570:47

reactj for building the uis but can also

1570:50

be used with other JavaScript Frameworks

1570:51

and libraries so a lot of people think

1570:54

that reactjs and redex Tool are totally

1570:56

the same thing but they are not and I

1570:59

can totally understand like why they

1571:00

think that way because there are

1571:02

countless courses which teaches reactjs

1571:05

and redex JS in the same video or in the

1571:08

same course so that's why these people

1571:10

think that reactjs and Redux toolkit or

1571:12

Redux is totally the same thing but they

1571:14

are not okay so that was just a quick

1571:16

overview of what a Redux is but now

1571:18

let's talk about something called the

1571:19

Redux toolkit so Redux toolkit is the

1571:22

official opinionated batteries included

1571:25

tool set for efficient Redux development

1571:28

wait what Redux development what are you

1571:31

talking about H okay so now let me tell

1571:34

you what's the difference between redex

1571:36

toolkit and just a redex score redex

1571:39

score makes the State Management easy

1571:41

and yeah it it makes it easy but you're

1571:44

going to have to learn a lot of things

1571:46

and you're are going to have to also

1571:47

write a lot of boiler plate code which

1571:50

is not going to be necessary now we are

1571:52

using the Redux toolkit okay so redex

1571:54

toolkit makes the redex development easy

1571:57

to work with Okay so yeah that was just

1571:59

a quick intro to what redex core is and

1572:02

also what a Redux toolkit is and that

1572:04

was just the differences between Redux

1572:05

core and also the Redux toolkit so now

1572:08

let's talk about how we are going to be

1572:09

using Redux and how Redux works so I

1572:12

want you to imagine this component

1572:13

hierarchy for a second and here you can

1572:15

see we have a app component right here

1572:17

and we would have some sort of important

1572:19

data inside this app component and we

1572:21

want this data inside this data

1572:24

component as well so how in the world we

1572:27

are going to be doing that I'm just

1572:28

asking a question like how in the world

1572:29

we are going to be pushing this data

1572:31

which is inside the app component to

1572:34

this data component right here so your

1572:37

answer will probably be like first of

1572:38

all we can also use uh the props and we

1572:41

can pass this data to the card component

1572:43

then we have to pass it to the user

1572:45

component then we have to pass it to

1572:47

this data component and that will

1572:48

totally work but here you can see we are

1572:51

repairing ourselves right here okay so

1572:54

now let me just delete that we are now

1572:56

repeating ourself and that's not a

1572:58

better practice well some of you will

1573:00

also give me this answer that we can

1573:02

pass this data by using the context API

1573:05

or by using the context yeah we can

1573:07

totally do that by just using a Contex

1573:09

and we can pass this data to any

1573:11

component that we like but I want you to

1573:13

imagine for a second that you are

1573:14

working with I don't know Google or

1573:16

maybe the Facebook or some other

1573:18

headquarters and they would have

1573:20

countless component so for that you're

1573:23

going to have to use Contex API like

1573:25

countless times but in Redux toolkit we

1573:28

are not doing that in Redux toolkit we

1573:30

are going to be defining something

1573:31

called the store you don't have to worry

1573:33

about what a store is let me just uh

1573:36

label that as a store we're going to be

1573:38

creating a separate store outside from

1573:40

this component and inside that store we

1573:43

are going to be placing all of logic and

1573:45

then we are going to be pushing our data

1573:47

or storing our data or you can say the

1573:49

logic or you can say the state um

1573:51

initial State values you can give it any

1573:53

name you like okay so we're going to be

1573:55

first of all creating a store then we're

1573:57

going to be storing some sort of a data

1573:59

inside the store and then we will be

1574:00

able to pass this data to any of the

1574:02

component that we like like for instance

1574:04

if I want to use the same data inside

1574:06

this data component so I can totally

1574:08

pass it right here or if I want to use

1574:09

it inside the header component I can

1574:11

totally pass it right here or if I want

1574:13

to use it in the card or in the time

1574:15

component or in the I don't know so you

1574:18

can reuse this data again and again so

1574:20

this is how the redex work and this is

1574:22

what we are going to be learning

1574:23

throughout the course plus we're going

1574:25

to be also learning about a lot of

1574:27

different things but not right now so I

1574:29

want you to imagine this hierarchy and

1574:32

we're going to be solving this problem

1574:34

by using our store so before we get into

1574:36

the store first of all I want to make a

1574:38

setup and I also want to show you the

1574:39

Redux toolkit dogs and then we're going

1574:41

to be jumping into the store so I want

1574:44

you to come to to this link which is

1574:45

called the rx. j.org and it's going to

1574:48

bring you to the redex score

1574:49

documentation right here we are not

1574:51

going to be using that but I want to

1574:52

show you something so they are now

1574:54

calling themselves as a predictable set

1574:56

container for JavaScript apps okay so if

1574:59

I just go a bit further so we are going

1575:01

to be using these two packages right

1575:02

here throughout the course the first one

1575:04

we have is a react Redux and it's going

1575:05

to allows us to work with the reactjs

1575:08

and also the Redux toolkit so this is

1575:10

just a binder for working with the

1575:12

reactjs and also the Redux toolkit and

1575:14

the next package which we are going to

1575:16

be using is you guessed it we are going

1575:18

to be using the Redux toolkit package so

1575:21

now I want to show you something so now

1575:23

if I click on this getting starting B

1575:24

right here so they are now officially

1575:27

recommending the Redux toolkit so it is

1575:29

now officially recommended approach to

1575:31

use the Redux toolkit okay so yeah and

1575:34

by the way here you can also see inside

1575:37

this U main documentation in the

1575:39

installation page they are also

1575:40

suggesting to install the Redux toolkit

1575:43

uh yeah Redux toolkit just a Redux core

1575:46

okay so we are going to be using this

1575:47

command and we are going to be also uh

1575:49

binding there with reactjs but first of

1575:52

all I want you to just click on this

1575:53

Redux toolkit and it's going to brings

1575:55

us to the Redux toolkit documentation

1575:57

right here so say byby to the Redux and

1576:00

we are going to be working with the

1576:01

Redux toolkit now I want to click on

1576:03

this getting started button right here

1576:05

and here you can see they are now

1576:07

suggesting to use this uh Redux tool kit

1576:09

and now I'm going to just click on the

1576:10

quick start or you know what Qui uh

1576:13

tutorial overview right here uh no not

1576:16

this one quick uh quick start would be

1576:18

fine we're going to be installing these

1576:19

two packages right here but first of all

1576:21

I want to make a setup for this course

1576:23

so we're going to be first of all

1576:24

installing the reactjs by using the weed

1576:27

so I'm going to just open my terminal

1576:29

inside my desktop right here let me just

1576:31

zoom in a bit so you guys can see

1576:33

everything a bit better and here I'm

1576:35

going to be just placing this command if

1576:37

I can expand that today I'm going to be

1576:40

just uh passing this command word here

1576:42

which is you know first of all let me

1576:44

just name that to something else I'm

1576:46

going to just rename that to like my uh

1576:49

RDX would be fine and now I'm going to

1576:52

just hit enter right here but first of

1576:53

all we are just creating a weed project

1576:56

and we are just naming that as my RDX

1576:58

you can give it any name you like and we

1577:01

are using the react template not a view

1577:03

template and also not an angular

1577:05

template we are using the react template

1577:07

and this what we are going to be doing

1577:09

so now let me just hit enter right here

1577:10

and now we have to go inside to that

1577:13

folder so I'm going to just write a CD

1577:15

and my RDX and I'm using a vs code so if

1577:18

you're using something else you know

1577:20

first of all let me just show you all of

1577:21

the files and folders which we currently

1577:23

have right here so here you can see it's

1577:25

going to gives us that public and all of

1577:26

that files and it will not gives us that

1577:29

not modules folder because we have to

1577:31

install all of the packages for that so

1577:33

I'm going to just write like npmi to

1577:34

install all of the packages inside that

1577:37

folder and it's going to just install

1577:38

the react by using a Ved inside that

1577:40

folder so everything is now successfully

1577:42

installed and I'm using a vs code code

1577:44

so I'm going to just write a codee DOT

1577:46

and it's going to open my vs code on the

1577:48

other screen so now let me just grab

1577:51

that right here and here you can see we

1577:53

have this folder structure right here

1577:54

and I already assume that you guys

1577:56

already know this stuff so I'm not going

1577:58

to explain all of that so I'm going to

1578:00

just delete this public folder and I'm

1578:02

going to go ahead and go to the SRC

1578:03

folder I'm going to also delete this

1578:05

sence folder we are going to be also

1578:07

deleting this uh app.css and now let me

1578:09

just remove every single thing from this

1578:11

index. CSS I'm going to also remove

1578:14

every single thing from this app and I'm

1578:15

going to just use the RFC and going to

1578:17

just create this component for us and

1578:19

now let me just go ahead and go to my

1578:21

main and I'm going to just remove this

1578:23

uh react strict mode and also this react

1578:25

strict mode right here let me just

1578:27

remove that s my file let's just go back

1578:29

and this is how everything currently

1578:31

looks like but now let me just run my

1578:33

project so I'm going to be using npm run

1578:35

Dev so it's going to just run my project

1578:36

by using this port now let me just click

1578:38

on there and here you can see it's going

1578:40

to just gives us that app right here why

1578:42

is that because currently we just only

1578:45

have this app right here so that's why

1578:46

we are now seeing this app okay so yeah

1578:49

that was the installation and cleaning

1578:50

up of redex tool oh by the way I forgot

1578:53

to install the Redux toolkit and uh the

1578:55

react binder let me just do that so

1578:57

first of all we're going to have to

1578:58

install the Redux toolkit for the state

1579:00

management and also we are going to have

1579:02

to install the react Redux to work with

1579:04

reactjs by using Redux okay so now let

1579:07

me just click on this command and now

1579:09

let me just open my terminal one more

1579:11

time and I'm going to be just placing

1579:12

this Command right here so it's going to

1579:14

just install all of the packages and

1579:15

everything is now successfully installed

1579:17

so I'm going to be using npm run day one

1579:19

more time and now let me just show you

1579:21

my package.json okay so here you can see

1579:24

it's going to install this redex toolkit

1579:26

and also this react redex right here

1579:29

okay so this is what we are going to be

1579:30

using throughout this course and

1579:31

everything is looking okay so enough

1579:33

about a setup and configuration now

1579:35

let's talk about a store but before we

1579:37

get into the store first of all I want

1579:39

you to keep in mind one thing throughout

1579:41

the course if I said Redux I mean the

1579:43

Redux toolkit okay so I want you to just

1579:45

keep that in mind so now let's talk

1579:47

about what a store is and why I should

1579:49

care about that so A store is a central

1579:51

place where the state of your

1579:52

application is stored and it can be

1579:54

created something called the configured

1579:56

store function which I'm going to be

1579:58

showing you in a few seconds and it

1580:00

holds the entire state three of our

1580:03

application so yeah that was just a

1580:04

quick intro to what a store is but now

1580:07

let's talk about how we are going to be

1580:08

creating a store well to create a store

1580:10

first of all we're going to have to get

1580:12

the configure store function from the

1580:14

redex toolkit and then we have to

1580:16

execute that function and inside this

1580:19

function we are going to be just passing

1580:20

our object and inside this object as a

1580:22

property we're going to have to pass the

1580:24

reducer and here we are going to be

1580:26

passing a lot of reducers right now we

1580:29

are going to be just focusing on

1580:30

creating a store and later we're going

1580:32

to be ping the slices and reducer and

1580:34

all of that kind of good stuff so now

1580:36

let me just write some code and then you

1580:37

will get to know what I'm talking about

1580:39

so here back to my project right here

1580:42

okay so I'm going to just sve there say

1580:44

byebye to this one now let me just zoom

1580:45

in a bit right here the first thing I

1580:47

want to do is that I want to create a

1580:48

separate folder right here you can give

1580:50

it any name you like a lot of people

1580:52

give it the name of Redux you can

1580:54

totally give it the name of Redux if you

1580:55

wanted to but in my case I'm going to

1580:57

just give a name of like app because it

1581:00

was mentioning the documentation so I'm

1581:01

going to just also use the official

1581:04

documentation okay so now inside this

1581:07

folder we're going to be creating a

1581:08

separate file I'm going to just give a

1581:09

name of like store and then JS because

1581:13

currently we are working with Javascript

1581:15

file so we have to name it as a

1581:16

JavaScript or extension as a JavaScript

1581:19

so now inside that if you wanted to

1581:20

create a store first of all we going to

1581:22

have to import the configure store

1581:24

function from where from the Redux

1581:27

toolkit and now we have to execute this

1581:29

function and inside this function we're

1581:31

going to have to pass our object right

1581:33

here let me just pass the object and

1581:34

inside this object we're going to be

1581:36

passing the property of reducer

1581:38

RCR and the value will be just set to

1581:41

the object okay now we have to just

1581:43

export this so that we totally use in

1581:45

other file so I'm going to just write

1581:46

like export and I'm going to just give

1581:48

it the name of store right here so yeah

1581:50

this is how we're going to be creating a

1581:51

store and that's totally a okay and

1581:53

totally easy to work with the first

1581:56

thing which you have to do is that we

1581:57

have to import the configur stol and

1581:58

then we have to execute them and then we

1582:00

have to just pass the reducer as a

1582:02

property and value will be set to

1582:03

totally empty uh object right here okay

1582:06

so we just have to export this so we can

1582:08

toally use in other files so yeah this

1582:10

how we going to be creating our store

1582:12

but now let's talk about how we are

1582:13

going to be using this store in our

1582:15

reactjs so we already learned about how

1582:17

we are going to be creating a store but

1582:18

now let's talk about how we are going to

1582:20

be providing that store to the reactjs

1582:23

so the first thing which you have to do

1582:24

is that we have to just import the store

1582:26

and then we also have to import the

1582:27

provider component from the react Redux

1582:30

okay so once we import that then we're

1582:32

going to be just wrapping our entire

1582:34

application from this component which is

1582:37

the provider component and here we are

1582:38

going to be passing our store and then

1582:40

our entire application will have access

1582:43

to our stores now let me just do that

1582:45

okay so I'm going to just close this one

1582:47

and now let me just go ahead and go to

1582:48

my main component right or main file

1582:50

right here the first thing we would do

1582:53

is that I'm going to just grab the store

1582:55

from where let's just oh not the Bible

1582:58

or Bible let's just go ahead and go to

1583:00

our app and then we have to go ahead and

1583:02

go to the store so we're going to be

1583:04

just grabbing the store first of all and

1583:06

then then we would also have to grab the

1583:09

provider from where from the react Redux

1583:12

okay so now we successfully grab both of

1583:14

them but now we have to use that so the

1583:16

first thing which I want to do is that I

1583:18

want to wrap my entire application by

1583:21

using that provider component okay so

1583:24

I'm going to just write a provider

1583:25

opening tag and closing tag now let me

1583:28

just hit enter right here and let me

1583:29

just provide my app inside this provider

1583:31

component and now we have to finally

1583:33

pass the store as a property and value

1583:36

will be stored okay so now our entire

1583:39

application will have access to or store

1583:41

which we just created a few seconds ago

1583:43

so yeah that was just intro to how to

1583:45

create a store and how we are going to

1583:47

be using that store inside our main

1583:49

component so now let's talk about

1583:50

another essential component of redex

1583:52

tool kit which is called the slices so

1583:54

what is a slice and why you should care

1583:56

about that so A Slice is a piece of

1583:58

store set and the corresponding reducer

1584:00

logic to update that specific St so

1584:02

slices are a way to organize our redex

1584:04

store by breaking it down into more

1584:06

smaller and more manageable parts and

1584:09

yeah I know that sounds a bit scary and

1584:11

confusing that's because it has a lot of

1584:14

BU words right here but now let me just

1584:15

break all of them down for you okay so

1584:18

here is the analogy so I want you to

1584:19

imagine that you have a big cake and you

1584:21

want to cut that specific cake into more

1584:23

smaller and more manageable pieces so

1584:26

each smaller piece is like a slice of

1584:28

the cake in the context of redex toolet

1584:30

a slice is like a smaller part of your

1584:32

application overall State and the

1584:34

instruction on how to change or update

1584:37

that specific part okay so yeah that's

1584:41

as simple as I can go okay so yeah that

1584:43

was a slices but now the question is how

1584:46

we are going to be creating a slice the

1584:48

syntax is looking a bit

1584:49

scary no it's not here you can see the

1584:52

first thing which we are doing is that

1584:53

we are grabbing the create slice

1584:55

function or method whatever you want to

1584:57

call there and then we are executing

1584:59

there and inside that we are passing the

1585:01

name property and we are providing some

1585:03

sort of a value for that name in this

1585:05

case I'm working with the counter so I

1585:07

just name it as a counter if you are

1585:09

working like I don't know maybe if you

1585:11

are working with a theme changer or I

1585:14

don't I don't know if you working some

1585:15

other slce so you would name it totally

1585:17

differently and I want you to keep in

1585:18

mind that this is totally

1585:21

important okay so you're going to have

1585:23

to P the name some sort of a specific

1585:25

name to that now let's talk about the

1585:27

initial value and the reducer and also

1585:29

the actions so first of all let's talk

1585:31

about what is initial State initial

1585:33

State as the name suggest is going to be

1585:35

the initial data of your St okaye what

1585:38

do I mean by that in this case I want

1585:40

you to imagine the initial state to be

1585:43

as your used St so in the U St you can

1585:46

pass anything you can pass the object

1585:48

you can pass the I don't know you can

1585:50

pass the string you can p some sort of a

1585:53

number or arrays or nested object or

1585:55

nested arrays or anything like that in

1585:57

my case I'm currently working with the

1585:59

counter so that's why I just specify the

1586:01

value I mean like the property of value

1586:03

and the value of zero right here so you

1586:05

can totally give it the name of like

1586:07

counter banana you can give it any name

1586:10

you like and then you can also specify

1586:12

any value that you like right here okay

1586:14

so yeah that was the initial steps so

1586:17

now let's talk about what in the world

1586:18

are reducers and why should care about

1586:20

that so reducers are like the

1586:22

instruction on what to do with each

1586:24

slice of the cake and they Define how

1586:27

the information in a particular slice

1586:29

can be changed or update so that's what

1586:32

reducers are and here you can see we are

1586:34

now telling how to change this data

1586:36

right here like how to change this value

1586:38

so first of all we have a method of

1586:40

increment and then we have a method of

1586:42

decrement these are something called the

1586:44

actions now you might be saying like

1586:45

hose what in the world are actions now

1586:48

let me just discuss what our actions are

1586:50

so actions are like a request or the

1586:52

commands you give to change a specific

1586:54

slice of a cake for example you can give

1586:57

it the command of like it a bite and

1586:59

that instruct how to take a bite from

1587:01

that slice right here okay so here you

1587:03

can see we are now telling how to change

1587:05

this initial State value so you can

1587:07

think about this initial state is like

1587:10

the U State and you can think about um

1587:13

what do we call it these actions as like

1587:15

the set and the state name that was an

1587:17

awful analy so here you can see we're

1587:19

just providing some sort of initial

1587:21

value and then we are going to be

1587:23

telling our rer like how to change this

1587:25

value so if somebody click on the

1587:27

increment Buton so we're going to be

1587:28

just adding one to it if somebody click

1587:30

on the decrement button so we are going

1587:32

to be just removing one from it so

1587:34

finally we just exporting our actions

1587:35

right here so currently we just have

1587:37

these two actions but if you have like a

1587:39

lot of them so we are going to be

1587:40

exporting a lot of them okay so here I

1587:42

want you to imagine you know I'm going

1587:43

to just tell you there in a few seconds

1587:45

and then finally we are just exporting

1587:47

the reducer from our counter slice so

1587:49

now let me just write some code and then

1587:51

you'll get to know what I'm talking

1587:52

about so here you can see back to our

1587:54

project and now let me just go ahead and

1587:56

go to my app folder right here let me

1587:58

just zoom in a bit and inside this app

1588:00

folder we are going to be creating a

1588:01

separate folder you can give it any name

1588:04

you like but if you want to follow the

1588:06

same Convention as the doc shows so for

1588:08

that we're going to have to pass the

1588:10

features and inside this feature we're

1588:12

going to be introducing some feature so

1588:15

inside that I'm going to be just

1588:16

creating a separate folder and by the

1588:17

way you don't even have to create a

1588:19

separate folder you don't even have to

1588:21

create a features folder but that was

1588:23

recommended in the dog so that's why I'm

1588:24

following that so now here you can see

1588:26

we're going to be attaching the feature

1588:27

of counter so that's why I'm going to

1588:29

just name this folder as a counter and

1588:32

inside this folder we're going to be

1588:34

creating a separate file and I'm going

1588:36

to name that to like uh counter slice

1588:39

right here and by the way this is also a

1588:41

community convention you can give it

1588:43

banana you can give it any name you like

1588:45

but in my case first of all we're going

1588:47

to have to pass the feature or the slice

1588:50

name and then finally at the end we're

1588:52

going to have to pass the slice okay so

1588:54

I'm going to just hit enter right here

1588:56

and yeah that was a lot of community

1588:58

conventions right here so now let me

1589:00

just go back and the first thing which

1589:02

you have to do is that we have to import

1589:03

or create come on create slice from

1589:07

where from the Redux toolkit so we going

1589:09

to be grabbing there by using the named

1589:11

export and then we're going to have to

1589:13

just pull this function right here and

1589:15

inside this function we're going to be

1589:16

passing our object and inside this

1589:18

object we're going to have to pass some

1589:20

sort of a name for our slice so in my

1589:21

case I'm currently working with the

1589:23

counter so I'm going to just give it the

1589:24

name of counter right here okay so now

1589:26

the next thing which you have to do is

1589:28

that we have to P some sort of initial

1589:29

State or the initial value whatever you

1589:32

want to call that so I'm going to just

1589:33

write initial State and here we're going

1589:35

to be passing the object and inside this

1589:38

object we're going to be passing the

1589:39

value you can give it the name of like

1589:41

count if you wanted to but in my case

1589:43

I'm going to just name it as the value

1589:45

okay and the initial value will be set

1589:47

to zero you can totally write your code

1589:49

like this and in some cases you'll see a

1589:51

lot of Engineers use this conventions

1589:53

right here so they will grab the

1589:55

functionality from the initial State

1589:57

then they will create another initial

1589:58

State variable outside from there and

1590:00

then they would paste this initial value

1590:02

inside there they can copy and place it

1590:06

as a property and value but they can

1590:08

also use the es6 way to use just name

1590:11

right here okay because the name in the

1590:14

values are totally the same so they can

1590:15

write their code like this but in my

1590:18

case we just have only small st so I'm

1590:20

going to just cut that from here and now

1590:22

let me just place it right here once

1590:23

again and now this is how we're going to

1590:25

be passing the initial value to there

1590:27

and now let's talk about the reducers so

1590:29

here we are going to be passing the

1590:31

reducers and inside this reducer we are

1590:33

going to be passing the action so how we

1590:36

are going to be changing this data so

1590:38

the first thing which I want to do is

1590:39

that I want to create the increment

1590:41

function right here and you can create

1590:43

it by using using the function Reser

1590:45

keyword if you wanted to but in my case

1590:47

I'm going to just write uh increment

1590:49

right here and then we're going to be

1590:50

grabbing our st. value and it's going to

1590:53

be equals to one and now a lot of people

1590:55

will say like hose what the hell are you

1590:57

doing you are accessing the state and

1591:00

you are directly mutating your state

1591:03

like what is going on and there's

1591:05

something called the Emeral Library

1591:07

which I'm going to show you in a few

1591:08

seconds and now let me just write a

1591:09

comma and then we're going to be also

1591:11

creating a decrement function as well

1591:13

now let me just pass my uh State part

1591:15

here and we're going to be just writing

1591:16

a state. value minus one in this case so

1591:20

what is going on in this area we are now

1591:23

accessing our state directly like here

1591:25

you can see we have uh the value inside

1591:27

the state and we are now accessing or

1591:29

state directly and we are now mutating

1591:33

or changing whichever name you prefer we

1591:36

are now mutating or changing our state

1591:38

directly and that's not allowed in

1591:41

reactjs because it's going to work

1591:43

behind the scene but it will not reender

1591:45

your application that's a big no no in

1591:47

reactjs but in Redux toolkit it uses

1591:50

something called the EM Library behind

1591:53

the scen so we can totally access or

1591:55

state and then we can totally mute or

1591:58

state directly right here okay so yeah

1592:01

this is how we going to be creating uh

1592:03

you know first of all let me just say

1592:04

that once again this is how we going to

1592:06

be grabbing the slice this is how we are

1592:07

going to be using the slice first of all

1592:09

we have to pass the name then we have to

1592:10

pass some sort of initial value to that

1592:12

then we have to provide the reducers and

1592:14

inside this reducers we're going to have

1592:16

to pass our actions right here and now

1592:18

finally let me just export that so I'm

1592:19

going to just write like export cons

1592:21

counter slice we now equals to this

1592:24

counter slice right here so that's

1592:26

totally a okay but we would also have to

1592:29

uh export this increment action and also

1592:31

this decrement actions right here and to

1592:33

do that first of all we're going to have

1592:34

to go a bit back and now let me just

1592:36

write export cons and we're going to be

1592:38

just exporting the increment and also

1592:40

decrement from more counter slice do

1592:43

actions and please please notice these

1592:47

are something called the actions with

1592:50

the S not just action let me just remove

1592:53

this s right here not just action these

1592:56

are plural I can't pronounce this name

1592:59

that's why I'm not doing that these are

1593:02

plural not a singular yeah English isn't

1593:05

my first language so that's why it is a

1593:07

bit difficult for me and now let me just

1593:09

write export default and let's just

1593:11

export our counter slice reducer okay so

1593:15

that's everything we need for now this

1593:17

is how we are going to be creating our

1593:18

slice but now how we are going to be

1593:21

binding this slice or this logic to our

1593:24

store now let's just learn about that so

1593:26

we successfully create our slice but now

1593:28

the next thing which you have to do is

1593:29

that we have to add that slice reducer

1593:31

to our store so the first thing which

1593:33

you want to do is that we are going to

1593:34

be grabbing our store I mean like we are

1593:36

going to be grabbing our reducer and

1593:38

inside this reducers we or reducer

1593:40

property we're going to be passing the

1593:42

property of n thing you can give it the

1593:44

name of anything you want but in my case

1593:46

I'm just giving it the name of counter

1593:48

and we're now passing a reducer to that

1593:50

so that's why it will totally work so

1593:52

now let me just write your code and then

1593:54

you will get to know what I'm talking

1593:55

about so I'm going to just go ahead and

1593:56

go to my store once again and here what

1593:58

I want to do is that I'm going to be

1594:00

grabbing my counter reducer right here

1594:02

you can give it any name you like and we

1594:04

are going to be first of all grabbing

1594:05

that from the feature then go to the

1594:07

counter and then go to the counter slice

1594:09

now let me just copy that and here we

1594:11

can give it any name you like as a

1594:12

property but might I gue I'm going to

1594:14

just name it as a counter and here we're

1594:16

going to be passing our counter slice so

1594:19

everything is now successfully done but

1594:22

the last part is missing which is how we

1594:25

are going to be attaching this logic to

1594:27

our react components and welcome to the

1594:29

final part of the redex toolkit so now

1594:32

let's talk about how we're going to be

1594:33

using the redex St in action in the

1594:35

react component so we're going to be

1594:37

using there by using the used selector

1594:39

Hook and the used dispatch hook it

1594:42

sounds a bit confusing and but trust me

1594:44

it's not and then we're going to be also

1594:46

grabbing our actions right here which is

1594:48

the increment and also a decrement and

1594:50

then finally we are going to be using

1594:52

the use selector and the use dispatch so

1594:54

now let's talk about what in the word is

1594:56

a use selector and also the used

1594:58

dispatch I don't want to confuse you so

1595:00

the use selector hooks allows us to read

1595:02

the data from our redex store as simple

1595:05

as that and the use dispatch function

1595:07

allows us to change that data which we

1595:10

are already reading by using this use

1595:12

selector the dispatch fun is used to

1595:14

send action to the store triggering

1595:16

updates to application state in simple

1595:18

terms it lets you change the state of

1595:20

your redex store from within your react

1595:23

component so how that we're going to be

1595:25

doing that and here you can see first of

1595:27

all we're going to be using the use

1595:28

selector to read some sort of a data

1595:30

from our store and then we're going to

1595:31

be just executing the used dispatch

1595:33

we're going to be just storing the in

1595:35

the dispatch function and here we are

1595:37

going to be just passing our increment

1595:39

and also the decrement function right

1595:41

here or action whatever you want to call

1595:43

that so now let me just write some code

1595:45

and then you'll get to know what I'm

1595:46

talking about so now let me just go

1595:47

ahead and first of all uh create a

1595:50

component outside from this app

1595:52

component let me just zoom in a bit

1595:53

we're going to be creating a component

1595:55

outside from this app component and

1595:56

we're going to be creating the inside

1595:58

this SRC so I'm going to just give it

1596:00

the name of like components and inside

1596:02

these components we're going to be

1596:03

creating another component uh of

1596:05

counter. jsx this is going to be our

1596:07

react component so now if you want to

1596:09

use the Redux logic inside our component

1596:11

the first thing which you have to do is

1596:12

that we have to grab the use

1596:14

selector let's just grab that like that

1596:17

from where from the Redux not Redux but

1596:20

the react and also the redex library so

1596:23

we're going to also need the use

1596:24

dispatch hook as well and let's just

1596:27

import our actions right here so we're

1596:29

going to be importing our action from

1596:30

there let's just go ahead and go to our

1596:33

app component folder then we have to go

1596:35

ahead and go to the features then we

1596:37

have to go to the counter and inside

1596:39

this counter we are going to be getting

1596:40

our logic from this counter slice right

1596:43

here okay so we're going to be just

1596:45

getting the increment and also decrement

1596:47

actions okay so now let me just go back

1596:50

and now let's just create some sort of a

1596:51

component right here I'm going to just

1596:53

give it the name of counter right here

1596:55

and inside this component let's just

1596:57

remove there and the first thing which

1596:58

you have to do is that we have to read

1597:00

the data from the uh redu store or just

1597:04

a store whatever you want to call that

1597:06

so we are going to be reading our data

1597:07

by using the use selector and inside

1597:10

that we're going to be passing our Arrow

1597:11

function so you can p the regular

1597:13

function if you want it in my case I'm

1597:15

going to be passing the arrow function

1597:16

so now let me just write a St and here

1597:19

we're going to be passing our reducer

1597:21

property so what do I mean by that here

1597:24

if I just write a counter and then do

1597:26

value from there this looks a bit scary

1597:28

like where in the what is this counter

1597:30

coming from this counter is coming from

1597:32

let's just go ahead and go to a store

1597:34

and here you can see we have a counter

1597:35

property and we are going to be reading

1597:37

our data from the state and also the

1597:39

counter that was the counter but where

1597:41

is this value coming from so now just go

1597:43

ahead and go to the slice and here you

1597:45

can see we have the value right here of

1597:47

the initial State okay so yeah here

1597:50

we're going to be first of all getting

1597:51

this data and now let me just store in

1597:53

some sort of a variable so I'm going to

1597:54

just write like con toown you can give

1597:56

it any name you like and then we are

1597:59

going to be changing let me just write

1598:01

changing the data come on c h n g i n g

1598:05

changing the data by

1598:08

sending uh actions to the store you

1598:12

don't have to worry about this commment

1598:14

which I just WR but now let me just use

1598:16

the use dispatch function and we are

1598:18

going to be storing there in the

1598:19

dispatch uh variable right here okay so

1598:22

now first of all let's just see are we

1598:24

want getting the data from our store let

1598:26

me just sell my file and now let me just

1598:28

refresh that and we are not getting the

1598:30

data I guess because we are not even

1598:32

using yeah we are not using this

1598:34

component anywhere so now let me just go

1598:35

ahead and go to my app and now let me

1598:37

just render my component right here so

1598:39

I'm going to be using the counter right

1598:41

here let's just copy that and let me

1598:44

just remove all of that and let's just

1598:45

use that right here and here you can see

1598:47

we're now getting the value of zero

1598:49

right here which is totally a okay but

1598:51

now we can totally change the data by

1598:53

using this dispatch function so I'm

1598:55

going to just uh cut this count from

1598:58

here and I'm going to be creating H1

1599:00

right here now let me just place this

1599:02

count inside that H1 and now the next

1599:04

thing which you have to do is that we

1599:05

have to create two buttons so I'm going

1599:06

to just creating a button I'm going to

1599:08

just write a plus and then the minus

1599:11

right here and I'm going to also

1599:13

attaching the on click event hander on

1599:15

both of them and we're going to be also

1599:17

passing the arrow function inside there

1599:19

and here we're going to be passing the

1599:21

dispatch what is a dispatch dispatch is

1599:23

a hook use dispatch is a hook and it's

1599:26

going allows us to send our action what

1599:28

is the action here you can see we have

1599:30

these actions right here and based on

1599:32

that specific action we're going to be

1599:33

changing the data inside our store so

1599:35

now let me just write uh my increment

1599:38

action right here i n c r e m e n t and

1599:40

then I'm going to be also writing a dis

1599:43

come on uh yeah dispatch one more time

1599:45

and here we're going to be also passing

1599:47

our decrement but that's not cool why is

1599:49

that because these are functions now let

1599:52

me just show you there let's just go

1599:54

ahead and go to our slices and here you

1599:55

can see this is a function and also this

1599:58

is also a function so now let me just

1600:00

execute both of them so now let me just

1600:02

provide a parenthesis to that and there

1600:04

you have it that was the entire flow of

1600:07

the Redux tool gits now let me just save

1600:09

that and here you can see it's going to

1600:11

gives us these buttons right here but if

1600:12

I click click on this button it's going

1600:14

allows us to increment our counter and

1600:16

if I click on this button so it's going

1600:17

to allows us to decrement or counter

1600:19

right here okay so yeah that sounds a

1600:23

bit confusing but trust me it's not if

1600:25

you just uh create a few actions and

1600:27

yeah if you just play around with that

1600:29

so you will totally get it and I did my

1600:31

best to show every single thing about

1600:33

the Redux toolkit now let's talk about

1600:36

the rtk query welcome to the next

1600:39

section of this course so in this

1600:40

section we're going to be learning about

1600:41

the rtk query

1600:43

so what is the rtk query and why you

1600:45

should care about that so rtk query aka

1600:48

the rtk is specially designed to

1600:51

simplify the data fetching caching and

1600:53

State Management for the API calls in

1600:56

react and Redux

1600:58

applications and that was it about the

1601:00

rdk query that's the only definition I

1601:02

can give you so in this section we're

1601:04

going to be learning about how we're

1601:05

going to be getting all the products how

1601:07

we're going to be getting a specific how

1601:09

we're going to be adding a product how

1601:10

we're going to be updating a product and

1601:12

deleting a product okay so yeah that was

1601:15

just a quick intro to what rtk query is

1601:18

and now let's get into the setup so the

1601:19

first thing which you have to do is that

1601:20

we have to install a new setup so I'm

1601:23

going to just cut all of them out oh you

1601:25

know let me just leave that right here

1601:27

now let me just open my terminal once

1601:29

again and we're going to be creating yet

1601:31

another react project by using the Weir

1601:33

so I'm going to just rename this one to

1601:37

um my rtk query or something like that

1601:41

and now let me just hit enter right here

1601:42

now then we have to go ahead and go into

1601:45

there my rtk query not this one my

1601:50

rtk query and now let me just open or

1601:53

you know before I open there I'm going

1601:55

to be using the npmi to install all of

1601:57

the dependencies for that and then we

1601:59

would also need to grab this Command

1602:01

right here as well I'm going to copy

1602:03

that right here and now let me just wait

1602:04

for this one to complete so everything

1602:06

is now successfully installed the next

1602:08

thing which you have to do is that we

1602:09

have to install uh the Redux toolkit and

1602:11

also the react Redux just hit enter

1602:13

right here so it's going to also install

1602:15

that in your machine so now let me just

1602:17

wait for that to do its thing and

1602:18

everything is now successfully installed

1602:20

I'm going to open my vs code right here

1602:23

and now let's just grab that right here

1602:25

and now let me just put that right here

1602:27

close this one let's just zoom in a bit

1602:30

okay so the first thing which I want to

1602:32

do is that I want to do a bit of clean

1602:34

ah I just accidentally deleted the SRC

1602:36

folder God damn it and here you can see

1602:41

that SRC folder is back and now let me

1602:43

just delete this assets and let's just

1602:44

delete this app and also let's just

1602:47

clean up this one right my rafc then go

1602:50

to the uh index. CSS remove that and

1602:53

then we also have to remove this trick

1602:56

mode right here we don't have to do that

1602:57

but I just want to make everything clean

1603:00

and yeah that's just a setup of um what

1603:02

do we call it that's just a setup of rdk

1603:04

query and I'm going to be using an npm

1603:06

run day one more time to run my

1603:07

application on this port so now let me

1603:09

just click on that and here you can see

1603:11

we have our app right here so yeah that

1603:12

was the setup up so that was the setup

1603:14

and now let's talk about how we are

1603:15

going to be creating a service or you

1603:17

can say um the slice in rtk query so we

1603:20

are going to be creating a separate

1603:22

folder I'm going to just name it as app

1603:24

and inside this app folder we are going

1603:25

to be creating yet another folder you

1603:27

can give it any name you like but in the

1603:29

documentation they are suggesting to use

1603:31

the service Vic and inside the service

1603:34

we're going to be creating yet another

1603:36

file and I'm going to just give it the

1603:37

name of like Demi data or yeah Demi data

1603:42

or API data you can give it any name you

1603:43

like but in my case I'm going to just

1603:45

give it the name of like demid data.js

1603:47

and now inside there we're going to be

1603:49

performing almost all of our logic but

1603:51

the first thing which you have to do is

1603:52

that we also have to create our store

1603:54

okay so now let me just create a file

1603:56

inside this app directory not inside the

1603:59

S I mean like not inside the service but

1604:01

inside the app directory so we're going

1604:03

to be creating a file now let me just

1604:05

give it the name of like uh store.js

1604:07

right here and inside the store the

1604:08

first thing which you want to do is that

1604:09

you want to grab or configure store

1604:13

store from where from Redux red Redux

1604:17

toolkit and then we have to just execute

1604:20

this configure store right here and

1604:21

we're going to be passing our object and

1604:23

inside this object we're going to be

1604:25

passing the reducer in a few seconds and

1604:26

we're going to have to do a lot more

1604:28

than that but we just have to WR export

1604:30

and then just export our state right

1604:32

here and now let's just attach that to

1604:35

not this one but to or main component so

1604:38

we're going to be just grabbing our uh

1604:40

store from where let's just grab there

1604:43

from where from let's just go ahead and

1604:45

go to our AB directory and let's just

1604:47

grab it from there and and we will also

1604:49

need to grab the provider from let's

1604:52

just write a provider from the react

1604:54

Redux and let's just copy and wrap it

1604:59

with this app component what the hell am

1605:01

I doing let's just hit enter right here

1605:04

and here we're going to be just placing

1605:06

that let's just close that and let's

1605:08

just place our entire application inside

1605:11

this SP now let me just write a

1605:13

and bind that so now let me just save my

1605:15

file and yeah that was the setup but now

1605:17

let's talk about the service so how in

1605:19

order we're going to be creating our

1605:20

service and then we're going to be using

1605:22

their service inside our store now

1605:24

inside the service file we're going to

1605:26

be doing almost all of our API logic

1605:28

like how we are going to be getting the

1605:30

data how we going to be posting the data

1605:32

deleting something and all of that kind

1605:33

of stuff by using our dummy API but in

1605:36

the project we are going to be using a

1605:38

real API if you care about this so you

1605:41

can definitely watch my entire project

1605:43

on that but if you don't care about that

1605:44

so you don't even have to worry about

1605:46

that so for now we are going to be just

1605:47

working with the dummy API so now we are

1605:49

going to be importing two things so the

1605:51

first thing which we are going to be

1605:52

importing is the create API and then the

1605:54

fetch base query okay so from where we

1605:58

are going to be grabbing all of that

1605:59

from the redex toolkit and then the

1606:02

query and react okay so we're going to

1606:04

be grabbing all of that stuff not all of

1606:06

them but these two stuff from this uh

1606:09

redex toolkit and then query and from

1606:11

the reactjs and now let's just uh create

1606:13

instance of the create API and inside

1606:16

that we're going to be passing our

1606:18

object right here and inside this object

1606:20

as we learn in the slices so we have to

1606:22

write a name but not right here here

1606:24

we're going to have to provide the path

1606:26

so I'm going to just write a reducer

1606:28

path and inside this reducer path we're

1606:30

going to be just providing some name

1606:32

right here in my case I'm going to just

1606:33

give the name of like products you can

1606:35

give it any name you like so you can

1606:37

think about that is like a name for our

1606:39

create API method and now we're going to

1606:41

be just passing our M query like where

1606:44

in the world we are going to be fetching

1606:46

our data like what will be the URL from

1606:48

where we're going to be fetching all of

1606:49

our data so now let me just write my

1606:51

fetch Bas come on fetch Bas query and

1606:54

inside that we're going to be just

1606:56

passing over curly braces and here we

1606:58

just have to write a Bas URL and here

1607:01

we're going to be just passing our URL

1607:03

right here so if you're working with the

1607:04

real API and uh you just create that by

1607:07

using Express and mongodb and all of

1607:10

that kind of stuff which I already show

1607:11

you in my mer St so you can totally

1607:13

provide there but in my case we are

1607:16

going to be just working with a dummy

1607:17

API so now let me just place a link off

1607:20

there so we are going to be fetching our

1607:22

data by using this dummy API okay so now

1607:24

let me just provide a comma and then

1607:27

here we just have to provide our

1607:28

endpoint so now let me just WR endpoints

1607:31

like from which specific URL we're going

1607:33

to be grabbing our data so now let me

1607:35

just show you the documentation of the

1607:37

dummy API okay so I'm going to just

1607:40

click on this one and and here I want

1607:43

you to just come to this link which is

1607:44

dummy jason.com and it is supremely

1607:48

white so now let me just make that dark

1607:50

I just click on that docs and it just

1607:52

brings us to this page right here so

1607:53

here you can see we're going to be

1607:54

posting or we are going to be getting

1607:56

our data from this uh dummy Json API and

1607:59

we have a lot of end points right here

1608:01

for different kind of things so we can

1608:03

also get the resources we can just limit

1608:05

that and we can do all L sort of stuff

1608:07

with them but we are not going to be

1608:09

doing all of them so now let me just

1608:11

show you like for instance if if you

1608:12

want to get all of the products so for

1608:14

there we going to be working with uh let

1608:17

me just show you the end point so for

1608:18

there we're going to be using this

1608:19

products endpoint right here let me just

1608:21

highlight that for you we are going to

1608:23

be fetching our data by using this

1608:24

endpoint so it's going to gives us all

1608:26

of our products so now let me just copy

1608:28

this link and now let me just place that

1608:30

right here in the new T so it's going to

1608:32

gives us all of that data with title

1608:35

description and images and every single

1608:37

thing right here so it's going to just

1608:39

give us all of the products then the

1608:40

next one we have is a specific product

1608:43

like for instance if you want to get a

1608:44

specific product like one page so now

1608:46

let me just copy this line of code and

1608:49

now let me just place it right here so

1608:50

it's going to just only gives us one

1608:52

product right here and if you want to

1608:54

just uh get the second product or

1608:55

something like that so I'm going to just

1608:57

provide a two and it's going to just

1608:58

gives us the second product with the ID

1609:00

of two right here okay so you can learn

1609:02

more about this API by yourself but yeah

1609:06

here we are going to be passing that

1609:07

specific endpoint we already provide our

1609:10

base API URL right here then we we're

1609:12

going to be working with some sort of a

1609:14

Endo so now let me just provide some

1609:16

sort of endpoint right here in this case

1609:18

we're going to have to pass over Arrow

1609:20

function and for the perimeter we are

1609:22

going to be passing the Builder and

1609:24

inside that let me just uh pour my C

1609:26

braces right here and inside there we're

1609:29

going to be doing a bit of magic or rtk

1609:31

will do a bit of magic so let's suppose

1609:33

if you want to get all of the products

1609:34

from this specific API so we're going to

1609:37

have to work with this end point right

1609:38

here which is the products okay so for

1609:41

that here we're going to we just

1609:42

creating our endpoint right here and

1609:44

here we just have to pass our API

1609:46

endpoint you can give it any name you

1609:47

like but in my case I'm going to just

1609:49

give it the name of like get um all

1609:53

products would be fine okay once again

1609:55

you can give it any name you like but in

1609:56

my case I'm going to just give it the

1609:58

name of like get all products and it's

1609:59

going to be set to the builder. query

1610:02

and why are we writing a query right

1610:04

here we are first of all using this

1610:06

Builder perimeter which this Endo will

1610:08

take and we are using this method on

1610:10

there well in this case we want to get

1610:13

all of the products so that's why we are

1610:15

now writing a query if you have to

1610:17

change some sort of a data in this

1610:18

endpoint like for instance if you want

1610:20

to change like change something or

1610:22

update something or delete something so

1610:24

for that we're going to have to write a

1610:26

mutation in this case we are not

1610:28

changing the data we are only getting a

1610:31

data from a specific endpoint of this

1610:33

URL so for that we are going to have to

1610:35

just pass the query we are reading the

1610:38

data or you can just write a reading the

1610:41

data we are reading the data so that's

1610:43

why we are now using this query method

1610:45

right here and inside this query method

1610:47

we are going to be passing our object

1610:49

and inside this object we just have to

1610:50

write a query okay so if we just write a

1610:53

query and here we just have to pass our

1610:54

error function and then finally we just

1610:57

have to pass our endpoint so you can use

1610:59

a single code you can use a double Cote

1611:01

or you can also use this back Tex right

1611:03

here something which I'm going to be

1611:04

showing you in a few seconds but here

1611:06

I'm going to be just sending request to

1611:08

this products right here so what are we

1611:10

doing I'm going to cut that from here

1611:12

and I'm am going to just place it right

1611:14

here so this is what we are doing so our

1611:15

best URL is this URL and we are now

1611:18

currently working with uh this products

1611:21

endpoint so that's why we going to have

1611:22

to pass this endpoint right in here so

1611:25

now let me just save that so now we

1611:27

successfully create or inpo right here

1611:29

but the real magic happens right here so

1611:32

what do I mean by the Magic by magic I

1611:35

mean that rtk query will automatically

1611:38

create a hook based on this Endo so how

1611:41

the what we are going to be using that

1611:43

hook or how in the world we are going to

1611:44

be even seeing that hook okay so the

1611:47

syntax is looking a bit confusing but I

1611:49

want you to bear with me for a few

1611:50

seconds so we're going to be exporting

1611:53

con and we're going to be exporting

1611:54

something from where we're going to be

1611:56

exporting there from the product API

1611:58

which we already store right here okay

1612:00

so we are going to be exporting

1612:02

something from this product API so what

1612:04

are we exporting well we just name or

1612:06

endpoint the get all products what rtk

1612:10

query will do for us behind the scene is

1612:12

going to just create some sort of a

1612:14

string and inside that string we already

1612:16

have the use and we already have either

1612:19

the query or we have the mutation okay

1612:23

so in this case we are working with the

1612:25

query because we want to just query some

1612:28

sort of a products right here so here

1612:30

you can see we're working with the query

1612:32

method so that's why the rtk query will

1612:34

behind the scene add the use first of

1612:36

all and then it's going to also add this

1612:39

query right here at the end and at the

1612:41

middle of this it's going to add this

1612:44

get all products so now let me just

1612:46

place it right here and I already told

1612:48

you that the syntax will look a bit

1612:49

confusing but trust me it's not and what

1612:52

it will do is that it's going to just

1612:53

make it as uppercase G and then the rest

1612:56

of them will be in lower case just like

1612:58

in a camel case whatever you want to

1612:59

call that so then it's going to just

1613:02

remove these empty spaces and this is

1613:04

what's going on behind the scenes so

1613:06

first of all we can create our endpoint

1613:07

like this or we can work with our

1613:10

endpoints and you can give it any name

1613:11

you like you you can give it the name of

1613:13

banana you can give it the name of Apple

1613:14

you can give it any name you like and

1613:17

then what rtk query will do behind the

1613:19

scene is that it's going to add this use

1613:21

as inside the string and then it's going

1613:23

to add the query so here is a bit of

1613:26

logic if you working with a mutation

1613:28

which I'm going to also show you in a

1613:30

few seconds so it's going to add that

1613:32

mutation right here so

1613:34

mutation right here but in this case

1613:36

we're working with a query so it's going

1613:38

to add this query right here and then we

1613:41

have this get all all products method

1613:43

right here okay or hook so it's going to

1613:45

just create the same hook for us now let

1613:47

me just remove that and we did not

1613:50

create this hook right here by ourselves

1613:52

so if I just write the use and here you

1613:54

can see it's going to gives us that get

1613:56

all products query so if I click on that

1613:59

and here you can see it's going to give

1614:00

us their use first of all and then it's

1614:02

going to make this first letter

1614:03

uppercase and the rest of them lower

1614:05

case or in camel Cas whatever you want

1614:07

to call that and finally it's going to

1614:09

attach this query at the end okay so now

1614:12

let me just sve my file and that was the

1614:14

entire logic okay so the first thing

1614:17

which you have to do is that we have to

1614:19

grab these two method and then we have

1614:21

to just execute this method we have to

1614:23

give it some sort of a name or the

1614:24

reducer path whatever you want to call

1614:26

that inside this Bas query we are going

1614:28

to be just specifying our API URL and

1614:32

then we are going to be sending request

1614:33

to specific URL okay so in this case

1614:36

we're just sending request to this

1614:38

product so it's going to just gives us

1614:39

all of that products and based on this

1614:41

spefic spefic endpoint it's going to

1614:43

just create a specific hook for us and

1614:45

first of all it's going to just attach

1614:47

the use first of all and then at the end

1614:49

it's going to also attach the query and

1614:51

inside there it's going to just add our

1614:53

endpoint name yeah that was a lot of

1614:56

talking now we successfully create our

1614:59

API right here but now the next thing

1615:00

which you have to do is that we have to

1615:02

register that inside our store so to

1615:04

register that inside our store the first

1615:06

thing which you have to do is that we

1615:07

have to grab one thing which is called

1615:09

the setup listener you you don't have to

1615:12

worry about this thing right here which

1615:14

I'm about to show you right here you

1615:15

don't even have to worry about this

1615:17

setup listener you have to write that

1615:19

but you don't have to worry about that

1615:20

the next thing which you have to do is

1615:22

that we have to grab our product API

1615:24

from this specific Services folder and

1615:26

then we have a Dem data so now we

1615:28

successfully grab this product API from

1615:31

there and now let me just go ahead and

1615:32

go to the reducer and we just have to

1615:34

registered there so now let me just

1615:35

registered there right here but here is

1615:37

a bit of catch we are not going to be

1615:39

writing a property and then value

1615:41

specific to that property first of all

1615:43

we're going to be just writing a opening

1615:45

bracket and then the closing bracket

1615:46

because currently we are working with

1615:48

the rtk query not just a Redux toolkit

1615:51

we are working with the rtk query so

1615:54

then we just have to copy the name and

1615:56

now let me just place that right here

1615:57

then we have to use the dot and here

1615:59

we're going to have to just provide this

1616:02

reducer path so I'm going to just copy

1616:04

then now let me just place it right here

1616:06

and it's going to be equals to this

1616:07

product API and then reducer okay so you

1616:11

just have to do the and now you might be

1616:13

asking like what in the world is this

1616:14

setup listener it is only helpful for

1616:17

caching and then you have to also attach

1616:20

two more things which you also don't

1616:23

worry about don't worry about this code

1616:26

which I'm writing right here but you

1616:28

have to specify this code so this is a

1616:30

middleware and it's going to just only

1616:32

help you with the caching nothing else

1616:34

in there okay so then finally we just

1616:36

have to use the set of listener and

1616:38

provide our dispatch to it so now let me

1616:40

just call this set of listener and we're

1616:42

going to be just providing a store and

1616:43

then dispatch and now let me just God

1616:46

damn what the hell did I just do so now

1616:47

let me just save that so and that was

1616:50

the entire setup or the entire flow of

1616:52

rtk query let me just rewind that once

1616:54

again very quickly the first thing which

1616:56

you have to do is that we have to grab

1616:57

every single thing then we have to

1616:58

provide a name for our API and then here

1617:00

we're going to be just passing our base

1617:02

query and we're going to be providing

1617:03

some sort of a URL and based on that

1617:05

endpoints it's going to just create a

1617:07

hook for us and then we're going to have

1617:09

to register there by using the by first

1617:11

of all grabbing this of listener and

1617:13

also we have to grab our API and inside

1617:16

that we're going to be just using these

1617:17

brackets and inside these brackets we're

1617:19

going to have to use our API name and

1617:21

then specific path which we are already

1617:24

providing right here and then we have to

1617:25

just set that to our API reducer that's

1617:28

all the thing that you have to do and

1617:30

that was just an entire setup of rtk

1617:32

query next we are going to be learning

1617:34

about how we are going to be using uh

1617:36

that specific uh endpoint which we

1617:38

already created right here inside our

1617:40

app component or react component so to

1617:43

use this endpoint the first thing which

1617:44

you have to do is that we have to create

1617:46

a separate folder inside the SRC folder

1617:50

so we're going to be creating a folder

1617:51

I'm going to just give name of like uh

1617:53

components and inside this component

1617:55

we're going to be just first of all

1617:56

creating all products. jsx now let me

1617:59

just use my RFC s my file and now let's

1618:03

just register that inside my app

1618:04

components now let's just remove that

1618:07

and now let me just add my all products

1618:10

and now let's just close there same my

1618:12

file let's just go back and let me just

1618:14

show you that and here you can see we're

1618:16

now getting all of the products right

1618:17

here which is okay let's just close

1618:19

every single thing and now we have to go

1618:22

ahead and go to this component and the

1618:23

first thing which we have to do is that

1618:25

we have to grab our specific hook which

1618:27

we already created right here okay so

1618:29

I'm going to just go ahead and show you

1618:31

that let me just go ahead and go to my

1618:33

Demi data and we're going to be just

1618:35

getting this hook okay so I'm going to

1618:37

just copy the name of this hook and we

1618:39

are going to be first of all importing

1618:41

that hook from let's just go ahead and

1618:43

go to the app then we have to go to the

1618:45

service then we have to go to the Dem do

1618:47

or Demi data okay so now let me just

1618:49

save there let's just go back and now we

1618:51

have to use that so I'm going to just

1618:53

copy that and now we have to call this

1618:55

hook right here so I'm going to just

1618:56

write like con res it's going to be

1618:58

equals to this use get all products

1619:00

query and here what I want to use that I

1619:02

want to write a cons log of R and now

1619:05

let's just save there and now let me

1619:06

just refresh there let me just make

1619:08

there a dark right click on there and go

1619:10

to the inspect area and now let me just

1619:12

zoom in a bit so it's going to just

1619:14

gives us a lot of objects and I'm going

1619:16

to tell you why let's just refresh that

1619:18

so here in this case we are now fetching

1619:20

our data so first of all it's going to

1619:21

just gives us the empty status right

1619:23

here then it's going to gives us the

1619:24

status of pending and then finally it's

1619:27

going to gives us the status of

1619:29

fulfilled because we are sending request

1619:31

to the actual endpoint so that's why we

1619:33

are now getting all of the data and here

1619:35

you can see we have the current data and

1619:36

we have a products and inside this

1619:38

products we have all of the products we

1619:41

have a brand we we have the category

1619:42

description discount we have the ID the

1619:45

images we also have the prices every

1619:48

single thing that we currently have

1619:49

right here and we also have something

1619:52

which I also want to show you but let's

1619:55

just collapse this one and we have the

1619:57

data right here but we have okay this

1620:00

one so here you can see we have a is

1620:02

error property and it is now set to

1620:04

false because we don't have any errors

1620:06

and we are getting our data but if we

1620:08

have some sort of Errors so we would uh

1620:10

render that specific error right here

1620:12

then we have a is lowering we can also

1620:14

provide a lower based on that and we

1620:16

have a is Success so we can totally use

1620:18

that so now let me just use the right

1620:20

here instead of talking I just want to

1620:22

write some code so the first thing which

1620:24

you want to do is that let's just uh let

1620:28

me just remove that from here and I'm

1620:30

going to be just destructuring first of

1620:31

all the data and then we are going to be

1620:33

also destructuring this is error which I

1620:36

already show you and we're going to be

1620:37

also destructuring this is loading as

1620:40

well okay so now let me just pour some

1620:42

sort of like if statement you don't have

1620:44

to do that but I am going to do that

1620:46

because if you have some sort of error

1620:48

so if is errored so what do you want to

1620:50

do in there we just want to return the

1620:52

H1 and I'm going to just say like

1620:55

oh

1620:57

no uh we got an error or something like

1621:02

that and if we have a loader I mean like

1621:04

if we have a loading is loading so what

1621:07

do you want to do in that case we just

1621:08

want to return the H1 come on H1 one and

1621:12

we are going to be just writing a

1621:13

loading dot dot dot let's just remove

1621:15

the empty space from there s file and

1621:18

refresh there so it's going to just giv

1621:19

us that loader for a second and then

1621:21

it's going to just gives us that all

1621:23

products right here okay so we are

1621:25

getting the data so everything is

1621:27

working a okay like we are getting the

1621:29

data but now we have to iterate over

1621:31

through all of that data and render that

1621:33

right here inside this div so now let me

1621:35

just remove that from here and what I'm

1621:37

going to do is that I'm going to just

1621:38

write my data right here if you have the

1621:41

data so what we want to do we are going

1621:42

to be just getting the products from the

1621:44

data and we are going to be iterating

1621:46

over through all of that product so we

1621:47

are going to be just passing this Arrow

1621:49

function and then we are going to be

1621:51

just rendering all of the products by

1621:53

using this H1 so now let me just write

1621:55

H1 right here and here we just have to

1621:57

pass the product. title and then we have

1622:00

to also provide a key and we just have

1622:02

to provide a specific ID key so now let

1622:04

me just save that and here you can see

1622:06

it's going of just gives us all of their

1622:08

data and all of the titles from the data

1622:11

right here so we we have a Samsung we

1622:13

have a lot of data right here okay so

1622:15

you can render all of the data you can

1622:17

provide a styling to that or you can

1622:19

even provide more logic than that but

1622:21

now let me just uh log the data to the

1622:23

console so we have a console log of data

1622:25

s file and here you can see it's going

1622:27

to just use us there let's just click on

1622:29

this so here you can see we're now

1622:30

fetching our data from this product so

1622:32

we have a specific product so you can

1622:34

grab the brand you can grab the category

1622:37

you can grab the description so now let

1622:38

me just grab a description right here so

1622:40

I'm going to just writing a

1622:43

paragraph and let's just render our

1622:45

paragraph dot description what was that

1622:49

description yeah let's just copy that

1622:51

and now let me just place it right here

1622:53

sell file but we have to WRA that inside

1622:56

the fragment so that's why it is

1622:57

freaking out right here now let's just

1622:59

close that and save that and here you

1623:01

can see it's going to also giv us that

1623:02

descriptions right here you can render

1623:04

all of that data right here but I guess

1623:06

that was enough for this specific

1623:08

example and yeah this is how we are

1623:10

going to be getting the this is how we

1623:12

are going to be handling the errors if

1623:13

you got one and this is how we going to

1623:15

be providing a specific loader you can

1623:17

even provide a PNG right here or you can

1623:20

even style this loader to something else

1623:21

by using TN CSS or a built-in loaders or

1623:25

something like that but in my case

1623:27

that's it baby okay so yeah this is how

1623:29

we going to be getting all of the data

1623:31

and now let's talk about how we going to

1623:32

be getting a specific product by ID so

1623:35

here you can see back to our Demi data

1623:37

and I'm going to just remove that and

1623:39

here we're going to be creating yet

1623:40

another endpoint so I'm going to just

1623:42

give it name of like Get product buy ID

1623:46

okay and here we're going to be just

1623:47

writing a builder. come on uh builder.

1623:52

query once again because we are fetching

1623:54

the data you're not mutating the data

1623:56

and here we're going to be just passing

1623:57

the ID right here in this case uh and

1623:59

now we are going to be sending our

1624:01

request to the products and then a

1624:03

specific ID right here okay so now let

1624:05

me just show you a documentation of let

1624:06

me just go ahead and go to there and

1624:08

here you can see we're going to be just

1624:09

specifying some sort of a dynamic ID to

1624:11

there so that's why we are now getting

1624:13

the ID and we are now rendering that ID

1624:16

dynamically so now let's just create a

1624:18

hook based on there it is already built

1624:21

so we don't have to create that by

1624:23

yourself so we going to be just writing

1624:24

a use and here you can see we have a use

1624:27

uh products by ID there we go so now let

1624:29

me just saell there and here you can see

1624:31

it's going to give us that use products

1624:32

by ID let me just copy there and now we

1624:35

have to use that inside or another

1624:37

component and I'm going to be creating a

1624:38

component given name of like s come on S

1624:41

P fic specific product. jsx right here

1624:46

and I'm going to be using the RFC save

1624:49

my file and copy there come on copy

1624:52

there let's just go ahead and go to the

1624:53

app we have to comment this line out and

1624:56

what the hell did I just do let's just

1624:58

place right here save my file and we

1625:00

have to also even grab that so let's

1625:02

just grab that and now let me just show

1625:04

you that right here so here you can see

1625:06

we're now getting specific product and

1625:08

now let's just work with that I'm going

1625:09

to even comment this line out sa my file

1625:11

and now let's work with this specific

1625:13

product the first thing which you have

1625:14

to do is that we have to grab our Hook

1625:16

from this Dem data which is already

1625:19

created right here so now let me just

1625:20

copy that and we are going to be

1625:22

grabbing that hook right here from where

1625:25

from let's just go ahead and go to the

1625:27

app then we have to go to the service

1625:29

then we have to go to the Demi data so

1625:31

I'm going to copy that and now let me

1625:32

just write con uh data and then is error

1625:36

if you have one and then is loading uh

1625:39

it is loading there we go go from where

1625:42

from this hook and here we are going to

1625:44

be just passing some sort of a dynamic

1625:45

ID so in my case I'm going to just

1625:48

specify two in this case so now let me

1625:50

just log that data to the console so now

1625:51

let me just save that and refresh let me

1625:54

open my def tools and here you can see

1625:56

it's going to just first of all giv us

1625:57

the undefined undefined and then it's

1625:59

going to giv us the brand of apple and

1626:00

then it's going to giv us the category

1626:02

of Smartwatch now let me just copy that

1626:05

and show you that whether it's working

1626:08

or not so I'm going to just specify two

1626:11

right here and it's going to indeed

1626:13

gives us the ID of two and the title of

1626:15

iPhone x what the hell where is the

1626:19

category let me just show you the

1626:21

category

1626:23

uh come on let's just search for the

1626:25

CATE there we go so the category

1626:27

smartphones yeah it is working totally a

1626:31

okay so we are getting something right

1626:33

here so we can totally do a lot of

1626:35

things with that but you know what let

1626:37

me just copy this logic from this

1626:39

component so I'm going to be just

1626:40

copying this logic and now let me just

1626:43

place that logic right here so if you

1626:44

have some sort of error then just show

1626:46

this error and if you have some sort of

1626:48

a loading so we are going to be just

1626:49

pting this loader right here we just

1626:51

told okay but now we have to work with

1626:54

this actual data which we are already

1626:56

getting right here so now let's just

1626:57

remove that from here and inside this D

1626:59

we're going to be just creating H1 and

1627:01

first of all we have to just specify if

1627:03

we have the data so what do you want to

1627:05

do we just want to get the brand from

1627:07

there so now let me just save that and

1627:09

here you can see it's going to give us

1627:10

the brand of Apple and now let's just

1627:12

duplicate that if we have some sort of a

1627:13

data so we also want to get the category

1627:16

if you wanted to s file and here you can

1627:18

see it's going to give us that category

1627:20

now let me just duplicate that we can

1627:21

also get the description if you want to

1627:24

s file and it's going to also giv us

1627:25

their description right in here okay so

1627:28

this how we going to be fetching a

1627:30

specific product using this query right

1627:32

here so we can specify different kind of

1627:34

ID so let's just provide a five ID so

1627:37

files so it's going to give us different

1627:39

datab based on there and now I can just

1627:41

specify like I guess 10 s files is going

1627:44

to give us totally different data okay

1627:46

so yeah so now I want to add a new

1627:48

product so I'm going to go ahead and go

1627:49

to my Dem data and here let's just go

1627:52

ahead and go to this endpoint and I'm

1627:54

going to be creating a different

1627:55

endpoint which will be add new product

1627:59

and here we are going to be using the

1628:00

builder. mutation because we are adding

1628:03

a product we are doing something we are

1628:06

not just querying the data we are not

1628:08

just fetching the data we are doing

1628:10

something with that data so in this case

1628:12

we are going to be just adding a new

1628:14

data or new item to our specific

1628:16

endpoint not actually because we cannot

1628:20

provide our new data to someone else API

1628:23

but I'm going to just show you a success

1628:24

message or something like that so in

1628:26

this case we have to use the mutation

1628:28

right here so what I want to do is that

1628:30

I want to provide my object right here

1628:32

and the syntax will be totally the same

1628:34

in this case we're going to be querying

1628:36

the data and we are going to be also

1628:37

providing the new product it and now

1628:39

let's just provide or for object once

1628:42

again and here we're going to be just

1628:43

spacing the URL and the URL in this case

1628:46

will be now set to this product and now

1628:49

let me just show you there we're going

1628:50

to be sending a request to let me just

1628:53

show you there so here you can see we

1628:54

have add a new product so here you can

1628:56

see get a single product not this one

1628:59

but eror product how we are going to be

1629:01

doing that now let me just click on that

1629:03

and yeah here you can see this how we're

1629:06

going to be adding a product so we're

1629:07

going to be using this API the end the

1629:09

end point will be products and then add

1629:12

okay so we are going to be also

1629:13

providing the method of post and the

1629:15

headers will be content and application

1629:17

Json and the Bor will be set to this in

1629:20

there okay I don't want to waste your

1629:21

time but now let me just show you there

1629:23

so in this case we're going to be just

1629:24

passing the add right here now let me

1629:26

just provide a comma here so this is

1629:28

going to be our end point now the next

1629:30

thing which you have to do is that we

1629:31

have to also past the method in this

1629:33

case we are posting the data so that's

1629:35

why we have to write a post method now

1629:38

the next thing which you have to do is

1629:39

that we have to also specify the heads

1629:41

as as well and the headers in this case

1629:43

they are now taking the content content

1629:46

and then type and here it's going to be

1629:48

equals to the application SL Json okay

1629:51

now let me just put a comma and then we

1629:54

also have to specify the body and for

1629:56

the body we are going to be attaching

1629:57

this new product to it which we are

1629:59

already providing inside the perimeter

1630:01

so we're going to be using that right

1630:02

here so now let me just save that and

1630:04

it's going to already already create

1630:06

this hook for us so I'm going to just

1630:07

write like use and here you can see add

1630:10

new product mutation now let me just

1630:11

save that and it's going to just uh make

1630:14

it a bit cool I'm going to copy there

1630:17

and here let's just create a new

1630:18

separate component for that so add new

1630:21

product. jsx I'm going to be using the

1630:24

RFC one more time and now let me just

1630:26

save that once again copy that and

1630:28

import that right here let's just come

1630:30

this line out and import that right

1630:34

here let me just hit enter right

1630:36

here and I'm going to be just commenting

1630:39

this line out and yeah let's just save

1630:41

there and here you can see we now

1630:43

getting add a new product now I'm going

1630:45

to just go to my component and then I'm

1630:47

going to copy there and now let me just

1630:49

use that right here okay so I'm going to

1630:51

just grab that first of all and then we

1630:54

are going to be just going into our app

1630:56

and then we have to go to the services

1630:59

and then we have to go to the Demi data

1631:01

now let me just create an instance of

1631:03

that but here is a bit of catch I'm

1631:05

going to just WR resence going to be

1631:06

equals to the same method or hook

1631:08

whatever you want to call that but if I

1631:10

just lock to the so this res semi file

1631:13

and refresh there right click on there

1631:14

and go to the inspect element and here

1631:16

you can see it's going to gives us array

1631:19

not an object like in these cases uh if

1631:22

you were to grab our data so we were D

1631:24

structuring our data by using this

1631:26

syntax which is the object destructuring

1631:29

but now in this case it is giving us the

1631:31

array okay so inside this array we have

1631:34

a status and we have is error loading

1631:36

success in every single thing right here

1631:38

so you know what let me just show you

1631:40

now I don't want to go to the pro

1631:41

protype but here you can see we have

1631:42

that function which we already created

1631:45

so it is taking the name and every

1631:46

single thing we don't have to care about

1631:48

that but we're going to be destructuring

1631:50

all of these data by using the array

1631:53

syntax or array destructuring syntax so

1631:55

I'm going to just uh remove this rest

1631:58

from here and in this case we have to

1631:59

specify the array D structuring syntax

1632:02

and in this case we have to just write

1632:03

add new product so new product in this

1632:07

case so why are we doing that this is

1632:09

going to be the function which we're

1632:10

going to using to add a new product so

1632:13

we are now using this add new product

1632:16

right here so I'm going to copy that and

1632:18

we can totally use that right here but

1632:19

we are going to be also

1632:21

destructuring a nested destructure so

1632:24

this is array destructure and inside

1632:26

there we have the object destructured so

1632:28

inside this object we are going to be

1632:30

first of all destructuring our data

1632:32

we're going to be also destructuring the

1632:33

error and also the is loading we're not

1632:36

going to be taking care of the rest of

1632:38

them but you know let me just take care

1632:40

of that let me just show you every

1632:42

single thing God damnn it so let me just

1632:44

if you have some sort of error so what

1632:46

do you want to do with that error we

1632:47

going to be just writing like error or

1632:50

something like that and if you have some

1632:52

sort of a loader so is loading so we're

1632:54

going to be just returning the H1 come

1632:57

on let me just return my H1 off loading

1632:59

dot dot dot so now let me just save that

1633:02

so everything is completed but now we

1633:03

are left with the add new product and

1633:05

also this data right here so now let me

1633:07

just take care of that while I was

1633:09

writing the rest of the code I just

1633:11

realize that I made a mistake right here

1633:12

inside a product it shouldn't be a

1633:15

product it should be a products with s

1633:17

so now let me just save there and here

1633:19

first of all we're going to be using

1633:21

this add new product and then we're

1633:23

going to be using this data so then we

1633:26

will be able to see like which kind of

1633:27

data we added so I'm going to just go

1633:29

ahead and create some sort of a function

1633:31

right here well you know first of all

1633:33

let me just create a button right here

1633:34

so now let's just create a button I'm

1633:35

going to create a button and I'm going

1633:37

to just say like add new product right

1633:40

here here and we're going to be adding a

1633:42

new product but first of all we're going

1633:43

to be just attaching some sort of event

1633:45

handler so we have on click event

1633:47

handler and we're going to be just

1633:49

passing some sort of a function which

1633:50

we're going to be creating in a few

1633:51

seconds which will be handle and product

1633:54

right here okay and we're going to be

1633:56

also providing a disabled State on there

1633:58

and if it's loading then it should be

1634:00

disabled so now let me just save there

1634:02

but now let's just create this function

1634:03

right here up above so let's just create

1634:06

or add new add new function or add

1634:09

handle product and it should be an

1634:11

asynchronous function because this is

1634:13

not our code we are currently working

1634:15

with the API so this should be an

1634:17

asynchronous code and inside that we're

1634:19

going to be using the TR and catch

1634:20

blocks for the catch block uh we are not

1634:23

going to be writing a total error we are

1634:25

going to be just writing a ER R and now

1634:26

let me just place that right here and

1634:28

for the tri block what do you want to do

1634:30

first of all we are going to be creating

1634:32

a new product so I'm going to just write

1634:33

like a new product uh or you know

1634:36

product data would be fine and we are

1634:38

going to be just writing like some sort

1634:39

of ID to it like ID will be one the

1634:41

title will be like amazing t-shirt or

1634:45

something like that and description will

1634:47

be I don't know I'm going to just copy a

1634:49

description from somewhere so now let me

1634:50

just place this description right here

1634:52

so now let me just save that now we

1634:54

successfully create our product but now

1634:56

we have to use this function which is

1634:58

the add new product now let me just copy

1635:00

that and I'm going to just place it

1635:02

right here but I'm going to call there

1635:05

but first of all we have to use the a

1635:07

because currently we're working with the

1635:08

asynchronous function and inside this

1635:10

function it is requiring the perimeter

1635:13

of uh what do we call the new product so

1635:16

we have to pass some sort of a product

1635:17

to it so we already create our product

1635:19

so now let me just copy this product

1635:21

name and then now let me just place it

1635:23

right here sell file we already binded

1635:25

this method right here but now the next

1635:27

thing which you have to do is that you

1635:28

want to see something once we add some

1635:30

data right here okay so what I want to

1635:32

do is that I'm going to just place this

1635:34

coding right here semi file so what are

1635:36

we doing first of all we are getting the

1635:37

ID then we are getting the title and

1635:39

also description so now let just saell

1635:41

that and refresh that and here you can

1635:43

see it's going to just giv us that add

1635:44

new product button which you already

1635:46

created right here but now if I click on

1635:48

that it's going to just give us the

1635:49

loading and then it's going to gives us

1635:51

that dare right here so it's going to

1635:53

give us that ID it's going to give us

1635:55

that amazing t-shirt and also this

1635:57

description which we already provided

1635:59

right in here okay so yeah this how we

1636:01

are going to be adding a new product to

1636:03

our dummy API by using the Builder

1636:06

mutation so now let's update our product

1636:08

not really but yeah I am going to show

1636:11

you that because docs allows us to do

1636:14

that so we are going to be doing

1636:16

something about that so let's just use

1636:17

our build our mutation because currently

1636:20

we're going to be mutating or changing

1636:22

the data so it's going to take a

1636:23

specific ID and then the updated product

1636:27

right here okay so now inside that what

1636:29

you want to we're going to just

1636:30

specifying the URL and we're going to be

1636:32

sending a request to a specific URL

1636:34

which will be a products and the

1636:36

specific ID but we have to provide the

1636:38

parentheses for here okay let's just

1636:41

provide our parentheses right here and

1636:43

I'm going to also provide a comma here

1636:45

and now the next thing which you have to

1636:46

do is that we have to add the method and

1636:48

the method will be put you can learn

1636:50

more about that in the documentation if

1636:51

you wanted to but haors and haors will

1636:54

be the content type and it's going to be

1636:58

now equals to the

1637:01

application and then Json okay so now

1637:04

let me just provide the final thing

1637:05

which will be the body and we're going

1637:07

to be just writing the updated product

1637:09

right here okay so now let me just save

1637:10

that and based on that we're going to be

1637:12

just creating a new hook which will be

1637:14

the use update product mutation so now

1637:16

let me just copy there cut this file cut

1637:19

this file out and now we are going to be

1637:21

creating yet another component so update

1637:24

product. jsx and here we're going to be

1637:27

using the RFC sa my file copy there and

1637:30

now let me just comment this line out

1637:33

and here we're going to be just passing

1637:34

this update product right here okay so

1637:37

let's just provide our update product

1637:38

and now let's just come in this line out

1637:41

semi file and let's just check it out so

1637:43

here you can see we have our update

1637:44

product Right Here and Now inside there

1637:47

the first thing which you want to do is

1637:48

that you want to go ahead and go to our

1637:51

uh Dem data and we have to copy that and

1637:53

we have to copy the hook and we have to

1637:55

just import that right here so we are

1637:57

going to be importing that from where

1637:59

from or let's just go to the app then we

1638:02

have to go to the service then we have

1638:03

to select the Dem data right here okay

1638:05

now let me just copy that and you

1638:07

already know that we are currently

1638:08

working with the mutations so there we

1638:10

we have to use the ARR structuring so we

1638:13

are going to be grabbing the updated

1638:15

product and also the data and the error

1638:18

and there is loading right here okay

1638:21

let's just go back s file and now let me

1638:24

just take care of the errors and stuff

1638:26

so I'm going to be just writing an error

1638:27

if you have one so let's just WR our H1

1638:30

and then let's just render that specific

1638:32

error and now uh I guess I'm going to

1638:35

also take care of the loader as well if

1638:38

we have some sort of isas loading so so

1638:40

then we just want to write H1 and

1638:43

loading dot dot dot Cas s file and now

1638:47

let's just take care of the rest of the

1638:48

data I'm going to be creating a separate

1638:50

button right here let me just name that

1638:53

as or label that as update product and

1638:56

we're going to be attaching the event

1638:57

listener on there which will be the on

1638:59

click and let's just add the handle

1639:02

update product and it is going to be

1639:05

disabled if it is loading okay so yeah

1639:09

now let me just create the right here

1639:10

I'm going to copy that and now let's

1639:12

just create that right in here it will

1639:14

be the asynchronous function because we

1639:17

are working with the API so now inside

1639:20

there we're going to be using the try

1639:22

and catch block let's just support the

1639:24

console log of error right here and for

1639:27

the tri block what do you want to do we

1639:28

just want to tr like updated Pro come on

1639:31

updated product data is going to be

1639:34

equals to some sort of updated title and

1639:37

title updator or something like that I'm

1639:39

going to also use the Emoji of this one

1639:41

right here save my file and then we're

1639:44

going to be just writing a and then we

1639:46

have to use our update product and we

1639:48

have to specify first of all some sort

1639:50

of ID to it so the ID will be just a

1639:52

product ID then we have to use our a n

1639:55

or function which will be update product

1639:58

and inside that you know what I want to

1640:00

do something I want to provide a prop

1640:02

here which will be the ID so I'm going

1640:05

to just write the product ID so I'm

1640:07

going to just write a product ID and

1640:09

it's going to be equals to two would be

1640:11

you know four would be fine so now I'm

1640:13

going to just save there and we also

1640:14

have to D structure there right here so

1640:16

I'm going to just write like product ID

1640:19

and now let me just copy there and now

1640:21

here inside there uh why are we getting

1640:24

there yeah let me just past it right

1640:26

here so inside that we're going to be

1640:28

passing the object and here we just have

1640:30

to specify the ID and ID will be this

1640:32

product ID and then we have to pass or

1640:35

updated product and it's going to be

1640:37

equals to the updated product data right

1640:40

here okay let's just select the same

1640:42

file but I don't know why we getting

1640:44

this error right here okay a word has no

1640:47

effect on the type of this expression

1640:49

but we are going to be still providing

1640:50

it anyways so yeah that's that I'm going

1640:53

to also have to just uh render my title

1640:55

right here I'm going to just place a

1640:57

right here so if you have some sort of a

1640:58

data then you want to get a specific

1641:00

title because currently we are only

1641:02

changing this title right here so here

1641:04

you can see it's going to give us that

1641:05

button but if I click on that uh it's

1641:08

going to give us an error

1641:10

uh okay so updating a product invalid

1641:13

hook call hooks can only be called

1641:15

inside of the body of the component what

1641:18

are we doing it shouldn't be updated it

1641:21

should be just update product I'm going

1641:24

to copy there and now let me just place

1641:26

there right here update product here and

1641:30

also yeah update product there we go so

1641:32

now let me just save there let's just

1641:34

refresh there and here you can see the

1641:35

air is gone but now if I click on this

1641:37

update product so it's going to gives us

1641:39

that title updated right here which is

1641:42

our own data okay so we can change that

1641:44

to like something else like something

1641:47

else or something like that now let me

1641:48

just save that refresh there and click

1641:51

on this update product so it's going to

1641:52

give us there something else right here

1641:54

so yeah this is how we going to be

1641:55

updating a data by using the rtk query

1641:58

so now let's talk about the final part

1642:00

of this project so which will be

1642:01

deleting a product so we're going to be

1642:03

creating yet another component which

1642:05

will be delete product BR uc. jsx I'm

1642:09

going to be using us the RFC copy the

1642:12

deleted product and now let me just

1642:14

render there right here and I'm going to

1642:16

be also passing a specific ID for this

1642:18

so I'm going to just WR a product ID and

1642:21

in this case we're going to be just

1642:22

deleting the ID of two and then we have

1642:25

to just F this uh deleted product right

1642:27

here so it's going to just Auto Import

1642:29

it right here now let me just comment

1642:31

this line out put that up above sell my

1642:33

file let's just go to our dummy API

1642:36

dummy API dummy data there we go okay so

1642:40

now Neath there what do you want to do

1642:41

we just want to delete a product so how

1642:43

what we are going to be doing there

1642:45

delete product will be now equals to the

1642:48

builder. mutation because we are

1642:51

changing something we are mutating

1642:53

something so that's why we have to

1642:55

specify the method of mutation and then

1642:57

we have to specify some sort of ID for

1642:59

that and inside that we're going to be

1643:01

passing our URL and it should be in the

1643:06

parentheses I always forget to include

1643:08

the parenthesis right here so now let me

1643:10

just for a products and then we are

1643:12

going to be just rendering a specific

1643:14

product and based on that specific ID we

1643:16

are going to be just deleting our

1643:19

product so now let me just put delete in

1643:20

uppercase okay so now let me just save

1643:23

them and now let's just create a hook

1643:25

for this so use delete product hook or

1643:27

mutation sell my file and remove them

1643:30

let me just go ahead and grab that right

1643:32

here I'm going to be just grabbing this

1643:34

Hook by

1643:36

using uh the name export so now let me

1643:39

just go ahead and go to my app and then

1643:41

we have to go to the service then we

1643:43

have to go to the Demi Demi data let me

1643:45

just copy that from here and inside that

1643:47

you already know what we have to do

1643:49

because we learned a lot about rdk query

1643:53

and now let me just place it right here

1643:54

we also even have to D structure or uh

1643:58

come on product ID right here and then

1644:01

inside that we're going to be also

1644:02

providing our delete product and list is

1644:05

provide our data and also the error and

1644:08

also is loading Okay so I'm going to

1644:10

just steal that other code from this uh

1644:13

add new product right here I'm going to

1644:15

just copy that and also this one and now

1644:17

let me just place it right here finally

1644:19

let's just create a button right here

1644:21

I'm going to just create a button which

1644:23

will say delete product right here okay

1644:26

and finally now let me just attach the

1644:28

on click event handler which will say

1644:30

the handle uh Delete product and it's

1644:33

going to be also disabled when it is

1644:36

loading okay so now let's just create

1644:38

the right here I'm going to just create

1644:41

the right here it's going to be

1644:42

asynchronous function and inside that

1644:44

we're going to be using the try and

1644:45

catch block for the catch block we're

1644:47

going to be providing that error and

1644:50

also we're going to have to write a and

1644:53

then just we have to execute or delete

1644:55

product and we have to specify that

1644:57

product ID okay which we are getting

1644:59

right here okay so yeah that's that but

1645:01

we also have to render some sort of a

1645:03

data right here so we can see something

1645:05

that something has been deleted so now

1645:07

let me just write my H1 and let's just

1645:09

see

1645:10

if we have the data. tile so what do you

1645:12

want to do in that case we just have to

1645:14

render or data. tile uh

1645:19

successfully deleted would be fine and

1645:22

if that's not the case we just want to

1645:23

provide empty string so now let me just

1645:25

save that and here you can see we have

1645:26

our delete product button but now if I

1645:28

click on that it's going to give us the

1645:30

loader and then it's going to just give

1645:31

us that iPhone x has been successfully

1645:34

deleted from the database so yeah that

1645:37

was a lot about RX toolkit and rtk query

1645:42

and next we're going to be building a

1645:57

project now let's talk about the design

1645:59

patterns so design patterns are common

1646:01

solution and best practices used to

1646:03

structure code efficiently making it

1646:06

more maintainable reusable and scalable

1646:08

but now that was just a quick definition

1646:10

of what are design patterns and we

1646:12

usually use design patterns in different

1646:15

programming languages but now the

1646:16

question is how the we're going to be

1646:18

using there in react JS as you all know

1646:21

that react itself is a UI library that

1646:23

focuses on building reusable components

1646:26

and design patterns provide a strategies

1646:28

for organizing component and logic

1646:31

within those component to promote

1646:33

consistency and optimize the development

1646:35

now I know a lot of you will ask me H

1646:38

why should I even care about learning

1646:39

Des design patterns in reactjs and I can

1646:42

give you a lot of answers to that

1646:45

questions but what I want you to do is

1646:47

that I want you to trust me that if you

1646:49

learn design patterns in reactjs you

1646:51

will have a lot more power than just a

1646:54

regular reactjs developer trust me it's

1646:56

going to give you a super power so yeah

1646:58

let's get into the setup of this course

1647:00

so now let me make a setup for recording

1647:02

Journey so I'm going to open my

1647:04

terminal I'm going to make that a bit

1647:06

bigger so you guys can see everything a

1647:08

bit better and I'm going to be using npm

1647:10

create we at latest I'll give it the

1647:12

name of DP demos like design pattern

1647:15

demos I'm going to choose reactjs with

1647:20

timecrimes and I'm going to install

1647:21

every single thing inside there now I'm

1647:23

going to go ahead and go to the tailin

1647:25

css.com click on the getting started

1647:27

button go to the framework and guides

1647:29

choose we and I'm going to copy all of

1647:32

these commands and place it right here

1647:34

I'm going to also hit enter so it's

1647:35

going to initialize my T CSS inside

1647:37

their project I'm going to copy this

1647:39

content from here just a content and I'm

1647:42

going to open my vs code right here now

1647:44

let me clean this up so I'm going to

1647:45

remove this public folder I'm going to

1647:47

also remove the SS folder the app. CSS

1647:49

folder and inside there I'm going to

1647:51

remove every single thing from the app.

1647:52

TSX file and I'm going to replace that

1647:54

with this RFC now let me go ahead and go

1647:57

to this T config file which is this

1647:59

config file and I'm going to replace

1648:01

them with this new content now I'm going

1648:03

to also copy all of these directives now

1648:05

let's just go ahead and go to index. CSS

1648:07

file remove every single thing from

1648:08

there and replace it with this new one

1648:11

I'm going to copy this line of code for

1648:12

the testing and replace that with this

1648:15

new one let me just save my file and I'm

1648:18

going to be using npm run Dev so it's

1648:19

going to start my server right here so

1648:21

I'll use like Local Host and now we are

1648:23

getting our hello word right here let's

1648:25

talk about the layout component so

1648:27

layout component are strategies for

1648:29

organizing and composing component that

1648:32

manages the layout structure of a

1648:33

project this component typically control

1648:36

the positioning and arrangement of a

1648:38

child element within a p agage and

1648:40

acting as a container for other UI

1648:42

element or sections so here you can see

1648:45

I have a component and inside this

1648:47

component I have a section and inside

1648:49

that section we have a div so that

1648:52

specific div in which we have our

1648:54

content is totally dependent on the

1648:56

styling of a section and here you can

1648:58

see I've provided a class of some layout

1649:00

styling so that specific div is totally

1649:03

dependent on that section classes or

1649:05

section styles to be precise now the

1649:07

question is how can I split that use the

1649:10

layout design pattern so if you want to

1649:12

split that here you can see I'm going to

1649:14

be ping a children and then I'm going to

1649:16

be creating a separate component in

1649:18

which I will put my content and then I

1649:21

will past that component as a children

1649:23

to that app component I know it may

1649:26

sounds a bit scary but trust me it's not

1649:28

so now let's get into the coding then

1649:29

you will get to know what I'm talking

1649:31

about now the first thing that I want to

1649:32

do is that I want to create a folder

1649:34

with the name of components and inside

1649:36

there we're going to be defining a few

1649:38

components like left. PSX let me just

1649:40

zoom in a bit and we're going to be also

1649:41

defining right. TSX and also the split

1649:45

screen. TSX file now let me go ahead and

1649:48

just write my RFC inside this component

1649:50

s my file rafc inside the right

1649:53

component s my file and rafc inside the

1649:56

left component and save my file now let

1649:58

me just go back and remove this return

1650:00

statement and replace there with this

1650:02

react fragments so I'll just write a

1650:04

high for now save my file and now we are

1650:06

getting that high so the next thing that

1650:08

I want to do is that I want to go ahead

1650:09

and go to my my left and right component

1650:11

and provide a bit of styling to them so

1650:13

I'll just write like the class name and

1650:15

background will be set to T 400 and also

1650:18

the height will be set to 46 Rim now let

1650:21

me just save this file I'm going to also

1650:23

go ahead and go to the right component

1650:25

and provide the styling here so I'll

1650:27

just write like class name background

1650:28

will be set to totally red 400 now let

1650:31

me just save this file and close there

1650:33

and now what I want to do is that I want

1650:35

to go ahead and just remove that from

1650:36

here and write my split screen and close

1650:39

them so for this split screen we going

1650:41

to be providing our left component and

1650:43

close there I'm going to also specify

1650:45

the right component and close there so

1650:47

now let me just save my file and this

1650:49

component will also take the left

1650:51

weight and I'm going to set that to like

1650:53

50 and it's going to also take the right

1650:56

we and I'm going to also set that to not

1650:59

50 but I guess 80 would be fine now let

1651:01

me just save my file and go into the

1651:02

split screen component and the first

1651:04

thing that I want to do is that I want

1651:05

to destructure a few things so we are

1651:07

going to be destructuring the children

1651:09

because we are going to to be using them

1651:10

we're going to be destructuring the left

1651:12

weight and also the right we right here

1651:14

so I'm going to save my file and create

1651:16

interface this all use like interface

1651:19

and I'm going to give it the name of

1651:20

like split screen props or something

1651:22

like that and it's going to take a

1651:23

children and children will be set to

1651:25

this react node and also the react node

1651:28

once again we going to be importing that

1651:30

from the react JS and also for the left

1651:33

WID it's going to be set to a number and

1651:35

also for the right wi it's going to be

1651:38

also set to a number now let me just

1651:40

copy a name of there and annotate my

1651:42

component with these props now let me

1651:44

just save my file the next thing that we

1651:46

have to do is that we have to use them

1651:48

but first of all before you even do that

1651:50

I'm going to go ahead and just

1651:51

destructure this left and right

1651:52

component now let me just show you there

1651:54

so I want to destructure this left

1651:56

component and also this right component

1651:58

so how can I go about doing that well we

1652:00

are going to be destructuring there from

1652:02

the children so I'll just write like

1652:04

left and also right and it's going to be

1652:06

equals to this children and now let me

1652:07

just log that to the console so you guys

1652:09

can see here so I'll just write like

1652:11

left and here I'm going to place that

1652:13

left and I'm going to also change that

1652:15

to right and place that right here so

1652:17

now if I save my file go to my component

1652:20

go to inspect element go to the console

1652:23

yep we are getting some sort of error so

1652:25

I don't know why but we are getting that

1652:27

error so let's just go ahead and go to

1652:29

our component oh that's because we have

1652:30

to import this so we also have to import

1652:33

this F component right here now if I sa

1652:35

my file and now we are getting a left

1652:37

component which you can see right here

1652:39

it has the the key prop reference and so

1652:41

on and so forth and we also have this

1652:43

right component as same as there so now

1652:46

let me just close there and the next

1652:48

thing that I want to do is that I want

1652:49

to just remove that from here now let me

1652:51

just remove the split screen from here

1652:53

and instead of providing a div I'm going

1652:55

to change that to section inside there

1652:57

I'll just render the div and it's going

1652:59

to say like left I'm going to also

1653:01

duplicate that and change that to a

1653:02

right so now if I sve my file so what

1653:04

are we getting we are now getting these

1653:06

styling right here but don't worry we're

1653:08

going to be fixing the so now you want

1653:10

to split this out so you want to just

1653:11

make the as a side by side like left and

1653:13

also the right so to do that we're going

1653:15

to be passing a class name and I'm using

1653:18

a tan CSS so if you're using just a pure

1653:20

CSS you're going to have to do a lot of

1653:22

stuff but in my case I'm only using a

1653:24

tailan CSS so I'm going to just right

1653:25

like Flex and the width will be set to

1653:27

totally screen now if I save my file so

1653:30

what are we getting we now getting this

1653:32

left component and we are also getting

1653:34

this right component right here which is

1653:36

something that we want and next we have

1653:38

to create a left f and also the right

1653:41

width so how in what we're going to be

1653:42

doing there this is how we are going to

1653:44

be doing this so I'll just use like con

1653:46

left width it's going to be equals to

1653:49

this left width so now let me just

1653:50

render this left width right here which

1653:52

we are now taking as a perimeter for

1653:54

this component and I'm going to also

1653:56

specify the rim value to this now let's

1653:58

just provide a rim I'm going to also

1654:00

provide the right width and the right

1654:03

width will be equals to this right width

1654:06

right here as a prop and we're going to

1654:08

be placing a rim value to there now let

1654:10

me just save my file but still we have

1654:13

to use this left and also the right

1654:14

width so this is how we are going to be

1654:16

using this so I'll just write like a

1654:18

style and here for these styling we're

1654:21

going to be passing first of all the

1654:22

width and for each width first of all

1654:24

we're going to be copying this left

1654:26

width now let me just place there then

1654:28

I'm going to copy the right width and

1654:29

I'm going to also place it right here

1654:31

save my file and Yep this is something

1654:33

which we are getting right now which is

1654:35

not looking that much cool so now let me

1654:37

just remove this component and I'm going

1654:39

to change there to like 20 maybe and

1654:41

here you can see when now getting this

1654:42

sidebar I can also change that to like

1654:44

10 I guess 15 would be fine yeah 15 is

1654:47

totally fine and also we can totally

1654:49

change the right value and so on and so

1654:51

forth now we have a lot of flexibility

1654:53

and we can do a lot of things so you

1654:55

know what let me just show you there if

1654:57

I go ahead and go to my left component

1654:59

and I'm going to remove this left from

1655:02

here I'll just write like UL Li and

1655:04

anchor tag and now I want them to be I

1655:07

don't know maybe uh four will be fine so

1655:09

first of all I'm going to be providing

1655:10

like home and then some sort of about

1655:13

section God then I'm going to provide

1655:16

the context section and also the

1655:18

portfolio or something like this so now

1655:20

if I sa my file here you can see we are

1655:22

now getting all of that content right

1655:23

here and if I want to change something

1655:25

inside the right component I can totally

1655:27

do that so I'll just go ahead and go to

1655:29

my right component remove this right

1655:31

from here and I'll just write like I

1655:33

don't know maybe H1 something cool and

1655:36

also a paragraph with a lot of LM Epsom

1655:38

inside there and yeah we are now getting

1655:40

these result right here so this is how

1655:42

we are going to be splitting our UI by

1655:45

using the layout component so here you

1655:47

can see inside this split screen we're

1655:49

only using this Flex prop or you can say

1655:52

styling and we're just providing a be of

1655:54

width today so yeah this is how we are

1655:56

going to be splitting our UI by using

1655:59

the layout component all righty so now

1656:01

let's make another setup for our coding

1656:03

Journey now I know a lot of you will ask

1656:05

me hose what's the point of this another

1656:07

setup well now we are going to be

1656:08

working with the challenge es and we are

1656:10

going to be writing all of the

1656:11

challenges inside this newly created

1656:13

setup so what I'm going to do is that

1656:16

I'm going to open my terminal and let me

1656:18

just zoom in a bit so you guys can see

1656:19

everything a bit better like so and I'm

1656:23

going to just write like npm come on in

1656:25

lowercase npm create we at latest and

1656:28

I'll just give it the name of like maybe

1656:31

um DP like design patterns challenges

1656:35

and now inside there uh you know first

1656:37

of all let me just go ahead and go to

1656:38

the react and choose reactjs and now we

1656:40

are going to be choosing typescript and

1656:43

now I'm going to go into the DP folder

1656:45

and let's just install every single

1656:47

thing inside there so now then

1656:48

successfully done I'm going to open

1656:50

there in my vs code by using Code Dot

1656:52

and this is how it looks like right now

1656:55

so I'm going to go ahead and remove this

1656:56

public folder I'm going to also go ahead

1656:58

and just remove the SS folder remove the

1657:00

app. CSS and now let me go ahead and go

1657:02

to my app. TSX remove every single thing

1657:05

from there and I'm going to just use my

1657:06

uh RFC inside there I'm going to also

1657:09

remove every single thing from this

1657:10

index. CSS remove there and now we are

1657:13

going to be running our server by using

1657:15

npm run Dev so it's going to run there

1657:17

on the Local Host that Port so yeah we

1657:19

are now getting our app which is looking

1657:21

cool I'm going to also go ahead and go

1657:23

to my come on tell when. CSS or tailn

1657:26

css.com I'm not sure whether I'm going

1657:29

to be using them or not but I'm still

1657:31

making this setup for the tailn CSS just

1657:33

in case so now let me go ahead and click

1657:35

on this we and now I'm going to install

1657:37

it by using this command let's just open

1657:40

there remove there and place my new

1657:42

commands right here and it's going to

1657:44

install there and it's going to also

1657:45

configure T in CSS inside our project so

1657:48

that's already done now let me just hit

1657:49

enter so it's going to also initialize

1657:51

our T when CSS let me also copy this

1657:54

content and I'm going to go ahead and go

1657:56

to my T config file and replace that

1657:59

with this new content let's just say our

1658:01

file and I'm going to also create or we

1658:03

already have our index. CSS file but now

1658:06

let me go ahead and go to the index. CSS

1658:08

file and and place the is right here and

1658:10

finally to test this out I'm going to

1658:12

copy this line of code and now let me

1658:14

just replace that with this new one Ser

1658:17

file and now let me use my npm run Dev

1658:20

so it's going to start running my server

1658:22

so let's just refresh there and yeah

1658:24

everything is working the way we expect

1658:25

them to work before we start all of

1658:27

their challenges I want to mention one

1658:30

thing all of that challenges are

1658:32

designed by me like no chat GPT involved

1658:36

but as you guys can guess my English is

1658:38

not that much much good so I use CH gbt

1658:41

to write this English for me and plus I

1658:43

also don't have a lot of time so I just

1658:46

copied my code like all the solution of

1658:48

the code and I asked chgb to write um

1658:50

what do we call a documentation for me

1658:52

so yeah this is what we are doing right

1658:53

now so what do we have to do first of

1658:55

all we have to create a header component

1658:57

so the header component will contain the

1658:59

dashboard title and profile log out

1659:01

button use CSS for The Styling and also

1659:04

this is the test like first of all we

1659:06

have to create our header. TSX inside

1659:08

the SRC component folder then we have to

1659:10

implement the following structure like a

1659:12

header with the background color and a

1659:14

title on the left side which will say

1659:16

like my dashboard and a profile button a

1659:18

logout button aligned to the right so

1659:20

then we have to create the footer

1659:22

component and the footer component will

1659:24

be a simple footer with a copyright

1659:26

message it should be style to stick at

1659:28

the top of the page and these are the

1659:30

steps that you have to follow like first

1659:31

of all we have to create our f. TSX file

1659:34

inside the SRC components folder and we

1659:36

also have to provide this as a paragraph

1659:38

inside or for that's it then we have to

1659:41

create the sidebar so so the sidebar

1659:43

component will be vertically sidebar on

1659:45

the left side including a list of uh all

1659:47

of that items like home settings and

1659:49

profile and so on and so forth and next

1659:51

we also have to create the content

1659:53

component so the content component will

1659:55

display the main dashboard content with

1659:57

some stat like some statistic like if

1659:59

you want to do that sure you can but if

1660:02

you don't want to do that you don't even

1660:03

have to do that like the total users and

1660:06

also the revenue okay so these These are

1660:09

the test that you can follow then we

1660:10

also have to create the split screen

1660:12

okay so the split screen component will

1660:14

manage the layout between the sidebar

1660:16

the sidebar and the content area so the

1660:19

component should accept two children

1660:20

like the left side a sidebar and the

1660:23

right side which will be our actual

1660:24

content which we are going to be

1660:26

creating right here for the content

1660:27

component so the width of each side

1660:30

should be controlled through the prop

1660:32

also you can learn more about that right

1660:34

here and finally we have to just

1660:35

assemble that or combine all of them

1660:38

together so inside the app. TSX file

1660:40

import all of the component you've just

1660:42

created like header footer sidebar and

1660:44

content and also the split screen and

1660:46

this is how you're going to be using

1660:48

there so give it your best shot if you

1660:51

can do it that's completely okay and by

1660:52

the way you don't even have to worry

1660:53

about the responsiveness I don't know I

1660:56

guess CH gbt I did there so let me just

1660:58

remove this step from here and yeah you

1661:00

don't even have to worry about that step

1661:02

step and I'm going to also remove this

1661:04

line from there so yeah now this is

1661:06

looking better so give it your best shot

1661:09

if you can do it that's completely okay

1661:11

then come back and watch the solution

1661:13

and now let me give you my solution so

1661:14

I'm going to just close all of them and

1661:16

now let's just start by defining our

1661:18

component folder so I'll just give it

1661:20

the name of like components let me just

1661:22

zoom in a bit and inside there we're

1661:23

going to be creating our file which will

1661:25

be our header. TSX and now inside there

1661:27

let's just use our RFC inside this our

1661:30

file let me go back so that we can see

1661:32

everything a bit better and I'm going to

1661:34

also remove that change that to the

1661:35

header because now we are working with

1661:37

the header and inside there we going to

1661:39

be using H1 which will say like my

1661:41

dashboard and now underneath that we

1661:43

going to be creating our div and inside

1661:44

this div we have two buttons so I'll

1661:46

just write like button and which will

1661:48

say like profile I'm going to also

1661:50

duplicate that and change there to the

1661:51

log out and now that's going to be it

1661:53

for the header now I'm going to provide

1661:55

the styling to this component and you

1661:57

should also do that by either pausing

1661:59

this video and typing that manually or

1662:01

you can go ahead and go to my gab

1662:03

repository and copy all of the styling

1662:05

from there so let me just I'm going to

1662:07

come back in a second now to save my

1662:09

file and these are all the styling that

1662:11

you have to provide for the Herer

1662:13

component if you want to change there

1662:15

you can definitely go ahead and change

1662:17

that but in my case that's looking cool

1662:19

so the next thing that we have to do is

1662:21

that we have to create our footer so I'm

1662:23

going to go ahead and just create my

1662:24

footer come on

1662:27

f.x and now inside there let's just use

1662:29

our RFC and now let me just save my file

1662:32

and inside this fotter we're not going

1662:33

to be doing anything crazy but I'll just

1662:35

change that to the footer and inside

1662:37

this footer we are going to be creating

1662:38

our paragraph and I'm going to just

1662:40

provide that same uh HTML entity which

1662:43

was and and then copy and close there in

1662:46

2025 my dashboard app or something like

1662:50

that now let me save my file and I'm

1662:52

going to also provide this styling to

1662:54

this so yeah this is all the styling

1662:56

that you have to provide for the footer

1662:57

and that's going to be it so I'm going

1662:59

to also close there now let's take care

1663:01

of the sidebar so I'm going to just

1663:03

create a new file with the name of

1663:04

sidebar. TSX and I'm going to use my RFC

1663:07

inside this and my file file and let me

1663:10

just close there and inside there I'll

1663:12

just use my H1 and I'll select dashboard

1663:15

so my file underneath there we have to

1663:16

use our UL inside this UL we have to

1663:19

provide our Ali and inside this each ali

1663:22

uh yeah we are going to be providing our

1663:24

anchor tag and let's just spride like

1663:25

for this first one I'm going to say like

1663:27

go to the home like you don't even have

1663:29

to do that if you don't want to do that

1663:31

but I want to do that so I'll just Pride

1663:33

the home and I'm going to duplicate

1663:35

there like three times or maybe two

1663:36

times so the first one we have is a home

1663:39

then we would have our settings and

1663:40

finally our profile so I'm going to just

1663:42

change that to like settings and I'm

1663:44

going to also change this level to the

1663:45

settings and here let's just change

1663:47

there to the profile so I'll just

1663:49

provide my

1663:51

profile and change this one to the

1663:53

profile like so now let me save my file

1663:56

I'm going to go back and here now I'm

1663:58

going to provide a lot of styling today

1664:00

and these are all the styling that you

1664:02

also have to provide so here you can see

1664:04

this is how we're going to be providing

1664:05

our styling for the div then for the H1

1664:07

ul and then for the anchor tag and for

1664:10

the anchor tag again and again so that's

1664:13

also totally done now let me also close

1664:15

this sidebar next we have to create our

1664:17

content component so I'll just create my

1664:19

content. TSX and now inside there let's

1664:22

just use our RFC so my file and close

1664:25

there and inside this div I'm going to

1664:27

be providing my H2 and which will say

1664:29

like welcome to the dashboard and

1664:32

provide my explanation mark there Prov a

1664:34

paragraph which will say like here are

1664:37

your stats for today and now we are

1664:40

going to be providing a bit of stats

1664:42

let's just create our div and inside the

1664:44

and provide another div and inside this

1664:46

div we're going to be providing our H3

1664:48

which will select total users and now

1664:51

underneath they provide my paragraph

1664:52

which will Select 1 comma 2 4 five some

1664:56

some sort of arbitrary number and now

1664:58

underneath we are going to be also

1664:59

providing our div and inside this div

1665:02

let's just provide our H3 which will s

1665:03

like revenue and I'm going to also

1665:05

provide a paragraph and let's just

1665:06

provide random Revenue like I don't know

1665:08

May I guess that's going to be fine so

1665:11

let's just save our file and now I'm

1665:13

going to go back to provide my styling

1665:15

inside this component so here are my

1665:17

styling like here you can see we're now

1665:18

providing a styling for the div then for

1665:20

the H2 paragraph Dev div H3 paragraph

1665:24

and so on and so forth so this is how we

1665:26

are going to be creating our components

1665:28

now let me just show you there here you

1665:30

can see this is how we going to be

1665:31

creating our component and now let's

1665:33

just assemble or combine all of them

1665:36

inside the split screen design pattern

1665:39

component so I'll just use my RFC inside

1665:41

there let's just go back and the first

1665:43

thing that we have to do is that we have

1665:45

to restructure a few things because we

1665:47

would need that inside this UI so I'll

1665:49

just destructure the children we would

1665:51

also destructure the left W which we

1665:53

just saw a few seconds ago and we would

1665:55

also destructure the right we which we

1665:57

also saw a few seconds ago so now let me

1666:00

just sve my file and I'm going to also

1666:01

create an interface for this so that we

1666:03

don't get the typescript error so let's

1666:05

just put our split uh screen props and

1666:08

in side there I'm going to provide the

1666:10

children and provide the as a react node

1666:13

which will be coming from the react J

1666:15

and also the react no once again put a

1666:18

comma there let's just put our left

1666:20

weight w GT which will be set to a

1666:23

number and also the right we which will

1666:26

be also set to a number okay save my

1666:28

file I'm going to copy the name of the

1666:30

provide there right here or or annotate

1666:32

my component with these props so now let

1666:34

me just save my file now the next thing

1666:35

that we have to do is that we also have

1666:37

to nested the structure so we are going

1666:39

to be destructuring all of our stuff

1666:41

from the children so we would need uh

1666:44

what do we call it the left and also the

1666:45

right which we also just a few seconds

1666:48

ago and now me we will just provide our

1666:50

left WID and also our right width okay

1666:53

so I'll just write like con left R come

1666:55

on left W and this going to be equals to

1666:58

this back Tex and put my left R right

1667:01

here and put that as a rim value I'm

1667:03

going to also duplicate that and change

1667:05

this value to the right F we e i g HT

1667:09

and here also change that to the right R

1667:12

like so save my file and now our

1667:14

typescript is freaking out that's

1667:16

because we have to use these variables

1667:18

so now let me just remove there and

1667:20

inside that you know let me just change

1667:21

that to a section maybe and inside this

1667:23

section I'm going to also provide a

1667:25

class names like Flex and also the flex

1667:26

will be set to one and I'm going to

1667:28

provide my div and in this we're going

1667:30

to be providing our lift value and now

1667:32

let me just duplicate there and we're

1667:34

going to be providing our right value

1667:36

and I'm going to also provide a bit of

1667:37

styling to this so for this styling for

1667:39

the width we are going to be using our

1667:41

own width which will be set to like

1667:43

width or left weight there we go and

1667:45

also let me just prob a bit of pairing

1667:47

all around like maybe pairing all around

1667:49

a four I'm going to also copy there

1667:52

right here change that and I guess

1667:54

that's going to be fine now we're going

1667:56

to be also providing a style and for

1667:58

this style the W will be set to the

1667:59

right now still our typescript is

1668:01

freaking out oh it shouldn't be W it

1668:05

should be with WTH there we go and now

1668:08

let's just copy there place it right

1668:11

here I'm going to also copy there place

1668:13

it right here semi file and that's done

1668:16

so now let me go ahead and go to my app

1668:17

component and use that inside this

1668:19

component so you know I'm going to just

1668:21

use my RFC once again save my file and

1668:24

the first thing that we have to do is

1668:25

that we have to import all of their

1668:26

components so we have to import the

1668:28

header and I forgot the names of there

1668:31

but we also have to import the F and we

1668:34

also have to import the split screen

1668:36

because we're going to be obviously

1668:38

using them and we also have to import

1668:40

the sidebar and finally we have to

1668:42

import the content component let's just

1668:45

go back save my file and this is how it

1668:47

looks like so now let me go ahead and go

1668:49

to my div or my jsx and I'm going to

1668:52

proide a bit of uh what the hell was

1668:55

that now we provide a b of classes today

1668:56

like Flex and flex will be set to a

1668:58

column and height will be set to toall

1669:00

the screen so that it will take up the

1669:02

entire screen so first of all we have to

1669:04

render our header and now let me just

1669:06

save my file and this is how my header

1669:08

looks like right here now we are going

1669:11

to be also rendering our footer so now

1669:13

let me just render my footer close there

1669:16

and I'm going to also just close it like

1669:18

this so my file and now we also getting

1669:20

our folder so if I type something at the

1669:22

middle so I'll just write my H1 and

1669:25

something maybe and here you can see we

1669:27

are now getting there right here so now

1669:29

let me just close there and which means

1669:31

like now we are going to be providing

1669:32

our sidebar and also our content so I'll

1669:35

just use first of all my sidebar and as

1669:37

soon as I do there let me just provide

1669:39

my sidebar and close there save my file

1669:41

here you can see we are now getting our

1669:43

sidebar and now I'm going to also

1669:45

provide my content component so let's

1669:47

just do this semi file and we are also

1669:49

getting our content but we also have to

1669:51

wrap both of these component inside our

1669:54

split screen component which we just

1669:56

created right here okay so to do that

1669:59

now we are going to be using our split

1670:01

screen component and I'm going to just

1670:03

close there like so I'm going to cut

1670:05

that from there place it right here and

1670:07

now it requires a few prom

1670:09

so we have to provide the left weight

1670:10

which will be I guess set to like three

1670:12

maybe and I'm going to also provide the

1670:14

right weight which will be set to maybe

1670:15

60 so let's just goad there sa my file

1670:18

and this is how my component looks like

1670:21

right here I know it is not looking the

1670:22

most beautiful UI but here it is using

1670:26

something called the layout component

1670:27

behind the scenes so this is how we

1670:29

going to be splitting our component by

1670:31

using the layout component design

1670:33

pattern in reactjs now we are going to

1670:35

be learning about the list of data by

1670:38

using the the layout component so how in

1670:40

the world we're going to be doing there

1670:41

first of all we have our data folder

1670:43

inside there we have our data. TS file

1670:46

so inside there I have this games array

1670:49

and I also have this movies array so now

1670:51

let me just expand the games array so

1670:53

inside there we have a few objects so

1670:55

inside each object we have the game name

1670:57

the game rating game genre and also the

1671:00

language and then we have a few games

1671:01

right here so you can specify your own

1671:03

data if you wanted to but if you want to

1671:05

use mine you can definitely go ahead and

1671:07

go to my GitHub repository and grab all

1671:09

of that data from there and the next

1671:11

thing that we have is that we have a few

1671:12

movies so we have the movie title price

1671:15

description and rating right here so

1671:18

yeah if you want to get all of that data

1671:19

you can definitely go ahead and go to my

1671:21

gab repository but if you want to use

1671:23

your own one you are more than welcome

1671:25

to do that so the first thing that I

1671:26

want to do is that I want to create my

1671:28

components folder and inside this

1671:30

components folder we're going to be

1671:31

defining three component the first one

1671:33

will be a game info or games info

1671:37

rather. TX and I'll just use my RFC

1671:40

inside this save my file I'm going to

1671:42

also create yet another component for

1671:44

the movies uh info. TSX and I'll just

1671:48

use the RFC inside this component and

1671:51

finally I'm going to be creating a

1671:52

component for render list. TSX file and

1671:56

I'll use my RFC inside there save my

1671:58

file and now let's get into it so the

1672:00

first thing that I want to do is that I

1672:02

want to start working on this render

1672:03

list so I'll just remove this app from

1672:05

there and I'll use my you know let me

1672:07

just change that to the react fragments

1672:09

and now I'll just use like render list

1672:11

component and I'm going to close this

1672:13

now if I save my file this component

1672:15

will take a few props which we are going

1672:17

to be defining in a few seconds so the

1672:19

first prop it will take is going to be

1672:21

the data like which kind of data you

1672:23

want to provide for this component by

1672:25

which we are going to be iterating over

1672:27

through and we will do something with

1672:29

that data so in this case first of all

1672:31

we are going to be importing our games

1672:33

so I'll just import games uh from the

1672:35

data component or from the data file to

1672:38

be present size so now we are going to

1672:39

be importing all of that games which you

1672:41

can see right here so we have a lot of

1672:43

games now we are importing the inside

1672:45

this app. TSX file and now we are going

1672:47

to be providing there as a prop forward

1672:49

component so I'll just write like the

1672:51

data will be set to a games we're going

1672:53

to be also providing a resource name so

1672:55

I'll just use like resource name now

1672:57

it's going to be set to games in this

1672:59

case because now in this situation we're

1673:01

iterating over through the games so yeah

1673:03

games would be fine next we also have to

1673:05

pass another prompt for our component so

1673:08

so I'll use like data to render how to

1673:11

render the data whatever you want to

1673:12

call it so this is how we are going to

1673:14

be rendering our data by using this

1673:16

games info. TSX file so use like games

1673:19

info and I'm going to just place it

1673:21

right here so this is everything that

1673:23

you have to do first of all you have to

1673:24

create the render list component then

1673:26

you have to specify the data the

1673:28

resource name and also data to render

1673:30

component okay so that's done now let me

1673:32

just go ahead and go to this component

1673:34

and zoom in a bit so the first thing

1673:36

that I want to do is that I want to

1673:37

destructure a few things so now we

1673:40

already know that we are providing this

1673:42

data resource name and data to render so

1673:44

now we are going to be restructuring

1673:46

this so data can be yeah I'll just put a

1673:48

data right here and also the resource

1673:51

name and data to render so now let me

1673:54

just save my file and I'm going to also

1673:55

Define an interface for there so for the

1673:57

interface this going to be a render list

1673:59

props and here inside there we're going

1674:01

to be providing a data and data can be

1674:03

basically anything as array and also the

1674:05

resource come on resource

1674:08

name and the resource name will be set

1674:10

to string and data to render will be any

1674:14

so I'll just copy a name of them and

1674:16

inate my component like so now let me

1674:19

just save my file but we also have to

1674:20

use the inside our component so I'll

1674:22

just remove that from here and inside

1674:25

there first of all we are going to be

1674:26

iterating over through all of our data

1674:28

so I'm going to copy a name of there and

1674:29

place it right here and I'm going to use

1674:31

the map method and here we have to

1674:33

specify the item and also the index

1674:35

inside there and next I'm going to also

1674:37

rename this to the item component if you

1674:41

don't want to do that you don't have to

1674:43

do that but I want to do that so I'm

1674:44

going to copy a name of that and place

1674:46

this item component right here so I'll

1674:48

just close it like this and I'm going to

1674:50

also specify the key and the key will be

1674:53

that Index right here so I'm going to

1674:54

copy a name of them and place there

1674:56

right here and next we're going to be

1674:57

using a bit of weird syntax so first of

1675:00

all we're going to be making a clone of

1675:01

all of the props and then for the key we

1675:04

are going to be providing the resource

1675:05

name and for the value which will be set

1675:08

to that item right here so now let me

1675:10

just explain that once again first of

1675:11

all we are providing this item component

1675:14

then we are providing a key for the

1675:15

uniqueness then we are making a clone of

1675:18

our existing props and now for the key

1675:20

we are providing a resource name as

1675:22

array and also for the value we are

1675:24

specifying that specific item which is

1675:27

coming from or data so yeah that's

1675:29

totally done now let me just close it

1675:31

right here and the next thing that I

1675:33

want to do is that I want to go ahead

1675:34

and go to this games info component here

1675:36

you can see we're now getting our game

1675:37

info component again and again so now

1675:39

let's go into this game's info component

1675:42

and start working on there so now let me

1675:43

just zoom in a bit so you guys can see

1675:45

everything a bit better and the first

1675:47

thing that I want to do is that I want

1675:48

to restructure all of my games okay so

1675:50

this is going to be the first thing but

1675:52

first of all I also want to go ahead and

1675:54

go to my data file and here we have our

1675:57

game name game rating game genre and

1676:00

also the game language so now let me

1676:02

just create interface for there so I'll

1676:03

use my interface and for that I'm going

1676:05

to give it the name of like games info

1676:08

and here inside there we are going to be

1676:09

passing our games and each game will

1676:12

have the game name and this can be set

1676:14

to a string we're going to be also

1676:16

providing a game rating which will be

1676:18

set to a number I'm going to also

1676:19

provide the game genre and which will be

1676:21

set to a string I'm going to also

1676:23

provide the game language and which will

1676:25

be set to a string of array now let me

1676:28

copy a name of there and annotate my

1676:30

component with this games info the next

1676:33

thing that we have to do is that we have

1676:34

to destructure a few things from more

1676:36

games so if you you don't want to

1676:38

destructure that like you don't have to

1676:40

do that but I want to do that so I'm

1676:42

going to be destructuring a few things

1676:44

so I'll just first of all destructure

1676:46

what do we call it the game name and

1676:49

we're going to be also restructuring the

1676:51

game rating game genre and finally the

1676:54

game languages so that we can work with

1676:56

this so I'm going to sve my file right

1676:58

now and now I'm going to just remove the

1676:59

label from here I'm going to just

1677:01

specify like H1 game name and here we

1677:04

have to render our game name and now if

1677:07

I save my file and here you can see

1677:09

we're now getting our games names right

1677:11

here which is looking cool and I'm going

1677:12

to also write a paragraph um this

1677:15

paragraph will just render the game

1677:16

rating and here we have to just render

1677:19

our game rating and also I'm going to

1677:21

write a paragraph for the game genre and

1677:24

let's just render our game genre right

1677:26

here and here I'm going to just use my

1677:28

ul and provide my languages inside there

1677:32

now let's just itate over through all of

1677:34

our game languages so where in the word

1677:36

is I'm going to copy a name of then game

1677:38

language or game languages whatever you

1677:41

want to call that I guess it's game

1677:42

languages I'm not quite sure about that

1677:44

but let me just go ahead and go to the

1677:46

data and Yep this is a game languages so

1677:49

I'll just destructure there put there

1677:51

right here and I'm going to use the map

1677:53

method on there is going to take a

1677:54

language as a l and we're going to be

1677:57

annotating there as a string and inside

1677:59

they I'll just use my li and here we

1678:01

just have to render or L right here so

1678:03

I'll just uh render the the L and now

1678:06

let me just save my file and and here

1678:08

you can see we are now getting the game

1678:09

name rating genre and all of these

1678:12

languages right here forward specific

1678:14

game I can also provide a br if I wanted

1678:17

to solve just write a br and here you

1678:19

can see we're now getting all of that

1678:20

games so that's to done and you know

1678:23

what I made a mistake it should be game

1678:25

languages like so now let me just save

1678:27

my file now underneath them I'll just

1678:30

write HR and also the BR a few times

1678:33

like so okay just like that and I'm

1678:36

going to also render my my list once

1678:38

again and here now we are going to be

1678:40

providing a data and you guessed it we

1678:43

are going to be providing the movies

1678:44

data so now let me just destructure the

1678:46

movies I'm going to copy a name of there

1678:48

and place it right here as a data we're

1678:50

going to be also providing a resource

1678:52

name in this case that's going to be set

1678:53

to our movies I'm going to also provide

1678:55

data to render and now we are going to

1678:57

be providing this movie info right here

1678:59

so I'll use like movie info s my file

1679:02

and now let me go into this component

1679:04

and start working on there here you can

1679:06

see we now getting our movie info again

1679:08

and again so now let's start working on

1679:10

there I guess this is going to be

1679:11

exactly the same as the games one but

1679:14

first of all you know we have to

1679:15

destructure the movies so I'll just use

1679:17

like movies like so I'm going to also

1679:20

create interface for this so I'll use

1679:22

like interface movies info and here

1679:25

inside there we have to Define our

1679:26

movies and for each movie we are going

1679:28

to be providing the movie title which

1679:30

will be set to a string we also have a

1679:32

movie price which will be set to a

1679:34

number and also the movie description

1679:37

which will will be set to a string as

1679:39

well and the movie rating which will be

1679:42

a number so I'm going to sa my file copy

1679:44

a name of there and annotate my

1679:46

component with this movie info so now

1679:48

let me just go back next we have to

1679:50

destructure a few things so I'll just

1679:51

destructure first of all the movie title

1679:54

then the movie price the movie

1679:56

description and the movie rating from

1680:00

where from the movies so use like movies

1680:02

right here and I'm going to also go

1680:04

ahead and go to there and make as a

1680:07

react ments now we have to render our

1680:09

content so we just use like movie title

1680:12

paragraph the price and the price will

1680:14

be movie come on movie price and also we

1680:19

have a description movie description and

1680:22

finally a paragraph of ratings and here

1680:25

we have to specify the movie ratings

1680:27

inside there now let me just save my

1680:29

file and here you can see we're now

1680:31

getting all of that movies but I'm going

1680:33

to have to specify a bit of BR at the

1680:36

end and yeah now we are getting the

1680:38

Inception the Matrix The Dark Knight and

1680:40

Forest gum one of my favorite movies of

1680:43

all time so yeah this is how we're going

1680:45

to be iterating over through the list of

1680:47

data by using the layout component so

1680:50

here you can see we have our render list

1680:52

it's going to take a data is a prop

1680:54

resource name and data to render

1680:56

component and now inside there we are

1680:58

doing nothing but we are just iterating

1681:00

over through our data and providing a

1681:02

specific promps for our specific

1681:04

elements welcome to another challenge so

1681:06

in this one we are going to be creating

1681:07

a render list component which allows us

1681:10

to render our items to the Dom your

1681:12

first challenge is to create a container

1681:14

component that can dynamically render a

1681:16

list of items based on the props it

1681:18

receives so in this case you'll be

1681:20

rendering a list of products something

1681:22

which I'm about to show you in a few

1681:23

seconds so these are the step like first

1681:25

of all create a render list component

1681:27

and inside there it will take a few

1681:29

props so it's going to take like the

1681:30

data prop which will be array of items

1681:33

something which I'm about to show you in

1681:35

a few seconds it's going to also take

1681:36

the resource name and it will be the

1681:38

name of the resource for example like

1681:40

the products like you can render the

1681:42

electronics the clothing the HomeGoods

1681:44

or something like that something which

1681:46

I'm about to also show you in a few

1681:49

seconds then you have to create the main

1681:51

thing which will be a data to render

1681:53

component so the component there should

1681:55

be used to render each item like for

1681:57

example the uh product info component so

1681:59

in this component use the meth to

1682:01

iterate over through our data and then

1682:04

here is the catch like for each item in

1682:06

the list pass the individual item to the

1682:08

data to render component as a prop using

1682:11

the resource name to determine the key

1682:13

then we have another challenge which

1682:15

will be to create our presentational

1682:16

component which will be about like just

1682:19

rendering all of that item to the Dom so

1682:21

just create a product info. TSX file and

1682:24

inside this can also take like the name

1682:26

description price and rating and also

1682:28

the image and this data is already

1682:31

available to you inside my data. ts file

1682:34

which I'm also about to show you and

1682:36

inside the component so so display the

1682:38

product image display the product name

1682:40

description and price and also render

1682:42

the rating and yeah so you can learn

1682:44

more about if you wanted to and also I

1682:47

already provided you with the data. TS

1682:49

file so you can use that or if you want

1682:51

to create your own one you are more than

1682:53

welcome to do there then finally we have

1682:55

to create our uh what do we call it main

1682:57

component to render our list so this is

1682:59

how we are going to be rendering them

1683:01

inside where f.x file so here you can

1683:04

see we have this new folder which will

1683:06

be our data so now let me just expand

1683:08

there inside there we have our data. TS

1683:10

file so we have a few objects so now let

1683:13

me just expand them the first one we

1683:15

have is electronics so if I expand there

1683:17

we have the name description price

1683:19

rating image and so much more data about

1683:22

the electronics so now let me just close

1683:24

there we also have a clothing if I

1683:26

expand this so we have a name

1683:28

description price rating and image and

1683:30

so much more item about the clothing and

1683:33

finally we also have the H Goods same

1683:35

thing will be inside the hom Goods so we

1683:37

have the name description price rating

1683:39

and image and we have a few items inside

1683:42

there so basically all of their data is

1683:44

given to you but what you have to do is

1683:46

that you have to render them and you

1683:48

also have to style they correctly but

1683:51

you have to use the layout components so

1683:54

how in the world you're going to be

1683:55

doing there that's all up to you so give

1683:58

it your best shot if you can do it

1684:00

that's completely okay then come back

1684:02

and watch the solution and here is my

1684:04

solution so what I'm going to do is that

1684:06

I'm going to just Define my my

1684:07

components folder so let's just provide

1684:09

our components folder and inside there

1684:11

I'm going to be just creating my uh

1684:13

render list. TSX and I'll just use my

1684:16

RFC inside this sa my file now I'm going

1684:19

to go ahead and go to my app component

1684:21

and run this component right here inside

1684:23

this Dev so I'll use like render list

1684:25

and close the semi file but we're not

1684:28

going to be using that like this we're

1684:30

going to be also providing our data to

1684:31

this so first of all we have to import

1684:33

the data then we're going to be

1684:35

providing there as a prop so what I'm

1684:37

Inu that I'm going to only import the

1684:39

what do we call it Electronics from

1684:41

where from our data folder and inside

1684:44

there we have our data. TS file so now

1684:46

let me just copy a name of there and the

1684:48

first prop it will take is a data and

1684:50

now we're going to be providing our

1684:52

Electronics to there we also have to

1684:54

provide the resource come on resource

1684:56

name and that's going to be equals to

1684:57

the product and now I'm going to also

1684:59

provide not a comma but we also have to

1685:02

provide the data to render on render and

1685:06

here let's just pass our product info

1685:08

component which we are going to be

1685:09

creating in a few seconds so now let me

1685:11

just go back and save my file I'm going

1685:13

to also go ahead and go to my components

1685:15

once again I'm going to render my

1685:17

product or was that a yeah product info.

1685:20

TSX and now let me use my RFC inside

1685:23

there and now we have to render that

1685:24

component right here so this is how we

1685:28

are going to be importing there this is

1685:31

how we are going to be passing them now

1685:33

let me go ahead and go to my render list

1685:34

component and now let's just destructure

1685:37

all of that props so I'm going to just

1685:38

destructure the data I'm going to also

1685:40

destructure the resource name and

1685:42

finally we have to destructure the data

1685:44

to render but I'm going to also rename

1685:47

that to item come on item component like

1685:50

so now let me just sve my file and I'm

1685:52

going to go to the top and Define an

1685:53

interface for they so I'll just give it

1685:55

the name of like render uh yeah I guess

1685:58

render list props would be fine I'll

1686:00

just write like data and this it's going

1686:02

to accept any kind of list I'm going to

1686:04

also provide uh the resource

1686:08

resource name and that's going to be set

1686:09

to a string I'm going to also provide

1686:11

data to render and it should be any okay

1686:15

so now let me just copy a name of there

1686:16

and annotate my component like so sa my

1686:19

file and what are we getting oh we have

1686:23

to use there now we are destructuring

1686:25

there so which means like we have to use

1686:27

there I'm going to also provide the

1686:29

class names and for these class names

1686:32

I'll just put like product uh list I'm

1686:34

going to also provide these classes even

1686:36

so now we we have to use our data. M map

1686:40

over through our items so I'll just pass

1686:42

my item and also the index inside there

1686:45

and now let's just pass our item

1686:47

component like so and close it I'm going

1686:49

to pass the key and key will be just

1686:51

taking that index and now we have to

1686:53

spread out every single thing and now we

1686:55

have to provide the resource as a name

1686:57

come on resource name that will be our

1687:00

key and the value will be that actual

1687:02

item which we are now taking as a

1687:05

perimeter right here okay so now that's

1687:07

all you done now let me go back the next

1687:09

thing that we have to do is that we have

1687:10

to go ahead and go to our product info

1687:13

to render that component since we are

1687:15

already passing this so now inside there

1687:17

it's going to also render uh our product

1687:20

so let's just Pro our product so we

1687:22

already know how our product looks like

1687:24

so we can totally create our interface

1687:26

for this so I'll just use like product

1687:27

info and I guess promps would be fine

1687:31

yeah I'm going to just give it the name

1687:32

of props and inside there let's just

1687:33

provide our product and inside this

1687:35

product we have to provide the name name

1687:37

will be set to string the description

1687:40

will be uh set to string and we're going

1687:42

to be also providing the price and the

1687:44

price will be set to a string and

1687:46

provide the rating and rating will be

1687:48

set to a number image URL will be also

1687:51

set to a string now let me go ahead and

1687:53

go to the Top Copy a name of there and

1687:55

annotate my component like so let's just

1687:58

save our file and now we are going to be

1688:00

restructuring a lot of things from these

1688:02

products like uh you know let me just go

1688:04

ahead and go to my data. ts so we would

1688:06

need to destructure the name the

1688:08

description price rating and also the

1688:10

image URL so now let's just do that I'm

1688:13

going to go here and now let's just D

1688:15

structure a lot of things from the

1688:17

products and now here what do we have to

1688:19

do we have to first of all destructure

1688:21

the name then the

1688:23

description and also the price the

1688:27

rating and the image URL this is s file

1688:30

and now here let's just remove there and

1688:33

I'm going to provide a bit of styling to

1688:34

them so these are all the styling that

1688:36

you also have to provide right here if

1688:38

you want to copy that from my GitHub you

1688:40

can totally go ahead and just copy that

1688:41

from my GitHub but if you don't want to

1688:43

do that you can manually type that if

1688:45

you wanted to so for the source we're

1688:47

going to be passing our image URL and

1688:50

for the alternative text I'm going to

1688:52

just only pass the name and I'm going to

1688:54

also provide a bit of classes today for

1688:56

the image so the width will be set to 52

1688:58

and the height will be also set to 56

1689:00

we're going to be changing that to

1689:02

object toally cover so that it should

1689:03

take up the entire space and I'm going

1689:05

to also make it totally rounded for the

1689:08

top of totally large and let's say sa

1689:10

our file that's done now we're going to

1689:12

be also creating another div with the

1689:14

class of flex and flex will be set to

1689:15

column inside there we have to just

1689:17

render our product name description and

1689:19

price so I'll just write my H2 and here

1689:22

I'll just say like the name I'm going to

1689:24

also provide my paragraph which will say

1689:27

the description so let me just provide

1689:29

my

1689:30

description right here I'm going to also

1689:32

duplicate and change that to the price

1689:35

WR my price right here and I also added

1689:39

the styling like here you can see I

1689:40

added a style to the H2 to the paragraph

1689:43

and also to this paragraph as well now

1689:45

I'm going to go to the top and here I'm

1689:47

going to pass a function which will be

1689:50

responsible for the rating of the star

1689:52

or rendering a star component to be

1689:54

precise so here you can see we have our

1689:56

render star component and now we have

1689:58

our array and now we are iterating over

1690:00

through that array and for each

1690:02

iteration we are now pushing this UI or

1690:05

this star two the star array so that's

1690:09

exactly what we are doing right now and

1690:11

finally we are just returning there so

1690:12

we can get the value from there okay so

1690:15

now let me just hide there from here I'm

1690:16

going to copy a name of there go to the

1690:18

bottom and here we have to just render

1690:20

there so I'll just use my div and inside

1690:23

this we have to just render that render

1690:25

stars and provide my ratings inside was

1690:27

there ratings or just rating I'm going

1690:30

to copy the name of there which is a red

1690:33

thing and now let me place it right here

1690:35

I'm going to also provide like uh what

1690:36

do we call it reflex and margin for top

1690:38

will be set to two pairing all the xaxis

1690:40

will be set to four let's just save our

1690:42

file and check this out so here you can

1690:44

see we are now getting all of the data

1690:47

from the electronics so let me just show

1690:49

you there if I go ahead and go to my

1690:51

data here you can see we now getting

1690:53

that smartphone XYZ and we are also

1690:56

getting that 4K Ultra HDTV okay so which

1690:59

means like this data is coming from the

1691:01

electronics like suppose if you also

1691:03

want to render the clothing and also the

1691:06

home data or Home Goods so what we going

1691:09

to be doing there and that's quite

1691:10

simple and easy so now let me go ahead

1691:13

and go to my app and just duplicate

1691:16

there a few times so I'm going to

1691:17

duplicate there one and two time now we

1691:20

also have to destructure what do we call

1691:22

it uh let me just hold control space so

1691:25

we have to restructure the clothing and

1691:27

we also have to restructure the Home

1691:28

Goods I'm going to copy the name of this

1691:30

clothing place it right here I'm going

1691:33

to also copy the name of this home goods

1691:35

and place it right here here and the

1691:37

rest of them will be exactly the same

1691:40

and yeah this is how our UI looks like

1691:42

but you know what it is looking awful

1691:45

I'm going to just make the at the center

1691:46

so I'm going to just use like my div and

1691:49

provide my classes all used like Flex

1691:50

and flex will be set to ramp justifying

1691:53

will be set to toally Center and items

1691:55

will be set to totally Center s file and

1691:59

yeah this UI looks cool and that was our

1692:01

challenge about layout component now

1692:04

we're going to be building a model by

1692:05

using the layout component so what I'm

1692:07

going to do is that first of all let me

1692:09

just mention that we still have our

1692:10

data. TS file and inside there we have

1692:13

all of our games and all of our movies

1692:15

we're not going to be touching the

1692:16

movies but we are going to be working

1692:18

with the games I don't know so next we

1692:22

have our component so inside there we

1692:23

have our game info component I'm going

1692:26

to also Define the model. TSX file and

1692:29

use my RFC inside there go to my app and

1692:32

register there right here so I'll just

1692:34

remove that and change that as a react

1692:36

fragments and then inside there I'm

1692:38

going to be using my model so here for

1692:41

this model inside there we're going to

1692:43

be placing our games info and now for

1692:46

this games info we are going to be

1692:47

passing a data and that data will be our

1692:50

games so now let me just go to the top

1692:52

and import the games from where from our

1692:54

data file then we're going to be placing

1692:56

the as a prop for our games info so now

1692:59

let me just go ahead and go to my model

1693:01

and start working on there so the first

1693:03

thing that I want to do is that I want

1693:04

to destructure the children and I'm

1693:06

going to annotate the has a children

1693:08

react node and import that from the

1693:11

reactjs next we have to Define our state

1693:13

so I'll just go back and Define the

1693:15

state I'm going to give it the name of

1693:16

like show and then set show it's going

1693:19

to be equals to the use State and the

1693:20

initial value will be set to false okay

1693:23

so let's just change there to false now

1693:25

let me go ahead and go to my UI and

1693:27

change that from the DS to the react

1693:29

fragments and first of all we're going

1693:31

to be defining a button which will say

1693:33

like show the model and I'm going to

1693:35

also specify a bit of styling to the so

1693:37

when somebody clicks on there then we're

1693:39

going to be firing this function which

1693:40

will just say like set and we're going

1693:42

to be setting there to true and I'm

1693:44

going to also provide a bit of styling

1693:45

today so basically we're just providing

1693:47

a border and piring all around will be

1693:49

set to five and background totally 300

1693:52

this is how it looks like right here so

1693:54

now we are getting our component which

1693:55

is look I mean like we are getting our

1693:57

model button which is looking cool so

1693:59

now underneath that we have to start

1694:01

working on our UI so if we have the show

1694:04

so in this situation we're going to be

1694:06

showing the UI but if they set to false

1694:09

then we're not going to be showing

1694:10

nothing at all so what I'm going to do

1694:12

is that I'm going to just provide a

1694:13

paragraph and I'm going to say like um

1694:16

something cool okay so if I sa my file

1694:18

here you can see we're now getting wor

1694:20

something cool if I click on that

1694:22

nothing will happen because we have to

1694:24

provide the on click we are already

1694:26

doing there you know let me just refresh

1694:28

there currently we are not seeing

1694:29

anything but now if I click on there now

1694:31

we are getting what something cool right

1694:33

here so you know let's just remove that

1694:34

from here and inside there we going to

1694:36

defining a section on let's just Define

1694:39

our section so for this section we're

1694:41

going to be passing these classes so

1694:42

I'll just provide like fix and the left

1694:44

will be set to zero top of zero Z index

1694:47

10 width will be set to screen height

1694:49

will be set to full overflow Auto

1694:52

background to blank and opacity will be

1694:54

set to 50 and also when somebody clicks

1694:57

on there then we want to fire this

1694:58

function so I'll just use like set show

1695:01

and change that to false and inside this

1695:03

section what do you want to do we just

1695:05

want to Define our div and for this div

1695:08

uh we're going to be creating a button

1695:09

which will just say like hide hide the

1695:11

model so I'll just write like hide model

1695:14

and which is looking cool and when

1695:16

somebody clicks on this model what do

1695:17

you want to do in this situation you

1695:19

want to just fire this function you want

1695:20

to provide the event object and that's

1695:22

going to be coming from the react. mouse

1695:25

event and here we have to annotate as

1695:27

HTML div okay so let's just put our HTML

1695:30

div element and then we're going to be

1695:32

just setting the event do uh what do we

1695:35

call a stop stop propagation

1695:37

and that's going to be it so now if I

1695:38

save my file next I'm going to also

1695:40

specify a b of classes to this one so we

1695:42

have a background totally white margin

1695:44

for the xaxis of 10% margin on the y-

1695:47

axis will be set to Auto ping all around

1695:49

will be set to 20 pixel with will be set

1695:51

to 50% I'm going to also provide a bit

1695:53

of styling to this hide model and when

1695:56

somebody clicks on there come on when

1695:58

somebody clicks on there then you want

1696:00

to fire this function which is the set

1696:03

show and we're going to be setting there

1696:05

to false so let's just change that to

1696:07

file save my file remove that from here

1696:09

and now underneath this button we're

1696:11

going to be showing this children right

1696:13

here so if I save my file and now if I

1696:15

click on this show model so we are now

1696:16

getting our model and we are getting all

1696:18

of the data from this component so you

1696:21

know let's just go ahead and go to this

1696:23

component and I'm going to just hide

1696:25

there from here let's just comment this

1696:28

out so yeah we are now getting our model

1696:30

and which is looking cool now let's talk

1696:32

about the container component so

1696:34

container component are responsible for

1696:36

loading in managing data or their child

1696:39

component and this design pattern is

1696:41

often used in conjunction with

1696:43

presentational component also called a

1696:46

dump component to keep the UI more

1696:48

modular and maintainable so how that's

1696:50

going to look like here you can see I

1696:52

have a container component some sort of

1696:54

a parent component and inside there I

1696:57

have a few child component so inside

1696:59

each child component let's suppose if I

1697:01

want to fetch a data so I'm going to be

1697:03

using a use effect for fetching the data

1697:05

or for the side effect and then I'm

1697:07

going to be rendering that data

1697:09

accordingly then same thing will apply

1697:11

for the child 2 component then for the

1697:13

child 3 component and this is bad

1697:16

because we have to write all of that

1697:18

code again and again for each and every

1697:20

component and how the what we're going

1697:22

to be applying that container and layout

1697:24

design pattern to make our component

1697:26

reusable and we don't have to write a

1697:27

lot of code so first of all we're going

1697:29

to be creating our container component

1697:32

and inside that container component we

1697:34

can provide any kind of logic let's

1697:36

suppose if you want to fetch our data or

1697:38

maybe you wanted to handle some sort of

1697:39

a state or anything in this situation

1697:42

I'm going to be fetching my data so I'm

1697:43

going to just provide my use effect and

1697:45

fit some sort of a data inside that use

1697:48

effect and then I will past that data as

1697:50

a children to my component and then

1697:52

inside the child component I can totally

1697:55

access their data by just either

1697:56

destructuring that or I can just use a

1697:58

props and then I will just render that

1698:01

data Inside My Child component like

1698:03

inside the child one component the child

1698:05

two component and also so in the child

1698:07

three component depending upon our

1698:09

components so yeah that was just a quick

1698:11

theory about the container component and

1698:14

if you don't get it you don't have to

1698:15

worry about that because now we are

1698:16

going to be writing our code and then

1698:18

you'll get to know what I'm talking

1698:19

about all right so now let's talk about

1698:21

the container component so what I'm

1698:23

going to do is that I'm going to go

1698:25

ahead and create a components folder and

1698:27

inside there I'm going to create my

1698:28

to-do list. TSX file and I'll use my RFC

1698:32

inside there and next I'm going to do

1698:34

something a bit weird but here don't

1698:37

have to do that so what I'm going to do

1698:39

is that I'm going to Define yet another

1698:40

folder with the name of shared you don't

1698:42

have to do that like once again I can't

1698:44

stress this enough you don't have to do

1698:47

that but I want to do that because in

1698:49

this component we are going to be

1698:50

providing a logic which we are going to

1698:52

be using again and again so that's why I

1698:54

want to put that inside the shared

1698:55

component so what I'm going to do is

1698:57

that I'm going to define a component

1698:58

with the name of single too list or

1699:01

single to-do lower. TSX file and I'll

1699:04

use my rafc inside there now let me go

1699:07

ahead and go to my app and here we have

1699:09

to register there so I'll just use like

1699:11

single to-do lower and then I'm going to

1699:13

close there and inside there we're going

1699:15

to be providing our to-do list and close

1699:18

there like so so basically this single

1699:20

to-do loader is our container component

1699:23

because in this component we're going to

1699:25

be fetching a lot of data and then we're

1699:27

going to be passing that data to this

1699:29

to-do list and this is going to be our

1699:32

child component so now let me just say

1699:33

that once again so this is going to be

1699:35

our container component and this is

1699:38

going to be our child component so now

1699:40

let's just start working on our single

1699:41

to-do list loader first thing first I

1699:43

want to show you where in the world

1699:44

we're going to be fetching our data so

1699:46

we're going to be fetching our data from

1699:48

this JSM placeholder typi code.com and

1699:51

here inside there we're going to be

1699:54

specifically fetching our data from this

1699:56

Todo so I'm going to click on there and

1699:58

I'm going to copy the URL from there and

1700:00

now let me just put there right here I'm

1700:02

going to also open my terminal and here

1700:04

I'm going to be using npmi and then xus

1700:07

if you don't know what xus is you don't

1700:09

have to worry about that you can

1700:11

definitely go ahead and use a fetch if

1700:13

you wanted to but in my case xus would

1700:15

be fine so I'll just use like npm run

1700:17

day one one more time and now let's just

1700:19

start working on them the first thing I

1700:21

want to show you is that here you can

1700:22

see we have our user ID we also have our

1700:25

ID and we also have the title and

1700:27

completed flag so I'll just Define

1700:29

interface for this so I'll use like

1700:31

interface with the name of to-do and

1700:33

inside there we have to Define first of

1700:34

all the ID and the ID will be set to a

1700:37

number then we have to provide the title

1700:39

and the title will be set to a string

1700:41

and the completed will also be set to a

1700:43

string next we have to Define interface

1700:45

for the children so I'll just use like

1700:48

uh what do we call it children right

1700:49

here so I'll just write like children so

1700:52

I'll just use like interface and then

1700:53

single to do lower props and here inside

1700:57

there I'll just write like children and

1700:59

I'm going to annotate as a react node

1701:02

and I'm going to copy a name of them

1701:04

copy a name of and place it right here

1701:06

next I'm going to also create an

1701:07

interface for the child component so

1701:09

I'll just use like interface and then

1701:11

child component props and here inside

1701:14

there we're going to be providing a

1701:16

to-do so our to-dos will be either to-do

1701:18

or null value so now let's start working

1701:21

on our single to-do ler component so the

1701:24

first thing that I want to do is that I

1701:25

want to create a state where we are

1701:27

going to be putting all of our data so

1701:29

I'll just use like con and then toos and

1701:31

then set todos it's going to be equals

1701:33

to this used and we're going to be

1701:35

either providing to do or the null value

1701:38

to there so now let's just initially

1701:40

we're going to be providing a null value

1701:42

to there and now underneath there we

1701:43

have to fetch our data so which means

1701:45

like we're going to be doing some sort

1701:46

of a side effect so I'll just use like

1701:48

side effect Right Here and Now inside

1701:51

there we're going to be using a asnc but

1701:53

first of all we have to provide a

1701:54

dependency array and just provide empty

1701:57

dependency array for there so now we're

1701:59

going to be creating something called

1702:01

the ify function which is immediately

1702:02

invoke function expression if you don't

1702:04

want to do that you know I'm not going

1702:06

to do that what the hell so I'll just

1702:08

give it the name of like f data it's

1702:10

going to be equals to this as

1702:11

synchronous function and inside this as

1702:13

synchronous function we're going to be

1702:14

first of all getting the response from

1702:16

where from where come on a and then xuse

1702:20

dog and here we have to annotate as a

1702:23

to-do and I'm going to also close that

1702:25

and first of all we have to import this

1702:27

xus from the xus right here I'm going to

1702:30

also cut this link from there and remove

1702:33

this comment from there and now here

1702:35

we're going to be fing your data by

1702:37

using this get method so I'll just write

1702:39

like this URL and now I'm going to sve

1702:42

my file and now to need this response

1702:44

we're going to be using a set too and

1702:46

here we have to specify the response not

1702:48

the report error but the response. data

1702:51

now let me just save my file right now

1702:53

I'm going to copy a name of there and

1702:55

place there right here and execute my

1702:57

function if you don't like this approach

1703:00

you can definitely go ahead and just

1703:01

remove there and convert there to

1703:03

something called immediately um

1703:06

ify or immediately invoke immediately

1703:09

invoke function expression what the hell

1703:10

I just kind of forgot the name of that

1703:13

and I'm going to also cut there from

1703:14

here so this is how we are going to be

1703:16

defining our function and this is how

1703:18

immediately we are going to be executing

1703:20

our function like so so yeah this is

1703:23

also another way to do that if you want

1703:25

to do that you you can totally do that

1703:27

but if you don't want to do that you

1703:28

don't have to do that so this is how we

1703:30

are going to be fetching our data and

1703:32

yeah this is how we're going to be

1703:33

storing the inside our todos now let's

1703:36

get into into the UI so I'll just remove

1703:37

that from here and now we going to be

1703:39

getting the react J and then a children

1703:42

from this react J now let's just iterate

1703:45

over through all of our children and

1703:46

here is a first perimeter we're going to

1703:48

be providing a children to them and then

1703:51

we have to just use a function for

1703:52

iteration so I'll just provide a

1703:54

children and then what do I want to do I

1703:57

want to first of all check if we have

1704:00

that reactor is valid element so if that

1704:03

specific element is valid so we're going

1704:05

to be just making a clone up there so

1704:07

I'll just write like child component

1704:09

prop and now let me just close there and

1704:11

here we have to specify a CH not

1704:12

children but just a child so if that is

1704:15

the case so then you want to just return

1704:17

the react. clown you want to just make a

1704:19

clown of there so I'll just use like

1704:21

react. clown element and then we have to

1704:24

specify a child inside there and for the

1704:26

second perimeter we are going to be

1704:27

passing their todos which we're now

1704:29

fetching right here okay so that's done

1704:32

but if that's not the case so in that

1704:34

situation we are going to be only

1704:35

returning the child

1704:36

okay so now let me just import this

1704:38

react from that react JS and that errors

1704:41

are now successfully gone so yeah this

1704:43

is just our single to-do lader component

1704:46

and now let's just use the inside our

1704:48

file so yeah we are already using that

1704:51

but I'm going to go ahead and go to my

1704:52

to-do list component and here you can

1704:54

see we're now getting our to-do list

1704:55

component which is looking cool so the

1704:57

first thing that I want to do is I want

1704:59

to just Define an interface so I'll just

1705:00

Define the interface for to-do and here

1705:03

we have to specify the ID and ID will be

1705:05

a number and the title will be a string

1705:08

the completed flag will be the string as

1705:11

well completed flag is Boolean not a

1705:13

string so I'll just change that to

1705:15

Boolean like so next we're going to be

1705:17

restructuring the todos so I'll just

1705:20

annotate there but first of all let's

1705:22

just Define our interface for the to-do

1705:24

list props and here inside let's just

1705:26

provide your to-do so it's going to be

1705:28

either a to-do or null value okay so I'm

1705:30

going to copy a name up there and

1705:32

annotate my component with this to-do

1705:34

list props I'm going to sve this file

1705:36

and finally let's just destructure the

1705:38

to-do and also the ID so I'll just

1705:40

destructure the ID and also the title

1705:43

from where from the to-dos so either

1705:45

gives us all of their to-dos or gives us

1705:47

an empty object so now let's just use

1705:50

the inside our UI I'll just remove that

1705:52

from here if we have the todos so in

1705:55

that situation we're going to be showing

1705:56

one UI but if that's not the case so

1705:59

then we're going to be showing another

1706:00

UI so I'll just put a paragraph and I'll

1706:02

just say like loading dot dot dot and

1706:05

I'm going to also close this paragraph

1706:06

like so okay so now if we have the todos

1706:10

then you want to just get a div and

1706:12

inside this div I'll just put a

1706:14

paragraph and it's going to say like a

1706:16

strong tag to do ID or something like

1706:18

that and here I'll just render that ID

1706:21

right here and also I'm going to put the

1706:23

H1 and it's going to say like strong

1706:25

once again to Doom title and then here

1706:29

we have to just render that title right

1706:31

here oh my God that was a lot of

1706:33

explanation so now let me just refresh

1706:35

there so we are getting a to-do ID and

1706:37

also the title but we are not getting

1706:40

the actual value out of there you know

1706:42

what let's just log this todos to the

1706:44

console so I'll just use a to-dos open

1706:47

my

1706:48

console okay we are getting an array and

1706:51

inside this array then we have our

1706:53

objects God damn it yep so I'm just

1706:56

itating over through all of the todos

1706:58

and I'm getting each of the to-do and

1707:00

then rendering the to-do do ID and now

1707:03

we are getting all of their to-do IDs I

1707:05

can also get stuff so I'll just write

1707:07

this div not device but a div inside the

1707:11

let's just render or H1 and for the

1707:13

paragraph I'll select to do body was

1707:15

that b or something else title there we

1707:19

go so I'll just write a title and here

1707:21

we have to use or to do. title if I

1707:25

close this my file so we are also

1707:27

getting their title and I'm going to

1707:29

destructure the ID and also the tire out

1707:32

of there and select both of them remove

1707:35

them and yep we are now getting there

1707:38

here I'm going to also inate the erer to

1707:40

do and yeah that's looking better so

1707:43

this is how we going to be creating a

1707:44

container component and this is how we

1707:46

going to be ping a data today but this

1707:48

is not the better way to do stuff like

1707:51

sure we are getting this data from this

1707:52

URL but let's suppose if you want to get

1707:55

a specific item like maybe item one like

1707:58

to do one or maybe if I want to get like

1708:00

the comments or maybe the post or

1708:04

something like that now let me just show

1708:05

you these and points right here so if I

1708:07

go back let's suppose if I want to fetch

1708:09

that data from either the post or

1708:11

comments or albums poos to do or users

1708:14

how the what am I going to be doing

1708:16

there well for that we have to refactor

1708:18

our code time for the quick refactor so

1708:21

what I'm going to do is that I'm going

1708:23

to make it so that we can patch the data

1708:25

by specific ID so I'll just write like

1708:27

to do ID and here I'm going to specify

1708:29

like either one two or some ID right

1708:31

here so in this case I'm going to only

1708:33

specify two I'm going to save this file

1708:34

right now now let me go ahead and go to

1708:36

this single to-do lower and we are going

1708:39

to be getting that ID right here so I'll

1708:40

just write like to-do ID I'm going to

1708:43

copy a name of that and I'm going to

1708:45

make it as a template literal because we

1708:46

are going to be placing our ID totally

1708:48

dynamically so I'll just place my to-do

1708:50

ID right here if I check this out so now

1708:52

let me just open there here you can see

1708:54

it's going to giv us uh okay it's going

1708:56

to giv us an error so let's just refresh

1708:59

there you know let me just go ahead and

1709:00

go to this to-do list and now I'm going

1709:03

to comment this line out and I'm going

1709:05

to go ahead and just loog to the console

1709:06

there to do so if I just do this save my

1709:08

file and here you can see we're now

1709:10

getting a specific item based on that ID

1709:13

so we are now getting like the ID of two

1709:15

the title of some random title and also

1709:18

the user ID will be set to one uh I'm

1709:20

going to just go ahead and cut that from

1709:22

here I'm going to also remove that I'm

1709:24

going to uncomment that and now let me

1709:25

just log to the console that ID and

1709:27

title so I'll just write like ID and

1709:29

also the title and now let me just save

1709:31

my file let's just refresh there and

1709:33

here you can see we're now getting the

1709:34

ID and also the the title so what I'm

1709:37

going to do is that I'm going to render

1709:39

this I'll just remove it from here and

1709:41

I'm going to write return statement if

1709:43

we have the to-dos in that situation

1709:45

show one UI but if you don't have the

1709:47

to-dos then you want to just show a

1709:49

paragraph which will say like loading

1709:50

dot dot dot okay I'll I'll just write

1709:52

like uh div and inside this div we are

1709:55

going to be writing a paragraph and then

1709:56

a strong tag and it's going to say like

1709:59

too ID and I'm going to render that

1710:02

to-do ID right here just ID and now

1710:04

underneath that we going to be creating

1710:06

H1 and inside there let's just write our

1710:08

strong tag once again and I'll write

1710:10

like to do title and then I'm going to

1710:13

render the title right here so I'll just

1710:16

write like title now let me just save my

1710:18

file and it should be todos now let me

1710:21

just save my file and here you can see

1710:23

we now getting what to do based on that

1710:25

specific ID so now you can go ahead and

1710:28

just uh change there to like three maybe

1710:30

so and now let's just refresh there and

1710:31

it's going to gives us the ID of three

1710:33

it's going to also gives us that random

1710:35

title so so I can just duplicate the

1710:37

like how many time I want so I'll just

1710:39

duplicate the like three time and I'm

1710:41

going to just provide uh you know this

1710:43

is going to be one this is going to be

1710:46

two and this one will be three now let

1710:48

me just save my file now if I just

1710:50

refresh there so we are getting a to- do

1710:52

ID of one then two and three so yeah

1710:55

this is how we are going to be fetching

1710:56

our data by using a specific ID time for

1711:00

the refactor number three so here you

1711:02

can see in this situation we are only

1711:04

getting our data from the to-do resource

1711:06

but let's suppose if you want to get our

1711:08

data from either the post or comments or

1711:10

albums so how the what we are going to

1711:12

be doing there and to do them we're

1711:14

going to be defining yet another file

1711:16

and by the way uh I'm going to also just

1711:18

write like to do ID right here and I'm

1711:20

going to set that to number so it's

1711:22

going to just remove their typescript

1711:23

error from here so then you're done I'm

1711:25

going to also close this file and now

1711:27

let me just go ahead and go to my shared

1711:29

folder once again now we are going to be

1711:31

creating a resource lower. TSX and I'll

1711:35

write my FC inside this save my file and

1711:38

now let me go ahead and go to my app and

1711:40

remove all of that stuff from here and

1711:42

I'm going to specify the resource loader

1711:46

from our component spoiler and inside

1711:48

them we're not going to be closing it

1711:49

like this we're going to be closing it

1711:51

like this because we want to provide our

1711:53

children's inside there so for the

1711:55

childrens we are going to be providing

1711:57

our to-dos list and here it's going to

1711:59

take a few props so I'll just provide

1712:01

like first of all the URL you can either

1712:03

give it the name of like URL but in my

1712:05

case I'm going to specify like resource

1712:07

URL and for the resource URL first of

1712:10

all we are going to be fishing our data

1712:11

from the todos and then for the first

1712:13

to-do and I'm going to also specify the

1712:15

name so I'll write like resource name

1712:19

and here we have to specify the resource

1712:20

name as a to-do I'm going to also

1712:22

duplicate or you know we're going to be

1712:24

doing that in a few seconds but now let

1712:26

me go ahead and go to my resource lower

1712:28

and now let's just take care of there so

1712:30

the first thing that I want to do is

1712:31

that I want to destructure a few things

1712:33

so first of all we are going to be

1712:34

destructuring uh the resource URL so

1712:37

I'll just write like resource URL and

1712:40

also the resource name and finally the

1712:43

children so I'll just write a children

1712:45

right here now let me just go to the top

1712:47

and Define the interface for what for

1712:49

the resource loader props and inside

1712:52

there first of all we have to provide

1712:53

our uh resource URL and here we have to

1712:56

set that string we also have to provide

1712:58

the resource name and set that to string

1713:01

and for the children it's going to be

1713:03

set to react node okay so now let me

1713:05

just hit enter I'm going to copy the

1713:07

name of there and now let me place there

1713:09

right here as a resource loader prop now

1713:13

let me go back and save my file and then

1713:16

St done the next thing that we have to

1713:17

do is that we have to create a state for

1713:19

storing our data so I'll just write like

1713:21

State you can give it any name that you

1713:22

prefer and then set State and it's going

1713:24

to be equals to the US state it's going

1713:26

to take any kind of data and we have to

1713:29

specify the initial value of null today

1713:31

that's also done next we have to fetch

1713:33

our data so to fetch our data we are

1713:35

going to be doing this side effect so

1713:37

for there we have to use the use effect

1713:39

inside there we are going to be doing

1713:41

our data fetching but first of all we

1713:43

have to provide our dependency array and

1713:44

for the dependency array I'm going to

1713:46

specify the resource URL right here okay

1713:49

so I'm going to use my IF function once

1713:51

again and here I'm going to specify the

1713:53

as synchronous uh come on the asyn

1713:55

function and for this async function uh

1713:58

first of all we are going to be getting

1713:59

the response it's going to be equals to

1714:01

aware. xuse let's just get our xuse from

1714:04

our xos library and we're going to be

1714:06

getting the data from this URL so I'll

1714:08

just write like uh https and then Chase

1714:12

and placeholder do type I code.com and

1714:15

then for Slash and now we have to render

1714:18

or resource URL so I'm going to copy the

1714:21

name of there and now let me just place

1714:22

it right here okay and it's going to giv

1714:25

us some sort of a data so now we have to

1714:26

set that data to overate so I'll write

1714:29

like

1714:30

response. data and now let me just save

1714:32

my file this is how we are going to be

1714:34

fetching our data and this is this is

1714:35

how we are going to be storing the

1714:36

inside your state the next thing that we

1714:39

have to do is that we have to use our

1714:40

react children so what I'm going to do

1714:43

is that I'm going to make the as a react

1714:44

fragment and now inside there first of

1714:46

all we are going to be using react.

1714:48

children not clown but children there we

1714:51

go and first of all we have to grab the

1714:53

react react J from the react library and

1714:56

now we have to over through there and

1714:58

I'm going to specify children and here

1715:00

we have to provide a child inside there

1715:02

and now we have to check if we have the

1715:04

reactor is valid element come on is

1715:07

valid element so in that situation we

1715:09

are going to be first of all writing the

1715:11

children and then we have to clown there

1715:13

so use like react. clown element clown

1715:16

element and here we have to specify the

1715:18

child and now here we are going to be

1715:20

passing our resource name as a key and

1715:23

then for the value we going to be

1715:24

setting there to state so this how we

1715:27

are going to be clowning that element if

1715:29

it is a react valid element but if it's

1715:31

not so in that situation we are going to

1715:33

be only returning the child sold just

1715:35

for like return child and sve my file

1715:38

now let me just go ahead and go to my

1715:40

app and see what's wrong okay so we are

1715:43

not getting any errors let me just

1715:45

refresh

1715:46

it we are getting our data which is cool

1715:50

yeah we are getting our data but we are

1715:53

not able to render there so I'm going to

1715:55

go to the to-do list app let's just log

1715:57

that to-dos to the console say my file

1716:00

right

1716:01

now okay so everything is undefined oh

1716:04

it shouldn't be to do it should be a

1716:06

to-do just a singular to-do okay and

1716:10

yeah I'm going to remove that s from

1716:12

there and I'm going to also remove it

1716:14

from there and from here so now let me

1716:17

just save my file right now and here you

1716:19

can see we're now getting our title and

1716:20

also our ID right here which is looking

1716:23

cool now I can also go ahead and just uh

1716:26

go to my app and I can just change that

1716:28

to like maybe two or something like this

1716:30

so it's going to change there to two

1716:31

which is working totally fine but now

1716:34

I'm going to also fetch my data first of

1716:36

all let me just write HR and then BR now

1716:38

we have to fetch our data by using some

1716:41

different resource so I'll just use like

1716:42

resource lower once again and I'm going

1716:45

to close there and inside there we going

1716:47

to be rendering another component which

1716:48

we're going to be creating in a few

1716:50

seconds which will be a comments list

1716:52

and now it's going to take the resource

1716:54

URL and for the resource URL we're going

1716:56

to be fishing more data from this

1716:58

comment so I'm going to just click on

1717:00

there and I'm going to copy this entire

1717:02

thing or you know let me just copy this

1717:04

comments from here and now now let me

1717:05

just place it right here so comments and

1717:07

you want to get the first comment and

1717:09

I'm going to provide the resource name

1717:11

and the resource name will be set to

1717:12

comments now let me go ahead and just

1717:14

create this component so I'm going to

1717:15

copy a name of there and just create

1717:18

this component right here I'll use my

1717:20

rafc inside there sa my file check this

1717:23

out let's just refresh there and yeah we

1717:25

have to take care of there first of all

1717:27

now let me create the interface so I'm

1717:29

going to go ahead and first of all we

1717:30

have to take care of the post ID then

1717:32

the ID name email and body so I'm going

1717:35

to go to the top oh my God what the hell

1717:37

did I just do and I'm going to define

1717:39

the interface for the comment and inside

1717:41

there we have to provide the ID and ID

1717:43

will be a number the name will be a

1717:45

string the email will be also a string

1717:47

and the body will be a string as well

1717:51

next I'm going to Define interface for

1717:52

the comments list props and inside there

1717:55

it's going to take the comments it's

1717:57

going to be either the comments which we

1717:59

just Define so let's just provide our

1718:01

comments so it's going to be either the

1718:03

comments or no so I'm going to save this

1718:06

file I'm going to copy a name of there

1718:08

and now let's just annotate our

1718:09

component and first of all we have to

1718:11

destructure the comments then we have to

1718:14

annotate our component like this so now

1718:17

if I log to the console that comment so

1718:19

let's just log that to the com console

1718:22

and check this out so let's just refresh

1718:24

there and let me go ahead and go to my

1718:26

console like this and here you can see

1718:29

oh we are getting some sort of error so

1718:30

comment list is not defined oh this

1718:34

because we have to first of all import

1718:35

import there so I'll just go ahead and

1718:37

just import there like this and yeah now

1718:40

it is defined so now let's just refresh

1718:41

there and here you can see we are now

1718:43

getting first of all the user ID and

1718:46

also the completed flag the title and

1718:48

the user ID once again what the hell is

1718:50

that coming from so we are getting

1718:52

undefined undefined then we are getting

1718:53

the data this is not something that I

1718:55

want let's just go to the to-dos and

1718:57

remove that from there let's just close

1718:59

there and refresh there once again so we

1719:02

are getting undefined I don't know why

1719:04

but we are getting getting undefined oh

1719:06

I just made a mistake here you can see

1719:08

I'm providing a resource name it should

1719:10

be a resource uh you resource URL you

1719:14

know let's just copy there and place it

1719:18

right here and this one will be a

1719:20

resource name instead now let me just

1719:22

save my file and now let's just refresh

1719:24

there and here you can see it's going to

1719:25

gives us all of their data so we are now

1719:27

getting the body email ID name and post

1719:29

ID which is looking cool so now let me

1719:31

just go ahead and go to this component

1719:33

and remove that from here and and now we

1719:36

are going to be restructuring that ID

1719:38

the name and also the email and the body

1719:41

from where from the comments like so

1719:45

otherwise if that's not the case we are

1719:46

going to be setting that to empty object

1719:48

and now finally we just have to render

1719:50

this so what I'm going to do is that I'm

1719:51

going to provide a paragraph and inside

1719:53

the let's just provide our commment ID

1719:56

and render our ID right here I'm going

1719:59

to also specify the H1 maybe in this

1720:01

case and let's a strong tag and then the

1720:04

comment comment name and here we have to

1720:07

render the name uh another paragraph

1720:10

which will says strong and then comment

1720:12

email and here we have to render the

1720:15

comment email and then finally a

1720:18

paragraph for a with a strong tag then

1720:21

the comment body and here let's just

1720:24

render the body I'll just write a body

1720:26

right here sa my file and here you can

1720:28

see we are also able to fetch our data

1720:31

from the to-dos and also from the

1720:33

comment Resource as well so yeah this is

1720:36

how we are going to be making our

1720:37

resource lader it's going to take the

1720:39

URL it's going to also take the name and

1720:42

also the children and this is how we

1720:43

going to be fetching our data based on

1720:45

that specific resource URL time for the

1720:48

final refactor so what I'm going to do

1720:51

is that I'm going to go ahead and go to

1720:52

the shared folder and Define the data

1720:55

source. TSX file and use the RFC inside

1720:59

then go to my app and remove all of that

1721:02

stuff from here and I'm going to also

1721:04

remove all of them from here just like

1721:07

that now let me go ahead and render my

1721:09

data source component right here and I'm

1721:12

going to close there and here it's going

1721:14

to take the to-do list which we already

1721:16

defin I'm going to close there now in

1721:18

this situation it's going to take a few

1721:20

props so it's going to take the get data

1721:22

function which will be an actual

1721:23

function which we are going to be

1721:24

creating in a few seconds and it's going

1721:26

to also take the resource name okay so

1721:29

in this case I'm going to only specify a

1721:30

to-do because in this case we're going

1721:32

to be working with the to-do now let me

1721:34

go ahead and Define some sort of a

1721:36

function which allows us to fet your

1721:38

data for this prop okay so I'm going to

1721:40

go ahead and go to the top and I'm going

1721:42

to specify like server come on get

1721:45

server data and it's going to take the

1721:47

URL as a prop I mean like as a perimeter

1721:50

and I'm going to inate as a string and

1721:52

now here I'm going to use the

1721:53

asynchronous function and now inside

1721:55

there we're going to be getting our data

1721:57

so I'll just store the inside the

1721:58

response and I'm going to use like aw in

1722:00

xos get the xos from the xos library and

1722:04

we're going to be get them by using this

1722:06

URL right here and finally we just have

1722:08

to return or response. data and that's

1722:10

it's going to be a I'm going to copy the

1722:12

name of there and now let me just place

1722:14

that function right here and now this

1722:16

function will allows us to fish the data

1722:18

so I'll just write like https and here

1722:21

we have to put like this and placeholder

1722:23

do type come on type I code Type I code

1722:28

like so not a type but just a type or TP

1722:32

code.com and then for/ toos and then one

1722:35

I'm going to save this file right now

1722:37

now let me go ahead and go to this

1722:39

component and start working on this so

1722:41

now let's just go there and the first

1722:42

thing that I want to use that I want to

1722:44

restructure the get data function it's

1722:46

going to be equals to this initial value

1722:48

of function so I'll just set that to

1722:50

this empty function and also we are

1722:52

going to be providing a resource name

1722:54

and also the children as well so now let

1722:56

me just save my file go to the top and

1722:58

Define an interface for this I'll just

1722:59

use like uh interface data source props

1723:03

and here inside this then I'm going to

1723:06

specify the get data function and this

1723:09

is going to be optional function and we

1723:10

have to just return the white from there

1723:12

I'm going to also specify the resource

1723:14

name and for the resource name is going

1723:16

to be set to string and also for the

1723:18

children there's going to be a react

1723:20

node okay so now let me just copy a name

1723:22

of there and annotate my component with

1723:25

these props like so and the next thing

1723:27

that we have to do is that we have to

1723:29

create for state so I'll just use like

1723:30

cons and then State and set State and

1723:33

it's going to be equals to this use

1723:34

state function and I'm going to specify

1723:36

the N value today as initial value it's

1723:39

going to take any data now finally we

1723:41

have to use the use effect patching our

1723:43

data so I'm going to go there and first

1723:45

of all fold the dependency array I'm

1723:47

going to specify the get data function

1723:50

and inside then we have to use our ify

1723:52

or immediately in function expression so

1723:55

I'll just specify my ify right here and

1723:57

cons data and it's going to be set to a

1724:00

and get data function I'm going to also

1724:02

set the state and here we have to spef

1724:04

spey our data inside there now let me

1724:07

just remove that from here and change

1724:09

there to react fragments and inside

1724:11

there we have to specify all of that

1724:13

stuff first of all we have to get our

1724:15

react from react JS and now we are just

1724:17

traing over through there and now we are

1724:19

checking if we have the valid react

1724:20

element then we want to just make a

1724:22

clone of there but if that's not the

1724:24

case we want to just get the children

1724:26

now let me just save my file and yep we

1724:28

are getting our data based on that

1724:29

specific URL and we can totally and

1724:32

definitely change that to like 12 or

1724:34

something like that it's going to also

1724:35

gives us our data based on that specific

1724:37

URL so yeah I can also duplicate there

1724:40

so let's just duplicate there and I'm

1724:43

going to Pro a bon and also the H on for

1724:45

the horizontal line and I also want to

1724:47

fish the data from these comments so

1724:49

here you can see we're now getting our

1724:50

data from the comments and the first

1724:52

comment and I'm going to also change

1724:54

that to the comment like so or comments

1724:57

rather and render my component which

1724:59

will be a comments list now let me just

1725:01

save my file and here you can see we're

1725:03

now fing our data from the todos and

1725:05

also from the comments so yeah this is

1725:08

how we are going to be fetching our data

1725:09

by using this get server data function

1725:12

okay so time for another challenge so in

1725:14

this one we are going to be creating our

1725:16

container component for fetching our

1725:18

data something which we just saw a few

1725:20

seconds ago but now this is a challenge

1725:22

so what do we have to do your goal is to

1725:24

implement a reusable data fetching

1725:26

component in reactjs that can fetch the

1725:28

data from the external API and provide

1725:30

it to its child component and this

1725:32

should be done with proper error

1725:33

handling conditional r ring and

1725:35

flexibility in how data is passed down

1725:37

to its St component so how the steps

1725:39

going to look like this is how the steps

1725:41

going to look like so first of all we

1725:42

have to create a data source component

1725:44

and obviously you can read through all

1725:45

of there if you wanted to then we have

1725:48

to create our product list component in

1725:50

which we are going to be rendering or

1725:51

data so I'm going to be fetching my data

1725:53

by using exos from this fake store API

1725:57

and you are more than welcome to fetch

1725:58

your data from anywhere that you prefer

1726:01

so yeah if you want to give it your best

1726:02

shot you totally can but if you you can

1726:05

do it then that's completely okay come

1726:07

back and watch the solution and now let

1726:08

me give you my solution so what I'm

1726:10

going to do is that I'm going to create

1726:11

two folders so the first one will be for

1726:13

the components and the second one will

1726:15

be for the shared you don't have to

1726:18

create that but I want to create there

1726:20

so now inside the Shar component I'm

1726:22

going to be I mean like inside the Shar

1726:23

folder we're going to be creating our

1726:25

Shar or data source components so I'll

1726:28

give the name of like data source. DSX

1726:32

and now inside there let me just use my

1726:33

RFC so my file and now let me go ahead

1726:36

and go to my app and use that right here

1726:38

so the first thing that I want to do is

1726:39

that I want to go to the top and I want

1726:41

to import this so I'm going to just

1726:43

import uh the data source from that

1726:45

components folder and now inside there

1726:47

let me just remove this app from here

1726:49

and I'm going to just provide like H one

1726:51

is going to say like welcome to the F

1726:54

store or something like that because now

1726:56

we are going to be creating our F store

1726:57

I'm going to also provide the margin to

1726:59

the top of 20 uh pixel now let me close

1727:02

there now underneath there we have to

1727:04

call our components which will be our

1727:06

data source I'm going to call it like

1727:08

this and it's going to take a few props

1727:09

so what I'm going to do is that I'm

1727:11

going to be passing this function which

1727:13

allows us to fetch our data which will

1727:15

be a get data Funk okay so now let me

1727:18

just paste it and now we going to be

1727:19

pasting the name of like Get server data

1727:22

and let me just go back and now here

1727:23

we're going to be passing our API which

1727:25

will be our https and then uh F store

1727:29

ai.com for/ products okay so if you care

1727:33

about that you can just hold control and

1727:35

click on there and now it's going to

1727:36

give you all of that data right here so

1727:38

we have the title we have uh ID and we

1727:41

have the price and in a lot of this data

1727:44

so now let me just close there and what

1727:45

I'm going to do is that I'm going to

1727:47

also provide the resource name right

1727:48

here so I'll say like resource come on

1727:51

resource name that's going to be equals

1727:53

to the product so let's just say our

1727:55

file and now here inside there we are

1727:57

going to be creating yet another

1727:58

component inside this components folder

1728:01

not inside the shared folder but inside

1728:03

the components fer I'm going to give it

1728:05

the name of like um product or yeah I

1728:08

guess product list. TSX would be fine

1728:10

let me just zoom in a bit so this is how

1728:12

we are going to be creating or naming

1728:13

our file so now inside there I'm going

1728:16

to just use my RFC save this file let's

1728:18

just go to the app I'm going to go back

1728:20

so that you guys can see everything a

1728:21

bit better and now inside this data

1728:23

source I'm going to be passing my

1728:25

product list and now let me just close

1728:27

there so as soon as I do that now let me

1728:29

save my file and that's it now we have

1728:31

to Define this function to fetch or data

1728:33

but the first thing that we have to do

1728:34

is that we have to go to this data

1728:36

source component and destructure all of

1728:38

that props so let's just go there and

1728:40

here inside there what we have to do uh

1728:43

first of all we have to restructure the

1728:45

here data function and I'm going to also

1728:48

uh provide the initial value of this

1728:50

empty function today and then I'm going

1728:52

to also destructure something called the

1728:54

resource name which we are also

1728:55

providing and now we also have to

1728:57

destructure the children so now that we

1728:59

successfully destructured there but we

1729:01

also have to define a typescript

1729:02

interface for there so I'll give it the

1729:04

name of like interface and then data

1729:06

source uh props and now inside there we

1729:09

are going to be passing our get data

1729:10

function and I'm going to make the like

1729:12

totally optional and here let's just

1729:14

pass our Arrow function which will only

1729:16

return the white I'm going to also pass

1729:18

the resource name and that's going to be

1729:19

set to a string and then finally we have

1729:21

to pass our children and that's going to

1729:23

be the react node which will be coming

1729:25

from the react JS so now as soon as I do

1729:27

that it's going to import there from the

1729:29

reactjs now let me just copy this name

1729:32

and I'm going to annotate my component

1729:34

with these react props so let's just say

1729:36

our file and this is how we going to be

1729:38

annotating our component by using this

1729:40

data source props so now inside there we

1729:42

have to Define our state and also our

1729:45

errors so I'm going to just go ahead and

1729:47

Define my state and also my set State

1729:50

and going to be equals to the US St and

1729:52

the initial value I'm going to paste

1729:53

like null today and basically it's going

1729:55

to take like anything that you can

1729:56

provide right there and I'm going to

1729:58

also past the error and then set error

1730:01

it's going to be equals to the use come

1730:03

on oh my God

1730:05

use that there we go and here we have to

1730:07

P the initial value of null today so it

1730:09

can either take a string or it can take

1730:12

a null value as well so now let's sa our

1730:14

file and now underneath them we have to

1730:17

use this function to fetch our data and

1730:19

by the way we're going to be also

1730:20

creating this function inside this app

1730:22

but we're going to be doing that in a

1730:24

few seconds so now inside there now we

1730:26

are going to be doing a side effects so

1730:28

in this situation we're going to be

1730:30

using the use effect okay so now let's

1730:32

just provide the and for the dependency

1730:34

here array I'm going to only provide

1730:36

that prop which we now getting like

1730:37

which will be the get data function like

1730:40

whenever this function changes then we

1730:42

want to rerender this component or this

1730:44

use effect uh what whatever you want to

1730:47

call it and now inside I'm going to past

1730:48

the if like immediately in work function

1730:51

expression but if you guys don't know

1730:53

there so you can definitely just create

1730:54

your function and call so I'll just

1730:56

write like async and here I'm going to P

1730:59

my function inside there and now let's

1731:01

just space our try and catch blocks so

1731:03

for this try let's just go back for this

1731:05

try I'm going to just get my data by

1731:07

using this get data function and I'm

1731:09

going to execute there now it's going to

1731:11

give us some sort of a data so now we

1731:12

have to store the inside the variable so

1731:14

I'll just give it the name of like uh

1731:16

cons data it's going to be equals to

1731:18

this function I'm going to also set

1731:20

there to my state which will be set to

1731:21

this data but if you got some sort of

1731:23

error so in this situation we are going

1731:26

to be just setting that error and I'm

1731:28

going to S like down to fish the data

1731:31

and now let me just save my file that's

1731:33

all done I'm going to also hide that and

1731:35

the next thing that we have to do is

1731:37

that we have to go to the UI and start

1731:39

working on there and I'm going to also

1731:41

make the as a react fragment instead of

1731:43

the div now here the first thing that we

1731:45

have to do is that we have to check for

1731:46

the error so if you got the errors in

1731:49

this situation we're going to be

1731:50

rendering the error but if you don't got

1731:52

any error then we're going to be showing

1731:54

some sort of a UI so if you got some

1731:55

sort of error so I'll just write a

1731:57

paragraph and I'm going to say just

1731:58

render that godamn error okay so let me

1732:02

just change that to error and here we

1732:04

have to provide the class name and I'm

1732:06

going to just provide like I know maybe

1732:09

text uh text red would be fine red and

1732:12

I'm going to just choose this 600 right

1732:14

here okay because that's going to be it

1732:15

for the uh error and now if that's not

1732:18

the case so then we want to it over

1732:19

through all of the childrens and I'm

1732:21

going to use the map and here we have to

1732:23

pass the children like all of them and

1732:25

then we have to pass the child as a

1732:26

initial value perimeter and now inside

1732:29

then we have to check if we have the

1732:31

react that is valid element like if the

1732:33

element is the react element so in that

1732:35

situation uh what do we have to do in

1732:38

this situation we have to just return

1732:40

our react. clown element we have to just

1732:42

make the clown of this existing element

1732:45

and we also have to pass our child

1732:46

inside there and now here now we are

1732:49

getting this error because we also have

1732:51

to import the reactjs from the react so

1732:53

I'll just import the react and these

1732:56

error are now successfully gone okay so

1732:59

now here I'm going to paste the keys and

1733:01

values so for the key I'm going to paste

1733:03

the resource name and the value will be

1733:05

set to this state okay and now here

1733:06

let's just return our data so I'm going

1733:09

to just return only the chart and now

1733:11

let me just save my file and that's only

1733:13

done so this is how we're going to be

1733:14

defining our data source component and

1733:16

now let's just use that inside our app

1733:18

component we are already using there

1733:21

right here but now we have to create

1733:23

this function so I'm going to go to the

1733:25

top and I'm going to make this function

1733:27

right here so I'll just give it that

1733:29

same name and it's going to take the URL

1733:31

so let's just space our URL and that's

1733:33

going to be a string and now let's just

1733:35

make the as a asynchronous function and

1733:37

here inside them we have to just use our

1733:39

xuse but first of all we have to install

1733:41

the so I'm going to use npmi and then XU

1733:44

it's going to install the inside my

1733:45

dependency or inside my project to be

1733:47

precise and now let's just use our npm

1733:49

run Dev so it's going to just run there

1733:51

now I'm going to be using the A and I

1733:53

want to use the xuse and by the way you

1733:55

are not just limited to use the xus you

1733:57

can use the fetch if you want it to but

1733:59

in my case I'm going to be using xus

1734:01

doget to get my data by just passing

1734:03

this you L and now let me just use my um

1734:06

come on let me just store the inside the

1734:08

response variable and now it will freak

1734:10

out because we have to import the exuse

1734:12

from the exos and finally we have to

1734:14

just return the response. data and

1734:17

that's it okay so that's totally it so

1734:20

the next thing that we have to do is

1734:21

that we have to go ahead and go to this

1734:23

product list component and render our

1734:25

data properly so this is how my

1734:27

component looks like and now I'm going

1734:30

to just create an interface for my data

1734:32

so I'll just give it the name of like

1734:33

product and now inside there we are

1734:35

going to be expecting the ID and the ID

1734:37

will be set to a number we will be also

1734:39

expecting the title and the title will

1734:41

be set to a string and we can also

1734:43

expect the description and that's going

1734:46

to be set to a string as well we can

1734:48

expect the price that's going to be a

1734:49

number and also the image and that's

1734:52

going to be set to a string now based on

1734:54

this interface now we are going to be

1734:55

creating yet another nested interface so

1734:58

either use that or use a null value so

1735:01

I'll just give it the name of like

1735:02

product list props and inser side there

1735:04

let's just use our products so either

1735:06

use our product list which we just

1735:09

Define right here or use the null value

1735:13

okay like nothing at all so now let me

1735:15

just paste this null value I'm going to

1735:17

copy the name of there now let me go

1735:19

ahead and go to my component and let's

1735:21

just destructure our products so I'll

1735:23

just uh destructure my products and I'm

1735:25

going to annotate my component with

1735:26

these products okay so now here I'm

1735:29

going to remove this entire jsx and I'm

1735:32

going to just say like if we have those

1735:34

products so in that situation show this

1735:36

UI but if you don't have those products

1735:38

then show this another UI okay so now

1735:41

for this else class I'm going to just

1735:42

create a paragraph and I'll just say

1735:45

like I don't know maybe loading products

1735:47

dot dot dot would be fine and I'm going

1735:49

to also provide the class names and

1735:51

class name I'm going to just copy and

1735:53

place a few styling so I have to provide

1735:55

this loading message right here and now

1735:57

here for this first class now we have to

1736:00

render our content so I'll just create a

1736:02

div and inside this D I'm going to give

1736:04

it the class of like product list

1736:06

container come on container c n t i n e

1736:10

r there we go and I'm going to also PR

1736:12

the UL and now inside this UL Let's us

1736:14

go back we're going to be iterating over

1736:16

through all of that products which we

1736:18

now getting right now so now let me just

1736:19

P it right here and use. map and here

1736:22

let's just pass our product and here

1736:26

inside them I'm going to just pass all

1736:28

of my products let's space our lii and

1736:30

for this lii I'm going to be placing a

1736:32

key and the key will be coming from

1736:34

product. ID I'm going to also provide

1736:36

the class name and which will be set to

1736:38

product card and inside this Li uh I'm

1736:40

going to provide my H2 which will just

1736:42

render the product. title let's just

1736:46

check this out so now let me just save

1736:47

my file and here you can see we are now

1736:49

getting all of the products title which

1736:51

is looking cool and now the next thing

1736:53

that we have to do is that we have to

1736:54

create our paragraph and now uh we are

1736:56

going to be providing our come on

1736:58

product. description I'm going to also

1737:01

provide the product price so let's just

1737:03

provide our product our price and I'm

1737:06

going to also pass my dollar symol right

1737:08

there and here let's just also pass our

1737:10

price here and finally the image so that

1737:13

we can see the image as well so I'll use

1737:15

like product. image and here we also

1737:18

have to paste alternative text so which

1737:20

will be set to product. title let's just

1737:22

say our file and this is how everything

1737:25

looks like and I know it will look huge

1737:28

and there we go we are now successfully

1737:30

getting all of the data but the next

1737:32

thing that we have to do is that we have

1737:33

to style there I already prepared The

1737:35

Styling for there if you care about

1737:37

those styling you can definitely go

1737:39

ahead and copy that from my guub

1737:41

repository but if you don't so you don't

1737:43

even have to worry about that so now let

1737:45

me just place it right here semi file

1737:47

and this is how everything looks like so

1737:49

as you can see first of all we are now

1737:51

getting the title then the description

1737:53

then the price and then finally the

1737:55

image for each of these products right

1737:57

here which is looking cool and yeah that

1738:00

was the entire challenge which we just

1738:02

solv now let's talk about about the

1738:04

control and uncontrol design patterns in

1738:06

reactjs so a control component is a form

1738:09

element whose value is controlled by Rea

1738:12

State and react handle the state of the

1738:14

component and updates it based on the

1738:16

user input through event handler like on

1738:19

change event handler for example so yeah

1738:21

that was just a controll component and

1738:23

now let's talk about the uncontrolled

1738:25

component uncontrolled component is a

1738:27

form element that maintain its own

1738:28

internal State and react does not

1738:31

directly manage or track the values

1738:34

instead we interact with the form

1738:35

element using RS to access its value

1738:38

when we need it so yeah that was just a

1738:40

quick definition of uncontrol and

1738:42

control component and now let's get into

1738:45

the code then you'll get to know what

1738:46

I'm talking about time to create the

1738:47

uncontrol form component so I'm going to

1738:50

go ahead and create my components folder

1738:52

and inside there we're going to be

1738:54

creating uncontrol so come on

1738:58

uncontrolled form. TSX file I'll use my

1739:01

RFC inside there go to the app and

1739:04

registered this component right here so

1739:05

on control form component save this file

1739:08

and now let's just start working on

1739:10

there so the first thing that I want to

1739:12

do use that I want to define a form I'm

1739:13

going to remove that from here and

1739:15

change that to a form this form will

1739:17

have a few input Fields so I'll just

1739:19

write like input field with a type of

1739:20

text and also the class name will be set

1739:23

to border name will be set to name and

1739:25

the placeholder will also be set to name

1739:28

I'm going to duplicate this line of code

1739:29

and and change the class names I mean

1739:32

like change the name to be Edge and also

1739:35

the placeholder to Edge so I'm going to

1739:37

duplicate this line of code once again

1739:38

change the type to text and also the

1739:41

name to hair color and the placeholder

1739:45

to hair color once again and finally I'm

1739:48

going to be creating a button uh by

1739:50

using the input feeld so I'm going to

1739:51

provide the type of submit today and for

1739:54

the name we're going to be also

1739:55

providing a submit and for the

1739:57

placeholder is going to say submit now

1739:59

let me just sve my file and that's

1740:00

everything that we have to do but first

1740:02

of all we have to just scate a few RS we

1740:05

not going to be creating a state because

1740:06

then that will be a control component we

1740:09

going to be creating a RS which means

1740:11

like this is a unol component so I'll

1740:13

just create first of all the name input

1740:15

and it's going to be equals to the Riff

1740:17

I mean like the use riff uh like like so

1740:21

and I'm going to annotate there with the

1740:22

HTML come on HTML input element I'm

1740:25

going to also close there and the

1740:26

initial value will be set to now and

1740:29

just like there I'm going to also create

1740:30

another variable for the edge input it's

1740:33

going to be equals to the use rep once

1740:34

again and here for the initial value

1740:36

we're going to be providing a null value

1740:38

and this one will be HTML input element

1740:41

like so I'm going to also duplicate

1740:43

there and change that to the hair color

1740:46

input and going to be equals to this R

1740:49

now first of all let me just bind those

1740:51

refs so I'll just use like for the ref

1740:53

name input ref and then for the edge

1740:56

we're going to be providing a reference

1740:58

once again and here we have to specify

1741:00

the edge input and finally for the hair

1741:02

we're going to be providing a ref of

1741:04

hair color input so now let me just save

1741:06

my file and finally we have to just

1741:08

create a function which will be when

1741:09

somebody submit this form so we want to

1741:11

fire this function which is a handle

1741:13

submit and now let's just create this

1741:15

function right here I'm going to be

1741:16

using cons handle submit and here we

1741:19

have to specify the event object and

1741:21

let's just support our HTML form element

1741:24

like so and I'm going to close there

1741:25

we're going to be only returning a white

1741:27

from there we don't have to do that but

1741:29

I want to do that okay so let's just use

1741:31

our event. prevent default and just uh

1741:34

prevent the default Behavior which is a

1741:35

refresh and also we have to provide the

1741:38

name input field. current and Edge input

1741:41

field. current and the hair color

1741:45

current so if that's the case in this

1741:46

situation we just want to lock to the

1741:48

console like name input field. current

1741:50

value and I'm going to also just

1741:52

duplicate there like three times we

1741:53

don't want to do anything else with that

1741:55

so I'll just choose like Ed Edge input

1741:57

field and then the current value from

1741:59

there and then from the head color input

1742:01

field and we want to get the value from

1742:02

there and here you can we now getting

1742:04

our input field so now let me just go to

1742:06

the console and let's just refresh there

1742:08

I'm going to specify first of all my

1742:10

name and also my age is 22 and then the

1742:13

hair color is black and now let me just

1742:17

click on this submit and it's going to

1742:18

giv us all of that data so here you can

1742:20

see we are not using any St so which

1742:22

means like this is a uncontrolled form

1742:25

or you can see this is a uncontrolled

1742:26

component so how in the we're going to

1742:28

be making a control component let's just

1742:31

create our control component so I'm

1742:33

going to go ahead and and just create

1742:34

control Com or control form. TSX will be

1742:38

fine I'll use my RFC inside there go to

1742:40

the app comment this line out and

1742:42

provide my controled component or form

1742:45

sem my file yep we are getting our form

1742:47

so let's just close there so the first

1742:49

thing that I want to use that to start

1742:50

from the state so I'll use like name and

1742:52

then set name it's going to be equals to

1742:54

the use State and the initial value will

1742:56

be empty string I'm going to also

1742:59

provide the edge and then the set Edge

1743:01

it's going to be equals to the use St

1743:03

and the value will be empty string and

1743:05

then for the hair color and then set

1743:08

hair color it's going to be equals to

1743:10

the US St and the come on the use State

1743:14

and the initial value will be empty

1743:16

string and then for the final one which

1743:18

will be errors so I'll use like set

1743:20

input error and then set input or you

1743:24

know it should be name input error name

1743:27

input error and then set name input

1743:31

error it's going to be equals to this

1743:33

used

1743:34

and the initial value will be empty

1743:36

string now let me go ahead and go to the

1743:38

form so I'll just change that to the

1743:40

form and here inside this form we are

1743:42

going to be defining our input field so

1743:44

the type will be set to text name will

1743:46

be set to name and the placeholder will

1743:49

also be set to name and the value will

1743:51

be coming from the name okay so I'm

1743:54

going to also TR the on change event

1743:55

handler when somebody try to type

1743:57

something inside there so you want to

1743:59

just get this so I'll use like event.

1744:01

target. value I'm going to save this

1744:03

file file right now and for the classes

1744:05

we are going to be providing a border

1744:07

and margin all around will be set to two

1744:09

now underneath them let's just Define

1744:11

our input field for the type of number

1744:14

and here we're going to be also

1744:15

providing a name of Edge and the

1744:17

placeholder will also be set to Edge and

1744:20

the value come on the value will be set

1744:22

to Edge as well so when somebody try to

1744:25

type something inside there we're going

1744:27

to be firing this function which is a

1744:28

set Edge and here we have to specify the

1744:31

event. target. name I mean like value

1744:34

but we also have to convert that to a

1744:36

number like this or you know what we are

1744:39

going to be using a number Constructor

1744:41

and now let's just convert that to the

1744:44

number okay what the hell so we are

1744:46

going to be also providing a border and

1744:48

margin all around will be set to two now

1744:51

underneath there we have to Define our

1744:53

input field once again and the type will

1744:55

be set to text the name will be set to

1744:57

hair color and I'm going to also specify

1745:00

the placeholder of hair color and now

1745:03

here we have provide the value and the

1745:04

value will be hair color and also when

1745:07

somebody try to type something inside

1745:09

there we just want to fire this function

1745:11

which is a set hair color and the event.

1745:14

target. value inside there okay so for

1745:17

the classes is going to be set to border

1745:19

margin under will be set to two and

1745:21

finally let's just create our button

1745:23

which will says submit there we go I'm

1745:25

going to also render this error if we

1745:27

have that so what I'm going to do is

1745:29

that if we have the input error in that

1745:31

situation we only want to show this

1745:33

paragraph which will say like um come on

1745:36

name input error and here we have to

1745:39

provide our class names and the text

1745:41

will be set to totally rate of 500 now

1745:44

let me just save this file right now and

1745:45

I'm going to also use the user effect

1745:47

for this error so I'll use like the user

1745:49

P because you want to do our side effect

1745:51

inside there and for the dependency

1745:53

array we are going to be only providing

1745:54

a name and let's just check if we have

1745:57

the name length is less than two

1745:59

characters so in that situation we're

1746:01

going to be getting like set name input

1746:03

error and here we have to specify like

1746:05

name must be at least two characters or

1746:09

long and if that's not the case so we

1746:12

just want to write like set name input

1746:15

error and let's just set there to empty

1746:17

empty string or we can also use a trary

1746:20

for the so use like length is less than

1746:23

two if that's the case so we just want

1746:25

to copy this line of code and place it

1746:28

right here but if that's not the case so

1746:31

I'm going to just only copy this line of

1746:32

code and it here and now let me just

1746:35

comment this line out like so I'm going

1746:38

to save this file right now and here you

1746:40

can see we are now getting our error so

1746:42

if I just write like my name the error

1746:44

will be now gone I'm going to also

1746:45

specify the age of 22 and the hairs will

1746:48

be set to Brown in this case if I click

1746:50

on this it's going to just refresh there

1746:52

so now this component is a control

1746:55

component and why is there because we

1746:57

are now controlling them by using the US

1746:59

T and on the other hand this component

1747:02

is not a control component because we

1747:05

are just only referencing to the value

1747:07

but we are not controlling that value

1747:10

okay so time for another challenge so in

1747:12

this one basically you're going to be

1747:14

creating only one form component but you

1747:17

have to create them by using the control

1747:19

and also the uncontrolled component

1747:21

design pattern which we just saw a few

1747:23

seconds ago so basically you just have

1747:25

to create a simple form which will have

1747:26

the following field like the first name

1747:28

last name email subscribe to a

1747:30

newsletter which will be a checkbox and

1747:32

finally a message area are which will be

1747:34

a text area so this is what you have to

1747:36

do so give it your best shot if you can

1747:39

do it that's completely okay then come

1747:40

back and watch the solution and now let

1747:42

me give you my solution so what do we

1747:44

have to do I'm going to go ahead and go

1747:46

to my SRC folder and create another

1747:48

folder with the name of container not

1747:51

container but the components there we go

1747:53

and inside there we have to create the

1747:55

come on control form. TSX and we are

1747:59

going to be creating the uncontrolled

1748:00

one in a few seconds so now let me just

1748:02

use my rafc go to my app component and

1748:05

register there right here so I'll just

1748:07

register there with the name of control

1748:10

form and close there now let me just run

1748:13

my npm run Del so I'll use like npm rund

1748:16

Del so this is exactly something that we

1748:19

want and now let's just create our form

1748:21

so what I'm going to do is that first of

1748:22

all I'm going to be defining a state for

1748:24

my form so I'll just use like uh form

1748:27

data and then set form data is going to

1748:30

be equals to the Ed State and the

1748:31

initial value I'm going to be providing

1748:33

this object which will have the

1748:34

following properties like the first name

1748:37

which will be set to empty string and

1748:38

the last name which will be set to empty

1748:40

string we're going to be also passing an

1748:42

email and finally the Subscribe which

1748:45

will be set to false and finally the

1748:47

message and let is provide empty string

1748:49

inside there now let me just close there

1748:51

and now we have to go ahead and go to my

1748:53

UI and change that to the form okay so

1748:57

whenever we submit this form so we are

1748:59

going to be passing this function which

1749:01

we going to be creating in a few seconds

1749:03

so let's just type like on submit and

1749:06

let's just pass our handle submit

1749:07

function which we're going to be

1749:08

creating in a few seconds now inside

1749:11

there we have to first of all provide

1749:12

the input field which will have the type

1749:14

of text but we are going to be also

1749:16

providing the name and the name will be

1749:18

set to first name and we're going to be

1749:20

also providing the value so the initial

1749:22

value will be coming from the form data

1749:24

first name and whenever we type

1749:26

something inside this form so then we

1749:27

are going to be firing this function

1749:29

which is a handle change function and

1749:31

also the placeholder will be set to

1749:33

First name this is s our file now we

1749:35

have to create another form field which

1749:37

will be for the last name I'm going to

1749:38

create my input field and now here let's

1749:41

SP our name and which will be set to a

1749:43

last name and here we also have to

1749:45

provide the value and the value will be

1749:46

coming from the form data. last name and

1749:49

I'm going to also provide the own change

1749:50

event handler and let's space or handle

1749:53

change inside there and the placeholder

1749:55

will say like last name say our file and

1749:58

now underneath them we have to create

1750:00

another input field with the type of

1750:01

email so I'm going to just go ahead and

1750:03

type the input Fe with the type of email

1750:06

and I'm going to also paste the name and

1750:08

the name will be set to email you also

1750:09

have to provide the value and the value

1750:11

will be set to form data. email and we

1750:14

also have to provide the on change event

1750:15

handler and past the on change right

1750:18

there I'm going to also past the

1750:19

placeholder which will be set to email

1750:21

save my file then we have to create a

1750:23

label so let's just pass our label

1750:25

inside there which will not take any

1750:27

HTML input field but we are going to be

1750:29

also providing our input and here the

1750:31

type will be set to a checkbox because

1750:33

now we are going to be creating our

1750:34

check box for our subscribe and pass the

1750:37

name and the name will be set to

1750:38

subscribe and we also have to provide

1750:40

the check plag and for this check plag

1750:42

we have to P our form data. subscribe

1750:46

and we're going to be also providing the

1750:47

own change event handler which will be

1750:49

set to the handle change like so so

1750:52

let's just say our file and here for

1750:54

this input field we're going to be also

1750:55

passing like this sub come on subscribe

1750:58

to news come on newslet and now

1751:02

underneath there we have to create our

1751:04

text area so I'll use like text area and

1751:07

pass the name and the name will be set

1751:08

to a message and the ID will be I mean

1751:11

like I'm not going to be providing any

1751:12

IDs to this so I'll just past the value

1751:14

and the value will be coming from the

1751:15

form data. message and we also have to

1751:17

provide the own change like whenever

1751:19

somebody types something inside this

1751:21

input period so we are going to be

1751:22

firing this function and the placeholder

1751:24

will say like message like so and now

1751:27

inside this text area or not inside but

1751:30

now underneath here we're going to be

1751:31

creating our button and which will just

1751:33

say submit come on submit and also

1751:35

provide my type and the type will be set

1751:37

to submit now let me just save my file

1751:39

and now let me go ahead and go to the

1751:41

top and let's just create our handle

1751:43

submit function and then we're going to

1751:45

be creating that other function so I'll

1751:46

just create my handle submit which will

1751:49

take the event and we're going to be

1751:50

also just annotating the as anything and

1751:53

let's just use the event. prevent

1751:55

default and execute then now we can also

1751:58

use the console.log of form data and now

1752:01

let me just save my file now now finally

1752:03

we have to just create our handle change

1752:05

function now let's just create there

1752:07

right here so I'll just give it the name

1752:08

of like handle change and uh let's just

1752:12

use the event and I'm going to also

1752:13

annotate there s any inside there let's

1752:15

just restructure a few things like

1752:17

event. Target and here uh we are going

1752:20

to be restructuring the name the value

1752:23

and also the type and the chck and it's

1752:25

going to be equals to this event. Target

1752:27

and now finally we have to use the set

1752:29

form data and provide our previous data

1752:32

and here inside there let's our eror

1752:34

function first of all we have to make

1752:36

the clown off our existing previous data

1752:39

if you have there but if you don't so

1752:41

then we're going to be just creating

1752:42

this key and value but I don't know why

1752:44

we getting this error oh that's because

1752:46

we have to provide the error right here

1752:49

there we go so now let me just place a

1752:51

key as a name and for the value we are

1752:53

going to be checking if the type is

1752:55

equal to checkbox so in this situation

1752:58

we going to be changing that to check

1753:00

but if that's not the case so we are

1753:01

going to be changing that value

1753:03

so let's just Pro our comma and save my

1753:06

file and that's everything that we have

1753:07

to do right now so this is how our form

1753:10

looks like I know it is looking super

1753:12

awful but yeah this is how we are going

1753:14

to be providing our first name last name

1753:16

email and then the newslet and message

1753:19

so now let me go ahead and go to my

1753:20

console and now let's just refresh there

1753:23

first of all I'm going to provide my

1753:24

name which will be husan and then web

1753:27

dev come on web dev and I'm going to

1753:29

also provide like test at gmail.com and

1753:32

for the newsletter I want to subscribe

1753:35

to that because hosan is an amazing

1753:37

person and cool course I guess that's

1753:41

going to be fine so finally let me just

1753:43

click on this submit button now it's

1753:44

going to gives us this entire data right

1753:47

here so this is how we going to be

1753:48

building our form by using the control

1753:50

component but now let's create that same

1753:53

exact same form by using the

1753:54

uncontrolled component so I'll just give

1753:57

of like

1753:58

uncontrolled uh form. TSX would be fine

1754:02

and now I'll just use my RFC inside

1754:04

there I'm going to copy the name of

1754:05

there go to my app and comment this line

1754:07

out and render my component like so but

1754:10

we have to render that so that we also

1754:13

have to import it like so and yeah now

1754:16

we are getting our uncontrolled

1754:17

component let's just go there and the

1754:20

first thing that we have to do is that

1754:21

we have to Define our stats by using the

1754:24

US ref because this is a uncontrolled

1754:26

component so we would need the first

1754:28

name last name in email so I'll just go

1754:30

ahead and write like first name ref and

1754:33

it's going to be equals to the use ref

1754:34

not the reducer but the ref and I'm

1754:37

going to also just provide the initial

1754:39

value of null today but I'm going to

1754:41

also annotate there as HTML input

1754:43

element because we know that we are

1754:45

going to be using that for the HTML

1754:47

input so I'm going to also write like

1754:49

last name and then ref I'll just give it

1754:51

that name last name ref it's going to be

1754:54

equals to that same use ref not the

1754:56

effect but that ref God damn it I can't

1754:59

even type today and the initial value

1755:01

will be set to no and here here I'm

1755:03

going to also paste the HTML input

1755:04

element and that's it now we also have

1755:07

to create one for the email ref for the

1755:09

email reference and use my email ref and

1755:12

provide my null value inside there and

1755:15

now we are going to be using our HTML

1755:16

input element yeah I guess that's going

1755:18

to be fine and close them let's just

1755:20

create two more so now we are going to

1755:21

be creating yet another one for the

1755:23

Subscribe ref and it's going to be

1755:25

equals to that same user ref and now

1755:27

let's just use that HTML element or HTML

1755:30

input element rather and the initial

1755:32

value will be set to n and finally we

1755:34

have to create one more for the message

1755:36

refi it's going to be equals to the use

1755:38

refi and the initial value I'm going to

1755:41

type like html text area in this case

1755:44

okay so now let me just provide there

1755:45

and the initial value will be set to

1755:47

know now let me go ahead and go to my UI

1755:49

so let's just remove that and I'm going

1755:51

to change that to the form come on what

1755:53

the hell did I just do as I said today I

1755:56

can even type so let's just use our

1755:58

submit and here let me just pass my

1756:00

handle submit right here and inside this

1756:03

form we going to be creating our input

1756:04

feed with the type of text would be fine

1756:07

and we're going to be also providing the

1756:08

reference which will be set to the first

1756:10

name ref and now we also have to provide

1756:13

the placeholder which will select the

1756:14

first name I'm going to save this file

1756:16

right now but I'm going to also have to

1756:18

duplicate there a few times so I guess

1756:20

that's going to be fine but we also have

1756:22

to provide the another value which will

1756:24

be set to a last name reference and we

1756:26

also have to change the label to the

1756:28

last name there we go now we also have

1756:30

to change the text field to the email

1756:32

because we're going to be providing our

1756:33

email and also change that to the email

1756:35

refi and change that to and now let's

1756:38

just change the final one and not even

1756:40

the final one but you know let's just

1756:42

remove there and change that to the

1756:43

label and I'm going to also remove this

1756:45

HTML 4 from there and create my input

1756:47

field right here and I guess that the

1756:50

type will be set to checkbox and here we

1756:52

also have to provide the ref for the

1756:54

reference and provide my subscribe ref

1756:57

there we go and now underneath it we are

1756:59

going to be saying like subscribe to

1757:01

news come on news letter and that's

1757:04

going to be it

1757:05

now we have to create our text area and

1757:09

for this text area I'm going to just

1757:11

pass the me or you know we're not going

1757:13

to be doing it like this way but let's

1757:16

just remove both of them I'm going to P

1757:18

my reference right here ref like so and

1757:21

provide my message ref and I'm going to

1757:23

also paste the placeholder which will be

1757:25

set to a message and now finally let's

1757:27

just create our button which will say

1757:29

submit and provide my type which will be

1757:32

set to submit that's it for the UI but

1757:35

now we have to create this handle submit

1757:37

function here I'm going to just Define

1757:39

like const uh handle submit it's going

1757:43

to take the event so I'm going to also

1757:45

annotate as a react. form event because

1757:48

we're going to be using there for the

1757:49

form and we specifically want to use

1757:51

that for the HTML form element and close

1757:54

there and now inside there what we have

1757:55

to do we have to prevent the default

1757:58

Behavior like so and now we have to

1758:00

Define our form data so I'll use like

1758:02

conform data it's going to be equals to

1758:05

this object and first of all let's just

1758:06

get the first name not the reference but

1758:09

just a first name which will be coming

1758:11

from the first name reference current

1758:13

value that's going to be totally

1758:14

optional and get the value out of there

1758:17

but if you don't get there then you want

1758:19

to just provide the initial value of

1758:20

empty string today now let me just do

1758:22

the same thing for the last name so

1758:24

let's just provide our last name

1758:26

reference. current value and then we

1758:28

have to get the value from there but if

1758:30

you don't have the value so then we want

1758:31

to set that to empty string then we have

1758:33

to create the same thing for the email

1758:35

and then the email reference. current

1758:37

value and then uh we have to get the

1758:41

value out of there and if we don't have

1758:42

the value so in that situation we're

1758:44

going to be only providing the empty

1758:46

string and if that's not the case then

1758:49

we are going to be also creating one for

1758:50

the Subscribe subscribe and you should

1758:53

definitely subscribe to my YouTube

1758:55

channel if you're watching this video

1758:56

right now so subscribe reference. Uh

1759:00

current value if you have there then you

1759:02

want to get the checked from there so

1759:04

checked but if you don't have that then

1759:06

you want to set that to the false let's

1759:08

just change that to the false and that's

1759:09

going to be it finally let's just create

1759:11

one more for the message which will be

1759:13

coming from the message reference and

1759:15

then the current value then the dot

1759:17

value but if you don't have there then

1759:19

you want to set there to empty string

1759:21

now let me just log there to the console

1759:22

so that we can see there so I'll just

1759:23

use like form data and now it will freak

1759:26

out so you know let me just also create

1759:28

a uh what do we call it I'm going to go

1759:30

to the top and here let's just also

1759:31

Define that interface so I'll just give

1759:33

it the name of like form data you don't

1759:35

have to do that if you don't want to do

1759:36

that but I want to do this so I'll give

1759:38

it the name of like first name and

1759:40

that's going to be set to a string I'm

1759:41

going to also create a last name will be

1759:43

now set to string then we have the email

1759:45

which will be set to a string and then

1759:47

we also have the Subscribe which will be

1759:49

set to a Boolean and then finally we

1759:51

have the message which will be set to a

1759:52

string okay so now let me go ahead and

1759:55

copy this form data from there and I'm

1759:57

going to inate my form with this newly

1760:00

created interface so let's just say our

1760:03

and this is how my form looks like so if

1760:05

I just type something but I'm going to

1760:07

have to go ahead and go to my console

1760:09

and I'll just P like uh you know what

1760:12

someone cool and then someone cool

1760:17

gmail.com and I also want to subscribe

1760:20

to his or her newsletter and who course

1760:24

Huzan or something like that and now let

1760:26

me just click on this submit button and

1760:28

now it's going to gives us all of that

1760:29

data right here so this is how we are

1760:31

going to be defining work component by

1760:33

using the form the control component and

1760:36

also the uncontrolled component okay

1760:39

let's talk about everyone's favorite

1760:40

topic which is called the H or the

1760:43

higher order component so what are these

1760:45

and why should youone to care about

1760:47

there so the higher order component or H

1760:50

design pattern is used to reuse

1760:51

component logic and it is a function

1760:54

that takes a component as argument and

1760:56

return a new component that enhances the

1760:58

original one these patterns allows us to

1761:00

share functionalities across multip

1761:02

component without repeating our code so

1761:05

that was just a quick definition of what

1761:07

H is and now let me give you a quick

1761:09

note about the H so an hocc or higher

1761:12

order component does not modify the

1761:16

original component directly but instead

1761:18

wraps it in a new component thereby

1761:21

adding additional Behavior or modifying

1761:23

its props so yeah that was just a quick

1761:26

note and now let me give you a quick

1761:27

example of how our regular component

1761:30

looks like and how our higher order comp

1761:32

component looks like so this is how a

1761:34

regular component looks like first of

1761:36

all we are going to be creating some

1761:37

sort of a function and the first letter

1761:39

will be upper case because this is a

1761:41

component not just a function and inside

1761:44

this component we are going to be

1761:45

returning some sort of a jsx and this is

1761:48

what we call our regular component yes

1761:50

of course we can write our state and all

1761:52

of our logic but basically this is how

1761:55

we are going to be creating our regular

1761:56

component and now let me show you how

1761:59

our H component will look like so I'm

1762:01

going to give you the most basic example

1762:04

of H or higher order component so here

1762:07

you can see this is how the code will

1762:08

look like first of all we are going to

1762:10

be creating a function and now I know a

1762:12

lot of you will notice like the first

1762:14

letter is lower case and why is there

1762:17

that's because this is not a component

1762:20

this is a function which take a

1762:22

component as a argument or as a prop

1762:25

whatever you want to call it and then we

1762:27

can do whatever we want to do with that

1762:29

component okay so here you can see I'm

1762:30

just passing a props to that n component

1762:33

and I'm just logging there something

1762:35

which I'm going to be showing you in a

1762:36

lot of details so without wasting any

1762:38

time now let's get into the coding and

1762:40

then you will get to know what I'm

1762:41

talking

1762:43

about now let's talk about the higher

1762:45

order component so what I'm going to do

1762:47

is that I'm going to create a new folder

1762:48

with the name of utils and I'm going to

1762:50

be creating my higher order component

1762:52

inside this utils folder you are more

1762:54

than welcome to create the inside the

1762:56

components folder but in my case I'm

1762:58

going to be creating the inside the

1762:59

utils folder and now let's just give it

1763:01

the name of like print promps TSX and

1763:04

notice my file name does not start from

1763:07

the upper case it start from the lower

1763:09

case and why is there I'm going to tell

1763:12

you why is there in a few seconds so now

1763:14

let me just hit enter right here and I'm

1763:16

going to just use like const and first

1763:17

of all we are going to be creating a

1763:19

function which will be a print props a

1763:21

higher order component is just basically

1763:23

a function which take a component as a

1763:25

perimeter and then we can do whatever we

1763:27

want to do with that perimeter or that

1763:29

specific component so I'll just make it

1763:31

as a function like so and this function

1763:34

we'll take the component as a perimeter

1763:36

so I'll give it the name of component

1763:37

and you are more than welcome to give it

1763:39

any name that you prefer you can give it

1763:41

the name of like apples banana or

1763:43

anything that you prefer but in my case

1763:45

I'm going to give it the name of

1763:46

component and here I'm going to otate

1763:48

the as any because in this case we're

1763:51

now providing a component inside there

1763:53

this is how we are going to be creating

1763:54

our function like first of all we have

1763:56

to create our function and this function

1763:58

will only take a component as a

1764:00

perimeter and I'm going to just return

1764:02

my component so I'll use like props and

1764:04

here I'm going to just uh annotate the

1764:06

as any and inside this component we can

1764:09

do whatever you want to do inside this

1764:11

so I'm going to just log to the console

1764:12

my props because the name of my

1764:14

component is print props which means

1764:16

like we are going to be only printing or

1764:18

logging these props to the console and

1764:20

now let me just return my component

1764:22

which we are now taking as a perimeter

1764:24

and now here I'll just use like dot dot

1764:26

dot come on uh dot dot dot props and now

1764:29

let's just close there and now this is

1764:31

how we are going to be creating our

1764:32

first higher order component now let me

1764:34

just export that so that we can use that

1764:36

in other file I'm going to go to my app

1764:38

component and now let's just use that

1764:40

right here the first thing that I want

1764:41

to do is that I want to import my print

1764:43

props and now we have to create an

1764:45

instance of there so I'll just use like

1764:47

print props and here inside there as we

1764:50

all know that it's going to take a

1764:51

component as a perimeter so which means

1764:53

like we have to specify some sort of a

1764:55

component to there so I can just create

1764:57

my component like uh like so but in my

1765:00

case we already have this to-do list

1765:01

component component if you don't have

1765:03

that you don't even have to worry about

1765:04

that you can just write your RFC inside

1765:07

there but you have to have some sort of

1765:08

a component which you will need to pass

1765:11

which you'll need to pass inside the

1765:13

Sprint props so I'll just go ahead and

1765:15

just write like Todo list and import

1765:18

them and now the next thing that I want

1765:19

to do is that I want to store them some

1765:20

sort of a variable so I'll use like

1765:22

to-do list r or rapper would be fine and

1765:26

now I'm going to call there to-do list

1765:27

rapper as a component so I'll use like

1765:30

to-do list rapper and I'm going to just

1765:32

quite a few props to this so I'll just

1765:33

use like uh one and it's going to be set

1765:36

to one I'm going to just say like two

1765:38

it's going to be set to I don't know

1765:40

hello and I'm going to also write a

1765:42

three and it's going to be set to some

1765:43

sort of object like name will be set to

1765:45

hose and now we are ping these props to

1765:48

this component and now let's just see

1765:50

whether it will gives us or not here you

1765:52

can see we now getting our to-do list

1765:53

I'm going to open there inside my

1765:55

console and now let's just refresh there

1765:57

and here you can see we now getting our

1765:59

one two prop and also our three prop

1766:01

right here here and why is that that's

1766:04

because we're now printing those prompts

1766:06

by using our higher order component and

1766:09

that was our first higher order

1766:10

component let's create another higher

1766:12

order component so I'll just create a

1766:14

new file with the name of with loading.

1766:17

TSX and it's going to allows us to Prov

1766:19

a loader okay so first of all let's just

1766:21

create over with loading and it's going

1766:23

to be taking a WRA component come on WRA

1766:27

component and I'm going to annotate as a

1766:29

react. component type and here we have

1766:32

to specify our generic I'm going to also

1766:34

specify generic right here for the

1766:36

beginning so I'll just write like B

1766:38

generic and we're going to be extending

1766:40

there extends from the object so I'll

1766:43

just use like object and close there now

1766:46

let me just create the body of this

1766:47

function like so so now let's just say

1766:49

our file and from this function we are

1766:51

going to be returning our component so

1766:52

I'll just use like function and here we

1766:54

have to specify the name of with loading

1766:57

and for the perimeter uh I'm going to

1766:59

specify like you know let's just remove

1767:01

that I'm going to provide like is

1767:03

loading and then dot dot dot all of the

1767:05

props I'm going to also Define interface

1767:07

for this so let's just go to the top and

1767:09

Define interface for the so I'll give it

1767:11

the name of like with lowering props

1767:13

it's going to take the flag of is

1767:15

lowering which will be set to Boolean

1767:17

and it's going to also take the key and

1767:19

which will be set to a string and we're

1767:20

going to be returning any from there

1767:23

okay so I'm going to copy a name of

1767:24

there and place it right here for this

1767:26

component and now inside this function

1767:28

we have to first of all check so if it

1767:30

is lowering so that situation we're

1767:33

going to be only returning H1 which will

1767:35

say lowering dot dot dot and now

1767:37

underneath that uh if that's not the

1767:39

case we are going to be just rendering

1767:41

our rep component it's going to take all

1767:43

of their prompts so let's just go our

1767:45

prompts come on uh prompts is a p

1767:48

generic and now let me just close that

1767:50

let me go back and this is how it looks

1767:52

like right here and I'm going to also

1767:54

export this so we can use it in other

1767:55

files so I'll use like export and now we

1767:58

will be able to use that in other file

1767:59

but before we use that I'm going to

1768:01

remove this to-do list component from

1768:03

there and I'm going to Define my

1768:05

component. TSX and I'll use my RFC

1768:08

inside there and that's going to be here

1768:10

let's just go ahead and go to our

1768:13

component and remove that I'm going to

1768:15

also remove both of them and this one as

1768:17

well and the first thing that I want to

1768:18

do is that I want to get my width

1768:19

loading and also my component so I'll

1768:22

use like my component like so and now we

1768:25

have to use or with loading and specify

1768:28

my component inside there and I'm going

1768:30

to store that in the variable with the

1768:32

name of my component with lowering and

1768:35

going to be equals to this function I'm

1768:37

going to also specify a state so I'll

1768:38

use the cons is loading and then set is

1768:41

loading it's going to be equals to the

1768:43

use St and the initial value will be set

1768:45

to true and also for the data we're

1768:47

going to be using like set data it's

1768:49

going to equals to this use State and

1768:51

the initial value will be set to empty

1768:53

string I'm going to also use the use

1768:54

effect so I'll use like the use effect

1768:56

and we are going to be doing a side

1768:58

effect so I'll just provide like empty

1769:00

dependency array and here I'm going to

1769:02

be using like set time out and that's

1769:04

not that much important but we are going

1769:05

to be getting some sort of a loader so

1769:07

that's why I'm providing the set time

1769:09

out so or set data will be set to data

1769:12

or f e t c h e d there we go and also

1769:15

our set lowering will be set to totally

1769:17

false and for the duration we're going

1769:20

to be setting there to 2 seconds and I'm

1769:22

going to go to the top and copy the name

1769:23

of my component and call that component

1769:26

right here so I'll just use like my

1769:28

component with loading and it's going to

1769:30

take the is loading prop and we have to

1769:32

set that two is loading and also fold

1769:35

the data we're going to be setting there

1769:37

to data and close there now I'm going to

1769:38

also go ahead and go to my component and

1769:41

here we're going to be only

1769:42

destructuring the data and now let me

1769:44

just render the destructure data so I'll

1769:47

use like data and close the semi file

1769:50

and I'm going to also wrap the as any so

1769:52

that it will not gives us any errors and

1769:54

now if I just refresh that and here you

1769:56

can see first of all it's going to gives

1769:57

us a lowering for 2 seconds and then

1769:59

it's going to gives us the data F so let

1770:01

me just WR once again so for 2 seconds

1770:03

we're going to be getting that louder

1770:05

and then it's going to gives us that

1770:06

data fetch so yeah that was another uh

1770:10

higher order component now let's Fitch

1770:12

some data by using our higher order

1770:14

component so I'll give it the name of

1770:16

like with do. TSX and here we are going

1770:18

to be fetching some sort of a data first

1770:20

of all we're going to be creating our

1770:22

function with the name of with to do and

1770:24

let's just zoom in a bit and it's going

1770:25

to take a component as a perimeter so

1770:28

I'll use that component and that's going

1770:30

to be any I'm going to also put to do ID

1770:32

to there and that's going to be set to

1770:34

string and inside there we're going to

1770:36

be defining our component so I'll just

1770:38

return like the props and PRS can be

1770:41

anything so I'll just write like any and

1770:43

inside there first of all we have to

1770:45

create our state so I'll use like cons

1770:47

to do and then set to do it's going to

1770:49

be equals to the Ed St and the initial

1770:51

value will be set to null I'm going to

1770:53

go back now underneath that we have to

1770:55

do our side effect which means like we

1770:57

have to fetch our data by using the use

1770:59

effect and here inside there I'm going

1771:01

to specify first of all my empty

1771:03

dependency array and inside this use

1771:05

effect we're going to be using our um if

1771:08

or immediately in function expression so

1771:11

here we have to just provide our ify and

1771:14

now we are going to be getting our

1771:15

response from our a uh or xos doget

1771:19

method now we are going to be providing

1771:21

our URL so I'll just use like https and

1771:23

Json Place holder. type I cod.com SL and

1771:28

we're going to be getting our data from

1771:30

the to-dos and here we have to render

1771:32

for to-do ID which we are now getting

1771:34

let me just save this file which we are

1771:36

now getting from as a perimeter so now

1771:38

let's just place the to-do ID right here

1771:41

and now finally we have to just provide

1771:43

our set too and the response. too or

1771:46

data to be precise so now let's say save

1771:48

our file and this is how we going to be

1771:50

fetching our data and finally underneath

1771:52

this use effect we're going to be

1771:54

returning our component and for this

1771:56

component let's just close them we are

1771:58

going to be providing first of all all

1772:00

of the props and then then we're going

1772:02

to be providing our to-do and that's

1772:04

going to be coming from the to-do state

1772:06

which we are now putting right here

1772:07

finally let's just export this so we can

1772:09

use that in other files now let me go

1772:11

ahead and go to my app component and

1772:13

remove every single thing from there and

1772:16

replace it with this app component and

1772:18

the first thing that I want to do is

1772:19

that I want to get my with low not

1772:22

lowering but with to do rather and the

1772:24

next thing that we have to do is that we

1772:26

have to create instance of there so with

1772:28

to do it's going to take a component so

1772:31

we are going to be passing our to-do

1772:33

list component oh I forgot I already did

1772:36

it this I'll just write like to-do list.

1772:38

TSX file I'm going to use my RFC inside

1772:41

there and now let's just grab our to-do

1772:43

list component and we are going to be

1772:45

also providing the to-do ID so in this

1772:48

case I only want to fetch my data from

1772:49

the second ID and now we have to store

1772:51

them in some sort of variable so I'll

1772:53

use like Todo list rapper and it's going

1772:55

to be equals to this to-do list rapper

1772:57

so I'm going to copy a name of there and

1772:59

I'm going to remove this app from there

1773:01

and call my component like so and I'm

1773:03

going to also close this so now if I

1773:05

save my file and now I'm going to also

1773:07

go ahead and go to my to-do list and

1773:09

place these coding right here once again

1773:11

so we have that same to-do list first of

1773:13

all we have our to-do interface then we

1773:15

have yet another interface now we are

1773:18

getting our to-do then we are only

1773:20

restructuring the ID and the title we

1773:22

are checking if we have the to-do so in

1773:23

that situation we are going to be

1773:24

showing that to-do ID and also the title

1773:27

but if that's not the case so we are

1773:28

going to be providing a loader so that's

1773:30

totally done and here you can see we are

1773:32

now getting our data so I can also

1773:34

change that to like I don't know maybe

1773:35

24 and now if I just refresh then it's

1773:38

going to give us 24 and also different

1773:40

data so this is how we going to be using

1773:42

the higher order components to fetch our

1773:44

data so this challenge which you are now

1773:46

about to perform will be a bit difficult

1773:48

but I want you to still give it your

1773:50

best shot if you can do it that's

1773:52

completely okay then come back and watch

1773:54

the solution but I want you to at least

1773:56

give it your best shot so what do you

1773:58

have to do so you have to create the

1773:59

higher order component to access control

1774:01

contr and dynamic prop injection so

1774:03

you'll need to implement the higher

1774:05

order component that does the following

1774:07

things so first of all the access

1774:09

control and then the dynamic prop

1774:10

injection so what is the access control

1774:13

so the higher order component should

1774:15

accept a rolles prop which is an array

1774:17

of allowed roles and the higher order

1774:19

component should check if the user has

1774:21

the required roles and if not it should

1774:24

display the fallback component like not

1774:26

authorized message or redirect that to

1774:28

the other page we're not going to be

1774:29

taking care of the redirect to other

1774:31

pages because now in this case we are

1774:33

not using any third party libraries like

1774:35

the Rea router Dom and something like

1774:37

that so you can just display a component

1774:39

which will select not authorized message

1774:41

next it should also take the dynamic

1774:43

prop injections so the higher order

1774:46

component should also be able to inject

1774:47

the dynamic props into the rep component

1774:50

based on a certain condition so like for

1774:52

example based on the user Ro the higher

1774:54

order component should inject additional

1774:57

prop into a rep component like the

1774:58

special content or feature based on

1775:00

their specific rols so what are the

1775:02

requirements so you need to Define the

1775:04

types for the components then the higher

1775:07

order component should be flexible to

1775:08

handle any type of the component with

1775:10

the ability to inject custom props

1775:12

handle default props and dynamic props

1775:14

injection based on the rules and

1775:16

implement the rules prop properly

1775:18

ensuring that the injected component

1775:20

only render for the user with the

1775:21

correct role so give it your best shot

1775:23

and once again I have to emphasize that

1775:27

this is going to be a bit Advanced

1775:29

challenge so if you can do it that's

1775:30

completely okay okay I totally

1775:33

understand and now let's get into it so

1775:35

what we have to do first of all first of

1775:36

all we have to create a few folders then

1775:39

we are going to be filling those folders

1775:41

so I'm going to just Define first of all

1775:42

the types folder in which we're going to

1775:44

be defining our types then we have to

1775:47

Define our components folder so I'll

1775:49

just give it the name of like components

1775:51

and finally we have to Define our U

1775:53

tails in which we are going to be

1775:54

defining or creating or higher order

1775:57

components so that's done the first

1775:59

thing that we have to do is that we have

1776:00

to take care of the types I'm going to

1776:02

create a file with the name of x's a c e

1776:05

s and then types. TS so you don't have

1776:08

to give it this name but I want to give

1776:09

it this name and basically it should be

1776:12

access control. types. TS okay so now

1776:15

inside there I'm going to be defining a

1776:17

few types so I'll just Define first of

1776:19

all the interface for the X's control

1776:22

props and inside there it's going to

1776:24

take the rules and we're going to be

1776:25

annotating there by a string of array

1776:28

and then it's going to also take the F

1776:29

back component so I'll just P like file

1776:31

back component and here let's space for

1776:34

react. component types component types

1776:37

there we go and we should get the react

1776:40

from the react J so that it will not

1776:41

gives us any error so let's just get the

1776:43

react from the react J and that's all

1776:46

done now underneath we also have to

1776:48

provide or injected props so

1776:51

injected i n j e c t e d injected props

1776:55

that's going to be totally optional here

1776:56

let's just pass or uh key to the and key

1776:59

will be set to totally string and it

1777:01

should should accept anything so that's

1777:03

to done we also have to export this so

1777:05

that we can use that in other file so

1777:07

now that's to done the next thing that

1777:09

we have to do is that we have to create

1777:10

an interface for the injected props so

1777:13

I'll just Define my interface and by the

1777:14

way we also have to export this so we

1777:17

can use the in other file and I'm going

1777:18

to give it the name of like injected

1777:21

injected props and inside there let's

1777:23

just put our username totally optional

1777:25

and make the as a string user

1777:28

permissions yeah user permission and we

1777:30

also have to inate the has a string of

1777:32

array and finally we have to create the

1777:34

final interface for one for the WRA

1777:38

component props okay and we should

1777:41

extend the functionality from the

1777:43

injected props and now inside there we

1777:45

have to provide the additional one which

1777:47

will be set to a message and provide my

1777:49

string inside there so this is what we

1777:50

have to do right now now we are also

1777:53

exporting there so that we can use that

1777:54

in other files so that's all done now

1777:56

let me just close that now we have to

1777:58

Define our higher order component so to

1778:00

do that we are going to be creating a

1778:02

new file with the name of withd because

1778:04

we now creating our higher order

1778:06

function or components and I'm going to

1778:08

give it the name of like

1778:10

XCS control. TSX yeah I guess that's

1778:14

going to be fine let's just go back and

1778:16

the first thing that we have to do is

1778:17

that we have to define the role by that

1778:19

specific role we're going to be

1778:21

providing our functionality like either

1778:23

authorized or not authorized so I'll

1778:25

just give with the name of like uh

1778:26

current user role and it's going to be

1778:28

set to the admin initially you want to

1778:30

check the function it of the admin and

1778:32

now we are going to be creating our

1778:34

higher order components so use like

1778:35

export because we're going to be using

1778:37

the in other files now we have to create

1778:39

like with x's uh control yeah I guess

1778:43

that's going to be fine and we also have

1778:44

to provide our generic which we're going

1778:46

to be extending which will extend from

1778:48

the object okay so let's space our

1778:51

object inside there and close there and

1778:53

inside there what do we have to do we

1778:55

have to pass our perameters but we're

1778:57

going to be doing that in a few second

1778:58

but now let me just create my arrow

1778:59

function right here so so first of all

1779:01

we going to be providing a WRA component

1779:04

so let's just write like w component and

1779:07

I'm going to be passing that from the

1779:09

component type and provide my generic

1779:11

right here and the injected prompt which

1779:14

we going to be getting uh from our types

1779:16

file so injected prompts there we go so

1779:19

let's just import that and use that

1779:21

right here and we also have to import

1779:23

the component type from the react JS and

1779:26

this is what we have to do right now now

1779:27

let me go ahead and go to my higher

1779:29

order component and start working on

1779:31

there so we are going to be returning

1779:33

come on let's just return the props

1779:36

first of all prop will take the generic

1779:37

ofy and also the exis control which we

1779:40

just Define inside that other file now

1779:43

let me just pass my arrow function right

1779:45

here so now inside there we're going to

1779:47

be providing our uh props right here so

1779:49

we're going to be destructuring a lot of

1779:51

things from our props so let's just

1779:53

destructure that things I'm going to go

1779:55

ahead and destructure the row rows come

1779:58

on that's going to be the first thing

1779:59

and we also have to get the fallback

1780:01

component and let's just annotate to the

1780:04

fallback which we're going to be

1780:05

creating in a few seconds so this should

1780:07

be in lower case b and I'm going to also

1780:09

provide my injected props and the

1780:11

initial value I'm going to specify this

1780:13

object to there and finally we have to

1780:15

just get the rest of the props so I'll

1780:17

just use like rest props and go back s

1780:19

my file and this is how everything looks

1780:22

like right here now we have to check

1780:23

whether the user is available or not or

1780:26

has the AIS or not so in that situation

1780:28

we're going to be getting that roles and

1780:30

we have to use the JavaScript includes

1780:32

method on there and then we have to pass

1780:34

our current R which is now initially set

1780:37

to this admin right here so once we do

1780:40

that I'm going to also store the inside

1780:41

the variable so I'll just give it the

1780:42

name of like has X and that's going to

1780:45

be here so let's just say our file and

1780:48

now if the user does not have access so

1780:50

has access is not the case in this

1780:53

situation we're going to be returning or

1780:55

F back component which we're going to be

1780:57

creating in a few seconds so let's just

1780:59

do that also so now we have to merge our

1781:02

props so in this situation we're going

1781:04

to be using like merge props and let's

1781:07

just pass our object first of all we

1781:09

have to get the rest of the props and we

1781:11

also have to get the injected props so

1781:13

then it's going to allows us to merge

1781:15

all of them now underneath that we have

1781:17

to just return our WRA component and

1781:20

also let's just close it like this I'm

1781:22

going to be passing uh first of all let

1781:24

me just even make the clone of there so

1781:26

I'm going to pass my merge prompts and

1781:29

as a generic p and and our on injected

1781:32

props so let's just space the same my

1781:35

file so this is how we going to be

1781:36

defining our uh what do we call it our

1781:38

higher order component and now we have

1781:40

to use that inside our app so now let me

1781:43

just go ahead and go to my app and the

1781:45

first thing that we have to do is that

1781:46

we have to you want to import them so

1781:48

that we can use that so I'll just go

1781:50

ahead and import the with access control

1781:52

and now I'm going to go ahead and also

1781:54

Define two other components inside this

1781:56

components folder one will be for the

1781:59

authorized user and another one will be

1782:00

for for not authorized user so I'll just

1782:03

create a file with the name of first of

1782:04

all not authorized authorized do TSX and

1782:08

we're not going to be doing anything

1782:10

special inside there but I'll just use

1782:11

my rafc and here we just have to write

1782:14

like you are come on you are not

1782:16

authorize a h o r a z e d to view this

1782:21

content and now let me just sell my file

1782:23

go back and that's only done now we also

1782:26

have to go ahead and just create another

1782:27

component so that we can see something

1782:29

on the screen so I'll just uh create

1782:32

like my component TSX I guess that's

1782:35

going to be fine and I'll use my RFC

1782:38

inside there and here it's going to take

1782:39

a few props so I'm going to have to

1782:41

destructure them I'm going to just

1782:42

destructure the message the user uh name

1782:45

and also the user permission user

1782:48

permission and that's going to be it but

1782:50

we also have to annotate that with our

1782:52

rap component which we already defined

1782:54

in inside our types so so we are now

1782:56

talking about this R component props and

1782:59

which we are already providing right

1783:00

here here so now inside there let me

1783:02

just remove that from here and provide

1783:04

my H1 and render my message first of all

1783:07

so I'll use like message m e s a g e I'm

1783:10

going to also provide my paragraph which

1783:12

will say like welcome and then that

1783:14

specific username and also the paragraph

1783:17

and it will say like your permission and

1783:18

then here let's just pass for your

1783:20

permission what the hell was that your

1783:23

permission it should be optional like if

1783:25

you get there then we're going to be

1783:26

joining there with this comma and now

1783:28

let me just save my file and your

1783:31

permission your user permission there we

1783:34

go and it is not defined because we are

1783:36

not even providing the inside your app

1783:38

component so now let's just use that I'm

1783:40

going to go ahead and go to the top and

1783:43

here let's just use like with xess

1783:45

control and here I'm going to be passing

1783:47

my own component which we just defined

1783:49

okay and now here let me just store the

1783:51

inside the variable with the name of

1783:52

like I don't know maybe my component

1783:55

with Access Control I know the name is

1783:59

super long but yeah it is what it is so

1784:02

now here inside my app close them I'm

1784:05

going to be calling that component so

1784:07

I'll just call like my component with

1784:09

the access user control or access

1784:12

control I know the spelling is super

1784:13

long so I'm going to also close there or

1784:17

execute that like so and here we have to

1784:20

first of all past the roles and the

1784:21

rules can be the admin and also oh there

1784:25

that's because we have to provide the

1784:26

curly braces and now we have to specify

1784:29

our R so I'll just give the name of like

1784:31

admin and also the manager okay and now

1784:34

outside from there we're going to be

1784:36

also creating our fallback component or

1784:38

providing our fallback component which

1784:40

will be set to like not authorized and

1784:42

now let's just say our file and also I'm

1784:45

going to provide some sort of a message

1784:47

so let's just say like hello and then

1784:49

admin or something like that and also

1784:51

the injected props as well so here

1784:54

inside they we injecting these prompts

1784:56

like username it's going to take like my

1784:58

own name husan webd and I'm going to

1785:00

also has the user permission uh per what

1785:04

was that user permission so let's just

1785:06

copy that let's it right here and I'll

1785:08

just say like uh I don't know view view

1785:13

passwords and also view come on view the

1785:17

settings or something like that now let

1785:19

me just save my file and while in the

1785:20

world we are providing a comma there

1785:22

let's just save our file now let me just

1785:25

uh refresh there so here you can see

1785:26

it's going to give us like hello admin

1785:28

and also welcome my name and now finally

1785:31

we have the permission to see the

1785:33

passwords and also the settings we can

1785:35

also change that to like I don't know

1785:36

maybe uh dashboard or something like

1785:39

this I'll just write like dashboard save

1785:41

this file so we can also see the

1785:43

dashboard and also the settings so

1785:45

that's to done but you know what instead

1785:47

of just providing this admin and user I

1785:49

mean like admin and manager I'm going to

1785:51

duplicate and comment this line out and

1785:53

change that to the user and also change

1785:55

this one to the guest or something like

1785:57

that if I sa my file and now it's going

1785:59

to gives us like you are not authorized

1786:01

to view this content which is our

1786:03

fallback component which you can see

1786:05

right here which we are also providing

1786:08

uh as a FB component to or higher order

1786:10

component so yeah that was it about the

1786:12

higher order component Challenge and

1786:15

let's just get into the next one now

1786:16

let's talk about the custom hooks so

1786:18

custom hooks are a powerful feature that

1786:21

allows us to encapsulate and reuse logic

1786:23

across component they help to extract

1786:25

component logic into reusable functions

1786:28

making our code cleaner more modular and

1786:30

and easier to maintain so here is a code

1786:33

without using a custom hook so here

1786:35

inside there first of all we are just

1786:37

creating some sort of a step for storing

1786:39

our data then we are using a use effect

1786:41

to fetch our data and finally we are now

1786:43

rendering our data but now imagine for a

1786:46

second that you have a lot of component

1786:48

and you have to fish your data in all of

1786:49

that component so first of all you're

1786:51

going to be creating your state then

1786:53

you're going to be using that use effect

1786:54

and all of that kind of logic and then

1786:56

finally you're going to be rendering

1786:58

your data so to encapsulate all of that

1787:00

logic into a separate function we are

1787:02

going to be using a custom hook for

1787:04

there and here you can see this is how

1787:05

we are going to be using there by just

1787:07

passing our URL and then finally we have

1787:09

to render our content and that's not

1787:11

only it we are going to be learning a

1787:13

lot of stuff anytime you are working

1787:15

with the hooks first of all you have to

1787:16

provide the use and then you can give it

1787:18

any name that you prefer you can give it

1787:20

the name of like use hook name use your

1787:23

name or anything that you prefer but

1787:25

first of all you have to specify the use

1787:27

keyword in the beginning of the custom

1787:29

hook name welcome to one of my favorite

1787:33

Topic in this entire course which is

1787:35

called the custom hook I already

1787:37

discussed this topic in the first part

1787:38

of this course but if you didn't watch

1787:41

that section well you don't have to

1787:43

worry about it I got you baby I got you

1787:46

we already discuss what in the world is

1787:47

a custom Hook is but now we are going to

1787:49

be building a lot of stuff by using this

1787:51

custom hook so first of all let me just

1787:53

go ahead and Define my components folder

1787:55

and inside there we are going to be

1787:57

starting from without custom hook. TSX

1788:01

case I'll just use my rafc inside there

1788:03

go to my app and register there right in

1788:06

here so without the custom hook and yep

1788:09

we are now getting there which means

1788:10

like everything is working the way we

1788:12

exp him to work first of all we are

1788:13

going to be fetching our data without

1788:15

using the custom hog and then we going

1788:18

to be refactoring that code to use the

1788:20

custom hog so what I'm going to do is

1788:22

that still I'm going to be using that

1788:24

Json Place holder. type I code and I'm

1788:26

going to just face forward I'm not going

1788:28

to be explaining all of the data

1788:29

fetching logic and something like that

1788:31

so I'll just write like data and then

1788:32

set data it's going to be equals to the

1788:34

US St and the initial value will be no

1788:37

and also I'm going to Define interface

1788:39

for this I'll use like interface of to

1788:40

do and inside they let's just s our ID

1788:43

of number and the title will be set to a

1788:45

string so my us will either take the

1788:48

to-do as array or null value like this

1788:51

now let me just save my file and go back

1788:54

and here let's just provide where use

1788:55

effect and inside there I'm going to

1788:58

provide my empty array and now here here

1789:00

let's just put our fetch method and here

1789:02

we're going to be using our https Json

1789:06

placeholder come on Json placeholder

1789:09

typei code.com

1789:11

and now let's just use our then method

1789:15

and let's just provide our response if

1789:16

for response if you have the response we

1789:18

want to convert that to Json and I'm

1789:21

going to also use the then method once

1789:22

again and provide my data inside there

1789:25

and I'm going to also annotate there but

1789:26

first of all let's just use our set data

1789:28

and provide our data inside there I'll

1789:30

just be using my too and just annotate

1789:34

there with this to-do now let me just

1789:35

remove that and here I'm going to be

1789:37

checking if we have the data so in this

1789:39

situation then we want to iterate over

1789:41

through that data so I'll just use like

1789:43

the item here and inside them I'm going

1789:47

to be returning a paragraph so let's

1789:49

just return a paragraph and I'm going to

1789:51

just return like item. tile and I'm

1789:53

going to also spfy the key which will be

1789:55

set to item. ID now let me just sa my

1789:58

file check this out so I guess I made

1790:00

some sort of a mistake and yes I guess I

1790:03

did fa to fish the data and I made a

1790:06

typo inside there so I just fix that and

1790:08

yeah we are now getting all of our data

1790:10

so now let's talk about how we are going

1790:11

to be extracting all of the data

1790:13

fetching logic into our custom hook and

1790:15

then we are going to be only rendering

1790:17

the UI okay so to do that I'm going to

1790:20

go ahead and first of all Define another

1790:22

folder with the name of hooks you don't

1790:23

have to do that but I want to do that

1790:26

and I'm going to Define my use fetch.

1790:28

TSX now inside there let's just Define

1790:30

find our custom hook and you guys

1790:32

already know that if you are creating

1790:34

our custom hook so we have to specify

1790:36

the use for the first name then we can

1790:38

give it any name that we prefer so in my

1790:40

case I'm going to only specify like use

1790:42

fet and now we have to set that to the

1790:44

type generic and let's just close the

1790:47

like not text but just a type there we

1790:49

go and it's going also take the URL and

1790:51

the URL will be set to string and we're

1790:53

going to be returning the type or the

1790:56

null value out of there okay so now in

1790:58

this situation we're going to be just

1791:00

def with data and then set data as a

1791:03

state and it's going to be equals to the

1791:04

U State and the initial value will be no

1791:07

and I'm going to also provide my generic

1791:09

type or null value to there and I'm

1791:12

going to close there like so I'm going

1791:13

to go back so you guys can see

1791:15

everything a bit better and now let me

1791:16

use my use effect because we're going to

1791:18

be fetching our data by using the use

1791:20

effect and I'm going to also provide my

1791:22

URL as a perimeter I mean like

1791:23

dependency array to be precise now

1791:25

inside there I'll just use like PCH data

1791:28

and it's going to be equals to that

1791:29

asynchronous function once again again

1791:31

and now let's just use our try and catch

1791:32

block so if we have some sort of error

1791:34

so in that situation we are going to be

1791:36

logging that error to the console so

1791:38

I'll use like console. error and here

1791:40

I'll just write like fetch error or

1791:43

fetching error or something like that

1791:45

and now I'm going to specify my error

1791:47

inside there I'm going to be also using

1791:49

my set data and the initial value will

1791:51

be set to now and for the tri block we

1791:53

are going to be first of all getting the

1791:55

response all use like response it's

1791:57

going to be set to a and then petch and

1791:59

here we have to spe specify that URL

1792:01

which we're now taking as a perimeter

1792:03

for this use petch and I'm going to

1792:05

specify that right here and based on

1792:07

that specific URL we are going to be

1792:08

fetching our data so let's just close

1792:11

that and I'm going to also check if we

1792:13

don't have any response. okay so right

1792:16

like response. okay so if you don't have

1792:19

that so in that situation uh we are

1792:21

going to be only throwing this new error

1792:24

which will say like network was not okay

1792:27

and now underneath there let's just get

1792:29

a result can be set to a and then

1792:31

response. Json and we are going to be

1792:34

getting there as a type generic okay and

1792:38

also we have to use our set data and

1792:40

provide my result inside there so this

1792:42

is how we are going to be getting our

1792:43

data I'm going to copy a name of there

1792:45

and now let's just execute this function

1792:47

right here so fetch our data and this is

1792:49

how we are going to be fetching our data

1792:51

from this hook we are going to be only

1792:52

returning our data out of there so I'll

1792:55

just use like return and data now let me

1792:57

just save my file and finally we have to

1792:58

export there so we can use it in other

1793:01

file so I'll use like export default and

1793:03

then I use PCH I'm going to save my file

1793:06

right now and I'm going to Define

1793:07

another component with the name of with

1793:09

custom hook. TSX okay so now in this

1793:13

case I'm going to go to the without one

1793:15

I'm going to copy every single thing

1793:16

from there and place it right here

1793:18

inside the with custom hook. TSX file

1793:21

and I'm going to just remove basically

1793:22

all of them and here we have to just use

1793:25

our use petch function petch hook to be

1793:27

precise which we just created and now

1793:29

here for the U URL we are going to be

1793:31

providing that same URL so I'll just

1793:32

past it right here which is that Json

1793:35

placeholder typei code.com

1793:37

for/ and now from there we are going to

1793:40

be only restructuring our data so I'll

1793:42

use like data and now let's just close

1793:44

there like so so this is how we are

1793:46

going to be fetching our data by using

1793:48

this custom hook but I'm going to also

1793:50

provide this to do of array and close

1793:52

that so that errors are now successfully

1793:54

gone I'm going to also remove that line

1793:56

of code and still once again we are

1793:58

getting all of that data right here and

1794:00

we can do whatever we want to do with

1794:02

that data so instead of providing like

1794:05

all of that logic for every single

1794:07

component we don't have to do that no

1794:09

more we can use our use patch function

1794:11

and we just have to specify our URL and

1794:14

it's going to fetch our data so here you

1794:16

can see this is how we are going to be

1794:17

doing there first of all we just

1794:18

creating some sort of a state to store

1794:20

our data then we are using a use effect

1794:22

for side effect and now here you can see

1794:25

we're just creating as synchronous

1794:26

function try and catch block and for the

1794:28

triy block we're using the fetch but you

1794:31

can also use exus Library you can

1794:33

totally do that if you wanted to but I

1794:35

am only using the Fetch and now we are

1794:37

specifying that URL which we're now

1794:39

providing and which we are using right

1794:43

here so we are now providing that URL

1794:45

and based on that URL is going to give

1794:47

us that Json response and then finally

1794:49

we are just pushing the two our states

1794:51

so that our state will hold all of our

1794:53

data and finally we are just returning

1794:55

our data and this is how we are using

1794:58

the inside our component like s and

1795:01

finally we have to render that to our UI

1795:03

and that's done I already stopped

1795:04

recording this video but then I realized

1795:06

that I forgot to include something

1795:08

called the

1795:09

flags so now let me just add the first

1795:12

of all we are going to be adding the

1795:13

lowering so I'll just WR God damn it

1795:16

lowering and then set lowering and it's

1795:18

going to be equals to the use State and

1795:19

initial value will be set to true in

1795:21

this case and I'm going to also annotate

1795:23

there as a Boolean value just like that

1795:26

I'm going to also provide the error and

1795:27

then set error it's going to be equals

1795:29

to the use St value and the initial

1795:31

value will be set to no and I'm going to

1795:33

also annotate there as any like so I'm

1795:37

going to write like set loading and I'm

1795:38

going to set there to true and also for

1795:41

the catch block we're going to be

1795:42

setting the error to error and also I'm

1795:45

going to add the finally so when it is

1795:48

finally in this situation we are going

1795:49

to be setting the lowering to totally

1795:52

false and now we are going to be also

1795:54

restructuring the loading so I'll just

1795:56

write like loading and also the error as

1795:58

well now let me go ahead and go to my

1796:00

component which is a with custom hook

1796:02

and now let me just restructure there

1796:04

I'll use like Ling and also the error

1796:07

and here what I want to do is that I

1796:08

want to write like first of all if

1796:10

lowering in this situation we are going

1796:12

to be returning a paragraph of lowering

1796:14

so I'll just write like lowering dot dot

1796:17

dot and also underneath there we're

1796:19

going to be writing like if we got some

1796:20

sort of error so in this situation we're

1796:22

going to be returning the error fetching

1796:26

uh to do and here let me just render

1796:28

that error. message right here so now if

1796:31

I just refresh there you will not able

1796:33

to see that lowering because we already

1796:35

rendered that data but here you get the

1796:37

idea so now let's create a custom hook

1796:38

for our form and form validation but

1796:41

first of all we're going to be creating

1796:42

our form without using the custom hook

1796:45

then we are going to be refactoring that

1796:46

code to use the custom hook so what I'm

1796:48

going to do is that I'm going to go

1796:50

ahead and Define my components folder so

1796:52

I'll just Define them inside that we're

1796:54

going to be creating like my form. TSX

1796:56

or something like that and now let's

1796:58

just start working on it so I'll just SA

1797:00

this file go to my app and and register

1797:02

there right here so I'll use like my

1797:04

form and close there the first thing

1797:06

that I want to do is that I want to

1797:07

create a controlled form so what I'm

1797:09

going to do is that I'm going to create

1797:11

a name come on let's just write name and

1797:13

set name it's going to be equals to the

1797:15

use State and the initial value will be

1797:17

set to empty string I'm going to also

1797:19

provide the email so I'll just write

1797:21

like um if I can type it today so set

1797:25

email and also use stand and the initial

1797:28

value will be empty string and finally

1797:30

for the submitted so I'll use like

1797:32

submitted and then set submitted like so

1797:36

it's going to be equals to the use St

1797:37

and the initial value will be set to

1797:39

false in this case now let me go ahead

1797:41

and go to my form and start working on

1797:43

there but first of all we are going to

1797:44

be checking if we have the submitted

1797:46

form in this situation we are going to

1797:48

be showing one UI but if that's not the

1797:50

case then we are going to be showing

1797:52

another UI so you know what let's just

1797:54

write a paragraph or H2 to be precise

1797:56

and it's going to say like thank you for

1797:59

uh sub meting your information like so

1798:03

but if that's not the case we are going

1798:05

to be creating our form like this I'm

1798:07

not going to be providing any action

1798:08

today but now inside this form we're

1798:11

going to be creating our div and inside

1798:13

this div let me just provide a label

1798:14

we're not going to be providing any HTML

1798:16

4 today and this label will say like

1798:18

name and I'm going to also provide my

1798:20

input field and here for this input

1798:22

field the type will be set to text and

1798:24

the value will be coming from that name

1798:26

State and when somebody try to type

1798:28

something inside this we are going to

1798:29

use like set name and provide my event.

1798:32

target. value inside there and it should

1798:34

be required so now let me just save my

1798:37

file and this going to be it for this

1798:38

div so now let me just collapse them and

1798:40

now let's just create another div for

1798:42

the email so I'll just create a div and

1798:44

inside this div let's just provide with

1798:46

level not HTML 4 inside this level I'll

1798:49

just say like email and also my input

1798:51

field with the type of email and here we

1798:53

are going to be passing a value and the

1798:55

value will be set to email and when

1798:57

somebody try to type something inside

1798:59

there then we're going to be using the

1799:00

set email function provide my event.

1799:02

target. value and also required like so

1799:05

now underneath this D let me just hide

1799:08

there underneath this D we are going to

1799:10

be creating our button and I'll just

1799:11

select submit and here the type will be

1799:14

also set to totally submit that's

1799:16

totally done but now let me also take

1799:18

care of the submitting so here on this

1799:20

form I'm going to attach my own submit

1799:22

event handler and when somebody clicks

1799:24

on there or submit there you're going to

1799:26

be firing this handle submit function so

1799:28

I'm going to copy a name of there and

1799:30

now let's just create that right here so

1799:32

I'll use the ions handle submit it's

1799:34

going to take the event and I'm going to

1799:35

otate that with the react come on our

1799:38

react. form event like so and here we

1799:42

just have to pass over event. prevent

1799:44

default and close them I'm going to also

1799:46

use the set submitted value and here we

1799:49

have to set to true and I'm going to

1799:51

also log to the console like

1799:53

submitted and I'll just say like name

1799:55

and also the email now let me just save

1799:57

my file and that's totally done now let

1800:00

me check this out but first of all we

1800:01

also have to provide what do we call it

1800:03

our border so I'll just attach my border

1800:06

there and also here so let's just add my

1800:10

class name is going to be set to a

1800:12

border and yep we are now getting this

1800:15

one let me just zoom in a bit we are now

1800:16

getting a border for this one and also

1800:18

for that one I'm not going to be

1800:20

worrying about the what do we call it

1800:22

the styling because we don't have to

1800:23

worry about the styling right now if you

1800:25

care about the styling you can

1800:27

definitely go ahead and go to my the

1800:28

first video of this course which is I

1800:30

guess about 13 hours of long content so

1800:33

I'll just write like something for the

1800:35

name I'm going to specify my own name

1800:37

and for the email I'll just say like

1800:39

test gmail.com and now if I click on

1800:41

this submit and here you can see what

1800:43

are we getting we are now getting our

1800:45

submitted form and also we are getting

1800:47

the email and also the name which means

1800:49

like everything is working the way we

1800:50

expain to work and also we are now

1800:52

getting this thank you message so that's

1800:54

cool and everything but I want you to

1800:56

imagine that you have a lot of form

1800:59

inside your app appliation so how in the

1801:00

audio are going to be handling there

1801:02

well to do that we can just create all

1801:05

of that logic inside that component or

1801:07

we can be a bit better developers and we

1801:09

can create our custom hooks inside this

1801:12

folder so I'll just go ahead and just

1801:13

create my use form. TSS and not from

1801:17

form use come on use f o RM there we go

1801:22

and now let's just start working on

1801:23

there so the first thing that I want to

1801:25

do is that I want to create my use form

1801:27

it's going to take the initial value so

1801:28

I'll just write like in initial value or

1801:31

values rather and here we have to

1801:34

specify the key and the key will be set

1801:36

to string and also we are going to be

1801:38

returning a string out of there so now

1801:40

inside there what do we have to do and

1801:42

it should be inside so now let me just

1801:44

cut there and place it right here so now

1801:47

inside there what we have to do first of

1801:48

all we have to get the values and also

1801:51

the submitted data so I'll just use like

1801:53

values and set values and it's going to

1801:55

be equals to the use State and the

1801:57

initial value which we are going to be

1801:59

grabbing from this form so now let me

1802:01

just place it right here so that's going

1802:02

to be my initial value let me just go

1802:04

back I'm going to also provide the

1802:05

submitted Flex I'll use like submitted

1802:08

and also set submitted like so and it's

1802:11

going to be equals to the use State and

1802:13

the initial value will be set to false

1802:15

now let's just take care of the handle

1802:16

change like when somebody try to type or

1802:19

change something inside the input field

1802:21

so for there we are going to be firing

1802:22

this function which is a handle change

1802:25

and here we can do a lot sort of stuff

1802:26

but first of all let me just provide my

1802:28

event and it's going to be coming from

1802:29

the react first of all let's just get

1802:31

from the react and then change event and

1802:34

we are going to be also providing the

1802:35

HTML input element and now let me just

1802:38

an there and now inside there we're

1802:40

going to be getting a few things from

1802:42

the event. Target and we are going to be

1802:45

getting first of all the name and also

1802:47

the value from this event. Target and

1802:50

now let me just set the to my values so

1802:52

I'll just use like set values and

1802:54

provide my previous St and here I'm

1802:56

going to just P like dot dot dot first

1802:58

of all we have to make a clone for

1803:00

previous St and then for the key we are

1803:02

going to be passing the name and for the

1803:04

value we are going to be passing this

1803:05

actual value now then stly done but now

1803:08

we also have to take care of the

1803:09

submitting of the form when somebody try

1803:12

to submit our form so in that situation

1803:14

we are going to be firing this function

1803:15

which is a handle submit and it's going

1803:18

to be equals to the call back and here

1803:20

for this call back we have to just

1803:22

specify our wi we're going to be

1803:23

returning our event and that's going to

1803:25

be coming from the react. form event

1803:28

like so okay now inside there we're

1803:30

going to be first of all preventing the

1803:32

default behavior and then we're going to

1803:34

be using set submitted value and set

1803:36

there to false okay which we already

1803:38

created right here so we have a

1803:40

submitted and set submitted so now we

1803:42

are setting that to false and then we

1803:44

are going to be passing this call back

1803:45

function and we have to execute there

1803:47

now finally we have to just render all

1803:48

of that values and also the handle

1803:51

change and also the handle submit and

1803:53

finally the submitted value as well so

1803:56

then stly done finally we have to just

1803:58

export this so we can use the in other

1804:00

files so I'll use like export default

1804:02

come on default and then use form and

1804:05

close there so then stly done now let me

1804:08

just close this file and now we have to

1804:10

use the inside our component so now let

1804:12

me just go ahead and go to my component

1804:14

and I'm going to remove every single

1804:16

thing from there so what I'm going to do

1804:18

is that I'm going to grab my use form

1804:20

and inside this use form we going to be

1804:21

providing the initial value of name

1804:23

which will be set to empty string and

1804:25

also for the email which will be also

1804:27

set to empty string so now from there

1804:29

we're going to destructuring a few

1804:30

things so what do we have to destructure

1804:32

let me just destructure a few things

1804:34

like the values the handle change and

1804:37

also the handle submit and the submit it

1804:40

out of there so now let me just save my

1804:42

file and when somebody try to submit

1804:44

there so in that situation we going to

1804:46

be using like onsubmit and here I'll

1804:49

just call this function which will just

1804:50

say like I don't know cons. log of

1804:53

submited and here we also have to

1804:55

specify all of that values inside there

1804:57

now let me just go ahead and go to my

1804:59

handle submit I mean like on submit and

1805:01

here we have to specify our handle

1805:03

submit and on submit which we just

1805:05

created right here that's done and for

1805:08

this value I'm going to first of all

1805:10

provide my values. name come on not

1805:12

valuse but just a values. name and for

1805:15

the set name or you know what we're not

1805:17

going to be providing any of that so

1805:18

I'll just remove the and change there to

1805:20

a handle change handle change like so

1805:22

that's totally done I'm going to go to

1805:24

the bottom once again and change that to

1805:26

the

1805:27

values. email I'm going to also remove

1805:30

there and provide my handle change

1805:32

inside there and I guess that's going to

1805:34

be done so now let me just save my file

1805:36

and I'm going to also remove that from

1805:37

there and let me just try there once

1805:39

again by using our custom hook so I'll

1805:42

just remove there and provide my name

1805:44

which is

1805:45

hosan oh my God I can't even type

1805:47

something inside there okay so it took

1805:50

me a lot of time but finally I realized

1805:52

that I forgot to include the names God

1805:55

damn it so let's just provide the name

1805:56

and the name will be set to name for the

1805:58

first one and for the second one the

1806:00

name will be set to email now let me

1806:03

just save my file and now I can type

1806:05

whatever I want to type right here so

1806:06

I'll just write my name husan and test

1806:10

gmail.com and now if I click on there

1806:12

and here you can see it's going to gives

1806:13

us their thank you message and also we

1806:15

are now getting our data right here and

1806:18

this all thanks to uh this use form hook

1806:22

to be precise now we are going to be

1806:24

creating a custom hook for reading and

1806:26

writing data to the local storage but

1806:28

first of all we going to be creating our

1806:30

component without using the custom hook

1806:32

and we are going to be refactoring that

1806:34

code to use the custom hook so what I'm

1806:36

going to do is that I'm going to create

1806:37

my components folder components and

1806:40

inside there let's just create our theme

1806:42

toggle. DSX and I'm going to be using my

1806:44

rafc inside there let's just go ahead

1806:47

and go to our app and register that

1806:49

component right here just like that so

1806:52

toggle theme was there a toggle theme oh

1806:55

theme toggle there we go and now let me

1806:56

just close there check this out so yeah

1806:59

we are now getting there so let's just

1807:00

refresh there and now let's start

1807:01

working on there so the first thing that

1807:03

I want to do is that I want to create my

1807:04

state so I'll use like theme and then

1807:06

set theme it's going to be equals to the

1807:08

use St and here we have to specify the

1807:10

initial value of light to there and I'm

1807:13

going to also annotate as a string and

1807:15

that's going to be done so now the next

1807:16

thing that I want to do is that I want

1807:17

to use my use effect for the side effect

1807:20

and here for the dependency array we are

1807:21

not going to be providing nothing today

1807:23

so now let's just get the data from the

1807:25

local storage so what I'm going to do is

1807:27

that I'm going to be using my windows.

1807:29

Lo local storage. get item so let's just

1807:32

write a get item itm there we go and I'm

1807:34

going to just provide a theme to there

1807:36

I'm going to also store in some sort of

1807:38

variable like store theme and it's going

1807:40

to be equals to that data now the next

1807:42

thing that we have to do is that we have

1807:43

to check if we have the store theme in

1807:47

that situation we're going to be using

1807:48

the set theme and we have to password

1807:50

json. parts inside there and here we're

1807:53

going to be passing our store theme

1807:55

inside there just like so the next thing

1807:57

that we have to do is we have to go to

1807:58

our UI and now let's just um first of

1808:01

all write or H1 let me just write H1 and

1808:03

here I'm going to say like current theme

1808:06

and render my theme inside there and I'm

1808:08

going to also create a button which will

1808:10

allows us to toggle our theme okay so

1808:13

I'm going to also provide the on click

1808:14

when Handler when somebody triy to type

1808:16

something ins I mean like when somebody

1808:17

tried to click on this button so we are

1808:19

going to be finding this toggle theme

1808:21

function now let's just create that

1808:23

right here I'm going to go ahead and

1808:24

Define my toggle theme and inside there

1808:27

first of all this is get word theme so

1808:28

I'll use like

1808:30

new theme and it's going to be equals to

1808:31

this theme and let's just write if that

1808:35

is equal to light so in that situation

1808:37

we're going to be changing there to dark

1808:38

but if that's not the case we are going

1808:40

to be setting that to light so that's

1808:43

done now let me just push that to my

1808:45

theme St so I'll use like new theme and

1808:47

also let me just push that to the local

1808:49

storage so I'm going to be using like

1808:51

windows. local storage and then the set

1808:53

item this just use our set item inside

1808:56

there we're going to be passing a theme

1808:57

to there and then Json come on json. par

1809:01

I mean like not part but stringify and

1809:03

here we have to pass a new theme two

1809:05

there so that's also done I'm going to

1809:07

also go ahead and just provide a bit of

1809:08

styling today so I'll just use like

1809:10

style and for this style I'm going to

1809:12

provide a bit of uh background color

1809:14

first of all so I'll use like background

1809:16

I mean like just background would be

1809:17

fine and that's going to be set to if we

1809:19

have the theme equals to the light okay

1809:22

so if that's the case so in this

1809:24

situation we are going to be setting

1809:25

there to totally white but if that's not

1809:27

the case we are going to be setting

1809:28

there to three 3 3 that's done I'm going

1809:31

to also provide the color so for the

1809:33

text color if the theme is equal to

1809:35

light so in that situation what we have

1809:37

to do we have to set that to totally

1809:38

black but if that's not the case we have

1809:40

to set that to totally white I'm going

1809:42

to also provide a bit of padding to this

1809:44

so padding will be set to 20 pixel all

1809:46

around I'm going to provide a comma

1809:48

there and also there and now let me just

1809:49

save my file and that's tot done now let

1809:52

me go ahead and click on there so here

1809:53

you can see it's going to giv us the

1809:54

current theme and now that is set to

1809:56

totally dark and if I click on there

1809:58

once again so it's going to make it as a

1810:00

light so you know let me just also go

1810:02

ahead and go to my inspect element and

1810:03

I'm going to also go to the application

1810:06

and now let me just show you there here

1810:08

you can see inside this local storage

1810:10

what do we have oh my God if I can get

1810:12

that today so what do we have we have

1810:14

our theme and which is now currently set

1810:16

to light I'm going to delete all of them

1810:19

and now as soon as I click on this

1810:20

toggle theme here you can see our theme

1810:22

is now set to dark and now if I just

1810:25

refresh my page here you can see still

1810:27

we are getting this dark theme right

1810:28

here but if I click on there once again

1810:31

so it's going to change there to light

1810:32

so this is how we are going to be

1810:34

setting and also getting the data from

1810:36

our local storage without using our

1810:38

custom hook so now let me just refactor

1810:41

all of that code to use our custom hook

1810:43

so that we can use that again and again

1810:45

and now let me just go ahead and create

1810:47

my hooks folder and inside there going

1810:49

to be defining our use local storage.

1810:53

DSX file or you can also just set there

1810:55

to TS if you wanted to so I'm going to

1810:57

set there to TS and now let's just start

1810:58

working on there so the first thing that

1811:00

I want to do is I want to create my use

1811:02

local storage is t o r a g e it's going

1811:05

to take that type generic and I'm going

1811:07

to also provide a key and the key will

1811:09

be set to string and I'm going to also

1811:11

provide the initial value and initial

1811:12

value will be set to their generic so

1811:15

I'm going to have to provide a comma

1811:16

there and now we're going to be just

1811:19

creating our function right here so

1811:21

inside there the first thing that we

1811:22

have to do is that we have to create our

1811:24

stored value so I'll just go ahead and

1811:26

just create my store now let's use a set

1811:29

store value inside the going to be

1811:32

equals to or Us St and the initial value

1811:34

will be set to type generic so now

1811:37

inside there we're going to be passing

1811:39

our call function and inside there let's

1811:41

just use our try and catch block for the

1811:43

catch block we're going to be using

1811:44

console. error and here we have to

1811:46

render our error so error reading local

1811:49

storage key and we also have to render

1811:52

our key inside there come on just a key

1811:55

and now let me just close there and now

1811:58

outside from there we have have to

1811:59

render or error we can also do that

1812:01

inside but yeah you get the idea I'm

1812:04

going to also return the initial value

1812:06

and now for the tri block what we have

1812:07

to do we have to first of all get the

1812:09

item from our local storage so I'm going

1812:11

to be using like window. local storage

1812:14

and then get item and what are we

1812:16

getting we are now getting that key

1812:18

which we are going to be passing for or

1812:20

use local storage so now let me just

1812:22

store them in some sort of a variable

1812:23

Sol use like IR can be equals to this

1812:25

window. local storage and so on and so

1812:27

forth and now let me just return item if

1812:30

that is the case if we have the item so

1812:32

then we have to use json. parts and we

1812:35

have to specify our item inside there

1812:37

but if that's not the case so we have to

1812:39

set that to the initial value that's

1812:41

also done I'm going to collapse that and

1812:43

now the next thing that we have to do is

1812:44

that we have to set the value so this is

1812:46

how we going to be getting the value but

1812:48

now we also have to set the value so

1812:50

I'll just use like cons uh set value

1812:53

this going to be equals to that value

1812:55

and here we have to specify our generic

1812:57

or our value in inside this all use like

1813:00

value it's going to be also set to their

1813:01

generic and here we're going to be

1813:03

returning a generic function from there

1813:05

so now inside there let's just use our

1813:07

try and catch block and for the catch

1813:08

block uh we are going to be using

1813:10

console. error and here we have to

1813:12

specify like error setting local come on

1813:15

local storage key so let's just space

1813:17

our key inside there and that key will

1813:20

be set to this specific key and I'm

1813:22

going to also render my error inside

1813:24

there just like so we're going to be

1813:26

using like value to store and here is

1813:29

going to be equals to Value the instance

1813:32

of so I'll use like instance of function

1813:35

if that is the case so in this situation

1813:37

we are going to be using like value and

1813:39

place our stored value inside there but

1813:41

if that's not the case so we are going

1813:43

to be setting there to our initial value

1813:45

just like this also we have to get this

1813:47

store value and we have to set that to

1813:49

our local I mean like to our state I'll

1813:52

use like set store value and let's just

1813:54

space our value to store inside there

1813:56

I'm going to also provide the window.

1813:57

local storage set item and here inside

1814:01

there let space our key and json. pass

1814:04

json. string IFI rather and we're going

1814:06

to be passing like value to store inside

1814:08

there that's also done I'm going to

1814:10

collapse there and now the next thing

1814:11

that we have to do is that we have to

1814:13

use our use effect once again so we use

1814:15

like use effect now it's going to allows

1814:17

us to change our data from our local

1814:19

storage so I'm going to just go ahead

1814:20

and use my handle storage change and

1814:23

it's going to be equals to this function

1814:25

and inside there let's just get our item

1814:27

and it's going to be equals to the

1814:28

windows local storage. get item and here

1814:31

we have to specify our key inside there

1814:33

and if we have that item like if we get

1814:36

that item so we are going to be using

1814:37

like set stored value and here we have

1814:39

to use our json. par and pass our item

1814:42

inside there but if that's not the case

1814:45

we're going to be using like set store

1814:46

value come on set store value and we are

1814:50

going to be placing our initial value to

1814:52

there that's done now underneath this

1814:54

function what we have to do we have to

1814:55

create our we have to attach our event

1814:57

listener on our storage so we just use

1814:59

like window. add listener from our

1815:01

JavaScript and now we are able to do

1815:03

that because we are now inside the use

1815:05

effect so that's why we would be able to

1815:07

provide your effect or our side effect

1815:09

to be precise so I'll just get the

1815:11

storage s r a g and I'm going to past

1815:14

that function which is a handle store

1815:16

change which we just Define right here

1815:18

so that's totally done now finally I'm

1815:20

going to also do a bit of cleanup so

1815:21

I'll just return like this clean of

1815:23

function and here we have to pass our

1815:25

window. remove event listener and we

1815:28

have to provide our storage once again

1815:30

then we're going to be using like handle

1815:31

storage change then only done and now

1815:34

from this function for the dependency

1815:36

array we are going to be passing the key

1815:38

and also the initial value so that's

1815:40

totally done I'm going to hide there now

1815:43

we have to export all of the data which

1815:45

we just import which we just created so

1815:47

I'll just use like return and here we

1815:49

have to specify our stored value and set

1815:52

value is a constant hey that's totally

1815:56

done finally we have to export this so

1815:57

we can use it in other file file so I'm

1815:59

going to be using like export default

1816:01

and then use local storage and now let

1816:04

me just save my file and then stor done

1816:07

let me expand that also expand this one

1816:10

and also expand that one so that's all

1816:12

done so now let's just use the inside

1816:13

Word file now let me go ahead and go to

1816:15

my file and I'm going to basically

1816:17

remove every single thing from there so

1816:19

let's just remove all of them say byebye

1816:21

to all of them and I'm going to be using

1816:23

my used local storage and here we have

1816:25

to specify first of all the theme for

1816:27

the key and we also have to provide the

1816:29

initial value for this so for the

1816:31

initial value I'm going to specify light

1816:33

as initial value now we are going to be

1816:35

destructuring the theme and also the set

1816:38

theme out of there so I'll use like set

1816:40

theme and it's going to be equals to

1816:41

this use local storage now let's just

1816:43

create our function which will allows us

1816:45

toggle or theme so I'll use like toggle

1816:47

theme and why the hell did I just remove

1816:49

the my bad so now I'm going to be using

1816:52

my set theme and here we have to specify

1816:54

first of all my previous video and for

1816:57

this previous video If there is set to

1816:59

the light in this situation we going to

1817:01

be setting there to dark if that's not

1817:03

the case we are going to be setting

1817:04

there to light once again I'm going to

1817:07

remove there so now let me just try

1817:08

there once again so let's just refresh

1817:10

there click on the toggle and I'm going

1817:12

to also go ahead and go to my use local

1817:14

storage and remove that from there and

1817:17

now let me just click on there once

1817:19

again so we are now getting a dark value

1817:21

if I click on there once again so we are

1817:22

now getting a light value right here

1817:24

yeah that's amazing okay so yeah we also

1817:28

traded a toggle theme or use local

1817:31

storage whatever you want to call it

1817:33

time to create a custom hook for the

1817:35

model but first of all we're going to be

1817:37

creating our component without using the

1817:39

custom hook then we will refactor that

1817:41

code to use our custom hook so let me

1817:42

just go ahead and create my components

1817:44

folder and I'll just Define my model.

1817:47

TSX inside there I'm going to be using

1817:49

my rafc and go to my app and registered

1817:52

there right in here so I'll use my not F

1817:55

but my model component so let's just use

1817:57

our model and close there now let me go

1818:00

ahead and go to this model and first of

1818:02

all it's going to take a few props so is

1818:04

open and then on close so it's going to

1818:08

take these props I'm going to go to the

1818:09

top and let's just create an interface

1818:11

for there I'm going to P my Model come

1818:13

on model props like so and I'm going to

1818:16

say like is open it's going to be set to

1818:18

a Boolean and on close it's going to be

1818:20

set to this function and I'm going to

1818:22

say like white I'm going to also

1818:24

annotate my component so model props and

1818:27

now the next thing that we have to do is

1818:29

that we have to check if not is open so

1818:32

in that situation we are going to be

1818:33

returning only null that's done now let

1818:36

me go ahead and go to my model and

1818:38

provide a bit of styling today so I'll

1818:39

just use like class name of to fix the

1818:42

top will be set to zero the left will

1818:44

also be set to zero the right will be

1818:45

set to zero bottom totally zero flex and

1818:48

justify will be set to tot the center

1818:51

and items will also be set to toly

1818:52

Center and now let me just save my file

1818:55

I'm going to also provide a styling and

1818:57

for this styling I'll just say select

1818:59

background will be set to this rgba come

1819:02

on rgba and the red value will be zero

1819:05

green value will be zero black value

1819:06

will be zero and the alpha transparency

1819:08

will be set to 0.5 and now let me just

1819:11

save my file so now inside this D what

1819:13

do we have to do we have to create a d

1819:15

with the class of background holy white

1819:18

and I'm going to also specify padding

1819:19

all around of 20 pixel and now let me

1819:21

just close that and inside this D let's

1819:23

just our H2 model title and now

1819:26

underneath there let's just create our

1819:28

or par gra which will say like this is a

1819:30

model content and now I'm going to also

1819:32

put a button and it's going to say like

1819:34

close and when somebody try to click on

1819:36

there we're going to be firing this

1819:38

function which is on close and now let

1819:40

me just save there that's to done now

1819:42

I'm going to also go to my app and

1819:44

create a few things right here so first

1819:46

of all we are going to be creating like

1819:48

is model open and then set is model open

1819:53

is going to be equals to the US St and

1819:54

the initial value will set to totally

1819:56

false I'm going to also create two

1819:58

functions so I'll just say like uh open

1820:00

model it's going to be set to this

1820:02

function it's going to say like set is

1820:04

model open and it's going to set that

1820:06

true I'm going to duplicate that and

1820:08

change that to false and change the

1820:10

function name to close model so it's

1820:12

going to allows us to close our model

1820:14

and now here I'll just say like H1 my

1820:17

amazing model and now underneath there

1820:20

button which will just open our model

1820:23

and here I'm going to also attach the on

1820:25

click V Handler and when somebody clicks

1820:27

on this we are going to be firing this

1820:28

on model and here for this model we are

1820:31

going to be passing like is open from

1820:33

and here we have to just set that to is

1820:35

model open and also on the close here we

1820:38

have to pass our close model function

1820:40

now let me just save my file and let's

1820:42

just refresh there and here you can see

1820:43

we're now getting our open model button

1820:45

and now if I click on there it's going

1820:47

to gives us that model right here and

1820:49

now if I click on this close so it's

1820:50

going to also close there so you get the

1820:52

idea but now the question is how in the

1820:55

world we are going to be extracting all

1820:56

of that logic to create a separate C

1820:58

hook for there so you know let's just

1821:00

start working on there I'm going to go

1821:02

ahead and Define my hooks folder and

1821:04

inside there I'm going to be creating my

1821:05

use one use model. TS file now let's

1821:09

just start working on there so I'll just

1821:10

use first of all my use model and here

1821:13

it's going to be set to this function

1821:14

and first of all we going to be creating

1821:16

a state for is open and then set is open

1821:19

it's going to be equals to the use St

1821:21

and the initial value will be set to

1821:22

false and now underneath them we have to

1821:25

create their two functions so now let me

1821:26

just go ahead and uh I'm going to copy

1821:29

both of them and place it right here

1821:31

instead of providing this model open I'm

1821:33

going to copy them and place them right

1821:35

here both of these areas I'm going to

1821:37

save my file right now and finally we

1821:39

have to just return those values so I'll

1821:42

just return like his open and also the

1821:46

open model and close model like so now

1821:49

let me just save my file and finally we

1821:51

have to export this so we can use that

1821:53

right here so we have a use model and

1821:55

now let me just save my file so now

1821:56

let's just use this so I'm going to go

1821:57

ahead and go go to my app and remove all

1822:00

of that stuff from here and I'm going to

1822:02

be using my used model and I'm going to

1822:04

restructure a few things like uh is open

1822:07

and also the open model and the close

1822:10

model like so it's going to be coming

1822:12

from this use model and now I'm going to

1822:15

just past it right here so instead of

1822:16

providing the is model open I'm going to

1822:18

provide like is open right here and I

1822:21

guess the rest of them will be totally

1822:23

fine so I'm going to just remove there

1822:24

save my file and now if I just refresh

1822:27

there and click on the open mode it's

1822:28

going to still open my model right here

1822:31

I can also click on there so it's going

1822:32

to make it disappear so yeah that was a

1822:34

simple hook which I want to show you

1822:36

okay so time for the custom hook

1822:38

challenge so in this one you're going to

1822:40

be building five custom hooks by

1822:43

yourself and I am not helping you in

1822:46

this one you are totally on your own and

1822:49

do whatever the hell you want to do I'm

1822:52

just kidding so you know what let me

1822:53

just explain the instruction and then

1822:55

we're going to be creating all of their

1822:57

hooks one by one so the first thing that

1822:59

we have to do is that we have to create

1823:00

a custom hook for the local storage

1823:02

which allows us to store our data inside

1823:04

the local storage then we have to create

1823:06

the use fetch which allows us to fetch

1823:08

our data and then we can render that

1823:10

data inside our UI and then we can

1823:13

create our use form which for the form

1823:14

validation and handling and then we have

1823:17

the used debounce and this is useful for

1823:19

the input fields which call the API

1823:21

whenever we change something inside

1823:23

those input field inside the forms and

1823:26

then we have the use previous one and

1823:27

basically it's allows us to use the

1823:29

previous value so give to your best shot

1823:31

if you can do it that's completely okay

1823:33

then come back and watch the solution

1823:35

and here is my solution so I'm going to

1823:37

just Define my hooks folder and inside

1823:40

there we're going to be creating our

1823:41

custom hooks so let's start from the

1823:43

first one which is called the use form

1823:46

so I'll just use like use form. TS and

1823:48

now inside there let's just Define our

1823:50

custom hook I'm going to go ahead and

1823:51

Define my use form and here it's going

1823:53

to take the generic of T and we also

1823:56

have to provide the initial value which

1823:57

we are going to be doing there but first

1824:00

of all let's just create the body of

1824:01

there so I'll just P like the initial

1824:03

value and I'm going to also come on

1824:07

initial value and I'm going to v l there

1824:10

we go and I'm going to also inate the as

1824:12

a t and now inside there let's just

1824:14

Define our use St so I'll just use like

1824:16

the U St and the initial value will be

1824:18

that initial value which we are now

1824:20

taking as a perimeter and I'm going to

1824:22

also type as a generic so we're going to

1824:25

be getting the values so let's just

1824:27

write like values and then set values

1824:29

out of the I'm going to save this file

1824:31

right now and here you have to create a

1824:34

function which allows us to handle the

1824:36

input change so I'll just create a

1824:38

function with the name of handle uh

1824:40

change and it's going to take the event

1824:42

and I'm going to also annotate as a

1824:43

react first of all let's just even get

1824:45

there then we have a change event and

1824:47

I'm going to be using there on the HTML

1824:49

input element and now let's just

1824:50

annotate our component like so and

1824:53

inside there we are going to be using

1824:54

our set values and P our object which

1824:57

will take all the values like the copy

1825:00

of the initial values and then we can

1825:02

use the event. target. name and then for

1825:05

the value we can use the event. target.

1825:08

value from there okay so let's just save

1825:10

this file go back and now the next thing

1825:12

that we have to do is that we have to

1825:13

create a function which allows us to

1825:15

submit our form okay so let's just use

1825:18

like const and then handle submit and

1825:21

it's going to be equals to uh this event

1825:24

object and we have to past the react

1825:27

form come on F RM form event from the

1825:30

reactjs and now we can just say like

1825:33

event. prevent default and execute there

1825:36

and we can also just log to the console

1825:37

this data and I guess that's going to be

1825:39

it and now underneath there we have to

1825:41

return all of that data so that we can

1825:43

use that in other file so I'll use like

1825:45

values and then handle change and handle

1825:48

submit I'm going to save this file right

1825:50

now handle submit it it should be with

1825:54

one t there we go and now finally we

1825:56

have to export this I'll use like export

1825:59

default and then use form I'm going to

1826:01

save this file right now close this file

1826:03

to my app and here inside there let's

1826:06

just use there so the first thing that I

1826:08

want to use that I want to use my use

1826:09

form okay so let's just import there and

1826:12

now we are going to be placing the

1826:13

initial value of username which will be

1826:15

set to empty string I'm going to also

1826:16

past the email and which will be also

1826:18

set to empty string and now let's just

1826:20

store the inside or you know let's just

1826:22

destructure a few values from there so

1826:25

let's just destructure the values and

1826:27

also the handle change and also the

1826:30

handle submit I'm going to save this

1826:31

file right now go back and now here I'm

1826:34

going to just remove the and provide my

1826:37

class names and I'm going to just say

1826:39

like pairing for all around will be set

1826:40

to four and inside this div I'm going to

1826:43

just write H1 which will say like custom

1826:45

hooks in action or something like that

1826:48

and now underneath that we going to be

1826:49

creating a div which will have the class

1826:50

of margin for the bottom of four and

1826:53

inside this da we are going to be

1826:55

defining where H2 which will have the

1826:56

classes of text um extra large and form

1827:01

handling example there we go say our

1827:03

file underneath that we have to create

1827:05

our form and now we are not going to be

1827:07

providing any action today but we are

1827:09

going to be providing the on submit and

1827:11

whenever we want to submit this so in

1827:13

this situation we're going to be firing

1827:14

this function which is a handle submit

1827:16

which we already defined and now inside

1827:18

this form we have to Define our a few

1827:20

input Fields so I'll just provide the

1827:22

type of text I'm going to also provide

1827:24

the class names and let's just proide

1827:25

our border pairing all around of two Mar

1827:28

for a bottom of two and the name will be

1827:30

set to username and also the value will

1827:33

be coming from the values do username

1827:36

I'm going to save this file right now

1827:37

and whenever we want to change this we

1827:39

want to F this handle change function

1827:41

and here we also want to provide the

1827:43

placeholder which will say like username

1827:45

I'm going to save this file right now

1827:47

and can we even CL no we can't so I

1827:51

guess I'm going to have to duplicate

1827:53

there one more time so let's just

1827:55

duplicate there change not going to be

1827:58

change yeah we are going to be changing

1828:00

that to email and also the name to the

1828:03

email and change the values to the email

1828:06

and I guess that's going to be fine but

1828:08

we also have to change the placeholder

1828:09

to email and then we would have our

1828:11

button which allows us to submit our

1828:12

form so I'll just use like button and

1828:15

submit come on submit and here inside

1828:18

there I'm going to P the type of submit

1828:20

to there and for the class name I'm

1828:22

going to past the border and ping all

1828:23

around of two let me just refresh there

1828:25

and this is how our form looks like and

1828:27

I can just type my username like husan

1828:30

webd and then husan or not h test

1828:34

gmail.com and if I click on there it's

1828:37

going to gives us the value inside this

1828:39

console log which is an object and now

1828:41

we are getting the email and also the

1828:43

username so that's all you're done let's

1828:44

just close there next we have to define

1828:47

or use debounce so I'm going to just

1828:49

collapse there and go to my custom Hooks

1828:52

and Define another hook which will be

1828:54

the US D bounce. TS for un C yep the

1828:59

spelling is totally correct so use like

1829:01

use D bounce it's going to be taking

1829:04

this t as a as a generic we're going to

1829:07

be also passing a value which will be

1829:08

taking the T and the delay will be set

1829:11

to a number like how much we want to

1829:12

delay there so now inside there we have

1829:14

to Define our stat so use like uh D

1829:18

bounce d o u n c e d I guess d e b o u n

1829:24

CED D bounce value and then set d b o u

1829:27

n and CED value set D bounce value and

1829:30

the initial value will be now set to

1829:32

totally that value which you're now

1829:34

getting from that parameter but we're

1829:36

going to be also providing this type

1829:38

generics so let's say our file and now

1829:40

underneath that we have to use our use

1829:42

effect so that we can fetch some data or

1829:44

provide some sort of a side effect

1829:46

inside there so let me just go ahead and

1829:48

provide my set time out and here inside

1829:51

there we're going to be passing our

1829:52

Arrow function which will be using that

1829:54

set debounce value and now we're going

1829:56

to be passing that value in side there

1829:58

and for the delay we're going to be also

1830:00

passing that delay which is now coming

1830:01

from this perimeter and I'm going to

1830:03

also store the inside the Handler

1830:05

variable so Handler and it's going to be

1830:07

equals to this value now underneath we

1830:09

have to just return our Arrow function

1830:11

for the cleanup and let's just space for

1830:14

Clear timeout and pass my Handler inside

1830:17

there okay so now for the dependency

1830:20

aray we are going to be passing the

1830:21

value and also the delay inside there

1830:24

and then St down but why the we carrying

1830:27

these errors it shouldn't be text it

1830:29

should be just a t there we go and

1830:31

finally we have to just return this

1830:33

debounce value so we can use that in

1830:35

other files okay so let's just use like

1830:38

uh return debounce value and finally

1830:40

export default and then use debounce so

1830:43

our file but I'm going to go to the top

1830:45

right now and I guess that's going to be

1830:47

fine so now let me just close there and

1830:49

use the inside our jsx now underneath

1830:52

we're going to be defining yet another

1830:54

de and I'm going to provide like margin

1830:55

for the bottom of four

1830:58

my H2 which will have like text of extra

1831:01

large and it's going to say like d bounc

1831:03

input element or example would be fine

1831:07

okay so now let's just Define our input

1831:09

field which will have the type of text

1831:11

and we're going to be also providing a

1831:12

classes of Border pairing all around of

1831:14

two and now we have to take care of the

1831:16

input value so I'm going to go to the

1831:19

top right here and Define my input value

1831:21

initially so I'll use like use State and

1831:23

the initial value will be set to empty

1831:25

string and now let me just restructure

1831:27

the in put come on the input value and

1831:29

then set input value and which will be

1831:32

coming from the US St now we are going

1831:33

to be providing that specific value for

1831:36

or use debounce so I'll use like use

1831:38

debounce let's just grab there now we

1831:41

have to paste that input value which we

1831:42

are now taking right here now we have to

1831:45

past that and we can also specify the

1831:46

delay of 5 Seconds or 5 milliseconds

1831:50

rather and I'm going to be using const

1831:52

and then D bounced input and it's going

1831:55

to be equals to this used D bounce I'm

1831:57

going to now go in there and Define yet

1832:00

another hook which will be called the

1832:02

use previous hook so I'll just give it

1832:03

the name of like use previous ands and

1832:07

and this should be quite simple and easy

1832:09

so I'll just give it the name of like

1832:10

use previous i o s there we go and then

1832:14

name should be come on use p r e v i o u

1832:18

s there we go so the name is now totally

1832:21

fine we also have to annotate as a

1832:22

generic it's going to take the value of

1832:24

T and now inside there we have to first

1832:27

of all get the reference so I'll just

1832:28

use the ref it's going to be equals to

1832:30

the use ref right here and the initial

1832:32

value will be set to nothing and I'm

1832:35

going to also annotate the as our type

1832:37

generic and inside there we are going to

1832:39

be performing the S effects so now let's

1832:41

just pass for uh use effect inside there

1832:44

and for the dependency array we are

1832:45

going to be only passing that specific

1832:47

value inside there and I'll will use

1832:49

like reference. current value which will

1832:51

be now equals to this value I'm going to

1832:53

save this file right now and I'm going

1832:55

to also use return reference. current

1832:58

value save this file and finally we have

1833:00

to export that so that we can use that

1833:01

in other file okay so I'm going to save

1833:04

this file right now and that's only done

1833:06

now we have to use that inside or or not

1833:09

even inside the jsx but now we have to

1833:10

use that right here so I'll use like use

1833:12

previous value and I'm going to be

1833:14

placing my input value inside there and

1833:16

now let me just s it inside the previous

1833:19

uh value or something like that I'm

1833:22

going to save this file but the spelling

1833:24

p r e v i o u s yep that's all correct

1833:27

now let me go ahead and go to my jsx and

1833:29

provide my value inside there so I'll

1833:32

just go ahead and my value and which

1833:33

will be set to input value and whenever

1833:35

we change this we want to fight this

1833:37

handle change function or handle input

1833:40

change rather handle input change which

1833:43

we are going to be creating in a few

1833:44

seconds and the placeholder will be set

1833:46

to type to D bounce D bounce there we go

1833:49

s our file and now underneath that let's

1833:51

just create our paragraph which will

1833:52

select D bounced value and here let's

1833:57

just render or D bounce D bounced value

1834:00

not even input field D bounce input and

1834:04

also the previous input so previous

1834:06

value and here let's just render our

1834:08

previous value right here now let me

1834:11

just copy the name of there and go to

1834:13

the top and Define my handle input value

1834:16

so I'll just use like cons handle input

1834:19

change and it's going to take the event

1834:21

and I'm going to also annotate as the

1834:22

react change event and here I'm going to

1834:26

just specifically mention that want to

1834:27

use the HTML input element inside there

1834:30

and now inside there we're going to be

1834:32

using the set input value on set input

1834:36

value and provide my event. target.

1834:38

value inside there that's all done but

1834:41

now let me just check this out if I type

1834:43

something inside there like Huzan here

1834:46

you can see it's going to take a bit of

1834:47

time like the 5 second or the 5

1834:50

millisecond to complete there so now let

1834:52

me just type something else like uh I

1834:55

don't know and here you can see it's

1834:56

going to take that millisecond to

1834:58

complete that uh whatever I'm typing

1835:01

right here okay so yeah that was our

1835:03

debounce and now let's create our use

1835:05

local storage but I'm going to have to

1835:07

hide this one then we're going to be

1835:09

able to provide our new jsx I'm going to

1835:12

go to my Hooks and Define my used local

1835:14

storage so use local storage. TS and

1835:19

inside there we have to just use our

1835:21

used local storage and provide my

1835:23

generic first of all and provide the key

1835:26

which will be set to a string I'm going

1835:27

to also provide the initial value V and

1835:32

that's going to be also set to this

1835:33

generic type and the first thing that we

1835:36

have to do is that we have to Define our

1835:37

state so I'll just give it the name of

1835:39

like value and then set store value it's

1835:42

going to be equals to the US St and the

1835:44

initial value will be set to this aror

1835:46

function because we're going to be

1835:48

providing our items and also our try and

1835:50

catch blocks I'm going to also annotate

1835:52

that as a generic of T and inside there

1835:55

we're going to be using our TR and catch

1835:58

so if we have some sort of error so in

1835:59

this situation we're going to be using

1836:01

console. error and I'm going to just

1836:03

pass my error inside there and return my

1836:05

initial value right here but if that's

1836:08

not the case so in this situation we're

1836:10

going to be using our window. local

1836:12

storage this is how we are going to be

1836:14

accessing our local storage and now if

1836:16

you want to access a certain so in this

1836:18

situation we are going to be using our

1836:19

get irm function or method and now we

1836:22

can specify our key inside there so if

1836:24

you want to get there I'll just store

1836:25

the inside the item variable

1836:27

and now we have to check let's just save

1836:29

our file and I'm going to check like if

1836:31

we have the item then we can use the

1836:33

json. pars and now let's just space our

1836:36

item inside there but if that's not the

1836:38

case we're going to be using that

1836:39

specific initial value inside there

1836:42

that's all done so now let me just hide

1836:44

there right here and now underneath this

1836:46

St we're going to be using our set value

1836:48

so set value and it's going to be taking

1836:50

the value and the T generic inside there

1836:53

what do we have to do we have to call

1836:55

our try and catch block once again if

1836:57

you have have some sort of errors in

1836:58

this situation we are going to be using

1837:00

console. error and P my error inside

1837:02

there but if we don't have the errors so

1837:05

I can use like set stored value and pass

1837:08

my value inside there and now I can use

1837:10

like come on window. local storage. set

1837:14

item and pass the key and also the json.

1837:17

stringify and paste the value inside

1837:20

there I'm going to save this file right

1837:21

now and I'm going to also hide there and

1837:24

underneath we have to just return those

1837:26

Valu so that we can use there in other

1837:28

places all use like uh come on sword

1837:32

value and then set value there we go and

1837:34

also you want to get there as the

1837:36

constant so this is basically the

1837:38

typescript stuff now we have to export

1837:40

there so that we can use that in other

1837:42

pile so I'll use like export default of

1837:44

use local storage and I'm going to save

1837:48

this file right now now let me just

1837:49

close this file and go to my jsx and now

1837:52

underneath this one we're going to be

1837:54

defining yet another uh jsx which will

1837:56

be set to de with a class of margin for

1837:59

bottom of four and inside the let's just

1838:02

user two which will have the classes of

1838:04

text extra large of local storage

1838:07

example sove this file and now

1838:09

underneath it let's just create our

1838:11

input field with the type of Border not

1838:13

B with the type of text and also the

1838:16

classes of border and it should be

1838:19

border and piring all around will be set

1838:21

to two and the value which we now going

1838:23

to be providing is going to also have

1838:25

the placeholder of set

1838:28

local storage I guess that's going to be

1838:30

fine save my file now let me go to the

1838:32

top and Define uh my local store

1838:35

variable right here so I'll just use

1838:37

like use local storage and past like the

1838:40

username as initial value and for the

1838:43

next perimeter uh we're not going to be

1838:45

passing nothing today but now we have to

1838:47

restructure the stored value come on S

1838:50

stored value and also set stored value

1838:54

out of there like so now let me go to

1838:56

the bottom and here let's just provide

1838:58

those input values so I'll use like

1839:00

value and it's going to be set to

1839:02

store uh stored value and now underneath

1839:06

whenever we want to change this in this

1839:08

situation we're going to be fing this

1839:10

function and set stored value and place

1839:13

my event. target. value inside there and

1839:16

I guess that's going to be fine so let's

1839:17

just say our file now let me just

1839:19

refresh this so we only have this input

1839:21

feed which allows us to set our item

1839:23

inside our local storage so I'm going to

1839:25

go to my application first of call go to

1839:28

the application so we already have this

1839:30

data I'm going to clear this out so we

1839:32

are now inside this local storage and

1839:34

now inside there we have our local

1839:37

storage totally open let type like my

1839:39

own name maybe like hus or hus like so

1839:43

and now if I just refresh this browser

1839:46

still we are now getting this husan like

1839:48

no matter how many time I refresh my

1839:50

browser still we are going to be getting

1839:51

this uh data so if you want to change

1839:53

this so I can totally change that to

1839:55

something else and now it's going to

1839:57

also change there right here if you want

1839:59

to delete there we can just click on

1840:01

this icon so it's going to remove there

1840:03

and now if I just refresh and that data

1840:05

is now successfully gone and I can type

1840:08

whatever I want to type so it's going to

1840:11

also store the inside our local storage

1840:13

right here so that's only done I'm going

1840:15

to also hide there right here and the

1840:17

final thing that we have to do is that

1840:19

we have to create uh another hook for

1840:21

fetching our data so I'll just give it

1840:22

the name of like us fetch. PS and inside

1840:25

there we're going to be fetching data

1840:27

we're going to be also taking care of

1840:29

the loading and also the error set so

1840:31

I'll just use like use PCH and it's

1840:33

going to take the T as a generic and P

1840:36

My URL of string inside there and here

1840:38

let's just take care of the data which

1840:40

we're going to be getting from the

1840:42

external API and set data now here we

1840:45

have to use the use St and the initial

1840:47

value will be set to totally null but we

1840:49

also have to annotate the SD or the null

1840:52

value and now underneath there we can

1840:54

just take care of the loading so let's

1840:55

just use the loading and set loading is

1840:58

going to be equals to this use St once

1840:59

not transition God damn it so use St

1841:02

once again and the initial value will be

1841:04

set to true and I'm going to also otate

1841:05

there to Boolean Boolean like so and I'm

1841:09

going to also take care of the error

1841:10

state so I'll use like error and set

1841:12

error and it's going to be equals to

1841:14

this U St once again and the initial

1841:16

value will be set to null and we can

1841:18

annotate this so either U string or null

1841:21

value inside there okay so that's to

1841:23

done now we are going to be performing

1841:25

the side effect so in this situation we

1841:27

going to be using the use effect and

1841:29

inside there we are going to be

1841:31

performing our S effect so if you want

1841:33

to fish our data so we going to be using

1841:35

our as synchronous function and here

1841:37

inside there we're going to be

1841:38

performing or try and catch blocks so

1841:41

what I'm going to do is that I'm going

1841:42

to store the inside the fetch data

1841:44

function it's going to be equals to this

1841:46

function this I'll use my try and catch

1841:48

block so for the tri block or you know

1841:51

for the catch block if you have some

1841:52

sort of error I'm going to also annotate

1841:54

the as any and I'm going to use like set

1841:56

error

1841:57

which we already defined up above and

1841:59

now we can use that same error. message

1842:01

and we can push that to our messages I'm

1842:04

going to also provide the finally start

1842:05

so finally uh the set loading it's going

1842:09

to be set to false okay so now for the

1842:11

tri block what do we have to do we have

1842:13

to first of all use the aw and then

1842:15

pitch and pass my URL inside there okay

1842:18

so now we can store the inside the

1842:20

response variable like so uh it should

1842:24

be

1842:25

response there we go if we did not found

1842:28

the response or if we don't have

1842:30

response. okay in this situation we have

1842:33

to throw a new error which will select

1842:36

network uh response was not okay this is

1842:41

s file and underneath it we have to use

1842:44

our result going to be equals to this

1842:45

type generic like so and now we are

1842:48

going to be getting that value we have

1842:50

to convert that to the Json response and

1842:52

now need we can use the set data and

1842:55

pass my result inside there that's

1842:57

totally done now let me just copy the

1842:59

name of this function and we have to

1843:01

execute that right here so that we can

1843:03

see all of that results so I'm going to

1843:05

just you know what let me just even

1843:07

collapse I can't even see that let me

1843:09

just collapse that and execute this

1843:11

function right here and for the

1843:13

dependency array we are going to be

1843:14

passing uh yeah for the dependency array

1843:17

we are going to be passing that URL

1843:19

Right Here and Now underneath that we

1843:21

can just return our data and loading and

1843:24

also the errors so that we can see them

1843:26

finally we have to export them so we can

1843:28

use the in other file so use PCH semi

1843:31

file now let me go ahead and go to my

1843:33

app. TSX and here we can use my margin

1843:37

for the bottom of four inside there we

1843:40

can use the H2 which will have the class

1843:41

of text extra large and provide my fetch

1843:45

data example I'm going to go to the top

1843:47

and get my items or my entire data from

1843:51

my uh local or Custom Custom hook so

1843:54

I'll just use the use Fetch and here we

1843:57

have to just P that same

1844:00

https and then Json placeholder do type

1844:04

I code and then.com for/ poost and now

1844:08

we are going to be just restructuring a

1844:09

few things like data loading and also

1844:12

the error from the from this used T okay

1844:15

so now let me just save my file getting

1844:17

this error because we have to use that

1844:19

so now underneath there we going to be

1844:21

providing our loading state so if you

1844:23

have the loading state in this situation

1844:25

we're going to be showing this paragraph

1844:27

and which will s like loading dot dot

1844:29

dot and now underneath that we're going

1844:31

to be also using the error so if you

1844:33

have the error in this situation we have

1844:34

to use like error and then just render

1844:37

that specific error so we can see that

1844:40

and if we have the data so finally just

1844:43

render their data inside not the pre

1844:45

what the hell am I doing inside the pre

1844:48

there we go and I'll just P my json.

1844:52

stringify oh my God there we go so we

1844:55

have our Json do stringify and past the

1844:58

data and now and two and now let me just

1845:01

save my file and refresh this so here

1845:04

you can see we are now getting all of

1845:05

that post and we have the user ID then

1845:09

the title and then the B so this is how

1845:10

we are going to be fishing our data and

1845:13

this is looking cool now let's talk

1845:15

about the factory design pattern so the

1845:17

factory design pattern is a way to

1845:18

create objects without specifying

1845:21

exactly what kind of objects we are

1845:23

creating it's like having a factory that

1845:26

makes objects for US based on some

1845:28

condition or inputs instead of just

1845:30

directly deciding which react component

1845:32

render inside your app you will have a

1845:34

factory function that decides which

1845:36

component to create based on some

1845:38

condition like props or data so this is

1845:41

how the basic syntax will look like

1845:43

first of all we are just going to be

1845:44

creating a simple component and inside

1845:46

there we're going to be using either if

1845:48

andl statement or switch in cases and

1845:51

we're going to be providing different

1845:52

cases like if the case is primary so

1845:54

render one button if the case is

1845:56

secondary then render another button or

1845:58

if the case is danger then render the

1846:00

danger button okay so this is how we are

1846:03

going to be creating our Factory

1846:04

function and then this is how we are

1846:06

going to be using the inside our app so

1846:08

we will just specify first of all the

1846:10

type then the label and then the

1846:12

function of what to do with that button

1846:15

so that's going to be a lot of fun so

1846:17

now let's get into the coding then you

1846:18

will get to know what I'm talking about

1846:20

now let's talk about the factory

1846:21

functions so what I'm going to do is

1846:23

that I'm going to create a folder with

1846:24

the name of components I'm going to

1846:26

create yet another folder for the shared

1846:29

you don't have to create this folder if

1846:30

you don't want to do that but I want to

1846:32

do that so inside the components folder

1846:34

we are going to be defining our primary

1846:36

button. TSX file and I'll use my RFC

1846:39

inside there I'm going to also Define

1846:41

yet another component for the secondary

1846:44

button. TSX and I will use my RFC inside

1846:47

there I'm going to also provide the

1846:49

danger so I'll use like danger button.

1846:52

TSX and I will use my rafc inside there

1846:55

now let me go ahead and go to this

1846:57

primary button and I'm going to remove

1846:59

this D from here and I'm going to Define

1847:01

my button with a class of background

1847:02

toilet teal of 300 and also padding all

1847:05

around will be set to four and I'm going

1847:07

to also give it the class of button

1847:09

primary you don't have to provide there

1847:11

but I want to provide there it's going

1847:13

to also take a label and I'm going to

1847:15

also annotate the label as a string okay

1847:18

so let's just annotate there I'm going

1847:20

to save my file and now let's just use

1847:22

the inside this button so I'll just put

1847:23

this label right here now let me just

1847:25

sve my file and close there I'm going to

1847:27

also go ahead and go to the secondary

1847:29

button I'll just remove this line of

1847:31

code and I'm going to provide my button

1847:32

with a class of background holy purple

1847:34

and 300 I'm going to also provide ping

1847:36

all around of four and button totally

1847:38

primary and inside there I'm going to

1847:41

specify my label I'll say like label and

1847:44

here we have to specify the label and

1847:46

string okay so inside there I'm going to

1847:49

render that label right here and that's

1847:52

done I'm going to also go ahead and go

1847:53

to the danger and once again we are

1847:55

going to be removing them so let's just

1847:57

remove there and I'm going to provide my

1847:59

button with a class of background

1848:00

totally green or you know what R would

1848:02

be fine red of 300 and also padding all

1848:05

around will be set to four Buton totally

1848:08

danger so now inside there I'm going to

1848:11

restructure the level once again and I'm

1848:13

going to proide the label and it's going

1848:14

to be a string okay and here let's just

1848:17

render over label okay so I'm going to

1848:19

be using like label and now let me just

1848:21

save my file and now these buttons are

1848:22

now totally done the next thing that I

1848:24

want to do is that I want to Define my

1848:26

button factory so I'll use like button

1848:28

factory. TSX and now inside there we're

1848:32

going to be creating our component or

1848:34

we're going to be rendering our

1848:35

component based on a certain condition

1848:37

so what I'm going to do is that I'm

1848:39

going to specify my button factory and

1848:42

it's going to take a type and type will

1848:44

be set to string it's going to also take

1848:45

a label and label will be also set to a

1848:47

string so inside there we're going to be

1848:50

using our switch and cases and for the

1848:52

switch we're going to be providing a

1848:53

type and for the first case if the type

1848:56

is primary so in this situation we're

1848:58

going to be returning our primary button

1849:00

okay so I'm going to just close there

1849:02

and for the prop we going to be

1849:03

specifying that label right here there

1849:06

we go I'm going to also remove this Brak

1849:08

and now let me provide yet another case

1849:10

so if the case is set to secondary in

1849:12

then situation we are going to be

1849:13

rendering our secondary component like

1849:16

so and I'm going to also specify a level

1849:18

inside there and for this level I'm

1849:20

going to also provide that label which

1849:22

you are now taking as a perimeter if

1849:24

that's not the case and if the case set

1849:26

to Danger so in this situation we're

1849:28

going to be returning our danger button

1849:31

and now let me just close there and here

1849:33

I'm going to also provide the label and

1849:34

for the label we're going to be

1849:36

specifying that label as a perimeter and

1849:38

for the default value let's just remove

1849:40

our break and I'm going to be returning

1849:42

just a simple button with a label okay

1849:45

so let's just put our label inside then

1849:47

now let me just save my file and this is

1849:48

how we are going to be defining our

1849:50

Factory function or our Factory

1849:52

component for our button factory so I'm

1849:55

going to copy a name of that and I'm

1849:56

going to just export this so we can use

1849:58

the in other file okay so let's just go

1850:00

ahead and go to our app and now let's

1850:03

just use the inside our component so I'm

1850:05

going to just remove that let me just

1850:06

zoom in a bit and here we are going to

1850:08

be rendering or button factory component

1850:11

let's just grab there and here it's

1850:13

going to take the type and it's going to

1850:14

also take the label so for the type you

1850:17

know let's just Define this type right

1850:18

here okay so I'll use like button type

1850:21

and it's going to be equals to primary

1850:23

so this can come from the prop or this

1850:25

can also come from the St sometime but

1850:27

in my case I'm just only providing there

1850:29

as a variable so now underneath there

1850:31

I'm going to also create a button label

1850:33

and you can specify basically any label

1850:35

that you prefer but in my case I'm going

1850:37

to say like click me okay so let's just

1850:40

spride our type first of all so now let

1850:42

me just provide the type I'm going to

1850:44

also provide the button label and now

1850:45

let's just close there I'm going to go

1850:47

back and this is how it looks like right

1850:49

here so if I right click on there and go

1850:51

to the inspect element and what are we

1850:53

getting we are now getting this button

1850:54

primary right here and also so this

1850:56

background of totally te 300 and why is

1850:59

there because now we are setting this

1851:01

Buton type to primary that's why we are

1851:04

now getting this button primary right

1851:05

here and if I change that to like

1851:07

secondary here you can see the button

1851:09

color is changed and we are also getting

1851:11

this button primary and we shouldn't be

1851:13

getting this primary we should be

1851:15

getting a secondary let's just go ahead

1851:17

and go to for a secondary and it should

1851:21

be secondary like so I'm GNA also go to

1851:24

the danger and yeah that's fine okay so

1851:27

yeah we are now getting our button

1851:28

secondary right here and now if I change

1851:31

them to dangers now let me just change

1851:34

the to danger and now if i s my file and

1851:36

here you can see we're now getting our

1851:38

danger button right here and also we are

1851:40

now getting this class name of button

1851:42

danger so that was example one of the

1851:44

factory function and now let me give you

1851:45

yet another example so I'm going to go

1851:47

ahead and Define a components folder so

1851:49

I'll use like components and inside

1851:51

there we're going to be defining a few

1851:53

components so I'll use like image card.

1851:55

TSX now I'll use my RFC inside there I'm

1851:58

going to also create another component

1852:00

for the profile card. TSX and I'm going

1852:02

to use my

1852:04

RFC inside there and I'm going to also

1852:07

create a text card. TSX right here and

1852:10

I'm going to say RFC inside there now

1852:12

these components are totally done I'm

1852:14

going to also create yet another folder

1852:16

for the shared you can give it any name

1852:18

that you prefer but in my case I'm just

1852:20

giving it the name of Shar and inside

1852:22

there we are going to be defining our

1852:23

card factory. TSX o r y there we go now

1852:28

let me hit enter and I'm going to just

1852:29

Define my RFS oh you know we're not

1852:31

going to be doing that right now first

1852:32

of all let me go ahead and go to the

1852:34

component folder and I'm going to go

1852:36

into the image card and now let's just

1852:38

make that a bit cool so I'll just remove

1852:41

them and here I'm going to specify a few

1852:43

classes to it so I'll use like border

1852:45

pairing all around will be set to 10

1852:47

pixel and margin all around will be set

1852:49

to 10 pixel and inside this T we are

1852:51

going to be providing our image and for

1852:53

the source we are going to be taking

1852:54

there is a prop so I'll just restructure

1852:57

there right here like image source and

1852:59

also the alternative text and I'm going

1853:01

to annotate the as a name okay so let's

1853:04

just provide our image source right here

1853:06

image source and for the alternative

1853:08

text I'm going to also specify like alt

1853:10

text and we will also provide a bit of

1853:12

classes to it so like width will be set

1853:13

to five frame and also height will be

1853:16

set to five frame now let me just save

1853:18

this file and that's totally done I'm

1853:19

going to close there now let me go ahead

1853:21

and go to my profile card component and

1853:23

inside there I'll just remove this text

1853:26

I'm going to also provide a bit of

1853:27

classes to it like border pairing all

1853:29

around will be set to 10 pixel and

1853:31

margin all around will be set to 10

1853:33

pixel like so and inside this D we're

1853:36

going to be providing our image and for

1853:38

the image we are going to be providing

1853:39

the from our prop so I'll just

1853:41

destructure the name bio and Avatar I'm

1853:43

going to also inate the as any and now

1853:46

here I'll just write my avatar right

1853:49

here and also for the alternative text

1853:51

we're going to be providing the name and

1853:53

also I'm going to provide a bit of

1853:54

classes to it like with will be set to

1853:55

10 R and close there so now underneath

1853:58

this image we're going to be providing

1853:59

our H3 and inside there let's just

1854:02

render our name and I'm going to also

1854:04

provide a paragraph and the paragraph

1854:06

will be set to bio now let me just save

1854:08

my file and that's going to be It

1854:09

Forward profile card and I'm going to

1854:11

close there let's just go into our text

1854:14

card and I'm going to just remove that

1854:16

from here or you know what I'm not going

1854:17

to remove this so I'll just remove that

1854:19

text and I'm going to put a bit of

1854:20

classes to it like border pairing will

1854:22

be set to uh 10 pixel and also much will

1854:26

be set to 10 pixel and close there so

1854:29

inside this D we going to be rendering

1854:30

our paragraph of text which we are going

1854:33

to be getting from our prompt so I'll

1854:35

just destructure there and I'm going to

1854:36

annotate there as any now let's just

1854:38

close there and start working on our

1854:40

Card Factory and based on there we are

1854:42

going to be rendering our component like

1854:44

which component to render so I'll just

1854:46

use like cons Card Factory f y there we

1854:51

go and here we are going to be

1854:52

restructuring the type and also the data

1854:55

and now let's just

1854:57

uh annotate the as any and now let's

1854:59

just create our component so first of

1855:01

all we are going to be using our switch

1855:02

in cases so for the switch we're going

1855:04

to be providing the type and if the type

1855:06

is set to image in that situation we're

1855:08

going to be returning our image card

1855:10

okay so let's just render them and I'm

1855:12

going to also provide the image source

1855:14

SRC and here it's going to be coming

1855:16

from the data. SRC and I'm going to also

1855:18

provide the alternative text and for the

1855:20

alternative text we are going to be is

1855:22

going to be coming from the data. alt

1855:25

and now let's just save I'm going to go

1855:26

back and remove this break from there

1855:28

I'm going to also put another case and

1855:30

if the case is set to text in this

1855:32

situation we're going to be returning

1855:33

our text card and now let's just render

1855:37

there it's going to take the prop of

1855:38

text and here we have to provide there

1855:41

like as a data. text and now underneath

1855:44

that uh if the case is set to profile in

1855:47

this situation we're going to be

1855:49

returning our component like profile

1855:51

card and I'm going to close there like

1855:53

so and here it's going to take a few

1855:55

props like name and name will be coming

1855:58

from the data. name and this can also

1856:00

take the bio and the bio will be coming

1856:02

from data. bio bio like so and Avatar

1856:06

will be coming from data. Avatar and if

1856:08

that's not the case so for the default

1856:10

one we're going to be only returning

1856:12

word d and it's going to say like

1856:14

unknown part type or something like that

1856:18

now let me just save my file I'm going

1856:19

to copy a name of there go to the bottom

1856:21

and I'm going to export there so that we

1856:23

can use it in other files and so now let

1856:25

me just just sem my file and this is how

1856:27

we are going to be creating or defining

1856:29

our Factory function and now and based

1856:32

on these conditions we're going to be

1856:34

rendering our components so now let's

1856:36

just close there and go to our app and

1856:38

start working on there the first thing

1856:40

that I want to do is that I want to

1856:41

place a bit of data right here and you

1856:43

can find this data in my gab repository

1856:45

so first of all we have our image card

1856:47

data and inside there we have our image

1856:49

and also our alternative text then we

1856:52

have our text card data and only has

1856:54

this text and this is just a simple card

1856:57

text right here and then finally we have

1856:59

our profile card data so inside there we

1857:01

have our name bio and Avatar so yeah we

1857:04

are going to be rendering there so I'm

1857:05

going to collapse there like so and I'm

1857:08

going to go back so you guys can see

1857:09

everything a bit better now here we are

1857:11

going to be rendering our components so

1857:14

first of all inside this H1 I'm going to

1857:17

make it as a react fragments and now

1857:19

inside there we're going to be rendering

1857:21

where H1 is going to say like Factory

1857:23

design pattern in react

1857:26

so now underneath there I'll just use a

1857:29

d with a class of flex and flex will be

1857:30

set to to a ramp and inside this one we

1857:33

are going to be using a factory function

1857:35

to render different cards so I'll just

1857:37

use like Card Factory and now here we're

1857:40

going to be providing first of all the

1857:41

type and if the type is set to image

1857:44

which means like we're going to be

1857:45

rendering the data of the image card so

1857:47

I'll just use like data and then the

1857:49

image card data and if the type is you

1857:52

know let's just remove there I'm going

1857:54

to render my uh card Card Factory and

1857:56

close there and if the type is set to

1857:59

text so in this situation we're going to

1858:01

be rendering our data and it's going to

1858:02

be set to text card data now underneath

1858:05

there let's just use our Card Factory

1858:06

once again and close there here we're

1858:08

going to be specifying the type and if

1858:10

the type is set to profile then we are

1858:12

going to be rendering or passing our

1858:14

profile card data now let me just save

1858:17

my file and that's going to be it and

1858:19

here you can see we are now getting all

1858:20

of these cards right here so um for the

1858:23

type of image we are now getting this

1858:25

card and for the type of text we are

1858:27

only getting this text card and for the

1858:30

type of profile we are getting the image

1858:32

also the name and also the description

1858:34

right here so now let's just go ahead

1858:36

and go to our profile card and yeah we

1858:38

are now getting all of these stuff so

1858:40

yeah that was our Factory function or

1858:42

our Factory design pattern in reactjs

1858:45

okay so time for the dynamic component

1858:47

Factory with Advanced configuration

1858:49

challenge so if it sounds a bit mouthful

1858:52

of course it is okay so what do you have

1858:55

to do you have to create component

1858:56

Factory that dynamically generates a

1858:58

different UI components based on a

1859:00

specific configuration and ensure type

1859:02

safety for each component configuration

1859:04

so what are the requirements you have to

1859:06

Define several component first of all

1859:08

like uh you going to be creating a

1859:09

button card and model at least I'm going

1859:12

to be just creating there and you are

1859:14

more than welcome to create as many

1859:15

component as you prefer and then you

1859:17

have to define a component config

1859:19

interface something which we are going

1859:20

to be doing and you should also do that

1859:23

by yourself and then implement the

1859:25

factory you already know how you're

1859:26

going to be creating a factory component

1859:29

and finally just render your content

1859:31

dynamically so I want you to read

1859:33

through there and then give it your best

1859:35

shot if you can do it that's completely

1859:37

okay then come back and watch the

1859:38

solution and now I'm going to give you

1859:40

my solution so now let me just close

1859:42

there and the first thing that I want to

1859:43

do is that let me just even zoom in a

1859:45

bit I'm going to just create a folder

1859:47

with the name of UIL so I'll just give

1859:49

it the name of like UT tails and inside

1859:51

there I'm going to be creating a file

1859:53

with the name of uh component types TS

1859:56

and inside we are going to be providing

1859:58

all of our types for our compound and

1860:00

props so you know let's just start from

1860:02

the first one which will be let's just

1860:03

create our interface I'm going to start

1860:05

by defining the model props which will

1860:07

take these props it's going to take the

1860:08

header and I'm going to place a string

1860:10

inside there and also the content and

1860:12

the content will be set to a string and

1860:14

also the folder which will be also set

1860:16

to a string now let me just export this

1860:18

so we can use that in other files so

1860:20

that was our first one now let me just

1860:21

create another one so I'll just create

1860:23

interface with the name of card props

1860:25

and inside there it's going to take a

1860:27

title which will be set to a string it's

1860:29

going to also take a Content which will

1860:31

be set to a string it's going to also

1860:32

take a fotter which will be also set to

1860:34

a string that's also done the final one

1860:37

we have to create is uh button props and

1860:40

now inside this going to take a label

1860:42

and we are going to be annotating the as

1860:44

a string and going to also take the on

1860:46

click event function so we are going to

1860:48

be only returning the white from there

1860:50

and also for the disabl St d i s a b l e

1860:53

d we're going to be setting there to

1860:55

Boolean now let me just save this file

1860:57

and that's it for our component type so

1860:59

now let's just close there the next

1861:01

thing that we have to do is that we have

1861:02

to create another folder with the name

1861:03

of components so I'll just give it the

1861:05

name of like components and inside there

1861:07

we're going to be creating three

1861:08

components so first of all we are going

1861:10

to be creating our button. TSX file and

1861:13

inside there let's just use our RFC

1861:14

inside there and here what do we have to

1861:17

do we have to go there and we have to

1861:19

just destructure first of all the label

1861:21

which it is going to take and the on

1861:23

click when function and the disable prop

1861:25

d s abl l there we go and here let's

1861:28

just close there and in you know let me

1861:30

just change that to button because we're

1861:32

going to be only creating this component

1861:34

for the button so whenever somebody

1861:36

clicks on there so we are going to be

1861:38

firing this function which which it is

1861:40

now providing as a prop and on the

1861:42

disabl state we're going to be also

1861:44

providing the from or props dynamically

1861:47

like so and for the content let's just

1861:50

uh render that level which you are also

1861:52

passing as a prop and I'm going to

1861:53

annotate this component with that button

1861:56

props which we just defined inside our

1861:58

component types so here you can see

1862:01

we're going to be defining or providing

1862:02

this button props component or interface

1862:05

right here for our component so now let

1862:07

me just close there the next thing that

1862:08

we have to do is that we have to create

1862:10

our card component so I'll just give it

1862:12

the name of like card. TSX and inside

1862:14

there let's just use our RFC inside

1862:16

there and once again it's going to take

1862:18

a few props like title and it's going to

1862:21

also take the content come on content

1862:23

it's going to also take the footer okay

1862:25

so now let me just render that content

1862:27

inside there I'm going to also provide

1862:29

the class or you know we're not going to

1862:31

be doing that so now inside there let's

1862:33

just provide our H3 and inside this H3

1862:35

I'm going to render their title we're

1862:37

going to be providing a paragraph and

1862:38

render our content inside there and

1862:41

finally the folder and here we have to

1862:43

just render our folder right here I'm

1862:45

going to save this file right now and

1862:47

I'm going to also annotate my component

1862:48

with that card props uh let me just

1862:51

import there from where from from our

1862:54

component. types file okay so we now

1862:56

just annotating our component with these

1862:58

props so now let me just close there

1863:00

close this file now let me create

1863:01

another component with the name of model

1863:04

so I'll just write like model. TSX use

1863:07

my RFC inside there and here it's going

1863:09

to take a few prompts so it's going to

1863:11

take the header it's going to also take

1863:12

the content and it's going to also take

1863:14

the footer and I'm going to also

1863:15

annotate this component with the name of

1863:17

or with the type of models there we go

1863:20

and now let me just remove that from

1863:22

here and I'm going to go inside there

1863:25

and provide my H2 inside there and I'm

1863:27

going to just render my header as H2 and

1863:29

for the paragraph We are going to be

1863:31

rendering our content and also we have

1863:33

to render our footer and here let's

1863:36

space our footer inside there now let me

1863:37

just save my file close there and here

1863:41

I'm going to also close there and I'm

1863:42

going to go into the UTS folder and

1863:44

inside there we're going to be defining

1863:46

uh our component Factory so I'll use

1863:48

like component Factory d r y. TSX okay

1863:53

so now inside the let's just uh we not

1863:55

going to be providing our RFC right here

1863:57

so the first thing that we have to do is

1863:59

that we have to import our button

1864:00

component we also have to import come on

1864:03

our card component and we also have to

1864:06

import our model component and now

1864:08

underneath that we are going to be also

1864:09

importing our types I'll just import

1864:11

like the button props and come on this

1864:14

one and we're going to be also importing

1864:16

our card props and finally we have to

1864:19

import one model props right here I'm

1864:21

going to save this file right now next

1864:23

we have to Define our component or

1864:25

Factory component so now let me just go

1864:27

back and here I'm going to just Define

1864:29

my function and this function will have

1864:31

the name of like component Factory you

1864:33

can basically give it any name that you

1864:34

prefer and I'm going to just put my

1864:36

config because it's going to take a

1864:38

configuration and now we are going to be

1864:40

passing a type of uh component config

1864:43

which we're going to be creating in a

1864:44

few seconds so now let me just close

1864:46

there and here we have to create our

1864:48

component config so we can use that so

1864:50

I'll just Define the type and I'm going

1864:52

to give it the name of like component

1864:53

come on uh component config is going to

1864:56

be equals to this type and you know

1864:59

we're not going to be providing it like

1865:00

this because we're going to be providing

1865:01

a lot of types so first of all we are

1865:04

going to be providing a type and the

1865:05

type will be set to a button and then uh

1865:08

we are going to be also providing a

1865:10

props and props will be set to these

1865:12

props right here which we already

1865:13

defined inside another file so we can

1865:15

either use that or we can use another

1865:19

type for another component so I'm going

1865:21

to just write that all right here and we

1865:23

have to Define another type for that

1865:25

another component so I'll just uh create

1865:27

a type for the card component and we're

1865:29

going to be passing these uh props to it

1865:32

so I'll just pass like card props and

1865:34

now let me just save my file and this is

1865:35

how it looks like and now let's just

1865:37

import the even why aren't we even

1865:39

getting there so we have these card

1865:41

props now let me just paste the carard

1865:42

props it is already fine but I know why

1865:45

we getting that error uh implicitly has

1865:48

any type God damn it my bad we have to

1865:51

provide our props and then we have to

1865:52

provide our type inside there now we are

1865:54

going to be also creting a configuration

1865:56

for another component which will be for

1865:58

our model component so I'll just past

1866:01

like the props and the props will be

1866:02

coming from that model props okay so now

1866:05

let me just provide there and that's

1866:06

only done so now that we are

1866:08

successfully creating this component

1866:10

configuration and now we are

1866:11

successfully passing that right here so

1866:13

the next thing that we have to do is

1866:14

that we have to use that inside our

1866:16

component so now let me just go there

1866:18

and here we're going to be using a

1866:20

switch in cases but you are more than

1866:21

welcome to use uh ifnl statement but now

1866:24

we are going to be providing that config

1866:26

which we now taking as a perimeter and

1866:27

we are going to be getting a type from

1866:29

there like each of them have a type like

1866:32

that if the type is button so do

1866:34

something if the type is card then do

1866:36

another thing and so on and so forth so

1866:38

now we are providing a configuration.

1866:40

type and here inside they we are just

1866:42

providing a different cases so if the

1866:44

type is set to a button in this

1866:46

situation what do we have to do we have

1866:48

to just return this component which is a

1866:50

button component okay so now let me just

1866:52

close the and which we are also

1866:54

importing right here here okay so it's

1866:56

going to also take a few props because

1866:58

we are now providing these props right

1867:00

here to our component so I'm going to

1867:01

just spread out all of the config and

1867:04

here come on config and here we have to

1867:06

just access the props and that's

1867:08

everything that we have to do for our

1867:10

button component so now let me just

1867:11

close there and provide another case for

1867:14

the card and here I'm going to just

1867:16

provide like return the card component

1867:18

and I'm going to close that and here

1867:20

let's just provide or dot dot dot config

1867:22

once again and now we have to specify

1867:24

those now we have to provide the final

1867:27

case for the final component which will

1867:29

be for the model component so now let me

1867:31

just paste them and we are going to be

1867:33

only returning the model component in

1867:35

this situation now let me just also

1867:37

close there and spread out all of that

1867:39

config file so let's just provide that

1867:41

config or props there we go and for the

1867:44

default I'm going to just remove this

1867:45

break from here we're going to be

1867:47

throwing an error so throw new error uh

1867:50

which will just say like unknown

1867:52

component type or something like that

1867:54

now let me just say this file so this is

1867:56

how we are going to be defining our

1867:57

component Factory I'm going to also

1868:00

export that so we can use that in other

1868:02

file so use like export default of

1868:04

component not config but component

1868:07

Factory now let me just save this file

1868:09

and that's it for our component Factory

1868:12

I'm going to close that and now let me

1868:13

go ahead and go to my app. TSX and call

1868:16

that right here so I'm going to go there

1868:18

and remove there and inside there we're

1868:20

going to be uh you know first of all you

1868:22

want we have to get there so I'll just

1868:24

import the component Factory so I'll use

1868:27

like component Factory we have to import

1868:30

that and pass it right here we have to

1868:32

execute that component and it's going to

1868:34

require some sort of a configuration as

1868:36

we just provided right here so now that

1868:39

we have to define those configuration so

1868:41

you know let's just Define the cons

1868:43

button config and it's going to be

1868:45

equals to this object but we also have

1868:47

to go ahead and I forgot to do that but

1868:50

now let me just export that so that we

1868:51

can also use that inside this

1868:54

configuration so I'll just annotate the

1868:56

with that component config so let's just

1868:58

proide our component config right here

1869:01

we also have to import that now we are

1869:03

going to be specifying the type and the

1869:05

type will be set to a button and we are

1869:07

going to be also providing a different

1869:08

props to there so I'll just specify the

1869:10

label and the label will say like click

1869:12

me I'm going to also provide the on

1869:14

click EV Handler like whenever somebody

1869:16

clicks on that so what you have to do in

1869:18

that situation we just want to alert and

1869:20

we want to say like you clicked me I

1869:22

guess like you clicked me would be fine

1869:25

okay and I'm going to also proide the

1869:27

disabl state and for the disabled State

1869:29

initially you want to set that to false

1869:30

okay so now let me just copy there and

1869:33

place that right here so our file and

1869:36

here you can see we're now getting this

1869:37

button and whenever we click on there so

1869:40

we are now getting like you clicked me

1869:42

so this is how we are going to be

1869:43

defining or rendering our first

1869:45

component by using the compound Factory

1869:47

component design pattern and now let me

1869:49

just close them and now we have to

1869:51

render that other component so I'll just

1869:53

Define like card config fig and we also

1869:56

have to provide that component config

1869:58

right here and inside that we're going

1870:00

to be providing a type and the type will

1870:02

be set to a card and the prompts will be

1870:04

set to oh my God what the hell was that

1870:07

okay so it's going to take a few prompts

1870:09

like title and title will say like C

1870:11

title and now we also have to provide

1870:14

some sort of a content and I will say

1870:15

like uh some come on some random content

1870:19

or something like that and I'm going to

1870:21

also provide a fer and I'm going to set

1870:23

there to fter s file we have to provide

1870:25

our comma there I'm going to copy the

1870:27

name of there and now I'm going to just

1870:30

hit enter right here and I'm going to

1870:33

also hit enter right here duplicate this

1870:34

line of code and instead of providing my

1870:36

button configuration I'm going to

1870:38

specify the card configuration and now

1870:41

here you can see we're now getting all

1870:42

of that value from those props like card

1870:44

title some random content and finally

1870:47

over fter so yeah that was there about

1870:49

four or complex challenge about the

1870:52

component Factory now let's talk about

1870:54

the compound component design pattern so

1870:57

the compound component design pattern

1870:58

allows for creating more flexible

1871:00

reusable and easy to combine components

1871:03

it involves splitting a complex

1871:05

component into smaller individual

1871:07

subcomponent that can be used together

1871:09

but maintain some degree of internal

1871:11

control over their behavior so that was

1871:14

just a quick definition of what a

1871:15

compound component is but now here is a

1871:18

bit note about the compound component

1871:20

this pattern is useful when you want to

1871:22

create a component that has multiple sub

1871:25

components but you want to maintain the

1871:27

ability to customize or control the

1871:29

behavior of each subc component from the

1871:31

parent or the container let's suppose if

1871:34

you want to build this card without

1871:35

using the compound component or without

1871:37

using the compound design pattern so

1871:40

first of all we have a title then we

1871:41

have a content and then we have a footer

1871:44

first of all we are just going to be

1871:45

creating some sort of a card which will

1871:47

take the title content and footer we

1871:49

will provide some sort of a styling to

1871:50

them and then we can past the title

1871:53

content and fot as a prop to that

1871:55

component this is good but not that much

1871:58

suppose later if you want to change

1872:00

something inside that UI so how what

1872:03

we're going to be doing there well we

1872:05

can definitely do that but that's going

1872:07

to be a lot of hard work and we will

1872:09

very soon end up creating another

1872:11

component without just using that card

1872:14

component now let's refactor all of that

1872:16

code to use a compound component so as

1872:18

we all know that functions in JavaScript

1872:21

are just an object so which means like

1872:23

we can attach the properties we can also

1872:25

attach another function and we can do a

1872:27

lot sort of stuff with there so now we

1872:29

are going to be treating our component

1872:31

as object and we are going to be

1872:33

attaching a different component to that

1872:35

as a properties and values so what do I

1872:37

mean by all of that jabish so here you

1872:39

can see we are going to be extracting

1872:41

all of that UI logic from the card

1872:43

component and we are going to be

1872:44

splitting that into multiple component

1872:46

like Tyle we are going to be putting

1872:48

that inside the card component same will

1872:50

goes for the card content and also same

1872:53

will goes for the card footer okay so we

1872:55

going to be extracting all of that logic

1872:57

from the card component and we are going

1872:59

to be putting that inside individual

1873:01

multiple components and then we are

1873:03

going to be using that card component as

1873:06

a object and we will attach some sort of

1873:08

a properties on there and that specific

1873:11

property will be equal to their specific

1873:13

component so that we can use that again

1873:15

and again once again if you don't get it

1873:18

you don't have to worry about there

1873:20

because now we are going to be writing

1873:21

our code then you'll get to know what

1873:23

I'm talking about so now let's get into

1873:25

let's talk about the compound component

1873:27

so first of all we are going to be

1873:28

creating our card without using the

1873:30

compound component and then we will

1873:32

refactor our code to use a compound

1873:34

component I can't even say that word

1873:36

compound what the

1873:37

hell so you know let's just start

1873:39

working on this so I'm going to go ahead

1873:41

and Define my components folder and

1873:43

inside there let's just Define our card.

1873:44

TSX and I'm going to be using my RFC

1873:46

inside there go to my app and render

1873:49

there right in here so I'll just use

1873:52

like card component and close there and

1873:55

this card component will take a few

1873:56

props so we are going to be first of all

1873:58

providing the title it's going to just

1873:59

say like card title or something like

1874:01

that we're going to be also providing

1874:03

the content and I'm going to just say

1874:04

like this is uh the content of the card

1874:08

or some random stuff like that we're

1874:10

going to be also providing a footer so

1874:12

it's going to say like this is the

1874:13

footer or something like that now let me

1874:16

just s my file and go into the card

1874:18

component and start working on this so

1874:20

let's just zoom in a bit and first of

1874:22

all we are going to be restructuring all

1874:23

of their prompts so let's say

1874:25

destructure the title content and also

1874:27

the footer so I'm going to define the

1874:30

interface for the car props and here

1874:33

inside let's just put the title and the

1874:35

title will be set to string the content

1874:37

will also be set to string and the

1874:39

footer will also be set to string so

1874:41

let's just put there I'm going to copy

1874:43

the name of there and annotate my

1874:45

component with this card props and now

1874:48

inside there what do we have to do let's

1874:49

just remove them I'm going to go back

1874:51

and provide a bit of classes to it so

1874:53

let's just provide these classes you can

1874:55

pause the video and write The Styling by

1874:57

yourself or you can go ahead and go to

1874:59

my gab repository and grab all of that

1875:01

styling from there so I'm going to just

1875:03

provide H2 and this H2 will say like

1875:05

title now underneath them we're going to

1875:07

be creating another div and inside this

1875:09

div I'm going to provide a paragraph

1875:10

which will say like content so I'm going

1875:12

to just provide like content right here

1875:15

and now underneath this div we going to

1875:17

be defining yet another div with the

1875:18

class of footer and I mean like the

1875:21

paragraph and inside that we are going

1875:23

to be rendering our footer so now I'm

1875:25

going to fast forward the video and I'm

1875:27

going to provide a bit of classes to

1875:28

them and you can also pause the video

1875:30

and provide these classes to your

1875:33

component okay so you know what let me

1875:35

just save my file and here you can see

1875:37

this is how my card looks like I know it

1875:39

is looking super

1875:41

amazing because we are not using any

1875:44

compound component so yeah you get the

1875:46

idea like this is how we going to be

1875:47

usually defining work or card but now

1875:50

the question is how in the world we are

1875:51

going to be making this card to use the

1875:54

compound design pattern and that's very

1875:56

simple and easy so what we have to do is

1875:58

that we have to take all of these stuff

1876:01

or all of these sections inside this

1876:03

card and we have to create a separate

1876:04

components for them and then we are

1876:06

going to be combining all of that

1876:07

components or you can say that we have

1876:10

to split this entire UI into multiple

1876:14

compounds you can say there if you

1876:15

wanted to so what I'm going to do is

1876:18

that first of all I'm going to define a

1876:19

few components I'm going to define a

1876:21

component for the card and then card

1876:23

content. X I'm going to also Define yet

1876:26

another component for the card footer.

1876:29

TSX and also for the card title. TSX and

1876:33

this should be a card tile. TSX there we

1876:35

go now inside the card title what I'm

1876:38

going to do is that I'm going to cut

1876:39

this D from there and I'm going to save

1876:42

this file and go ahead and go to my card

1876:44

title and I'm going to use my RFC inside

1876:46

there and replace there with this

1876:48

content right here I'm going to also

1876:51

grab the children so let's just use our

1876:53

children and here I'm going to inate the

1876:55

children as the react node and now I'm

1876:58

going to copy this children from there

1877:00

and let's just paste it right here I'm

1877:02

going to save this file right now and

1877:04

that's going to be it for the card title

1877:06

now let me go ahead and go to my card

1877:07

content but before I do that I'm going

1877:09

to have to go ahead and go to my card

1877:11

and grab all of these content from there

1877:13

save my file go into my card content and

1877:15

I'm going to use my rafc inside there

1877:18

and let's just place there with this new

1877:20

content and I'm going to use my children

1877:22

once again and annotate there and as a

1877:25

children and react node okay so I'll

1877:28

just copy the name of this children and

1877:30

place it right here sa my file that's

1877:32

done now finally let me go ahead and go

1877:33

to my card once again and I'm going to

1877:35

have to cut this folder and now let's

1877:38

just save this file and I'm going to go

1877:39

ahead and go to my folder and use my RFC

1877:42

inside there and place it right here I'm

1877:44

going to once again destructure the

1877:46

children and here we have to annotate

1877:49

the children as a react node and now I'm

1877:52

going to copy these children and place

1877:53

it right here so my file and now as you

1877:56

can see we created a separate compound

1877:58

component for this entire UI or for this

1878:01

entire card now the question is how in

1878:04

the we are going to be combining all of

1878:06

them and to combine them first of all

1878:08

let me just remove this interface from

1878:09

there and also this one and this

1878:11

component will only take the children

1878:13

and I'm going to also annotate there is

1878:15

a children in the react node and I'm

1878:19

going to take this children from there

1878:20

copy the name of there and inside this D

1878:23

we have to just render their like so and

1878:26

now the question is how in the world

1878:27

we're going to be combining this card

1878:29

content fot title and all of that with

1878:32

this card component you guys already

1878:34

know that in JavaScript functions are

1878:36

just an object which means like we can

1878:38

assign property to there we can assign

1878:40

like different kind of stuff today this

1878:42

is how we are going to be trating this

1878:43

function or this component to attach

1878:46

properties and values to there what do I

1878:49

mean by that first of all we are going

1878:50

to be accessing our function or

1878:53

component whatever you want to call them

1878:54

there then I'm going to use the dot

1878:56

notation and here we can specify any

1878:58

kind of property and any kind of value

1879:01

for that specific property so in my case

1879:03

I'm going to just give it the name of

1879:04

like title and you can give it any name

1879:06

that you prefer and now this card title

1879:09

will be set to this card title component

1879:12

which we've already defined and now we

1879:13

import it there right here so now if I

1879:15

go ahead and go to there so here you can

1879:17

see we have our C tital component so

1879:19

what are we doing we are now accessing

1879:21

our card component and then we are

1879:23

specifying specific title today and now

1879:27

that specific title will be equal to

1879:29

this card title component okay so this

1879:31

is how we are going to be attaching or

1879:33

combining those different compound with

1879:36

this main component okay so I'll use

1879:38

like car. content in this case and you

1879:41

can give it like any name that you

1879:42

prefer and it's going to be set to card

1879:44

content and now let's just grab this

1879:46

component right here and also we're

1879:48

going to be using card. fer it's going

1879:51

to be equals to card fer okay like so

1879:54

and now we are accessing there now let

1879:56

me just save my file now if I save this

1879:58

file and go ahead and go to my card we

1880:01

are getting some sort of error so I'm

1880:02

going to just remove there and I'm going

1880:04

to also remove there and here we're

1880:06

going to be passing our card component

1880:08

which will be our main component and

1880:11

watch what happens but first of all we

1880:13

have to grab this card and now I want

1880:15

you to watch what happens so now if I

1880:17

just use card and do what are we getting

1880:19

we are now getting all of that

1880:21

properties right here we are now getting

1880:22

the content full title and so on and so

1880:25

forth so now I can choose this title and

1880:27

now let me just close there and here I'm

1880:29

going to specify like some something

1880:31

cool or something like there and now if

1880:34

I just use card dot we are now getting

1880:36

their content so I'm going to choose

1880:38

this content and close there and I'm

1880:39

going to say like amazing stuff or

1880:41

something like that I'm going to also

1880:43

access the card once again and finally

1880:44

we we're going to be choosing this foter

1880:47

and I'm going to say like and the end or

1880:50

something like that now if I save my

1880:52

file here you can see we are now getting

1880:54

this amazing card we can reuse this card

1880:56

we can do a lot sort of stuff with there

1880:58

let's suppose in some situation maybe if

1881:01

I want to push this amazing stuff to

1881:03

maybe either here or maybe at the top so

1881:05

how can I go about doing them well we

1881:08

just have to duplicate this card and now

1881:11

we can just move this around like let's

1881:12

suppose if I want this one to be at the

1881:14

top so now let me just save my file and

1881:16

here you can see this is now at the top

1881:18

and we can do a lots of stuff with that

1881:21

so that was our compound component or

1881:24

compound design pattern to be precise

1881:26

okay so time for the compound component

1881:28

challenge it sounds a bit mouthful like

1881:31

compound component challenge anyways so

1881:33

what do you have to do you'll have to

1881:34

implement the following features so a

1881:36

model container that can house multiple

1881:39

child component a way to control the

1881:41

visibility of the model and also it

1881:43

should accept the tial body and for area

1881:45

within the model that can be customized

1881:48

with the content pass as a children so

1881:50

give it your best shot if you can do it

1881:52

that's completely okay then come back

1881:53

and watch this solution and now here is

1881:56

my solution so I'm going to go ahead and

1881:58

just Define a folder with the name of

1882:00

components components and inside there

1882:03

we have to define a few components so

1882:05

I'm going to go ahead and Define the

1882:07

first one which will be for the model

1882:09

title. USX and I'll just use my RFC

1882:12

inside there and that's going to be it

1882:15

for the boiler plate and I'm going to

1882:18

just remove this it's going to take the

1882:19

child because we already know it's going

1882:21

to require a lot of data so we are going

1882:24

to be also annotating the as the react

1882:26

or yeah I guess the react node and I'm

1882:28

going to just hit enter and here we have

1882:30

to past that child inside the H2 so I'll

1882:33

just past them and here we have to past

1882:35

the children there we go and I'm going

1882:37

to also provide a bit of styling so the

1882:39

text will be set to extra large and the

1882:41

P will be set to semi Bol TT toally gray

1882:44

of 800 would be fine so let's space for

1882:47

800 say pile close there the next thing

1882:50

that we have to do is that we have to

1882:51

Define another component with the name

1882:52

of model board b. TSX and here let's

1882:56

just use our RFC inside there I'm going

1882:59

to go ahead and remove there and I'm

1883:00

going to also proide a bit of margin for

1883:02

the top of two and inside there we have

1883:04

to provide our paragraph and render our

1883:07

children inside there like so it should

1883:09

also accept the children here so then we

1883:12

would be able to

1883:14

past okay children and react node grab

1883:18

that so our file and finally we have to

1883:21

provide our classes so that we can style

1883:23

this so text will be set to gray of 600

1883:26

and text will be set to small so our

1883:29

file Clos there and now we have to

1883:31

Define another component for the

1883:33

model. TSX and inside there let's just

1883:36

use our RFC and here I'm going to remove

1883:40

that from there and I'm going to also

1883:42

provide my children like so and annotate

1883:46

my component as children react node like

1883:49

so now let me just save my file and here

1883:51

inside there we're going to be defining

1883:53

yet another d and I'm going to put their

1883:55

children inside there I'm going to also

1883:57

style a bit so margin for top will be

1883:59

set to four justify will be set to tot

1884:02

not Center but end and spacing on the

1884:05

x-axis will be set to two I'm going to

1884:08

save this file right now close there and

1884:10

we also have to define the final final

1884:12

component which will be just a model

1884:14

component so I'll just give it the name

1884:16

like model. TSX and here we're going to

1884:18

be combining all of that compounds into

1884:21

one simple component so I'll just first

1884:24

import the model uh title we would also

1884:27

need to import the model body we would

1884:30

also need to import the model uh forward

1884:33

there we go and now underneath there we

1884:34

have to Define our component right here

1884:36

now let me just s my file it's going to

1884:38

take the children and we also have to

1884:40

annotate is the react come on react node

1884:44

and now let me just seter so it's going

1884:45

to also import that right here I'm going

1884:47

to also close there and inside there

1884:49

let's just Define another div go back

1884:52

and it's going to take those children

1884:53

like so I'm going to also inate that

1884:56

component like background totally white

1884:58

and pairing all around will be set to

1884:59

six round it totally large and withd

1885:02

will be set to 20 Rim I'm going to close

1885:05

that right here I'm going to also

1885:07

provide a bit of classes like uh fixed

1885:09

inser will be set to zero background

1885:11

toly black and background opacity will

1885:14

be uh set to 50 and flex justify will be

1885:18

set to totally center items will also be

1885:20

set to totally Center and the Z index

1885:23

will be set to 50 now let me just save

1885:25

my file and this is how it looks like

1885:26

but finally we have to combine all of

1885:28

that compounds into one simple component

1885:31

so we are going to be using like model

1885:33

uh. tile and it's going to be equals to

1885:35

that model title and we also have to use

1885:38

the model. body come on body and it's

1885:40

going to be equals to model body like so

1885:44

and finally we have to use the model.

1885:46

putter it's going to be equals to model

1885:48

footer like so I'm going to save this

1885:50

file right now close there now let me go

1885:52

ahead and go to my app comp component

1885:54

and use there so the first thing that I

1885:56

want to do is that I want to import my

1885:58

uh come on my model component from from

1886:02

there and now we have to Define our St

1886:04

first of all so like is model open and

1886:06

then uh set is model open it's going to

1886:10

be equals to the used St and the initial

1886:12

value will be set to false I'm going to

1886:14

save this file right now now let me go

1886:15

ahead and go to this Dev and I'm going

1886:17

to Define my button component which will

1886:19

say like open I guess open would be or

1886:22

you know open model would be fine and

1886:24

here we have to provide the on click

1886:26

when Handler like whenever we click on

1886:28

there so we want to F this function

1886:30

which we are going to be creating in a

1886:31

few seconds and also provide a bit of

1886:33

styling today like pairing for the xaxis

1886:35

will be set to four pairing for the y

1886:36

axis will be set to two background

1886:38

totally green of 400 and also text of

1886:41

totally white and totally rounded medium

1886:44

like so now let me just save my file and

1886:47

here now underneath this button we are

1886:49

going to be rendering all of our content

1886:51

and you know I'm going to just comment

1886:53

this line out because we're going to be

1886:54

creating there in a few seconds okay so

1886:57

here we have to first of all check so is

1887:00

our model open or not so if our model is

1887:03

open then we have to show this content

1887:05

but if our model is not open then we

1887:08

don't want to show nothing at all so

1887:10

I'll just render that model component

1887:11

and now inside there we have to render

1887:13

one model. tile and as you can see if I

1887:16

just hit control space we are now

1887:17

getting like body uh footer title and so

1887:20

on and so forth so I'm going to just

1887:22

only choose this title right here

1887:24

because now we are going to be providing

1887:25

some sort of a title for or model so

1887:27

I'll just use like model title and now

1887:29

underneath there we are going to be

1887:31

rendering our model. body right here and

1887:34

I'll just P like this is the body of

1887:37

come on of the model or something like

1887:39

that you can past basically anything

1887:40

that you prefer but in my case that's

1887:42

going to be fine and then we have to

1887:44

render our model. come on model. footer

1887:48

and now let me just close that and

1887:49

finally we have to just specify

1887:51

something inside the model footer and

1887:53

I'm going to just provide like button

1887:54

right here inside this button uh we are

1887:57

going to be first of all providing the

1887:58

cancel button and now let me just

1888:00

duplicate the confirm button or

1888:02

something like that I'm going to also

1888:03

specify a few classes today like pairing

1888:05

for the x-axis will be set to four and

1888:08

pairing for the Y axxis will be set to

1888:09

two text will be set totly white

1888:12

background gray 500 and round it totally

1888:16

medium and also text will be set to

1888:18

totally small I'm going to save this

1888:19

file right now here we also have to

1888:21

specify a few more classes like pairing

1888:23

for the X will be set to four pairing

1888:25

for the y axis will be set to two text

1888:27

toally white background to

1888:30

te 500 and margin for the left will be

1888:33

set to 0.3 RM and I'm going to also

1888:36

specify around it totally medium and

1888:39

text toally small like so I'm going to

1888:41

save this file right now and whenever we

1888:43

click on this cancel button so let's

1888:46

just use like on click so we want to

1888:47

fire this function like close model we

1888:50

are going to be closing our model

1888:52

because this is a cancel button and then

1888:54

we have our confirm button so yeah it's

1888:56

going also close our model so whenever

1888:58

we click on there so close the model and

1889:01

confirm it so now let me go ahead and go

1889:04

there and I'm going to uncomment this

1889:05

line out I'm going to copy the name of

1889:07

there and Define my function right here

1889:10

so I'll give it the name of like open

1889:11

model and inside there we have to use

1889:14

the set is model open come on now let me

1889:17

just copy it and place it right here set

1889:20

that to true and now let me just save my

1889:22

file and now we are going to be creating

1889:24

this function which is a close model

1889:26

okay so now let's just use like cons

1889:28

close model and here let's just create

1889:31

that is model open and set there to

1889:34

false I'm going to save this file right

1889:35

now and refresh there so here you can

1889:37

see we are now getting this open model

1889:39

button if I click on this so it's going

1889:41

to open our model if I click on this

1889:43

cancel so it's going to cancel or cancel

1889:45

or remove there and now if I click on

1889:47

the confirm here you can see it's going

1889:49

to also disappear or disable our model

1889:51

and we are also getting this model title

1889:54

and also the body of the model so yeah

1889:57

that was it about the compound component

1889:59

Challenge and I hope you enjoyed it now

1890:01

let's talk about the slot design pattern

1890:03

so slot design pattern allow a component

1890:05

to accept Dynamic content from its

1890:07

parent and place that content into a

1890:09

specific area or section of a component

1890:12

it sounds a bit like a props isn't it

1890:14

yeah of course it is because in reactjs

1890:17

there is no built-in slots so we are

1890:19

going to be using a props to achieve

1890:22

slots so the slot design pattern is not

1890:24

formal or native concept like some other

1890:27

design pattern in reactjs but it draws

1890:30

inspiration from the way slot works in

1890:32

the web component especially in

1890:34

Frameworks like wujs or Shadow Dom or

1890:37

from patn ideas from other UI Frameworks

1890:40

so yeah you got to know that slots are

1890:42

not buil-in or native to reactjs so what

1890:45

are we going to be learning about the

1890:46

slots so first of all we are going to be

1890:48

learning about the default slot then we

1890:50

are going to be learning about the name

1890:52

slot or multiple slot and then compound

1890:54

slot and finally we are going to be

1890:56

learning about the slot with context so

1890:58

you know what there's enough theory

1890:59

about the slots and now let's just start

1891:01

from the first one which is called the

1891:03

default so default slot is known as a

1891:05

children property so whatever you pass

1891:08

between the opening and closing tag of

1891:10

the component is pass as a children

1891:12

property to the component and acts as a

1891:14

default slot so you know what that's

1891:17

going to be it for the theory about the

1891:18

default slot now let's get into the

1891:20

coding then you'll get to know what I'm

1891:21

talking about let's talk about the def F

1891:24

slot so what I'm going to do is that I'm

1891:26

going to create a folder with the name

1891:27

of components and inside there I'm going

1891:29

to define a card. TSX and I'll just use

1891:32

my rafc inside there now let me go ahead

1891:34

and go to my app and registered there

1891:37

right here so I'll use like card and I'm

1891:39

going to close there like this and why

1891:42

is there let me just first of all import

1891:43

there because now we are going to be

1891:45

using something called the default slots

1891:47

or you can say the children inside this

1891:50

component so you know let me just write

1891:52

a comment like d for slots okay I guess

1891:55

that's going to be fine or you can also

1891:57

call them as a Anonymous slots so I'll

1891:59

use like Anonymous slots I hope the

1892:02

spelling is correct but I'm not quite

1892:04

sure about that so what I'm going to do

1892:06

is that I'll just write like H1 and

1892:08

going to say like this is my card title

1892:11

and now let's just save there I'm going

1892:12

to also provide a paragraph which will

1892:14

say like this is my card content and I'm

1892:17

going to also provide a button which

1892:18

will say like learn more let's just

1892:21

write a learn and more now let me just

1892:22

save my file and it is giving us an

1892:25

error because we have to use these

1892:26

children inside this component so what

1892:29

I'm going to do is that I'm going to

1892:30

destructure my children and I'm going to

1892:32

also annotate that as a react uh node so

1892:36

now let me just grab that from the react

1892:37

J and I'm going to only use that inside

1892:41

this uh jsx right here so now let's just

1892:43

sa our file check this out so here you

1892:45

can see we have our uh card title we

1892:48

also have our card content and then

1892:49

finally we also have our button so I can

1892:52

also style it if I want to I'll just

1892:54

write like I don't know maybe border

1892:55

would be fine and here you can see we

1892:58

are now getting a background of totally

1893:00

blank and text of totally white okay so

1893:03

I'll use like of toally white and yeah

1893:05

we are now getting that button right

1893:06

here so this is how we are going to be

1893:08

passing a default slots or Anonymous

1893:10

slots or children to our component now

1893:13

let's talk about the name slots so the

1893:15

name slots or props are simply

1893:18

properties that we pass to a component

1893:20

each with specific descriptive name and

1893:23

these name prompts allow the child

1893:24

component to access and use these values

1893:27

based on the names they are given so

1893:30

that's also it about the theory about

1893:32

the name so now let's talk about the

1893:33

name slot so what I'm going to do is

1893:36

that I'm going to open or not open but

1893:37

create my folder with the name of

1893:39

components and inside there let's just

1893:41

Define my card once again and I'll use

1893:43

my RFC inside there I'm going to go

1893:46

ahead and go to my app component and

1893:48

inside the app component I'll just call

1893:50

my card component like so and I'm going

1893:52

to close that and now here I'm going to

1893:54

past some sort of a jsx as a prompt for

1893:57

my component and I'm going to also give

1893:59

it some sort of a name too there so what

1894:01

I'm going to do is that I'm going to

1894:02

just write a comment for myself like

1894:04

named slots so now here I'll just past

1894:07

like card title you can also write a

1894:09

title if you want it to but in my case

1894:11

I'm going to write like card title and

1894:13

here I'm going to past some sort of a

1894:15

title as a jsx so I'll use like H1 it's

1894:17

going to say like this is my card title

1894:20

and now let's just say there I'm going

1894:22

to also provide the card content it's

1894:24

going to say like a paragraph and it's

1894:26

going to say like this is my card

1894:29

content and I'm going to also provide

1894:30

the card button and here it's going to

1894:33

only say a button and now let me just

1894:35

provide a level of learn more and I'm

1894:37

going to provide a class names of I

1894:39

don't know maybe background totally

1894:40

black and also text of totally white to

1894:43

there so now let's just go back save our

1894:45

file now it's going to gives us an error

1894:47

because we have to use that inside our

1894:49

component so now let me go ahead and go

1894:50

to my component and now let's just zoom

1894:53

in a bit so you guys can see everything

1894:54

a bit better what I'm going to do is

1894:56

that I'm going to destructure first of

1894:57

all my card title and I'm going to also

1894:59

destructure the card content and also

1895:02

the card button like so so let's just go

1895:05

back now let me just save my file and we

1895:07

also have to Define an interface for

1895:09

this I'll use like interface card props

1895:12

and here inside there let's just use our

1895:13

card title and provide my react now to

1895:17

the so I'll use like react node it enter

1895:19

so it's going to import there and I'm

1895:20

going to duplicate there like three time

1895:22

next will be for for the card content

1895:24

and finally we have a card button come

1895:27

on and now let me just copy a name of

1895:29

there and I'm going to annotate my

1895:31

component with this card props now let

1895:34

me just go ahead and go to my card and

1895:36

what I'm going to do is that first of

1895:38

all I'm going to be rendering my card

1895:39

title then we are going to be rendering

1895:41

the card content and finally we have to

1895:43

render the card button like so so now

1895:46

let's just sa our file check this out

1895:48

and still we are now getting this UI

1895:50

first of all we are now getting the

1895:52

title then we are getting the content

1895:54

and now we are getting the button and

1895:55

which is looking cool so yeah this is

1895:57

how we are going to be passing a name

1895:59

slot forward component and this is how

1896:01

we are going to be destructuring or

1896:03

getting there and this is how we are

1896:05

going to be rendering the inside our

1896:07

card component now let's talk about the

1896:09

compound slots or you can say the

1896:11

compound component slots so the slot

1896:14

design pattern can be applied to the

1896:15

compound component by defining the name

1896:17

slot using the props something which we

1896:19

just saw a few seconds ago customize a

1896:21

specific areas of compound component

1896:24

this way each subc component acts like a

1896:26

slot that can be filled with a different

1896:28

content so that was about just a theory

1896:30

about the compound slot and now let's

1896:32

get into the coding then you will get to

1896:34

know what I'm talking about now let's

1896:36

talk about the compound component slot

1896:38

so what I'm going to do is that I'm

1896:40

going to create my components folder and

1896:42

inside there let's just Define our card.

1896:44

TSX and you know what first of all let

1896:46

me just write my RFC inside this

1896:49

component and I'm going to also create a

1896:51

card title. TSX and I'll use my RFC

1896:54

inside there I'm going to also create

1896:56

one for the card content. TSX and I'll

1897:00

use my RFC inside there and finally let

1897:03

me just create another component for the

1897:04

card uh not for but card button. TSX

1897:08

would be fine and I'll use my rafc

1897:10

inside there and now I'm going to go

1897:13

ahead and go to my card title component

1897:15

and inside there let's just use our

1897:17

children's all used like children and

1897:19

here I going to inot it there is a

1897:21

children you know let is close there

1897:23

children react node now I'm going to

1897:26

copy a name of that and place that right

1897:28

here just like there now let's just

1897:30

close this file I'm going to go ahead

1897:31

and go to the card content and I'm going

1897:33

to destructure the children and I'm

1897:36

going to annotate there is a children

1897:38

react node and now we have to annotate

1897:41

them like this okay so I'm going to

1897:43

annotate them close this file close that

1897:45

file finally let me just go ahead and go

1897:47

to my button and here we also have to

1897:50

destructure first of all the children

1897:52

and we also have to inate there with

1897:54

that V node and I'm going to also go

1897:56

ahead and just render there right here

1897:58

now the final thing that I want to do is

1898:00

that I want to go ahead and go to my

1898:01

card component and inside this card

1898:03

component first of all we have to import

1898:05

all of that component so I'll just

1898:07

import first of all the card then we're

1898:09

going to be importing the card content

1898:12

and we also have to import the card um

1898:15

yeah card button yeah I guess the card

1898:17

button so first of all we have to write

1898:19

a card and then the button and this is

1898:21

how we are going to be importing there

1898:23

so next we have to create or destructure

1898:25

or children and then we have to annotate

1898:27

that children with the react node like

1898:30

so okay so I'm going to copy name of

1898:33

there and place it right here and now we

1898:34

have to use it inside our component so

1898:36

I'm going to just remove there I'm going

1898:38

to also make the as a react fragments

1898:40

and here we have to pass our children

1898:42

next we have to provide our compounds to

1898:45

our specific card so I'll use like card.

1898:47

title and here we are going to be

1898:49

setting that to the card title we also

1898:51

have WR the card. content content and

1898:54

here is going to be set to the card

1898:56

content and finally we have to write the

1898:58

card do button it's going to be set to

1899:00

the card button like so now that's done

1899:03

so now let me just go ahead and go to my

1899:05

app and use that inside my app so I'm

1899:07

going to just remove that and inside

1899:09

this app component first of all we are

1899:11

going to be importing our card and now

1899:13

if I hit dot so here you can see we have

1899:15

our button content and also the title so

1899:17

I'm going to just choose the title and

1899:19

close there I'm going to only provide my

1899:21

H1 it's going to say like C title or

1899:23

something like that now underneath there

1899:25

we are going to be rendering our card.

1899:27

content and now let's just provide some

1899:29

sort of a content to this so I'll just

1899:30

use like card content and now underneath

1899:33

this one we are going to be using our

1899:34

card. button and here we have to provide

1899:37

some sort of a button which will say

1899:39

like click me or something like that so

1899:41

this is how we are going to be using

1899:42

there inside our app and this is the UI

1899:45

we are now getting so we are now getting

1899:46

the title then the content and and then

1899:48

finally we are now getting that button

1899:50

right here so we can also style there if

1899:52

I want to Sol just use like background

1899:54

totally black and text of totally white

1899:57

now let me just save my file and now we

1899:59

are getting this button right here so

1900:01

yeah this is our compound uh slots or

1900:04

whatever you want to call them now let's

1900:06

talk about how we going to be using a

1900:07

slots with context API or just a context

1900:10

so what I'm going to do is that I'm

1900:12

going to Define first of all a few

1900:13

folders so I'll just Define like the

1900:15

components folder then we're going to be

1900:17

defining our context folder or shared

1900:20

folder after them we are going to be

1900:21

also defining the hooks folder and

1900:24

inside there we are going to be only

1900:25

storing a simple hook let's just start

1900:27

from the first thing which is to create

1900:29

our context so I'll just give it the

1900:30

name of like my context. TSX and inside

1900:34

there the first thing that we have to do

1900:35

is that we have to grab something called

1900:37

the create context from the react JS and

1900:40

now underneath that we're going to be

1900:42

creating our context so I'll just give

1900:43

it the name of like my context and going

1900:45

to be equals to this create context

1900:46

function and now the initial value I'm

1900:49

going to specify undefined today I'm

1900:51

going to also provide a bit of types

1900:52

today so let's create our interface and

1900:54

now we have to use that interface for

1900:57

our context so what I'm going to do is

1900:59

that I'm going to inate there like

1901:01

either use my context type or use

1901:04

undefined so now let's just go back and

1901:06

this is how we going to be defining our

1901:07

context but I'm going to also export

1901:09

this so we can use that in other file so

1901:12

now underneath we are going to be

1901:13

defining our provider so I'll just uh

1901:15

first of all use like cons my provider

1901:18

and here is going to take like a

1901:19

children first of all and now we are

1901:21

going to be using this so we have to

1901:23

also inate this all use like children

1901:25

from the react node okay so let's just

1901:28

get there from the react node it is not

1901:30

helping me in this situation I don't

1901:31

know why but you know we're going to be

1901:33

importing them manually so I'll just

1901:36

import something called the react note

1901:39

from the reactjs now the next thing that

1901:41

we have to do is that inside this

1901:43

provider we have to Define some sort of

1901:45

a data which we are going to be sharing

1901:47

inside our components so I'll just first

1901:49

of all Define a state which will be set

1901:51

to a value and then set value it's going

1901:53

to be equals to the use St and the

1901:55

initial value will be set to like hello

1901:56

from Context or something like that next

1901:59

we have to just return our provider so

1902:02

what I'm going to do is that I'm going

1902:03

to just use like my provider and here

1902:05

I'm going to specify my provider to that

1902:08

just a provider like so or it shouldn't

1902:10

be provider God damn it my context to be

1902:13

precise and now I'm going to provide the

1902:15

provider right here and now let's just

1902:17

close there and here we are going to be

1902:19

using our children and we also have to

1902:21

provide the value which we are going be

1902:23

sharing across our component so I'll

1902:25

just use like value and also set value

1902:28

like so V A there we go and now let me

1902:30

just save there finally we have to

1902:32

export this so that we can use that in

1902:34

other files so I'll use like export and

1902:37

that's only done so this is how we going

1902:39

to be defining our context and now let

1902:41

me go ahead and go to my Hooks and here

1902:43

we're going to be defining the use my

1902:45

context hook right here so I'll just

1902:47

give it the name of like. yes and first

1902:49

of all the first thing that we have to

1902:51

do is that we have to grab our context

1902:53

and also we have to grab or my context

1902:56

which we just created a few seconds ago

1902:58

now the next thing that we have to do is

1903:00

that we have to actually Define our

1903:01

custom hook so I'll just export this so

1903:04

we can use the in other file and now

1903:05

I'll just give the name of like use my

1903:07

context and here inside there first of

1903:10

all we are going to be getting the data

1903:12

from our context so I'll just use like

1903:14

use context and inside there we are

1903:16

going to be getting our data from our

1903:18

context and now I'll just store there in

1903:19

the variable with the name of context

1903:21

and it's going to be set to this value

1903:23

now we have to provide a check if we

1903:26

don't have the context so in this

1903:28

situation we are going to be throwing an

1903:30

error so I'll just use like throw new

1903:31

error and I'll just space like use my

1903:34

context must be used within a a my

1903:40

provider now let me just save my file

1903:42

but if that's not the case we are going

1903:44

to be only returning our context so I'll

1903:46

just use like context which we are

1903:49

storing right here in this variable so

1903:51

that's all you done now I'm going to

1903:52

close this file and now the next thing

1903:54

that we have to do is that we have to go

1903:55

to our app and wrap our entire

1903:57

application so I'll just remove that and

1904:00

I'm going to also remove that and I'm

1904:02

going to wrap my entire application by

1904:04

using my provider I'm going to copy the

1904:06

name of that and place it right here

1904:08

currently we don't have any components

1904:10

to render so now let's just create our

1904:12

components right here inside this folder

1904:14

I'm going to go ahead and Define my

1904:16

slots or you know it should be slot

1904:19

component come on slot component. TSX

1904:23

file and now here I'm going to just use

1904:26

my rafc inside there with the name of

1904:28

slot component and I'm going to also

1904:30

export this so we can use the I'll also

1904:32

destructure the children and I'm going

1904:34

to annotate the as a react node now let

1904:38

me just hit enter now let me just save

1904:40

my file and inside this component the

1904:42

first thing that we would do is that we

1904:44

would need some sort of a value so I'll

1904:46

just use like use my context and I'm

1904:48

going to execute that and from this

1904:50

context we're going to be destructuring

1904:52

that specific R and now we can totally

1904:54

use the inside our component so I'll

1904:56

just remove there and now inside this D

1904:59

we are going to be just writing like H3

1905:00

and also s like context value and here

1905:03

we just have to render our context value

1905:06

and I'm going to also provide a div and

1905:07

here we have to just use our children

1905:09

inside there now for this children we

1905:12

also have to create yet another

1905:13

component so I'm going to close that one

1905:15

and Define another component with the

1905:17

name of slot content do or not context

1905:21

but cont and there we go content. TSX

1905:25

I'll use my RFC inside there and I'm

1905:27

going to also export that so we can use

1905:29

that anywhere else and now here we are

1905:31

going to be using like use my context

1905:33

and I'm going to execute there and from

1905:35

there we are going to be restructuring

1905:37

the set value and now let me just store

1905:39

the inside uh I mean like we are going

1905:41

to be destructuring the and now let's

1905:43

just use the inside our component so

1905:45

I'll just uh remove the and replace it

1905:47

with the button and change this label to

1905:50

update context value

1905:53

and now when somebody clicks on this

1905:56

button so we just want to F this

1905:57

function which is a set value and here

1906:00

we have to just provide a new value to

1906:02

this so I'll use like new value from

1906:04

slot content component or something like

1906:07

that and that's only done so now let me

1906:09

just refresh the oh we are now getting

1906:11

an error because we have to register

1906:13

there inside our app component so now

1906:15

inside my provider I'm going to first of

1906:18

all render my slot component and I'm

1906:20

going to close that and inside the slot

1906:22

component we're going to be providing

1906:23

our slot content or yeah not slot

1906:26

component but slot content there we go

1906:28

and I'm going to also close there like

1906:30

this like a self closing tag now let me

1906:33

just save my file and here you can see

1906:35

we are now getting our value like

1906:36

context value which is now initially

1906:38

saying like hello from the context but

1906:40

as soon as I click on this button here

1906:43

you can see it's going to change that

1906:44

value to the new value from the slot

1906:46

content right here so yeah this is how

1906:49

we're going to be using a slot with the

1906:51

context now let's talk about about yet

1906:53

another design pattern and I guess the

1906:55

last design pattern of this course which

1906:57

is called the render prop so the render

1906:59

prop design pattern is used to share

1907:00

code between components by passing a

1907:03

function as a PRP to a component so this

1907:06

function which is typically referred to

1907:07

as a render prop return a react element

1907:10

that gets rendered so this pattern allow

1907:12

a component to be more flexible and

1907:14

reusable as the parent component can

1907:17

control the rendering of the content in

1907:19

its child component so you know what let

1907:21

me just give you example of there here

1907:23

you can see I'm now calling my component

1907:25

and I'm passing a render as a prop and

1907:28

inside there we are now passing a

1907:30

function which is taking a count as a

1907:32

perimeter and now we are returning some

1907:33

sort of a jsx which is saying like the

1907:35

current count is that specific count now

1907:38

we have our component and inside that

1907:40

component we are now destructuring that

1907:43

specific function or prop whatever you

1907:44

want to call that and now we are using

1907:47

that inside our jsx and here you can see

1907:49

we're now passing a count to there so

1907:51

you know what let me just write some

1907:52

code then you will get to know what I'm

1907:54

talking about so now let's see the

1907:55

render prop in action so first of all we

1907:58

are going to be creating our components

1907:59

folder and inside there we have to

1908:01

create our component. TSX and I'll use

1908:03

my rafc inside there and now let me go

1908:05

ahead and go to my app and render this

1908:08

component right here so I'll use like

1908:10

count and now let's just render there

1908:12

and I'm going to close there and now we

1908:14

going to be passing our render prop as a

1908:16

prop to this component so how in what we

1908:18

are going to be doing there well first

1908:20

of all we have to create some sort of a

1908:21

prop and by way you can give it any name

1908:23

that you prefer but in my case I'm going

1908:25

to give it the name of like render and

1908:27

here we are going to be passing our

1908:28

function and now let's just use our

1908:30

paragraph and it's going to say like the

1908:32

current count is and now let's just

1908:35

render or count which this function will

1908:37

take as a perimeter and now let me just

1908:39

paste there and we are going to be also

1908:41

returning a number from there because

1908:43

it's going to be a number now let me

1908:45

just save my file go back the next thing

1908:47

that we have to do is that we have to

1908:48

use this render prop inside our

1908:50

component so let me go ahead and go to

1908:52

my comp component and first of all we

1908:54

have to destructure there so that we can

1908:55

use that now let me just save my file

1908:58

and now inside this component we have to

1908:59

create our state so I'll use like count

1909:01

and then set count it's going to be

1909:03

equals to the use State and the initial

1909:05

value will be set to zero now let me

1909:08

just save this file and the next thing

1909:09

that we have to do is that we have to

1909:10

render our component or our function to

1909:13

be precise so I'll use like render and

1909:15

here we have to P that count inside

1909:17

there so as soon as I do that and we are

1909:19

now getting a typescript error so I'll

1909:21

just annotate there with any here you

1909:22

can see we are now getting the current

1909:24

value of zero inside there and I can

1909:26

also change that to like 10 it's going

1909:27

to give us that 10 value and so on and

1909:29

so forth now let me just create a button

1909:31

which will allows us to increment or

1909:33

decrement or counter so I'll use like

1909:35

button and I'll just say like increment

1909:37

and when somebody clicks on there then

1909:39

we want to F this increment function

1909:41

which we are going to be creating in a

1909:42

few seconds so now let me just copy a

1909:43

name of there go back and cons increment

1909:46

and then we're going to be only

1909:47

incrementing our counter by one so I'll

1909:50

use like count plus one say our file and

1909:52

now if I click on this so it's going to

1909:54

increase my counter by one so let me

1909:57

just set that to zero once again save

1909:59

this file and as soon as I click on

1910:01

there it's going to just increment my

1910:03

counter right here so this was just a

1910:05

simple example of a counter component

1910:08

now let me give you yet another example

1910:09

so what I'm going to do is that I'm

1910:11

going to go to my app but first of all

1910:13

we have to create something called the

1910:15

mouse tracker so I'll use like Mouse

1910:17

tracker. TSX component I'll use my RFC

1910:21

inside there go to my app and now I'm

1910:23

going to just remove this component from

1910:25

here I'm going to also remove that from

1910:26

there and now let me render my mouse

1910:28

tracker component and close there here

1910:31

we are going to be passing our render

1910:33

and inside this render we have to

1910:34

provide our function so I'll use like

1910:36

position and Position will be set to any

1910:39

and inside there let's just create our

1910:41

paragraph so I'll use like paragraph

1910:43

it's going to say like Mouse is at this

1910:45

position so I'll use like come on first

1910:47

of all let's just provide one position

1910:49

and then I'm going to provide another

1910:51

position so I'll just proide first of

1910:53

all the uh position position and

1910:56

Position will be set to and also I'm

1910:58

going to provide my position and

1911:00

Position will be set to Y now let me

1911:02

just save my file and it shouldn't be

1911:06

I'm treating it as an object it should

1911:07

be just position dot like so position

1911:11

dox and position doy and now let me go

1911:13

ahead and go to my component and use

1911:15

this render from inside that component

1911:18

first of all we have to destructure this

1911:19

so we can use the inside our component

1911:22

next we we have to Define our position

1911:23

so I'll use like position and set

1911:26

position and this going be equals to the

1911:28

UST St come on UST stad and the initial

1911:30

value will be set to X and x-axis will

1911:32

be set to zero and y axis will be also

1911:34

set to zero okay and next we have to go

1911:37

ahead and go to our UI and then we have

1911:40

to render our position or our render

1911:43

props so I'll just use like render and

1911:45

here inside there let's just provide our

1911:46

position inside there and I'm going to

1911:48

also annotate the as any for the time

1911:51

script to go away and now we are getting

1911:52

a mouse at zero position and also on the

1911:55

y- axis of zero position we can only

1911:57

change there to like 10 and 20 maybe

1912:00

like so manually now we are getting like

1912:02

mouses at this accordion I'm going to go

1912:05

there and this should be xaxis and this

1912:08

should be a y axis and now that's

1912:12

looking better so the next thing that I

1912:14

want to do is that I want to set that to

1912:15

zero once again I'm going to also set

1912:17

the y- axis to uh zero once again and

1912:20

now we are going to be attaching the

1912:21

mouse move so I'll use like on Mouse

1912:23

move and when our Mouse is moving so in

1912:26

that situation we are going to be firing

1912:28

this function which is a handle uh Mouse

1912:30

move and we are going to be also

1912:31

providing a bit of styling to this so

1912:33

I'll just provide like height and the

1912:35

height will be set to 100 VH now let me

1912:38

just save my file and create this

1912:40

function right here so it's going to

1912:41

track our mouse cursor so I'll use like

1912:44

con uh handle Mouse it's going to take

1912:46

the event and I'll just annotate the as

1912:48

any and I'll just provide my set

1912:50

position and inside this we are going to

1912:52

be getting the x value and x value will

1912:55

be set to that event object and we only

1912:57

want to get the client xais and then for

1913:00

the y axis we want to get like event and

1913:02

we only want to get the client Y axis in

1913:05

that situation so now it's going to

1913:07

gives us the perfect accordant anytime I

1913:09

move my mouse it's going to gives us a

1913:11

different accordance so it's going to

1913:12

giv us the x value and it's going to

1913:14

also gives us the Y value so yeah this

1913:17

is how we are going to be creating our

1913:18

render prop and then this is how we are

1913:21

going to be using there inside our

1913:23

component so this is going to be

1913:24

basically the most simple challenge in

1913:26

this entire course so what do you have

1913:28

to do basically you have to just create

1913:30

the data fer component by using the

1913:32

render PR design pattern which you just

1913:35

saw a few seconds ago so you need to

1913:37

create a reusable data fer component

1913:39

that fitches the data from the API and

1913:41

passes that data to his child component

1913:43

using the render prom design pattern so

1913:45

the child component will receive their

1913:47

data and can render it however it

1913:49

chooses so basically you'll need to

1913:51

perform these three steps like first of

1913:53

all the data feure component then the

1913:55

render prompts and you'll also have to

1913:56

keep in mind the error handling so let's

1913:58

start from the first one which is a data

1914:00

fure component so the data fure

1914:03

component should take the URL as a prop

1914:05

and FES the data from that specific URL

1914:08

so while the data is being fetched the

1914:10

component should show a loading spinner

1914:11

or some sort of a message in this

1914:13

situation and once the data is fetched

1914:15

the component should pass the data to

1914:17

its child through a render prop so then

1914:20

the render prop will receive the data we

1914:22

the render prop and render and renders

1914:24

it however it wishes like basically you

1914:27

can just provide any kind of UI for them

1914:30

and you will also provide a typescript

1914:32

for them so finally you will also need

1914:33

to take care of the error handling like

1914:35

if there is some sort of error so you

1914:37

have to show that specific error to the

1914:40

browser or to the user so these are the

1914:42

expected outputs so like while the data

1914:44

is being fish show a loading spinner or

1914:46

some sort of a loading message or

1914:48

something like that and once the data is

1914:50

being fet render the list of users and

1914:53

if there is an error for example like

1914:55

wrong URL or network issues then show

1914:57

that specific error so give it your best

1914:59

shot if you can do it that's completely

1915:02

okay then come back and watch the

1915:03

solution and now here is my solution so

1915:06

I'm going to go ahead and just create a

1915:07

component folder so I'll just create

1915:09

like components folder and inside there

1915:11

we're going to be creating two

1915:12

components or files rather so I'll just

1915:15

start from the data peter. TSX so now

1915:18

let me go ahead and just Define my

1915:20

component with the name of dat

1915:22

picture and I'm going to also annotate

1915:25

that as a type generic it's going to

1915:27

just render a few things so first of all

1915:29

we need to restructure the URL and also

1915:32

the render prop okay so then we have to

1915:34

create an interface for then so that it

1915:36

will not gives us that typescript error

1915:38

so now let me just Define my interface

1915:40

with the name of data fer props and here

1915:42

we have to specify the type of generic

1915:45

and it's going to take the URL and we

1915:47

have to annotate the as a string we also

1915:49

have to specify the render prop and it's

1915:51

going to take the data and we have to

1915:52

specify that like it's going to also

1915:54

take the the type generic or the null

1915:57

value and I'm going to also provide the

1915:58

is loading so whenever it is loading so

1916:00

there going to be a Boolean and we also

1916:02

have to specify the error so it can be

1916:05

either a string or null and now we have

1916:07

to past the as a GSX do element come on

1916:11

do element like so now let me just sell

1916:14

my file but why in the world I'm

1916:15

providing a semicolon there we have to

1916:18

specify a comma there and comma there

1916:20

I'm going to copy the name of that let's

1916:22

just copy there and I'm going to

1916:24

annotate my component with these props

1916:26

and now inside there and here we also

1916:28

have to specify the type generic and now

1916:31

inside this component we have to define

1916:33

a few States so first of all we are

1916:35

going to be defining a state for the

1916:36

data so I'll just give it the name of

1916:38

like uh C data because inside there

1916:41

we're going to be storing our data and

1916:43

then set data is going to be equals to

1916:45

the used St and initial value will be

1916:46

set to n and here we have to specify

1916:49

either the type generic or null value

1916:52

next we have to define the loader so

1916:54

I'll use like is loading and then set is

1916:56

loading is going to be equals to the use

1916:59

stand and the initial value will be set

1917:00

to true and now we have to define the

1917:03

error and then set error it's going to

1917:05

be equals to the US and the initial

1917:07

value will be set to null and we also

1917:09

have to annotate our component to either

1917:11

take a string or null value so that's

1917:13

going to be at for our states next we

1917:16

have to fetch our data by using the use

1917:18

effect so now we are going to be

1917:19

performing the side effect so in this

1917:21

situ ation we have to use our use effect

1917:24

okay so now inside there going to be

1917:25

passing a lot of things but first of all

1917:27

we have to provide the dependency array

1917:29

and for the dependency areay we are

1917:31

going to be only passing that URL which

1917:32

we are now taking as a perimeter okay so

1917:35

whenever that URL changes so we want

1917:37

this function or this component to

1917:39

reender okay so what do we have to do we

1917:42

have to use like set is loading and

1917:44

initially we have to set that to true

1917:46

and then the set error we have to set

1917:48

that to null and now we have to fetch

1917:51

our data so now we we are going to be

1917:52

using that fch you can also use xuse if

1917:55

you wanted to and now we are going to be

1917:56

passing that URL as you can see right

1917:59

here and based on that specific URL

1918:02

we're going to be fetching our data so

1918:03

now let's just use like the dot then and

1918:06

the dot catches and all of that stuff so

1918:09

uh let's just get the response and

1918:11

response. Json convert that data to the

1918:13

Json and then finally we have to use our

1918:16

data so it's going to give us that data

1918:18

so we have to provide that data to our

1918:21

state so store that data inside the

1918:23

state and let's just use our set is

1918:25

lowering and set that to false now let

1918:27

me just save my file and that's to done

1918:29

and what about the catch I'm going to

1918:31

just write like Dot and catch statement

1918:34

and here we only have to specify that

1918:36

error and inside there we can use like

1918:38

set error if we got one then we're going

1918:41

to be rendering that to or error stat

1918:44

all use like m e s a g e and then set is

1918:48

loading and set that to false initially

1918:51

now let me just s my file and this is

1918:53

how we going to be fetching our data by

1918:55

using this use effect now let me just

1918:57

close there the next thing that we have

1918:58

to do is that we have to return that

1919:00

render prop or P all of that data to

1919:03

that render so we are going to be

1919:04

passing that data and also the is

1919:06

loading and also that error and we have

1919:09

to just return that from this data

1919:11

feature component now let me just copy

1919:13

the name of that and now we have to

1919:14

export that so we can use that in other

1919:16

file now let's just say our file close

1919:19

there and now let's just use that inside

1919:21

our component so I'm going to go ahead

1919:23

and just Define my users component like

1919:25

users. TSX and I'll just use my RFC

1919:28

inside there now let me go ahead and

1919:30

just remove that and we have to render

1919:33

our data uh what do we call it data fer

1919:36

component which we just Define and close

1919:38

them not like this but like this there

1919:41

we go so the first thing that we have to

1919:43

do is that we have to specify our URL so

1919:45

I'll just past like URL and we're going

1919:48

to be fetching our data from this

1919:49

specific URL which is this Json

1919:52

placeholder typei code and then that

1919:54

specific users I'm going to also Define

1919:57

interface for this so let's just Define

1919:58

there I'm going to give it the name of

1920:00

like um interface user and inside that

1920:04

is a space ID and ID will be set to a

1920:06

number and also the name will be set to

1920:09

a string now let me just copy that from

1920:11

there and annotate my component with

1920:13

that user so let's just past there close

1920:17

there and paste that array inside there

1920:20

so this is how we going to be fetching

1920:22

data but now we also have to tell like

1920:24

how we are going to be rendering that

1920:26

data so I'll just use like render and

1920:28

here inside there we have to render our

1920:30

data so I'll just past like data that is

1920:33

loading which we also fetching come on

1920:35

is l o a d i n g and also the error okay

1920:39

so now let's just go back from there and

1920:41

inside there uh we have to first of all

1920:43

check you know let's just save our file

1920:45

inside there we have to first of all

1920:47

check if we have some sort of error so

1920:49

in this situation we are going to be

1920:51

returning the div and I'll just say like

1920:53

loading dot dot dot and I'm going to

1920:55

also render the div right here so this

1920:58

file and what about the error if we have

1921:00

some sort of error so in this situation

1921:02

let's just render like and then we have

1921:04

to render that specific error right here

1921:07

a r there we go now underneath that we

1921:10

have to return our content so that we

1921:12

can see them on our UI so I'll just

1921:15

return like UL I'm going to use that UL

1921:17

right here and inside the use the data

1921:20

if we got the data then we're going to

1921:22

be iterating over through that data so

1921:24

I'll just go ahead and provide my li and

1921:27

for this lii we are going to be

1921:28

providing a user. name okay and here we

1921:31

also have to specify the key and the key

1921:33

will be set to user. ID now let me just

1921:35

save my file and this is how we are

1921:37

going to be fetching our data and this

1921:39

is how we are going to be rendering our

1921:40

data and so on and so forth so finally

1921:44

the moment of truth and we are still

1921:47

getting that app that's because we have

1921:49

to go ahead and go to our app component

1921:52

and render our users component inside

1921:55

the close our file and what the hell is

1921:58

going on let's just close there now let

1922:00

me just refresh this so here you can see

1922:01

we are now getting all of that users

1922:03

right here from that API so this is how

1922:06

we are going to be fetching our data and

1922:07

that was it about the render prompts

1922:09

design pattern in reactjs let's talk

1922:12

about the 10 stack query so 10 stack

1922:14

query previously known as a Rea query is

1922:17

a popular Library used in Rea

1922:18

application for managing server State

1922:21

and hand link and synchronized data

1922:23

fetching it provides a set of hooks that

1922:25

simplify the process of fetching caching

1922:27

synchronizing and updating data in Rea

1922:29

application so that was just a quick

1922:31

definition of what a t St query is but

1922:34

10 St query is also a framework agnostic

1922:37

which simply means that you are not only

1922:39

limited to use the inside the reactjs

1922:42

you can use the with different

1922:43

Frameworks and libraries like VJs

1922:45

angularjs and so on and so forth but it

1922:48

is commonly used in the re community so

1922:51

yeah the was just a definition of what a

1922:52

10 St query is and now let's get into

1922:55

the setup then you'll get to know what

1922:56

I'm talking about so now let's make a

1922:58

setup 4 or coding Journey so what I'm

1923:00

going to do is that I'm going to open my

1923:02

terminal and I am going to make a setup

1923:05

for the reactjs I'll use npm create we

1923:08

at latest and now I'm going to give it

1923:10

the name of like uh 10 demo or something

1923:13

like or 10 stack demos would be fine so

1923:16

I'll choose reactjs with typescript now

1923:18

I'll go into the T demo and now install

1923:22

every single thing inside there now

1923:24

that's successfully done so I'll just

1923:25

clear this out the next thing that we

1923:27

have to do is that we have to go to the

1923:29

10 St query and now we are using the

1923:31

version five of L St query so they are

1923:33

now calling them themselves like

1923:35

powerful asynchron St management for

1923:37

typescript and reactjs in yeah I mean

1923:40

typescript with JavaScript reactjs solid

1923:44

JS VJs SW and also angular okay so yeah

1923:48

if you want to install that the first

1923:49

thing that we have to do is that we have

1923:50

to go ahead and go to this uh dogs now

1923:53

here you can learn a lot of stuff about

1923:54

there but I'm going to click on this

1923:56

installation and now let me just copy

1923:58

this link and now let's just place it

1924:00

right here and I'm going to just hit

1924:01

enter so it's can install that in my

1924:03

machine so yeah that's to done now I'm

1924:06

going to go ahead and go to my tailman

1924:08

css.com and click on the getting started

1924:10

go to the framework and guides choose

1924:12

weight and now I'll just copy uh yeah

1924:15

this line of code or command to be

1924:17

precise and now let me just place it

1924:18

right here so it's going to install the

1924:19

tailin CSS inside my project so now I'm

1924:22

going to just hit enter so it's going to

1924:23

initialize my tailin CSS right now and

1924:26

now I'm going to just copy there and now

1924:28

first of all we have to open that folder

1924:31

inside the vs code and this is how it

1924:33

looks like so I'm going to go ahead and

1924:34

go to the tailin config file and I'll

1924:36

just replace that content with this new

1924:39

one next I'm going to copy this index.

1924:41

CSS directives and now let's just go

1924:43

ahead and go to this um index. CSS file

1924:46

remove every single thing from there and

1924:48

replace it with this new one I'm going

1924:50

to remove the public folder and I'm

1924:52

going to also remove the SS folder

1924:53

remove the f. CSS go to the f. TSX file

1924:56

remove every single thing from there and

1924:58

I'm going to use my RFC inside there to

1925:00

create my initial component now let me

1925:03

just copy this line of code and now I'm

1925:05

going to place it right here so that we

1925:07

can see everything is working or not so

1925:09

I'm going to use like npm run Dev and

1925:11

now let's just test this out okay so

1925:14

yeah everything is working the way we

1925:15

exp him to work and that was our entire

1925:17

installation and now let's get into the

1925:19

10 St query in a more great detail

1925:21

detail now let me show you how we are

1925:23

going to be fetching and managing that

1925:25

data without using the 10 St query and

1925:28

then we are going to be refactoring that

1925:29

code to use the 10 St query so what I'm

1925:32

going to do is that I'll just close all

1925:34

of that files and here I'm going to just

1925:36

Define a component folder and inside

1925:38

there I'll just create a component with

1925:39

the name of like without uh 10 query.

1925:45

TSX I'll just use my rafc inside there

1925:48

and now let's just go into the ftsx file

1925:51

and now I'm going to register that

1925:52

component right here so without the 10

1925:54

St query now I'm going to save this file

1925:57

and here you can see we're now getting

1925:58

this message which means like everything

1926:00

is working the way we expect him to work

1926:02

so the first thing that I want to do is

1926:03

that I want to Define my stats so what

1926:05

I'm going to do is that I'm going to

1926:06

just Define a St for the ID and then set

1926:09

ID is going to be equals to the use St

1926:11

and the initial value will be set to one

1926:13

now I'm going to create a St for the

1926:14

data and then set data that's going to

1926:17

be equals to the use State and the

1926:18

initial value will be set to null yeah

1926:20

definitely you can provide your

1926:22

typescript and all of their stuff but

1926:24

I'm not going to so now we are going to

1926:26

be creating a St for that is lowering

1926:28

and also set is loading and it's going

1926:30

to be equal to the use St once again and

1926:34

the initial value will be set to true

1926:36

now we have to define a state for the

1926:37

error and then set error and it's going

1926:40

to be equals to the use State and the

1926:41

initial value will be set to totally

1926:43

null now underneath that we have to now

1926:45

fetch the data so which means like we

1926:47

have to do some sort of a side effect so

1926:49

I'll just use my use effect and the

1926:50

initial value I mean like not the

1926:52

initial value but for the dependency

1926:54

array we're going to be only providing

1926:56

that ID because we're going to be

1926:58

creating some sort of a button and

1927:00

anytime we click on that button so it's

1927:02

going to fetch a new data so now I'll

1927:04

just import that use effect from the VJs

1927:07

and now let's just do a bit of side

1927:08

effects so first of all we have to

1927:09

Define our race condition so I'll just

1927:12

use like RC for the race Condition it's

1927:14

going to be set to false and if you guys

1927:16

don't know what a race condition is you

1927:18

don't even have to worry about that

1927:20

because 10 step query will handle that

1927:22

behind the scene for us so now we have

1927:24

to create a function so I'll just use

1927:26

that handle uh PCH and it's going to be

1927:28

equals to the synchronous function and

1927:30

now inside there first of all we have to

1927:32

get the set is loading and we have to

1927:35

set that to true now we have to use the

1927:37

set error and we have to initialize that

1927:39

to the null value and now underneath

1927:41

that we have to use the try and catch

1927:42

blocks so for the catch block we have to

1927:44

specify some sort of error and it can be

1927:46

anything and now I'll just use like set

1927:49

error and here we have to specify like

1927:51

error message and we're going to be also

1927:53

providing the finally so I'll just

1927:54

choose like finally and here let's just

1927:56

use our set is lowering and provide the

1927:59

false value to there okay now for the

1928:01

triy block what we have to do we have to

1928:03

fish the data so I'll use the con Str

1928:06

going to be equals to A and then Fetch

1928:08

and here inside there now we are going

1928:10

to be fetching the data from this URL

1928:12

which we've already used in like almost

1928:14

all of my courses so we are now fetching

1928:16

our data from the Json placeholder typi

1928:19

code.com for/

1928:21

and now we are going to be fetching the

1928:23

data from a specific to-do now

1928:25

underneath that we have to take care of

1928:27

the rise condition so if we have the

1928:28

race condition in that situation we're

1928:30

going to be returning our data but if

1928:33

that's not the case we have to do a

1928:35

check so if you don't have the response

1928:37

okay so in this situation we're going to

1928:39

be throwing a new error okay so I'll use

1928:42

like error pitching data now we have to

1928:45

render our response. statistics uh like

1928:48

so and now let me just save my file and

1928:50

now finally we have to convert our data

1928:52

to the Json response I'll I'll just use

1928:54

like a word then response. Json and now

1928:57

we have to store in some sort of

1928:58

variable so I'll use like cons response

1929:00

or you know what result would be fine

1929:02

and now we have to set that set data and

1929:05

we have to specify the result that

1929:07

result or all of their data to there so

1929:10

now that's to done now we have to

1929:11

execute this function so what I'm going

1929:13

to do is I'm going to copy a name of

1929:15

there and we have to execute this

1929:16

function right here now I'm going to

1929:18

also provide a cleanup function for the

1929:20

rest condition so just return this data

1929:22

and now from this data I'll use like RC

1929:25

for the rest condition now it's going to

1929:27

fetch all of that data and now the next

1929:29

thing that we have to do is that we have

1929:30

to render that data to our UI so what

1929:33

I'm going to do is that first of all I'm

1929:35

going to be checking like if we have the

1929:36

loading state in this situation we are

1929:38

going to be using the H1 and we have to

1929:40

provide like loading dot dot dot and now

1929:43

if that's not the case and we got some

1929:44

sort of a error so in this situation

1929:46

we're going to be using the H1 and we

1929:48

have to render that specific error but

1929:51

if we have the data so in this situation

1929:53

we're going to be only rendering that

1929:55

data by using that Json stringify so

1929:58

I'll use like json. stringify and here

1930:00

we have to specify our data inside there

1930:03

now if I save my file here you can see

1930:05

we are now getting all of the data so if

1930:07

I just refresh that we are now getting

1930:08

that loading lower and also now we are

1930:11

getting our data which means like

1930:12

everything is working the way we exp him

1930:14

to work but now I'm going to be creating

1930:15

a button and here for this button we're

1930:17

going to be just saying like next or

1930:19

next page and when somebody try to click

1930:21

on there then we're going to be finding

1930:23

this function which is a set ID and now

1930:26

here we have to specify our previous ID

1930:28

today and now we have to use our

1930:29

previous id+ one and also I'm going to

1930:32

be providing a bit of classes to this so

1930:33

I'll use like pairing all around will be

1930:35

set to 20 Rim now let me just save my

1930:37

file and here you can see we are now

1930:39

getting this huge button but you know

1930:42

let's just change that to like maybe

1930:44

three rims and now I'll also change the

1930:46

color of that to like background totally

1930:48

black and text totally White let me just

1930:51

sve my file it is still looking

1930:54

supremely big and yeah I guess that's

1930:56

going to be fine so if I click on that

1930:58

here you can see it's going to gives

1930:59

another data and another ID so if I

1931:02

click on there once again it's going to

1931:04

fetch our data and now it's going to

1931:05

show our data but I want you to notice

1931:08

like here you can see we have to do all

1931:10

of that stuff for just fetching our data

1931:14

like here you can see we have to define

1931:16

the state for the ID then for the data

1931:18

then for the lowering then for the

1931:20

errors and also we have to take care of

1931:22

the race conditions and by the way if

1931:24

you guys don't know what a race

1931:25

condition is you don't have to worry

1931:27

about that because now T day quy will

1931:29

handle that for you so you don't have to

1931:31

worry about that now let me just expand

1931:33

that first of all you have to take care

1931:35

of your lowering logic and then you have

1931:37

to write a lot of try and catch blocks

1931:39

and then you have to even check for the

1931:42

responses and then finally you have to

1931:44

send your data you have to also take

1931:46

care for the catching and then you have

1931:48

to take care for the error logic and

1931:51

finally logic and there's a lot of

1931:53

hurdles and here you can see you also

1931:56

have to take care of the loading logic

1931:57

and also the data and then finally

1931:59

you're going to be showing some sort of

1932:00

a data to your UI so yeah this is like

1932:05

cool you totally can write your code

1932:07

like this but just imagine for a second

1932:09

like if you want to fch a lot of data in

1932:11

a lot of components it can get totally

1932:14

messy and totally tedious so for this

1932:16

kind of situation we are going to be

1932:18

using something called the 10 St query

1932:20

and trust me you are going to love that

1932:22

a lot so you know what let me just

1932:25

refactor this code you know we're not

1932:26

going to be refactoring this code so we

1932:28

are going to be starting from scratch

1932:29

and then we are going to be refactoring

1932:31

this code to use the 10 St query let's

1932:33

talk about that query client thing which

1932:35

we just saw a few seconds ago so if you

1932:38

say that query client is the heart of 10

1932:40

St query you won't be wrong you will be

1932:43

totally correct but you know let's just

1932:45

explore the bit more so the query client

1932:47

is the core object int query that

1932:50

manages the State and configuration of

1932:52

queries and mutation in our applications

1932:55

it serve as the primary API for

1932:57

interacting with the library and by

1932:59

Library I mean the t St query Library

1933:02

enabling us to perform actions like

1933:04

fetching the data managing the cash and

1933:06

setting up the global configurations so

1933:09

as I said that query client is the heart

1933:12

of the entire 10 St query so yeah you

1933:15

know let me just explore that bit more

1933:17

the first thing that we did is that we

1933:19

imported the query client which is just

1933:21

a heart of the 10 St query from where

1933:23

from the 10 St query from the react

1933:26

query next we create the instance of the

1933:29

outside from all of our component here

1933:32

you can see there and now we have to use

1933:34

that inside our entire applications so

1933:37

for then we use the query client

1933:39

provider which is just a context and now

1933:42

it is taking the client and now for the

1933:43

client we are now providing this query

1933:45

client basically all of that code simply

1933:48

means that we want to use that 10 step

1933:50

query

1933:51

inside our entire application you can

1933:54

think about this code is like this like

1933:56

basically this entire thing which we

1933:58

just imported and we created the

1933:59

instance of there and now we are

1934:01

providing there or even wrapping our

1934:02

entire application by using our query

1934:05

client provider context this all code

1934:08

simply means that we want to use our 10

1934:10

St query inside our entire application

1934:13

and that's it now let's talk about the

1934:15

main Hook from the 10 St query which

1934:18

you're going to be using like 99% of

1934:20

your time time maybe not 99% of your

1934:23

time but I guess 70 or 80% so I'm

1934:27

talking about something called the use

1934:29

Query Hook from the 10 St query so this

1934:31

is how we are going to be using there

1934:33

first of all we are going to be writing

1934:34

the use Query it's going to take a

1934:36

object and inside that object we're

1934:38

going to be providing a query key as a

1934:40

key and for the value we going to be

1934:43

providing some sort of a unique key to

1934:45

there and don't you worry because we're

1934:47

going to be explaining all of them one

1934:49

by one and after that we are going to be

1934:51

using another property which is called

1934:53

the query function or query FN and then

1934:56

we're going to be specifying some sort

1934:57

of a function which will allows us to

1934:59

fetch our data so you know what let me

1935:01

just break this down one by one first of

1935:03

all we have the use Query which is a

1935:05

function that help us fish and manage

1935:07

server data in our applications then we

1935:10

have a query key and then now we are

1935:11

specifying a to-dos today and you can

1935:14

specify anything today like you can

1935:16

specify I don't know it's going to

1935:17

totally depend on your situation where

1935:19

you're using there but in my guess I'm

1935:21

going to be fetching some sort of a

1935:22

to-dos so that's why I specify to-dos

1935:24

inside there so this is a unique

1935:26

identifier for the query it's like a

1935:28

label saying like we are working on that

1935:31

specific items or that to-dos in my case

1935:34

and finally we have our query function

1935:36

and now we specifying a fetch data

1935:38

function to there and this specify the

1935:41

function which is a fetch data that will

1935:43

actually get the data and it will be

1935:45

called to retrieve their to-do items so

1935:48

yeah that was just a basic theory about

1935:50

uh the use Query hook and now let's just

1935:52

use the inside our apps okay so I'll

1935:55

just close there and now I'm going to go

1935:56

ahead and go to my components folder and

1935:58

now we are going to be creating another

1936:00

component which will be a with uh

1936:02

10 query. TSX I'll use my RFC inside

1936:07

there let's just go ahead and go to our

1936:08

appom and this line out now we have to

1936:11

return the withd 10 St query so now let

1936:14

me just write this my file close there

1936:16

and here you can see we're now getting

1936:17

over with 10 St query which is looking

1936:20

cool the first thing that we have to do

1936:21

is that we have to import something

1936:23

called the use Query function or Hook

1936:25

from where from the 10 St query so I'll

1936:28

use like use Query and next we have to

1936:30

use there so I'll just use like use

1936:32

Query and inside there we have to

1936:34

specify our object and for this object

1936:37

we are now going to be providing the

1936:38

query key and that's going to be set to

1936:40

array and inside this array we are going

1936:42

to be specifying some sort of a unique

1936:44

key to there I'm going to provide a

1936:46

comma the next thing that we have to do

1936:47

is that we have to provide a function

1936:49

which will allows us to fetch our data

1936:51

so we have to use our query function and

1936:53

now we have to specify some sort of a

1936:55

function for there so I'll use like

1936:57

fetch data as my function which we are

1936:59

going to be creating in a few seconds so

1937:01

I'll use like con data and it's going to

1937:02

be equals to this use Query function and

1937:05

now outside from there I'm going to just

1937:07

create that function right here so I'll

1937:08

use that cons fet data and it's going to

1937:11

be a function it's going to be basically

1937:13

an asynchronous function because now we

1937:15

are going to be using or U what do we

1937:17

call it asynchronous operation so that's

1937:19

why it's going to be an asynchronous fun

1937:20

function and the first thing that I want

1937:22

to do is that I want to fetch my data so

1937:24

I'll use like Fetch and we want to fetch

1937:26

our data from the https and then Json

1937:29

come on Json placeholder do type I

1937:32

code.com for/ too now let's just store

1937:36

the inside the response variable and now

1937:38

let me just save my file next we have to

1937:40

check for the response so if the

1937:42

response is not okay so I'll use like

1937:45

response is not okay in this situation

1937:48

we're going to be throwing a new error

1937:50

it's going to select Network response

1937:53

was not okay and finally we just have to

1937:56

return the response. Json so use like

1937:59

response. Json and I'm going to execute

1938:01

there and this is how we are going to be

1938:03

fetching our data and by the way I know

1938:05

a lot of you thought that 10 St query is

1938:08

only used for fetching the data but

1938:11

that's not the case we are now fetching

1938:13

our data by using this fetch method we

1938:17

can also use x use for fetching the data

1938:19

but t query will not only allows us to

1938:22

fish our data it's going to also allows

1938:24

us to manage that data which means like

1938:27

we don't have to create a state for the

1938:29

lowering for the errors and so on and so

1938:31

forth we don't have to specify the try

1938:33

and catch blocks we don't have to take

1938:35

care of the RIS conditions and a lot of

1938:38

more stuff so you know what let me just

1938:40

uh log that data to the console so I'll

1938:41

just use the console.log of data and now

1938:44

let me just save my file now I'm going

1938:45

to right click on there go to my inspect

1938:47

element go to my console and yep we are

1938:50

now getting the data right here so there

1938:52

is something wrong inside the Json

1938:54

placeholder I'm not quite sure about

1938:55

that so you know let's just close that

1938:58

here you can see I'm now providing

1939:00

Triple T's right here so let's just

1939:02

change that to this URL so so now let me

1939:05

just save my file and now let me just

1939:06

refresh that and here you can see we're

1939:08

now getting our data so first of all we

1939:10

have our data which is now array of 200

1939:13

arrays and we also have like error we

1939:16

also have the failure and is error and

1939:19

we have a lot of these things which we

1939:21

are going to be destructuring in a few

1939:22

seconds so we also have like is it

1939:24

loading or Not So currently it is not

1939:27

loading so it's going to gives us a

1939:29

false paused or not so yeah this is not

1939:32

paused is it pending or not yep it is

1939:35

not so is it stale or not so yeah it is

1939:38

uh true and stale is something which we

1939:40

are going to be exploring in a lot more

1939:42

great detail but not right now so we're

1939:45

going to be destructuring a lot of

1939:46

things but now you get the idea that H

1939:50

Aquarium not only allows us to fish the

1939:52

data this going also allows us to manage

1939:54

that fetch data so you know let me just

1939:57

close there so to prove my point I'm

1939:59

going to also install the exos library

1940:01

and I'm going to also show you that we

1940:02

can also fet your data by using the exos

1940:06

so what I'm going to do is that I'm

1940:07

going to open my terminal and if you

1940:09

guys don't know what xus is you don't

1940:11

even have to worry about that so I'll

1940:12

just use like npmi and then xuse so it's

1940:15

going install the inside my project and

1940:17

now that's all done so I'll use like npm

1940:19

run Dev and I I'm going to comment this

1940:21

line out and now let me just create

1940:23

another function which will be a PCH

1940:25

data and here we're going to be using

1940:27

the ASN operation once again now let's

1940:29

just use like response and then aw an X

1940:32

use let's just get the from the xus

1940:35

first of all now we can use the get

1940:37

method and so on and so forth so I'll

1940:39

only use the get method and inside this

1940:41

get method I'm going to copy this link

1940:43

and now let me just place that link

1940:44

right here and now we are going to be

1940:46

only returning that response right here

1940:49

okay so yeah or you know it's going to

1940:51

be a response. data to be precise and

1940:54

now we can totally log that to the

1940:55

console now let me go ahead and go to my

1940:57

inspect element once again and go to the

1940:59

console and let's just refresh there now

1941:01

we are getting that data we're also

1941:04

getting that error and so on and so

1941:06

forth so now you get the idea that here

1941:09

you can see we can also use exuse we can

1941:11

use Fetch and we can use a lot of things

1941:14

so this is how the syntax will look like

1941:16

first of all you have to import the use

1941:17

Query and then inside the use Query you

1941:20

going to be providing an object inside

1941:22

this object the first key will be a

1941:24

query key and it's going to take a

1941:26

unique key you can specify like

1941:29

different kind of keys if you wanted to

1941:30

you can proide like even a gibberish if

1941:32

you wanted to and then you have to

1941:34

specify the query function which will

1941:36

allows us to fish your data you can

1941:38

definitely copy this entire thing and

1941:41

you can place it right here but in my

1941:43

case I'm not going to because I know

1941:45

it's going to look a lot ugly and now

1941:47

I'm teaching you all of that stuff so

1941:50

you know what I'm going to have to just

1941:52

uh stick with this convention so then

1941:54

stly done and now that you get the idea

1941:57

that how in the we're going to be

1941:58

fetching our data but now let me show

1942:00

you that we no longer have to create a

1942:03

state for the is lowering like we're

1942:05

going to be writing like uh is loading

1942:07

and we no longer have to create a state

1942:09

for like is error and so on and so forth

1942:12

we can totally destructure that from our

1942:14

10 St query so how in the all we're

1942:17

going to be doing there we can just use

1942:19

this D structure method

1942:20

or syntax whatever you want to call that

1942:23

we can totally destructure the data

1942:25

which will be the actual data which we

1942:27

are now fetching we can also destructure

1942:29

the error and we can also destructure

1942:31

the is lowering and we can do a lot of

1942:33

stuff so now that we successfully

1942:35

destructured them and now we can totally

1942:37

use that right here so if you have some

1942:39

sort of error so I'll use like if it is

1942:41

loading so in that situation we going to

1942:43

be only writing this H1 which will say

1942:45

like Loring dot dot dot and if you have

1942:48

some sort of error so in that situation

1942:49

we be only creating a paragraph it's

1942:52

going to say like an error occurred at

1942:55

this uh location or at this position so

1942:57

right like error. message and now let me

1943:00

just save my file and finally we have

1943:02

our data which we can now render to our

1943:04

UI so I'll just close there and inside

1943:07

this D I'll just write my H1 which which

1943:09

will be a data now underneath there

1943:11

let's just write or pre and here inside

1943:14

there I'm going to be using like json.

1943:16

stringify and here we have to pass our

1943:18

data and null value and also or two okay

1943:21

so now let me just save my file and here

1943:23

you can see we're now getting our data

1943:25

and we have a lot of data right here so

1943:28

we can now scroll through there and now

1943:30

that you get the idea like how the we're

1943:32

going to be using our 10 St query to

1943:34

fetch our data so yeah it is as simple

1943:38

as that let's talk about another Concept

1943:41

in t query which is called the D

1943:42

duplication so the D duplication means

1943:45

that if we try to fish the same data

1943:48

multiple times at once so it will only

1943:50

send one request instead of many D

1943:53

duplication helps avoid asking for the

1943:55

same data over and over again so that

1943:58

was just a quick theory about the D

1943:59

duplication and now let me show you the

1944:01

inaction so here you can see we have our

1944:04

cache which is just an object and now we

1944:07

are going to be using this code to fetch

1944:09

our data so now here you can see we have

1944:12

our use Query inside our use Query we

1944:14

are now passing our query key and for

1944:17

the query key we are now passing a

1944:18

random number then we have query

1944:20

function which will allows us to get a

1944:22

random number so in the first render we

1944:25

are going to be getting this random

1944:27

number which is like

1944:28

0.6 uh 55 and so on and so forth but on

1944:33

the second render what do you expect to

1944:35

get you might be thinking like we are

1944:37

going to be getting some random number

1944:39

once again but no we going to be getting

1944:42

that same number once again and why is

1944:45

there that's because we are now passing

1944:48

that random number as a query key to our

1944:51

use Query so which means like if we

1944:53

already have some sort of a data already

1944:55

available inside our cache it's going to

1944:58

only gives us that already available

1945:00

data but if we specify some other key

1945:03

for our query key then it's going to

1945:05

gives us another kind of random data so

1945:08

if you try there once again like for the

1945:10

third time still we are going to be

1945:12

getting that same response and why is

1945:14

there because it's going to go to the

1945:16

cash it's going to ask from where cash

1945:18

do you have something to share with me

1945:19

and it's going to say yeah I already

1945:21

have this random data it's going to

1945:23

gives us that random data but if we

1945:25

specify some unique key forward query

1945:28

key then it's going to gives us a new

1945:30

random data so that was just the theory

1945:32

of the D duplication and now let me show

1945:34

you the inaction okay guys so now let's

1945:37

see the D duplication in action so I'm

1945:39

going to just create a new folder with

1945:40

the name of components and inside there

1945:42

we're going to be creating a component

1945:44

with the name of D duplication. DSX and

1945:47

I'll use my RFC inside there now let me

1945:50

go ahead and go to my app and just

1945:52

remove that app from there and provide

1945:54

my D duplication come on d d l i c a o

1945:58

and S my file and this is how it looks

1946:00

like right now so the next thing that we

1946:02

have to do that we have to import the

1946:03

use Query from the re query so we import

1946:06

the use

1946:08

Query um we have to import them manually

1946:11

so now let me go ahead and go to the 10

1946:13

St query and then react query and now we

1946:15

have to use that right here so I'll use

1946:17

like the use Query I'm going to execute

1946:19

and now in side there we are going to be

1946:21

providing our object and for this object

1946:23

we're going to be passing a query key

1946:25

and now let me just P like that same

1946:26

code like the random number and now

1946:29

underneath there we are going to be just

1946:30

providing a query function which allows

1946:32

us to generate a random number so I'll

1946:34

give it the name of like Get random

1946:36

number and now let me just Pride my

1946:38

comma there and from here we are going

1946:40

to be restructuring a few things like

1946:42

data and now it's going to be equals to

1946:43

this use Query so now underneath that we

1946:46

have to render or let's just go back for

1946:49

data right here so I'll just use like

1946:50

data and I'm going to say like random

1946:52

number is and now let me just P sa right

1946:55

here sa my file and the final thing that

1946:57

we have to do is that we have to just

1946:58

create this function so that we can see

1947:00

the results all used like this function

1947:03

and inside this function we are going to

1947:05

be only returning the promise so I'll

1947:07

just use like promise. resolve and here

1947:09

let's just pass our math. random now let

1947:12

me just execute this s my file and here

1947:14

you can see we're now getting this

1947:16

random number but now if I go ahead and

1947:18

go to my app component once again and if

1947:20

I just duplicate this of my file here

1947:22

you can see still we are now getting

1947:24

that same number as compared to the

1947:27

first one and why is there that's

1947:28

because of the D duplication and now let

1947:30

me show you the 10 stack query D Tools

1947:33

in action so I'll use like 10 stack

1947:36

query and I'm going to go ahead and go

1947:39

to there and here you can see we have

1947:41

our Dev tools so I'll just choose there

1947:43

and the first thing that we have to do

1947:44

is that we have to install there so I'm

1947:46

going to copy this command and now let

1947:47

me open my terminal and I'm going to to

1947:50

make that a bit bigger and now let's

1947:51

just stop there and here we have to just

1947:53

use this command and hit enter so it's

1947:55

going to install the tquery diff tools

1947:57

inside our project now then you're done

1948:00

I'm going to use npm run once again now

1948:02

let me go ahead and go to my main and

1948:04

here we have to import this so I'll just

1948:07

uh import it right here I'll use like

1948:09

import the react query dep tools and now

1948:12

let me just hit enter so it's going to

1948:14

import it right here next we have to use

1948:16

so that we can see the inaction so I'll

1948:19

use like react query diff tools and now

1948:21

let me just close that and here for the

1948:23

initial is open uh we are going to be

1948:25

setting there to false so now let's just

1948:27

say our file I'm going to open my Local

1948:29

Host right here and here you can see

1948:31

we're now getting our icon so if I click

1948:34

on that it's going to gives us their

1948:35

diff tools right here so we can now

1948:38

filter stuff we can see the sort status

1948:40

we can do a lot of stuff with there like

1948:43

whether something is sted or Not St or

1948:46

something like that so yeah there was a

1948:48

10 St query D tools let's talk about the

1948:50

stale time so the stale time refer to

1948:53

the duration during which the cash data

1948:55

is considered fresh and during this

1948:57

period the data is served from the cach

1948:59

without triggering the background refes

1949:01

which can improve the performance and

1949:03

reduce unnecessary Network request I

1949:06

know that was a lot of gibberish which I

1949:08

just said but you don't have to worry

1949:10

about that so if you get it cool if you

1949:13

don't get it you don't have to worry

1949:15

about it because now I'm going to give

1949:16

you an example which will help you a lot

1949:18

so I want you to imagine for second that

1949:20

you're using some kind of a social

1949:22

network application suppose you're using

1949:24

either Facebook or Instagram or Twitter

1949:27

or X or whatever you want to call that

1949:29

you are using that for 5 minutes so in

1949:32

that 5 minute you are now getting

1949:34

something called the stale data you're

1949:37

now getting that data which is already

1949:39

available inside your cash so stale

1949:42

simply means that you are now getting

1949:44

outdated data but suppose if you want to

1949:47

get a new data so for there you will

1949:50

need to refresh your page so if you

1949:52

refresh your page it's going to give you

1949:54

something called the fresh data which

1949:56

simply means the new data so St data

1949:59

refer to the outd data and fresh data

1950:03

refer to the new data as simple as that

1950:06

so now let me just write some code and

1950:07

then you'll get to know what I'm talking

1950:09

about so now let me show you the stale

1950:11

time in action so I'm going to go ahead

1950:13

and Define another component with the

1950:15

name of St time. TSX and I'll use my

1950:18

rafc inside this go to my app and

1950:21

register this component right here so

1950:23

I'll comment that line out and I'll use

1950:25

my St time and close it save this file

1950:29

so now we are getting a stale time I'm

1950:31

going to also open my Dev tool so that

1950:32

we can see everything a bit better okay

1950:35

so that's tot done and I'm going to go a

1950:37

bit fast because I don't want to waste a

1950:39

lot of your time because we already

1950:40

cover all of that stuff so I'll use like

1950:42

data and then error also there is

1950:45

loading from where from the use Query

1950:48

and now let's just import the from mode

1950:50

H query it's going to take the query key

1950:53

and for the query key we have to specify

1950:55

what to do and I'm going to also provide

1950:57

the query function and here it's going

1950:59

to be set to the fetch data function now

1951:01

let's just sa our file and go back and

1951:04

here we have to create our fetch

1951:05

function Sol use like f data it's going

1951:08

to be equals to this asynchronous

1951:10

function and inside there we have to get

1951:12

our response so we are going to be using

1951:14

the fetch right like so and we're going

1951:17

to be fetching our data from this URL

1951:20

now let's just store that inside the

1951:21

response variable and I'm going to check

1951:23

if you don't have the response. okay so

1951:27

just throw this new error and it's going

1951:29

to say like Network

1951:32

response response was not okay and I'm

1951:36

going to also return the response okay

1951:39

not okay but Jason and this is how we

1951:41

are going to be fishing our data and now

1951:43

let me just also render that data right

1951:45

here but first of all we have to check

1951:47

for the loading there so if you have

1951:48

some sort of a loading instead in this

1951:50

situation we're going to be using H1

1951:52

it's going to say like uh lowering dot

1951:54

dot dot and also we have to check for

1951:57

the error so if we got some sort of

1951:59

error then we're going to be returning

1952:00

this H1 once again and error at this

1952:04

error. message now let's just sa our

1952:06

file and finally we have to render our

1952:08

data so I'll just use my H1 and I'll

1952:11

just write my data and I'm going to also

1952:13

write a pre and here we have to just use

1952:15

our uh what do we call it Json do and

1952:18

now I'm going to close that here we have

1952:19

to specify our data null value and two

1952:22

now let me just sell my file and here

1952:24

you can see we're now getting our data

1952:25

so now let's just refresh there I'm

1952:27

going to also close there for a few

1952:29

seconds so you guys can see everything a

1952:30

bit better so now let me just refresh

1952:32

there and what are we getting we are now

1952:34

getting wor stale data so how do I know

1952:37

this is a stale data here you can see we

1952:40

are now getting our to-dos which means

1952:42

like this is already available inside

1952:44

your cache so if I H my mouse over today

1952:47

it's going to gives us that this is a

1952:49

stale data which means like this is

1952:51

already available inside your cache so

1952:54

if I want to provide my own stale time I

1952:57

can totally do that let's suppose I know

1953:00

that I have some sort of application and

1953:02

which will not fetch our data that

1953:04

quickly so I can totally specify my

1953:06

stale time right here so I'll use like

1953:08

St time and here we can specify our

1953:11

milliseconds and minutes and something

1953:13

like there so I'll only specify like

1953:15

5,000 only wait for 5 seconds and then

1953:19

gives us over St data so now let me just

1953:21

save my file and now let's just refresh

1953:23

there and here you can see it's going to

1953:24

gives us first of all the fresh data for

1953:27

five seconds and after 5 seconds it's

1953:30

going to gives us a stale data or our

1953:32

data will become a stale this is how you

1953:35

can say that so you know what that's a

1953:38

lot of talking so now let me just

1953:40

refresh there once again so currently my

1953:42

data will be fresh and after 5 Seconds

1953:45

my data will become stale so yeah there

1953:48

was a stale time and you can specify

1953:50

like uh 5 million or billion or

1953:53

something like that but in my case I'm

1953:55

going to only specify like 5,000 for 5

1953:58

seconds let's talk about the refetch

1954:00

interval so the refetch interval is an

1954:02

option used to automatically fish data

1954:05

at specified interval so it allows us to

1954:08

keep our data fresh without requiring a

1954:10

minimal intervation so which simply

1954:12

means in some situation we would want to

1954:14

fetch our data after some delay or after

1954:17

some time so for that kind ofu equations

1954:20

you're going to be using the refet

1954:21

interval so you know what let me just

1954:23

show you the inaction then you'll get to

1954:25

know what I'm talking about okay so now

1954:28

let's get into it so the first thing

1954:29

that I want to do is that I want to

1954:30

create my component with the name of

1954:33

refetch

1954:34

interal uh I guess that's going to be

1954:36

fine. TSX so I'll use my rafc inside

1954:39

that go to my app and register that

1954:41

component right here so we have a

1954:44

refresh interval so let's just import

1954:47

that close this save my file and now we

1954:49

are getting our refret interval which

1954:51

means like everything is working the way

1954:53

we exp him to work so first thing first

1954:55

I'm going to go ahead and just Define a

1954:57

St for the current ID then Set current

1955:01

ID and it's going to be equals to the US

1955:03

St and the initial value will be set to

1955:05

one now we are going to be using our use

1955:07

Query to fish our data not queries just

1955:10

a use Query so let's just go back I'll

1955:13

use my use Query and grab that from the

1955:15

10 St query and put the query key and

1955:18

here is going to be to the to-dos or

1955:21

to-do rather and here we are going to be

1955:23

also passing the current ID for The

1955:25

Unique ID okay so let's just provide our

1955:28

comma and provide a query function which

1955:30

allows us to fish our data so I'll use

1955:33

like fish to do and here we have to pass

1955:35

our current ID inside there okay so I'm

1955:38

going to also destructure a few things

1955:39

so I'll just destructure first of all

1955:41

the data then the error and finally the

1955:44

loading so is loading God damn it is

1955:47

loading like so it's going to be coming

1955:48

from the use quy now let me just Define

1955:50

this function right here so I'll just

1955:52

place this coding we are not doing

1955:54

anything crazy but it is now taking ID

1955:57

and now we are passing that ID to that

1955:59

specific to-do and based on that we now

1956:02

getting that specific to-do okay so

1956:04

that's all done so I'm going to also

1956:06

hide there and now let's just use the

1956:07

inside our UI but first of all we going

1956:10

to be using the use effect for the side

1956:12

effect so I'll use like use effect and

1956:15

here uh what I'm going to do is that

1956:18

let's just provide or

1956:20

function and here it's going to take the

1956:22

dependency array of empty dependency

1956:24

array now we have to get the set

1956:26

interval and pass or Arrow function

1956:29

inside there and it's going to say like

1956:31

Set current ID and we have to provide

1956:33

our previous ID that's going to be set

1956:36

to um previous ID is less than 200 now

1956:40

we are assuming that the data which we

1956:42

are now fetching is equal to 200 items

1956:45

but if that's not the case so in in that

1956:48

situation we are going to be using our

1956:49

previous ID plus one but if that's also

1956:52

not the case so we are going to be only

1956:54

returning one okay and here we also have

1956:56

to specify 5 seconds for the interval so

1956:59

I'm going to store the inside a variable

1957:00

so I'll use like interval it's going to

1957:02

be equals to the set interval and

1957:04

finally we have to just uh clean this up

1957:06

so I'll use like return and now inside

1957:10

there we have to use our clear interval

1957:12

and pass our interval inside there so

1957:14

it's going to just clean up our interval

1957:16

or you can say that it's going to

1957:17

unmount our interval so let's just hide

1957:20

there now we have to check for the

1957:22

lowering and also for the errors right

1957:24

so if we have the lading so in that

1957:26

situation we are going to be rning our

1957:27

H1 so let's just use our H1 and it's

1957:30

going to say like uh loading one loading

1957:33

dot dot dot and also we have to check

1957:35

for the error if we got one so in that

1957:37

situation we are going to be returning

1957:39

H1 and error we have to render our error

1957:42

right here okay so that's also done now

1957:44

we have to go to our UI and inside this

1957:47

UI so I'll just write H1 of too and here

1957:50

we have to use our not pre P there we go

1957:54

and render our toos inside this I'll use

1957:56

like uh json. string IFI and password

1958:00

data null value and also second and and

1958:03

then we have to create a button and this

1958:05

Buton will say gives us a next to do and

1958:09

also when somebody clicks on there we

1958:11

are going to be fing this function which

1958:13

will just change the Set current ID

1958:15

inside then we're going to be passing

1958:16

our previous ID come on previous ID and

1958:20

what do we have to do we have to just

1958:22

use our previous ID is less than 200 in

1958:25

this situation we're going to be using

1958:26

our previous ID plus one but if that's

1958:30

not the case we are going to be only

1958:31

using one okay so that's totally done

1958:34

now here you can see we are now getting

1958:36

their data if I click on this button so

1958:38

it's going to giv us another data but in

1958:41

some situation we would want to fetch

1958:43

our data in some specified interval so

1958:46

for this situation we're going to be

1958:48

using another op or another property

1958:50

which is called the refetch interval so

1958:53

I'll use like refetch interval and here

1958:55

we can specify the duration so I'll just

1958:57

use like 5 seconds so now if I save my

1959:00

file and now I'm going to just refresh

1959:02

there and wait for 5 seconds so two 3 4

1959:07

5 and bang it's going to gives us a new

1959:09

data now I can wait for five more

1959:11

seconds and it's going to gives us more

1959:13

data and so on and so forth I'm not

1959:16

clicking on that button it is now

1959:18

refresing that data again and again by

1959:20

itself and that's because of this

1959:23

refetch interal property in some

1959:25

situation we would want to fetch our

1959:26

data from multiple endpoints at once

1959:29

like for example from the to-dos from

1959:31

the comments from the post and so much

1959:34

more so how can you go about doing that

1959:36

by using the 10 St query and 10 St query

1959:40

already have a hook for there which is

1959:42

called the use queries so the use

1959:44

queries is a hook that allows us to

1959:46

execute multiple queries in parallel and

1959:49

manage the result in a unified way this

1959:52

is useful when you need to fish data

1959:54

from multiple sources or end points in a

1959:56

single component but want to handle each

1959:59

query set separately for example loading

1960:01

error data while keeping the queries

1960:04

independent so this is just a use

1960:06

queries and now let me show you how the

1960:08

syntax will look like so first of all we

1960:11

would need to call our use queries H and

1960:14

it's going to also take a object as a

1960:16

perimeter and inside that object going

1960:18

to be passing something called the

1960:20

queries array okay so inside that array

1960:23

we have to specify the query key for

1960:25

each endpoint we are going to be passing

1960:27

an object and inside each endpoint we're

1960:30

going to be passing the query key and

1960:32

some unique key for that query and also

1960:34

a unique function which will allows us

1960:36

to fetch that specific item from that

1960:40

specific Source okay so we can now fetch

1960:42

our data from the todos from the post

1960:44

from the comments and so much more so

1960:47

that was just a theory about the use

1960:49

queries and now let's get into the

1960:50

coding then you will get to know what

1960:52

I'm talking about let's suppose if I

1960:54

want to fetch my data from both of these

1960:56

end points like for example from the

1960:58

post and also from the todos so how in

1961:00

the what we're going to be doing there

1961:02

by using the 10 St query and that's

1961:04

totally simple and easy so the first

1961:06

thing that I want to do is that I want

1961:07

to create another component with the

1961:08

name of uh PCH from multiple and points.

1961:13

TSX and I'll use my RFC inside then now

1961:17

let me go ahead and register there right

1961:18

here so I'll just return my fetch from

1961:21

multiple endpoints and now let me just

1961:23

close this file sa my now let me just

1961:26

close this sa my file close this out and

1961:28

here you can see we now getting one

1961:29

label which means like everything is

1961:31

working the way we expect him to work so

1961:33

what I want to do is that I want to

1961:35

Define two states so I'll use like first

1961:37

of all the current to do ID and then Set

1961:40

current uh to do ID and this going be

1961:43

equals to the US St and the initial

1961:45

value will be set to one okay we're

1961:47

going to be also creating a State for

1961:49

the current post ID so I'll use like

1961:52

post ID and then Set current post ID and

1961:55

can be equals to the use State and the

1961:57

initial value will be also set to one

1962:00

now we are going to be fetching our data

1962:01

from multiple end points by using the

1962:03

use queries H so I'll use like use

1962:06

queries and now if I hit enter so it's

1962:08

going to import the from the 10 St query

1962:11

react JS or react query to be precise

1962:14

okay so now I'm going to execute there

1962:16

and inside there it's going to take

1962:18

object and inside that object we're

1962:20

going to be specifying the queries or

1962:22

maybe this is totally optional but we

1962:24

can totally provide the options for

1962:26

there so in this situation we're not

1962:27

going to be providing any options today

1962:29

but I just provide my object and inside

1962:32

this object now we are going to be

1962:33

passing our queries so I'll use like

1962:35

queries and now here there's going to be

1962:37

an array and inside this array we can

1962:39

specify our end points from where we

1962:41

want to fetch our data so first of all I

1962:44

want to fetch my data from the post then

1962:46

I want to fetch my data from the to-dos

1962:49

so I'll just provide my query key and

1962:50

the query key will be in this situation

1962:52

A toce and also I'm going to specify my

1962:55

function which we did not create not yet

1962:58

but we will create that in a few seconds

1963:00

so I'll use like fetch todos and that's

1963:02

done and now we are going to be also

1963:04

fetching our data from the query keyless

1963:06

just Prov there we are going to be also

1963:07

fetching our data from the post and we

1963:10

are going to be also providing our query

1963:11

function to there so I'll just uh give

1963:13

it the name of like fetch post and now

1963:16

let me just save my file now that we

1963:18

specify your quick iies the next thing

1963:20

that we have to do is that we have to

1963:21

create this function so our Fetch to-dos

1963:23

and also our fetch post I'm going to

1963:25

also store that in some sort of a

1963:26

variable so I'll just give it the name

1963:27

of like um I don't know maybe results

1963:30

would be fine it's going to be equals to

1963:31

this use queries okay now let me go

1963:33

ahead and just create this function

1963:35

right here which one allows us to fish

1963:37

our data so I'll use like fish todos and

1963:40

here there's going to be an asynchronous

1963:41

function so I'll just Mark the as an

1963:43

async function and here this is Fitch

1963:45

over there I'm going to store the inside

1963:46

the response so use like a we and then f

1963:49

F my data by using just a fetch so I'll

1963:51

use like fetch you can also use the X

1963:53

use if you wanted to and now we are

1963:55

going to be fetching our data from this

1963:57

endpoint okay and now let's just check

1963:59

if we don't have response. okay

1964:02

response. okay so in that situation we

1964:04

are going to be throwing a new error and

1964:07

I'll just say like Network response was

1964:10

not okay but if that's not the case we

1964:13

are going to be only returning the

1964:15

response. Json and now let me just

1964:17

execute this sa my file and it's going

1964:19

to allows us to fetch our data from the

1964:22

from this Endo right here let me just

1964:24

highlight that it's going to allow us to

1964:26

fetch our data from only the to-dos now

1964:29

if you want to fetch or data from the

1964:31

fetch post as well so well we have to

1964:34

just create this same function now let

1964:36

me just duplicate that I'm going to

1964:37

change the name of this function to

1964:39

fetch fetch post and now we are going to

1964:41

be also changing there from the Todo to

1964:43

post and that's going to be it that's

1964:45

all the thing that we have to do right

1964:47

now now you can log that on to the conso

1964:49

so I'll just write like console. log of

1964:51

results and I'm going to also provide a

1964:53

bit of separator so if you can see there

1964:55

and I'll just save my file right so we

1964:57

prevented your connection to Json

1964:59

placeholder type code because it was

1965:02

dangerous type malicious this mous

1965:05

software that could harm your data

1965:07

computer on network God damn

1965:11

it you know what uh let me just test

1965:15

this out because I'm not building the in

1965:17

the production but you saw the okay like

1965:20

it this API is not secure so it will

1965:23

install some malicious data in your

1965:26

computer and it will try to hack your

1965:27

computer or maybe I don't know but from

1965:29

my antivirus software but uh you know

1965:33

what now let me just refresh there and

1965:35

here you can see we are now getting two

1965:37

datas so the one will be from the to-dos

1965:40

and if I expand there so here you can

1965:42

see we are now getting different toos

1965:43

and also one will be from that post so

1965:47

now let me just expand there and we can

1965:49

check this data out and these are all

1965:51

the post okay so now I can totally

1965:53

render my data inside my UI so this is

1965:55

how we are going to be fetching data

1965:57

from multiple endpoint and now we have

1965:59

to render the inside our UI so what I'm

1966:02

going to do is that I'm going to just

1966:03

destructure the Todo query and also the

1966:05

post query from where from the results

1966:08

so I'll just uh destructure there from

1966:11

the todos query and also from the post

1966:14

query it's going to be coming from this

1966:16

result so now that we successfully

1966:18

fetched there the next thing that we

1966:19

have to do is that we have to just check

1966:20

for the lowering stad you don't have to

1966:23

do that if you don't want to do that but

1966:25

I want to do that so I'll write my todu

1966:27

query do is Ling and then lowering or

1966:32

post query do is Ling if one of these

1966:35

states are lading so in this situation

1966:37

we are going to be just returning some

1966:39

sort of a lower so I'll just write like

1966:40

lowering dot dot dot and we also don't

1966:43

have to provide these curly braces

1966:44

because we can also do that in one liner

1966:47

so that's tot done we can also check for

1966:49

the errors if you got some so I'll just

1966:51

use like to do query. error or post

1966:54

query. error okay so in this situation

1966:57

we're going to be only returning a div

1967:00

and this div will say like an error

1967:02

occurred or something like that and then

1967:05

we are going to be just rendering our

1967:06

error so to do query. error if we have

1967:09

the error then we want to show only the

1967:11

message of that error but if that's not

1967:14

the case we are going to be also

1967:15

checking for the Post query error if you

1967:17

got the error from there there so in

1967:19

this situation we are going to be

1967:20

getting our message that's also done now

1967:23

finally we have to just extract the data

1967:25

from our post query and also from our

1967:28

to-do query so first of all let me just

1967:30

get the data so I'll just use like uh

1967:32

to-do's query and then we're going to be

1967:34

storing the inside the too come on todu

1967:38

data it's going to be equals to that

1967:39

data now let me just duplicate that and

1967:41

change that to uh post query so I'll use

1967:44

like post query and here we also have to

1967:47

change that to post data now let me just

1967:49

save this file and finally we have to

1967:52

render the inside our UI yes I'll just

1967:54

write my H1 or to do or something like

1967:57

that I'll also write my pre okay because

1967:59

here we're now rendering our data as a

1968:02

Json format so I'll just use like json.

1968:04

stringify and here I can just s like to

1968:07

do data come on it should be one t not

1968:11

twice so I'm going to have to remove one

1968:14

two from there so to do data. find here

1968:17

we have to specify the to-do and then

1968:19

to-do can be basically anything so I'll

1968:21

just write like to-do and any you can

1968:23

specify the type there but I don't have

1968:25

a lot of time so I'll use like to do. ID

1968:28

if that triple equals to that current ID

1968:31

which we are creating right here which

1968:33

is now initially set to one so if that

1968:35

is the case so in that situation what do

1968:37

we have to do we have to return that

1968:39

data I'm going to also specify the null

1968:41

and also the second perimeter for my

1968:43

stringify that's also done and finally

1968:46

we also have to create a button which

1968:47

allows us to get new data so I'll use

1968:50

like button and I'll say like next uh to

1968:53

do and here we going to be also

1968:55

attaching a function but you know we're

1968:57

going to be doing that in a few seconds

1968:58

and here you can see we are now getting

1969:00

our to-dos and this is our first to-do

1969:02

and I'll also provide a bit of styling

1969:03

to this so I don't know maybe background

1969:05

will be set to totally te 300 and the

1969:09

text will be set to totally white maybe

1969:11

and yeah we are getting our button but

1969:13

it should be maybe I don't know maybe

1969:14

700 would be fine okayy 700 and now

1969:18

there looking yeah not better but it is

1969:21

looking looking so yeah I guess that two

1969:24

would be fine and this is looking better

1969:27

now we have to attach a function for

1969:28

this button so when somebody clicks on

1969:30

there then we want to fire this function

1969:32

which is a handle next to do click and

1969:34

now let me copy the name of that go to

1969:36

the top and create that function right

1969:38

here okay so I'll just Define my

1969:41

function we not going to be doing

1969:42

anything crazy but we are going to be

1969:44

just getting new data so I'll just uh

1969:46

write like Set current to do come on set

1969:49

why am I not getting oh this because I'm

1969:51

creating the

1969:53

outside my bad so we have to Define this

1969:55

function right here and I'll use like

1969:57

Set current and I'll use like Set

1970:00

current to do is not post but to do ID

1970:04

and here we have to specify our previous

1970:06

ID and then we are going to be using

1970:08

like med. minimum and provide our

1970:10

previous ID + one and also the produce

1970:13

data. length Okay so what the hell is

1970:16

going on so I'll use like length and now

1970:18

let me just save my file and here you

1970:20

can see the user ID is one and the ID is

1970:22

also one and this is the title but now

1970:24

if I click on there and it's going to

1970:27

gives us a new data but I don't know why

1970:29

it is not giving us there let me just go

1970:31

ahead and go to my console and we are

1970:32

now getting some sort of error I click

1970:34

on there it should be getting us a new

1970:36

data why it's not working so let's just

1970:40

go back a bit I'm going to clear this

1970:43

out and now I want to click on

1970:47

there and it's not working and I know

1970:50

why it's not working because I spend a

1970:52

lot of time figuring out what the hell

1970:54

did I did wrong and here you can see

1970:57

we're now passing a current post ID and

1971:00

it and it shouldn't be a post ID it

1971:02

should be a current too ID now let me

1971:05

just space my current Tod do ID save my

1971:07

file and now let me just refresh there

1971:08

and I want you to watch what happen so

1971:11

if I click on there it's going to giv us

1971:12

the second ID and also it's going to

1971:14

change the title let me just click on

1971:16

there once again it's going to gives us

1971:18

new data anytime I click on there that's

1971:20

totally done but I also want to render

1971:23

my data from the post so it's going to

1971:26

be quite simple and easy so we just have

1971:28

to create H1 once again and I'll also

1971:30

provide a bit of BRS and also HRS right

1971:33

here and I'll just say like this is a

1971:36

post so I'll use like posts and now

1971:38

underneath there we are going to be

1971:40

using our pre once again and now let's

1971:42

just use our json. stringify and here we

1971:45

have to specify our post come on here we

1971:48

have to specify or post. ID post data.

1971:54

find and now here it's going to take a

1971:56

post and that's going to be any and now

1971:58

we are going to be checking if post. ID

1972:00

is triple equals to the current post ID

1972:03

so in this situation we are going to be

1972:05

getting our data I'm going to also

1972:06

specify a n and also second for the Json

1972:09

stringify and it should be inside there

1972:13

there we go so that's all you done and

1972:15

now underneath there we going to be also

1972:17

creating our button so I'll just create

1972:19

that button which will say like next

1972:20

post and now let me just save there and

1972:23

we are not getting anything we are only

1972:25

getting what post to I don't know why

1972:27

but there from here and we have to past

1972:30

that right in here there we go and now

1972:32

let me just close this s my file right

1972:35

now and we are now getting all of our

1972:36

data so now we are getting our to-dos

1972:39

and also we are getting our post but now

1972:41

if I click on that nothing will happen

1972:43

because we have to attach our event

1972:44

handler and also I'm going to just copy

1972:47

all of these styling from there let me

1972:49

just past the styling right here and

1972:51

also when somebody clicks on there we

1972:52

want to fire this function which is a

1972:54

handle next post come on post click okay

1972:57

so now let me just copy a name of there

1972:58

and go to the top and create their

1973:01

function right here so we are not going

1973:03

to be doing anything crazy but I'll just

1973:04

create this function right here and

1973:06

inside this function we are going to be

1973:08

using Set current uh post post ID in

1973:12

this situation now we have to put our

1973:14

previous ID and if m. minimum previous

1973:19

id+ one and also we have to render our

1973:21

post data. length Okay so now let me

1973:24

just save my file and if I click on

1973:26

there so it's going to giv us a new post

1973:27

right here and also if I click on this

1973:30

data so it's going to gives us a new

1973:31

to-do so this is how we are going to be

1973:33

fetching our data from multiple sources

1973:36

or multiple end points at once by using

1973:38

the use queries hook now let's talk

1973:40

about the use mutation hook so the use

1973:42

mutation Hook is used to handle mutative

1973:44

operations so what are mutative

1973:46

operations mutative operations are

1973:49

creating updating or deleting data on

1973:52

either the back end or the remote server

1973:54

so unlike the use Query which we just

1973:56

saw a few seconds ago which is used for

1973:58

fetching or caching the data now we are

1974:01

going to be learning about the use

1974:02

mutation so which is specially designed

1974:04

for actions that changes the data like

1974:07

either create update or delete that

1974:09

specific data so how the syntax will

1974:11

look like first of all we are going to

1974:13

be using the use mutation hook and we

1974:15

are going to be placing a function which

1974:17

allows us to mutate or change that

1974:20

specific data then we are going to be

1974:22

passing an options object and inside

1974:25

there we can pass like on mutate and

1974:27

this function will be called before the

1974:28

mutation function is fired and also we

1974:31

are going to be passing the on error

1974:33

which allows us to handle the error

1974:34

cases then we have the on success which

1974:36

allows us to handle the success cases

1974:38

and also we have the on settled which

1974:41

will be called once the mutation either

1974:43

succeed or fails so that's just a basic

1974:45

theory of what a used mutation is but

1974:48

now let's get into the coding then you

1974:49

will get to know what I'm talking about

1974:51

now let's see the use mutation in action

1974:53

so what I'm going to do is that I'm

1974:55

going to Define another component with

1974:57

the name of

1974:58

mutating data. TSX would be fine I'll

1975:01

use my RFC inside there and register

1975:04

there right in here so I'll use like um

1975:07

mutating data now let me just R it there

1975:10

to the Dom and here you can see we now

1975:12

getting our data which means like

1975:14

everything is working the way we expect

1975:16

him to work so inside there we're going

1975:17

to be first of all getting our query

1975:19

client so I'll use like use Query client

1975:22

let's just get there and I'm going to

1975:23

store that inside the query client

1975:26

function or not a function but inside

1975:28

the query client variable and I'm going

1975:30

to also Define my St so I'll give with

1975:32

the name of like title and then set

1975:33

title and it's going to be equals to the

1975:35

use State and the initial value will be

1975:37

set to empty string this like that now

1975:40

let me go ahead and go to my UI and what

1975:43

I'm going to do is that I'm going to

1975:44

just create my H1 which will be a create

1975:46

new too would be fine and now underneath

1975:49

we are going to be creating our form so

1975:51

this form will not take any action but

1975:53

it will take the on submit so when

1975:55

somebody submit this form we're going to

1975:57

be firing this function which is a

1975:58

handle submit and you know what we're

1976:00

going to be doing that a bit later

1976:02

because now it's going to gives us a lot

1976:03

of Errors so now inside there we are

1976:06

going to be creating our input field

1976:07

with the type of text I'm going to also

1976:09

specify the value and we are going to be

1976:11

getting the title and now let's just

1976:13

past that value inside there okay so

1976:16

we're going to be also passing the own

1976:17

chain

1976:18

so then we're going to be using that set

1976:20

title and here we have to password

1976:22

event. target. value inside there and

1976:26

also for the placeholder we are going to

1976:28

be passing like add or enter and that's

1976:30

St done underneath we are going to be

1976:32

creating our button which will allows us

1976:34

which allows us to add I'm going to also

1976:36

P the type and the type will be set to

1976:38

totally submit come on what the hell

1976:41

submit like that and now if I save my

1976:43

file that's to done and here you can see

1976:45

we are now getting our input field and

1976:47

also our buttons so you know what let me

1976:48

just provide a bit of styling today so

1976:50

for the classes I'll just provide like

1976:52

border it's going to be it yeah I guess

1976:54

that's looking cool and for these

1976:56

styling we're going to be only attaching

1976:58

like background toally black off yeah I

1977:01

guess that that would be fine and text

1977:03

will be set toally white and yeah that's

1977:05

allt cool we don't have to care about

1977:07

the styling for now and now when

1977:09

somebody try to submit this form so I'll

1977:11

use like own submit then we are going to

1977:12

beiring this function which will be

1977:14

which we are going to be creating in a

1977:16

few seconds now let me go ahead and go

1977:17

to the the top and here we're going to

1977:20

be creating that function like handle

1977:21

submit it's going to take that event and

1977:23

it's going to be coming from the re.

1977:25

form event come on like that and that's

1977:29

all done we also have to provide the

1977:31

HTML form element as our generic and now

1977:34

inside there we have to use our event

1977:37

prevent default and that's going to be

1977:39

done we're going to be also checking if

1977:41

the title. trim value like if we don't

1977:44

have any spaces or if you do have any

1977:46

spaces then we are going to be only

1977:48

returning the that's all done and now

1977:50

here we have to somehow mutate our data

1977:54

or send or data send our data like so so

1977:59

how in the world we are going to be

1978:00

doing there let's just see how we can do

1978:02

there the first thing that I want to do

1978:04

is that I want to Define my own

1978:05

interface for the to-do so I'll use like

1978:07

interface to-do and here inside there

1978:10

let's just proide our ID and that's

1978:11

going to be optional and we have to

1978:13

provide a number then we have to provide

1978:14

the title and the title will be string

1978:16

we also have to provide completed and

1978:19

that's going to be a Boolean now let me

1978:20

just save there and now we are going to

1978:22

be using that to do again and again for

1978:24

the typescript so now here we have to

1978:26

use or use mutation which will be coming

1978:29

from the 10 St query so it did not

1978:32

import the okay it did so now we are

1978:34

going to be using that right here so it

1978:36

expect two argument so if I H my mouse

1978:38

over today so it takes the mutation

1978:40

function and also it takes the option so

1978:43

let me just past it right here so now

1978:45

let me put my object and inside this

1978:47

object we going to be placing the

1978:48

mutation function which will allows us

1978:51

to change your data so we are going to

1978:53

be creating this function in a few

1978:54

seconds but I'm going to just space it

1978:56

right here like post the to-do because

1978:58

we want to post that to-do and next we

1979:00

have to provide our options so when we

1979:03

successfully add word to do so in that

1979:05

situation what do we have to do I'll

1979:07

just use something called the query

1979:09

client. invalidate queries so what in

1979:12

the word is that invalidate queries and

1979:14

why should you want to care about that

1979:15

so when a new to do is edit calling the

1979:17

invalidate query and we also have to

1979:19

past the to-dos inside there ensures

1979:21

that the next time you access that to-do

1979:24

they will be fetched from the server

1979:26

including the newly added to-do as well

1979:28

it is just used for the better

1979:29

experience and you don't even have to

1979:31

worry about that so what I'm going to do

1979:33

is that I'm going to just pass my to-do

1979:35

right here which we just created a few

1979:37

seconds ago so we now passing there

1979:39

right here and now we have to store

1979:40

there in some sort of a variable so I'll

1979:43

just give it the name of like result and

1979:45

that's going to be done now we have to

1979:46

create this post to do which allows us

1979:48

to post our data so I'm going to go to

1979:50

the top and now let's just create our

1979:52

post too so I'll use like post too and

1979:54

it's going to take an asynchronous

1979:56

function and now we have to provide a

1979:57

new to-do today and that's going to be

1979:59

that to-do okay so what I'm going to do

1980:02

is that I'm going to just write my aw

1980:04

pit and now we are going to be changing

1980:05

our data from this URL from for/ to Dos

1980:09

okay and also we have to provide our

1980:11

options so we are going to be adding

1980:13

that options in a few seconds but first

1980:15

of all we have to store the inside the

1980:16

response where like so response it's

1980:19

going to be equals to that a and that

1980:21

fetching data and now we have to provide

1980:23

our response and by the way you are not

1980:26

only limited to use the fetch you can

1980:27

use xus you can use whichever kind of

1980:30

solution that you prefer but I'm using

1980:32

the fetch because I know a lot of you

1980:34

know JavaScript but a lot of you don't

1980:36

know what xus and all of that uh new

1980:39

stuff is so that's the only reason I'm

1980:41

using fetch but if you know something

1980:42

else like some other Library you can

1980:44

definitely use that inside your fetching

1980:47

data or mutating data so I'll just give

1980:49

it the option of method and here we have

1980:51

to pass our post as a method and also we

1980:54

have to provide our headers and for

1980:56

these hers we're going to be setting

1980:57

that to content type come on content

1981:01

this going to be set to application SL

1981:03

Json and now for the body we are going

1981:05

to be adding that newly created body so

1981:08

I'll just use like json. stringify and

1981:10

then that new too okay so it should be

1981:13

to do like so there we go and now what

1981:16

do we have to do we we have to check for

1981:18

the response so if we don't have the

1981:21

response. okay so in this situation what

1981:24

we have to do we have to throw a new

1981:26

error so use like throw new error and

1981:29

it's going to say like Network response

1981:32

was not okay but if that's not the case

1981:34

we are going to be only returning

1981:36

response okay and I mean like not okay

1981:39

but uh Jason there we go God damn it

1981:43

Jason Json there we go and now we have

1981:46

to execute there and this is how we are

1981:48

going to be fetching our data first of

1981:49

all we have to tell like where we want

1981:51

to fetch our data then we have to

1981:53

provide which HTTP method we want to use

1981:56

then we also have to provide our hers

1981:58

and finally we have to add a new data

1982:00

which allows us to add a new data so now

1982:03

let me just close there and even I'm

1982:04

going to also close there so it's going

1982:07

to gives us that result and now we are

1982:09

getting a lot of stuff now it is giving

1982:11

us an error so what I'm going to do is

1982:14

that I'm going to add my error or to do

1982:18

there we go so now it's going to just

1982:19

remove that error and now we make

1982:21

console log that result to the console

1982:24

so I'll use like result now let me just

1982:26

close this save my file go into the

1982:28

inspect element go to the console and

1982:30

now let me just refresh there now it's

1982:32

going to give this thir object so inside

1982:34

this object we have the context you know

1982:36

let me just make the a bit bigger so you

1982:37

guys can see everything a bit better so

1982:39

inside there we have our context data

1982:41

error and we have a lot of things but

1982:44

the only thing we are now interested in

1982:46

is only the data

1982:48

also the error and also that muted

1982:50

function by using this muted function is

1982:53

going to allows us to change our data so

1982:56

we would need that error we would also

1982:58

need this muted function and we would

1983:00

need the status so if we can find the

1983:03

okay there we go so we would also need

1983:04

that status as well so now let's just

1983:06

use that I'm going to close that now let

1983:08

me just remove that and here we now

1983:10

going to be destructuring the muted

1983:12

function which will allows us to muted

1983:14

or change our data we also have to

1983:17

access all restructure the error and

1983:19

also the status from the case analysis

1983:21

used there inside where UI but first of

1983:23

all we have to mute it our data so I'll

1983:26

just remove that from here and now we

1983:28

are going to be using that muted

1983:29

function and now we are going to be

1983:30

passing a title the completed flag on

1983:34

the completed will be now set to totally

1983:36

false and now underneath that we have to

1983:38

use our set title and make that as a

1983:40

totally empty string now I'm going to go

1983:42

to the bottom and here we have to do a

1983:44

lot of things so let's just remove there

1983:46

here first of all we have to provide

1983:48

your status so if your status is equal

1983:50

to pending so in this situation we're

1983:53

going to be providing the label of aing

1983:55

do dot dot if that's not the case so

1983:57

I'll just proide like a to do now let me

1984:00

just save my file and now underneath

1984:01

that you also have to take care of the

1984:03

error so if you have some sort of error

1984:05

in this situation we are going to be

1984:06

just writing our H1 and I will say like

1984:09

an error occurred or something like that

1984:12

and now let's just render or error do

1984:14

message right here and now underneath

1984:16

that we also have to check for the

1984:18

stratus once again so if our Stratus is

1984:19

set to success in then situation we are

1984:22

going to be uh just providing a label

1984:24

I'll say like come on successfully there

1984:27

we go and now let me just save my file

1984:29

and now we are going to be adding a new

1984:31

to-do so I'm going to go to the inspect

1984:32

element then I'm going to go to the

1984:33

network Tab and now we are going to be

1984:36

adding a new to-do so I'll just write

1984:37

like new too and now if I click on the

1984:40

add to-do and it's going to gives us the

1984:43

2011 and also the 204 so which means

1984:45

like our new to-do is successfully it

1984:47

right here I'm now providing a new to-do

1984:50

and here you can see it is now set to

1984:52

post we now posting that data to that

1984:54

to-dos and it is now successfully

1984:56

created we can also see the preview and

1984:59

everything is working the way we expand

1985:00

him to work we can also click on these

1985:02

dep tools and here we are going to be

1985:04

going into this mutation and now I'll

1985:06

just add something else like uh

1985:08

something else okay so if I click on

1985:11

there and here you can see it's going to

1985:12

add there right here so if I click on

1985:14

there can see more details right here so

1985:16

variables are title something else and

1985:19

completed is now set to false the

1985:21

context is set to null and we have all

1985:22

of the data which you can see by

1985:24

yourself so that was amazing and this is

1985:28

how we are going to be adding a new

1985:29

to-do by using the use muted hook okay

1985:32

so welcome to the last topic of this

1985:34

course which is called the pagination so

1985:37

let's just create the p a g i n a t i o

1985:39

n penguin. TSX and I'll use my rafc

1985:44

inside then save this file go to the app

1985:46

and register there right here so I'll

1985:48

use like pagination and I'm going to

1985:50

close that save this file and here you

1985:52

can see we're now getting our pagination

1985:54

which means like everything is working

1985:55

the way we expect him to work so the

1985:57

first thing that I want to do is that I

1985:58

want to create my current page so I'll

1986:00

use like uh current page and then Set

1986:04

current page and it's going to be equals

1986:06

to the use State and the initial value

1986:07

will be set to now I mean like one and

1986:11

then we are going to be also creating a

1986:12

page size so I'll use like page size and

1986:14

it's going to be set to 10 pages 10 data

1986:17

page would be fine that's all done now

1986:19

we have to fetch our data by using the

1986:22

use Query so I'll use like use Query not

1986:24

queries but just a God damn it let's

1986:27

just remove the and get our data by

1986:29

using the use Query singular not plural

1986:33

I can't even speak that word and we have

1986:35

to specify the query key and the query

1986:37

key will be set to todos and also the

1986:40

current page and we're going to be also

1986:42

providing our query function and this

1986:45

query function allows us to fetch our

1986:47

data so use like page to do and here we

1986:49

have to pass our current page and also

1986:51

the page size like so and now we have to

1986:54

store them some sort of a variable or

1986:56

you know what we are going to be

1986:57

restructuring our data right away we

1986:59

don't want to store that in the

1987:01

variables because we already know what

1987:02

we are going to be getting so we going

1987:04

to be getting the data also the error

1987:06

and also the is loading from the use

1987:08

Query now let me just create that

1987:10

function so I'll use like con Fage to do

1987:12

and here it's going to it's going to be

1987:14

an asynchronous function so it's going

1987:15

to take a page and the default value

1987:17

will be set to one and it's going to

1987:18

also take the limit and the default

1987:20

value will be set to only 10 okay so now

1987:24

let me just sa my file and now let's

1987:26

just fetch our data so I'll use like a

1987:28

and fetch and here inside there we're

1987:30

going to be doing a pait of magic now

1987:32

that we already know that where we are

1987:34

going to be fetching our data which

1987:35

means like we are going to be fetching

1987:37

our data from this URL so we are going

1987:39

to be fetching our data from the Json

1987:40

placeholder do type I code.com for/ toos

1987:45

and question mark we are going to be

1987:46

getting what data from the page and Page

1987:48

will be now set to this Dynamic page

1987:51

which we are now taking as a perimeter

1987:53

and now we are passing a value for there

1987:56

which is now set to only one okay so we

1987:59

are going to be passing the data to

1988:01

dynamically so I'll use like page and

1988:04

it's going to also take the limit and

1988:06

the limit will also be totally Dynamic

1988:08

so I'll use like limit and this is how

1988:10

we are going to be fishing our data this

1988:12

is going to be the URL by which we are

1988:14

going to be fishing our data and it

1988:16

takes a page like from which page you

1988:18

want to fetch your data so we want to

1988:20

fetch your data from this first page it

1988:22

is now taking this page as a perimeter

1988:24

and we are now providing the default

1988:26

value of one today but we are going to

1988:28

be also changing this page whenever we

1988:30

click on the next button so for there we

1988:32

already Define our state and we've

1988:34

provided the initial value of one today

1988:36

and now we are passing that current page

1988:38

as a first perimeter to this fetch toos

1988:41

and it is now taking there right here

1988:43

and we are also providing the one as a

1988:45

default value today next we have the

1988:47

limit like how much data you want to get

1988:49

from this uh use Fed so we initially

1988:52

specify the initial value of 10 today

1988:54

but we are going to be also change I

1988:56

mean like we are not going to be

1988:57

changing there but the initial value we

1988:58

now specify 10 to there okay and now we

1989:01

are just rendering the 10 item right

1989:03

here so now let me just remove these

1989:04

empty spaces from here because they are

1989:07

annoying and we have to store they in

1989:09

some sort of variable so like response

1989:11

would be fine and now let me just save

1989:13

them and now we have to check so if we

1989:16

don't have the

1989:18

response. okay so in this situation we

1989:20

are going to be throwing a new error so

1989:22

throw throw the

1989:25

th Pro new error is going to select

1989:28

Network response was not okay there we

1989:32

go and return response.

1989:36

Json and execute there now let me just

1989:38

save my file and that's St done now we

1989:41

have to take care of the loading and

1989:42

also the error St so if we have the is

1989:46

loading so in this situation we are

1989:47

going to be returning our H1 and it will

1989:49

select Ling dot dot dot and if we have

1989:52

the error so in that situation we are

1989:54

going to be returning where H1 and I

1989:56

will say like in or you know what just

1989:58

error would be fine and I'll just render

1990:00

my error. message right here save this

1990:03

file now let me go ahead and go to my UI

1990:06

and provide my UI right here so for this

1990:08

H1 I'll select to do and for the pre uh

1990:12

I'll just render my data right here so

1990:14

I'll use like json. stringify and put my

1990:17

data null value and two now underneath

1990:20

that we going to be also creating our

1990:22

previous button and also our next button

1990:24

so I'll just create my div and inside

1990:26

this div we're going to be creating our

1990:28

button which will select previous or

1990:32

previous page and we're going to be also

1990:34

creating yet another button which will s

1990:36

like next uh next page so that's all you

1990:39

done so when somebody clicks on this

1990:41

button so we have to get the previous

1990:44

data so we going to be using like handle

1990:46

previous page and also we have to

1990:49

disable if our current page is equal to

1990:52

one so we are going to be dis disabling

1990:55

that button and also when somebody

1990:57

clicks on this next page button so in

1990:59

this situation we're going to be firing

1991:01

this function which is a handle next

1991:02

page and now let's just create both of

1991:04

these functions right here I'll start by

1991:06

defining this function which is a handle

1991:08

previous page and I'll use like const

1991:10

handle previous page and inside there we

1991:13

have to use our Set current page and

1991:15

here we have to pass our previous page

1991:17

like so now we are going to be using m.

1991:20

maximum or Max here we have to provide

1991:22

our previous page just remove one from

1991:25

there and for the second perimeter we

1991:27

are going to be passing one to there

1991:29

that's only done now we have to create

1991:30

our handle next page and we have to

1991:33

Define there right here so I'll use like

1991:35

cons handle next page and inside there

1991:37

we going to be using our Set current

1991:39

page and it's going to take the previous

1991:41

page and we have to just add one to that

1991:44

previous page so it's going to gives us

1991:46

like basically the next item and it's

1991:48

going to gives us the previous item now

1991:50

we are getting all of their to-dos and

1991:52

we have 10 items right here and you know

1991:55

let's just style these buttons so that

1991:56

we can see them a bit better and I'll

1991:58

provide like I don't know background to

1992:00

T of 300 I guess that's going to be fine

1992:04

and I'm going to also provide margin for

1992:05

the bottom of 10 maybe yeah that's

1992:09

totally looking cool and piring all

1992:12

around will be set to three yep that's

1992:15

looking cool I'm to basically copy all

1992:18

of that styling and put that right here

1992:21

remove that margin for the bottom and

1992:23

change the color to

1992:25

Crimson uh 300 oh not a crimson but I

1992:29

don't know maybe Canan

1992:32

Canan God we have a lot of colors in t

1992:35

CSS and I can't even choose one from

1992:37

them oh my God you know let's just

1992:39

search for a color I guess purple would

1992:41

be fine and yeah we are now getting our

1992:44

purple button which is looking cool if I

1992:46

click on this so load over data now it's

1992:48

going to gives us 11 12 till 20 and now

1992:53

if I click on this previous page so it's

1992:54

going to giv us that 10 and it's going

1992:56

to start from the one and then it's

1992:59

going to go through 10 if I click on

1993:02

there once again it's going to give us

1993:03

20 more item if I click on there once

1993:06

again so it's going to gives us a loader

1993:07

it's going to start from 21 it will go

1993:10

to 30 item and so on and so forth you

1993:13

get the idea so this is how we going to

1993:15

be performing a pagination

1993:17

intense query let's talk about testing

1993:20

so what is testing and why should

1993:22

everyone care about that so testing is

1993:24

the process of checking a program or

1993:26

application to make sure it works

1993:28

correctly it's like double- cheing your

1993:30

work to ensure everything functions as

1993:32

expected so there are a lot of types of

1993:34

testing but in this course we're going

1993:36

to be covering something called the

1993:37

automated testing so there are three

1993:40

flavors or types of automated testing so

1993:43

we have a unit test we have integration

1993:45

test and we have a end and test so let's

1993:48

just break them down one by one the

1993:50

first one we have is a unit testing and

1993:52

this course is totally focused on unit

1993:55

testing so what is a unit testing and

1993:57

why should everyone care about that so

1993:59

unit testing is where developer test

1994:01

individual component of an application

1994:03

like functions or classes to ensure

1994:06

their work is expected and these test

1994:08

focus on small isolated part of your

1994:11

code okay so that was about the unit

1994:14

testing and in this course we're going

1994:15

to be covering a unit testing so next

1994:18

one we have is a integration testing so

1994:20

integration testing or integration

1994:22

testing is about checking how different

1994:25

part of your application works together

1994:27

while unit test focus on individual

1994:29

component which we just saw a few

1994:31

seconds ago integration testing ensure

1994:34

that module database apis and other

1994:37

services interact correctly so that's

1994:39

just the integration testing and we're

1994:42

not going to be covering that in this

1994:43

course and finally we have end to end

1994:45

testing so end to end testing simulates

1994:47

real user scenarios to make sure the

1994:50

entire application work as expected from

1994:53

start to finish and it t the whole

1994:55

system including the front end and also

1994:57

the back end if you are aware of those

1994:59

topics and any external Services which

1995:02

we're not going to be covering like any

1995:03

services and that kind of stuff to

1995:05

ensure everything integrates and

1995:07

functions properly in a real world

1995:08

environment so that was the e2e or end

1995:11

to testing so here you can see I have

1995:14

this application right here which is not

1995:16

looking that cool I know there but this

1995:18

is just an example so if you want to

1995:20

break this down by using an end to end

1995:22

testing so this is how we are going to

1995:24

be breaking this down here you can see

1995:26

we are now testing individual component

1995:28

or just a specific part of this

1995:31

application so this is how we are going

1995:33

to be testing there by using the unit

1995:35

test and what if you want to test that

1995:37

as integration test so if you want to do

1995:39

that so this is how we are going to be

1995:41

testing the the combination of these

1995:42

component and we can see how this

1995:44

component combined together works and

1995:46

and finally we have a end to end testing

1995:48

the back end and the front end and also

1995:50

the services and all of that kind of

1995:52

stuff and we're going to be testing the

1995:54

entire application so that was just a

1995:56

quick theory about what is a testing and

1995:58

now let's talk about the Frameworks and

1996:00

their pros and

1996:02

cons let's talk about the testing

1996:04

framework so there are a lot of testing

1996:06

Frameworks that you can choose from so

1996:08

we have just we have vest Cypress play

1996:11

right mocha chai there are a lot of them

1996:14

but in this course we're going to be

1996:16

only using and we're going to be only

1996:18

focusing on the vest and why is that

1996:21

that's because vest is the fastest it

1996:24

support ecma script it supports

1996:26

typescript and it also supports jsx on

1996:29

the other hand those other Frameworks

1996:31

are also fast but not as compared to the

1996:34

vest and also they support esm but as

1996:38

experimental okay and I'm not sure

1996:40

whether they support typescript and jsx

1996:42

or not but vest does and this is the

1996:45

future so that's why we're going to be

1996:47

focusing on the we test so now let's

1996:50

make a set of four our testing coding

1996:51

Journey so what I'm going to do is that

1996:53

I'm going to open my terminal if I can

1996:56

open that today oh there we go I'm going

1996:59

to use npm create we at latest and let's

1997:03

just hit enter I'm going to give it the

1997:04

name of like uh react or not react not

1997:07

react but unit testing demos okay demos

1997:12

there we go I'm going to choose Vana and

1997:14

then I'm going to choose JavaScript not

1997:17

typescript but JavaScript and now I know

1997:19

a lot of you will ask me hose what the

1997:21

hell why aren't you using a typescript

1997:23

well that's because I'm using a

1997:25

JavaScript because we are now learning

1997:27

about the unit testing and it involves a

1997:29

lot of edge cases so I want to show you

1997:31

that as well and once we jump into the

1997:34

reactjs part then we are going to be

1997:35

using the TSX which means like reactjs

1997:38

with typescript so don't worry about

1997:40

that and if you want to choose

1997:41

typescript you can totally do that but

1997:43

I'm not going to and trust me you're

1997:45

going to love it so let's just choose

1997:47

JavaScript and I'm going to use npmi

1997:49

okay first of all we have to go into

1997:51

that unit testing demos and now let's

1997:53

just use our npmi to install there and

1997:56

now I'm going to open there by using my

1997:58

vs code command which is a code dot so

1998:00

it's going to open there right here so

1998:02

this is how it looks like so I'm going

1998:04

to go ahead and go to my public and

1998:05

remove there then I'm going to go to the

1998:07

SRC and totally delete there and now let

1998:10

me recreate my SRC folder so I'm going

1998:12

to just uh click on that icon and give

1998:14

it the name of SRC and now we have to

1998:17

install the vs what I'm going to do is

1998:19

that I'm going to open my terminal and

1998:21

I'm going to just type like npmi and

1998:23

then DD for the D dependencies and I'm

1998:26

going to give it the name of like vest

1998:28

and let's just set enter so can install

1998:30

there inside our package.json or inside

1998:33

our current repository so I'll just use

1998:36

like package.json right here and here

1998:38

you can see we have our weat and we have

1998:40

our we test with the version of

1998:43

2.1.8 and I'm pretty sure if you are

1998:45

watching this video in in the future so

1998:47

this version will be definitely Chang

1998:50

okay so let's just close there and also

1998:52

I'm going to go into my peg. Json once

1998:54

again I don't know why I just closed

1998:56

there and now let's just create our

1998:57

script so I'll use like test and then we

1998:59

have to just write a v test so now if I

1999:01

save my file and that's it that's it for

1999:04

the setup and now let's just close there

1999:06

okay so now let's write a basic code

1999:08

which we are going to be using inside

1999:10

our testing so I'll just first of all

1999:12

create a file with the name of like

1999:13

Matthew tals U LS JS and now inside

1999:18

there we are going to be doing craziness

1999:20

so first of all I want to create my ADD

1999:22

function and it's going to take the A

1999:24

and B as a perimeter and we just want to

1999:26

plus both of them so that's going to be

1999:28

my ADD function now let's just create

1999:29

our subtract function subtract it's

1999:32

going to also Take the A and B as a

1999:34

perimeter and let's just subtract a from

1999:36

B and we also have to create a multiply

1999:40

and it's going to also take a and b and

1999:42

let's just use a * B I'm going to use a

1999:45

* B and it's going to multiply there and

1999:48

finally we have to create yet another

1999:50

function for the Divide it's going to

1999:51

also take a and b as a perimeters and

1999:53

now let's just use like if our B value

1999:56

is equal to zero so we want to throw

1999:58

some error so I'll use like throw new

2000:00

error and I'm going to select division

2000:03

by zero is not allowed allowed there we

2000:07

go let's just go back save my file and

2000:09

also fin we have to just return or a

2000:12

divide by B now we have to export all of

2000:14

that functions so we can use that in

2000:16

another file so I'll use like export and

2000:18

also export here and also export here

2000:22

and finally for the division function as

2000:25

well so now let me just use there so

2000:26

that we can use this function inside

2000:28

other file so then stly done now let me

2000:31

just close there I'm going to go ahead

2000:32

and go to my root directory and inside

2000:35

there we're going to be defining yet

2000:36

another folder which will be forward

2000:39

test so you can either give it the name

2000:40

of like test and here you can see it's

2000:42

going to change the folder icon and I've

2000:45

personally seen a lot of other

2000:46

developers who uses this convention

2000:48

which is a double underscore which means

2000:50

like Dunder and this is a python thing

2000:53

so you don't have to worry about there

2000:54

and then they just write like test and

2000:56

then double underscore once again so

2000:59

still we are now getting that same icon

2001:00

right here if you prefer this syntax

2001:03

definitely go for there but in my case

2001:05

I'm not going to so I'll just give it

2001:07

the name of like test and hit enter and

2001:10

now inside there we are going to be

2001:11

creating our file so whenever we are

2001:13

creating our test file first of all we

2001:15

have to ask ourselves is that what in

2001:17

the world are we want testing so we are

2001:19

now testing our math utilities folder I

2001:22

mean like math utilities file so in that

2001:24

situation we're going to be creating our

2001:25

file with that same name you don't have

2001:28

to but I wanted to so I'll use like

2001:31

matth tals do

2001:33

test.js okay so whenever you use the DOT

2001:36

test so you are now telling your

2001:38

compiler that this file will be a test

2001:40

file and here you can see we're now

2001:42

getting the test icon so now if I hit

2001:44

enter right here and this is how how our

2001:46

test file will look like before I get

2001:48

into more detail first of all I want you

2001:50

to keep in mind that don't worry about

2001:53

this code which I

2001:56

am uh I am about to write you don't have

2002:00

to worry about the code which I'm about

2002:01

to write because I'm going to explain

2002:03

every single thing about that code in a

2002:05

lot of great detail but you don't have

2002:07

to worry about that so I'm going to just

2002:10

write this code if you want to follow

2002:11

along you can definitely do that but my

2002:13

recommendation will be to do not sweat

2002:15

about this code because we are going to

2002:17

be covering all of them in a lot of

2002:19

great detail so I'll just import first

2002:21

of all something called the describe

2002:23

we're going to be also exporting I mean

2002:25

like importing the it and also the

2002:26

expect function so let's just use our

2002:29

expect and that's it and we also have to

2002:31

import our function so I'll just import

2002:33

something from let's just go ahead and

2002:35

go to our SRC folder and then our math

2002:37

utilities folder and we're going to be

2002:39

importing the add function the subtract

2002:42

function the multiply function and or

2002:44

divide functions okaye so now need I'm

2002:46

going to just write a bit of code so

2002:48

which will be for describe and I'll give

2002:50

it the name of like math utilities and

2002:53

it's going to also take a callback

2002:54

function and I'm going to use my it

2002:56

sytax and it should sum two numbers and

2002:59

now we want to provide our expectation

2003:01

and here we have to call our function

2003:03

which is like two and three as a

2003:04

perimeter and we want this to be five

2003:08

okay so whenever we do this s file and

2003:11

now I'm going to open my terminal and

2003:12

I'm going to only write npm either D or

2003:15

test you can either give it the name of

2003:17

like T or you can also just write a test

2003:19

but in my case I'm going to only write T

2003:21

and if I hit enter right here so so it's

2003:23

going to gives us all of their

2003:24

description so we are now testing this

2003:26

file and our describe function name is a

2003:29

math utilities and we are just providing

2003:31

this one test which is like it should

2003:33

sum two numbers and both of the test are

2003:36

now successfully passing okay so I'm

2003:38

going to just close there and now let's

2003:40

learn about all of that stuff in a lot

2003:42

of great detail we just import a few

2003:44

things from the v test which is the

2003:46

describe it and also the expect so we're

2003:49

going to be learning about all of them

2003:50

in a few seconds but first of all let's

2003:52

start from the first one which is called

2003:54

the describe so what is that describe

2003:56

and why should even care about that so

2003:58

the describe function is used to group

2004:00

related test cases together and it helps

2004:03

organize test into a logical block

2004:05

making the test output more readable and

2004:07

structure and this is totally optional

2004:09

like if you want to provide that you

2004:11

totally can but you don't have to okay

2004:14

so when we want a group related multiple

2004:16

test when we are working with multiple

2004:18

test which we should be so in this

2004:20

situation we are going to be using the

2004:22

describe okay so describe only take the

2004:24

description and also the call back

2004:26

function whenever we are grouping

2004:28

related test cases so in that situation

2004:30

we are going to be using the describe so

2004:32

now let's talk about that it or test so

2004:35

you can either use the it or you can use

2004:37

the test so it describe a specific test

2004:40

case so both the test and it are used to

2004:43

define individual test cases and they

2004:45

work the same way and can be used either

2004:47

one to write a test case so whenever you

2004:50

are defining your test so in this

2004:52

situation we can either use the it or we

2004:54

can use the test something which I'm

2004:56

going to show you in a few seconds but

2004:58

first of all let's just talk about the

2004:59

syntax so we're going to be either using

2005:01

the it or we can use the test both of

2005:03

them will work exactly the same and it

2005:05

also take a description and a callback

2005:07

function so keep in mind whenever you

2005:09

are providing that description you have

2005:12

to provide some sort of a meaningful

2005:13

description for your test cases because

2005:16

later it's going to help you a lot it's

2005:18

not going to only help you but it's

2005:19

going to also help other Engineers when

2005:22

they are working with either your

2005:23

component library or in your project or

2005:26

something like that so that was it about

2005:27

the describing it and now let's talk

2005:29

about the final piece which is called

2005:31

the expect expect is also a function

2005:34

used to make assertion in our test cases

2005:36

and an assertion is a statement that

2005:38

checks if the value meets a certain

2005:40

condition like the equality truthiness

2005:43

fals Etc vs expect to check the result

2005:46

of one test is what we expect it to be

2005:49

so this is how the syntax will look like

2005:51

first of all we are going to be using

2005:52

the expect then we are going to be

2005:54

providing some sort of a value today and

2005:56

then we have different assertions so

2005:58

like we have to be and so on and so

2006:01

forth which we are going to be covering

2006:02

in a lot of great detail in this course

2006:04

so to sum it up this is how exactly our

2006:06

code looks like first of all we are now

2006:09

importing the describe it and expect

2006:11

then we are also importing our function

2006:13

which we want to test now that we know

2006:14

we are going to be testing a lot lot of

2006:16

things so if you want to group this so

2006:18

for that we are going to be using the

2006:19

describe function and then we can

2006:21

provide some sort of a description in my

2006:23

case I provided like math utilities or

2006:25

you can give it any name that you prefer

2006:27

and now inside the describe we are now

2006:29

providing our it function you can either

2006:31

use the it or you can use the test and

2006:33

then you have to specify some sort of a

2006:35

meaningful description for your test and

2006:38

then inside there we are going to be

2006:39

providing our expectation and now inside

2006:41

our expect we are now calling our

2006:43

function and we already know that

2006:46

function tag two perimeter so which

2006:48

means like we are going to be providing

2006:49

either two and three any value that you

2006:51

prefer and then we can specify the

2006:53

output result like what will be the

2006:55

output of that function execution okay

2006:58

so we are now providing like two and

2006:59

three and now we are expecting that to

2007:01

be five and we are also providing minus

2007:03

one and one and we are expecting it to

2007:06

be zero so yeah that was just the basics

2007:09

of describe it and expect and now let's

2007:11

get into the coding and then you will

2007:12

get to know what I'm talking about now I

2007:15

am totally confident because I know that

2007:17

you guys already know this code so I can

2007:19

definitely remove this comment from here

2007:22

save my file and let's get into our

2007:24

testing so I'm going to also just use

2007:25

expect one more time and I'm going to

2007:27

pass my minus one and one and it should

2007:30

be let's just write to be zero okay so

2007:33

let's just say our file and run our test

2007:35

one more time so I'm going to use like

2007:37

npm test and hit enter so it's going to

2007:39

run my test and both of the test are now

2007:41

successfully passing so if I let's

2007:43

suppose change that to maybe I don't

2007:45

know maybe 100 like so and now if I save

2007:48

my file what are we getting we are now

2007:50

getting an error it is expecting five

2007:53

and it got

2007:55

102 okay so this is not allowed combine

2007:58

like both of them like uh 102 so it's

2008:01

going to giv us like 102 and we are now

2008:03

expecting that to be five so this is not

2008:06

fair it's going to give us an error so

2008:08

now uh let's just get it back now let's

2008:11

just test our subtract function multiply

2008:13

function and divide function so now

2008:15

underneath this uh it and by the way I

2008:17

also mentioned there but I want to show

2008:19

you there we can either use the it or we

2008:21

can also use the test so if I copy the

2008:24

name of the test and now we have to

2008:26

place it right here so if I save my file

2008:28

and check this out still all of our test

2008:30

are now successfully passing and every

2008:33

single thing is working the way we

2008:35

expect it to work so you can either use

2008:37

test or you can use the Ed so I'll just

2008:40

remove that test and I'm going to just

2008:41

replace that with it because I love it

2008:45

so if you want to use the test you are

2008:46

more than welcome to do that now let's

2008:48

test our subtract function so I'm going

2008:50

to use that it one more time and it

2008:52

should

2008:53

subtract uh one number from another or

2008:57

from the other would be fine or another

2009:01

you can give it like basically any

2009:02

description that you prefer so I'll just

2009:04

provide my expectation and here we have

2009:06

to call our function and I'm going to

2009:08

provide like five and three and we are

2009:09

expecting the value to be only two so

2009:13

now let me just save my file and here

2009:14

you can see this test is is also passing

2009:17

I also want to show you one more thing

2009:19

now let me go ahead and go to my

2009:20

package.json file and here I'm going to

2009:23

provide a comma this is part our comma

2009:25

and I'm going to just create yet another

2009:27

script which will be a test and then UI

2009:30

and here I'm going to set the to vest

2009:33

and then d-i so now if I save my file

2009:36

and now let me just close this

2009:37

package.json file I'm going to open my

2009:39

terminal once again and hit control C to

2009:42

stop there and now you know let me just

2009:44

delete there so this is uh click on that

2009:46

trash icon and now we are going to be

2009:48

using npm run test and then colon UI so

2009:51

if I hit enter so it's going to ask me

2009:53

like do you want to install there yes of

2009:55

course I want to install there so I'm

2009:56

going to hit why so it's going to set

2009:58

that to yes and now it's going to take a

2009:59

bit of time to install there that's all

2010:02

done and now let me just rerun that

2010:03

command one more time okay so here you

2010:05

can see can it gives us our test UI

2010:08

which means like we can see the result

2010:09

of our test inside our application right

2010:12

here and why is that that's because now

2010:14

we install their dependen see inside

2010:16

your project and if you using a v test

2010:19

so it will be available for you but if

2010:21

you're using like G or mocha or

2010:23

something like that so it will not be

2010:25

available for you so here you can filter

2010:28

your test like you can click on the fail

2010:30

test if you want to check the skip test

2010:31

if you want to check the pass one or the

2010:33

only test so you can totally do that by

2010:36

the way if I click on this math

2010:37

utilities if I click on there here you

2010:39

can see it's going to gives us the code

2010:41

we can see the code we can see the

2010:42

console values and I'm not quite sure

2010:45

what the hell is is this mod module crap

2010:48

but yeah this is also something and we

2010:50

can also click on the report and every

2010:52

test is now successfully passing you

2010:54

know what let me just break some test so

2010:55

I'm going to provide like I don't know

2010:57

maybe five and KN I say there and here

2011:00

you can see one of our test is now

2011:02

breaking and which test is breaking this

2011:04

test is breaking so this test is passing

2011:07

I can't even speak English no more so

2011:09

this test is pcing and this I mean like

2011:12

this test is pcing and this test is now

2011:15

failing so here you can see uh it should

2011:18

sum two numbers and we have our object.

2011:20

is equality so it is expecting zero and

2011:23

we are now receiving or getting four so

2011:26

we can go ahead and go to the code and

2011:28

now we can see our code right here

2011:29

inside this UI or we can go ahead and go

2011:32

to our code and now let me just fix the

2011:34

sem file and here you can see all of our

2011:36

tests are now successfully passing so

2011:38

that's done and that was our UI if you

2011:40

prefer the UI you can totally see your

2011:42

test result inside this UI but if you

2011:45

prefer this terminal you can also see

2011:47

the result of your test inside your

2011:49

terminal so that's done now let's just

2011:52

uh test our multiply function so I'm

2011:54

going to just create yet another test

2011:56

suite and it should

2011:59

multiply uh two numbers come on numbers

2012:02

and here inside there let's just provide

2012:04

our expectation and multiply and let's

2012:07

just multiply 3 by 4 and to be I mean

2012:10

like the expected result to be 12 you

2012:13

can also provide another expect

2012:14

statement like multip mply there and

2012:16

here we can provide like Min - 2 and

2012:18

three and the expected result to be Min

2012:20

- 6 okay so let's just provide this our

2012:23

file and here you can see all of our

2012:25

test are now successfully passing

2012:27

nothing is broken right now if I click

2012:29

on there we can also see the code cool

2012:31

so that was our multiply function this

2012:34

is also create a test for or divide

2012:35

function so it should divide one number

2012:39

by another provide your expectation so

2012:42

let's just use our expect and provide

2012:45

our divide function and let's just

2012:47

divide 6 by 3 and the expected result to

2012:50

be two and I'm going to also provide

2012:53

like expect statement one more time and

2012:55

provide my divide function provide five

2012:57

and two and the expected value to be 2.5

2013:01

okay so let's just save there and once

2013:03

again all of our test are now

2013:04

successfully passing and everything is

2013:06

working the way we exp work let's just

2013:08

take care of that throw I'm going to go

2013:10

into that math utilities and also wanted

2013:13

to check for this error if we got the so

2013:16

you know let me just show you another

2013:17

syntax so I'll use like it should throw

2013:22

new error when dividing d i v ding

2013:26

dividing by zero and here inside the is

2013:29

provide we expect but in this case exped

2013:32

but in this case we're not going to be

2013:33

just calling our function first of all

2013:35

we are going to be using our Arrow

2013:36

function and then we have to call our

2013:38

function and provide our values like 5

2013:40

uh divide by 0 and then we can use

2013:43

another assertion and by the way we are

2013:45

going to be learning a lot of them but

2013:47

you don't have to worry about that so

2013:49

let's just use our two throw and

2013:51

division by zero is not allowed there we

2013:55

go so now this is s our file and here

2013:57

you can see this s is now passing that's

2013:59

only working and I guess that's going to

2014:01

be here so this is how we are going to

2014:02

be creating our function or we can

2014:04

create our classes and then we have to

2014:06

just import the and also we have to

2014:09

import the describe it and expect and if

2014:11

you wanted to combine all of our test

2014:13

cases so for there we are going to be

2014:14

using the the function and then if you

2014:17

wanted to create our T suit so there we

2014:19

are going to be using this it and if you

2014:20

want to provide our expectations so we

2014:22

are going to be using this expect then

2014:24

we have to provide some value and then

2014:26

the resulted value and there are a lot

2014:29

of these to be and to be truthy and

2014:31

falsy and there are a lot of things but

2014:34

yeah we are going to be exploring that

2014:35

in a few seconds all right guys so now

2014:37

let's make a setup for testing

2014:39

challenges or challenging testing

2014:41

whatever you want to call there so now

2014:43

let me just right click on there and

2014:44

open my terminal and I'm going to make

2014:46

it a bit bigger so you guys can see

2014:48

everything a bit better like so and now

2014:50

I'm going to use like npm create one

2014:53

create we at latest and I'm going to

2014:56

choose or you know first of all we have

2014:58

to give it the name of like um testing

2015:01

challenges or something like that I'm

2015:03

going to choose vanilla JavaScript and

2015:05

I'm going to choose JavaScript now let

2015:06

me go ahead and go to the testing

2015:08

challenges and I'm going to use npmi to

2015:10

install all of the dependencies inside

2015:12

there so that's toally done now let me

2015:14

open there in my vs code and this is how

2015:16

it looks like so I'm going to just

2015:17

remove the public folder and I'm going

2015:19

to just remove this entire SRC folder

2015:21

I'm going to recreate there once again

2015:23

now let me go ahead and go to that

2015:24

package.json file and here inside the

2015:27

scripts I'm going to just create another

2015:29

script for testing so I'll just give it

2015:30

the name of like test and here it's

2015:32

going to be equals to only the vest but

2015:34

first of all we also have to install the

2015:36

vest so now let me just close there and

2015:38

open my integrated terminal and I'm

2015:40

going to just write like npmi and then

2015:42

DD and then V so it's going to install

2015:44

that as a y inside my project so that's

2015:48

totally done okay so now that's totally

2015:51

done okay so now I can successfully use

2015:53

like npm to run my test or uh test would

2015:57

be fine so I'll just use like mpmt so we

2016:00

don't have any test so that's why it's

2016:01

going to gives us an error so now let me

2016:03

just stop there okay so here are all the

2016:05

instruction that you have to read and

2016:07

then give it your best sh if you can do

2016:09

it that's completely okay then come back

2016:11

and watch the solution and then I'm

2016:12

going to give you my solution but at

2016:14

least give it your best sh and I'm not

2016:16

going to read through all of that

2016:17

because it's going to waste a lot of

2016:18

your time and this course is super huge

2016:21

I don't want to make that no longer so

2016:23

once again read through all of that give

2016:26

it your best shot if you can't do it

2016:27

that's completely normal and then come

2016:29

back and watch the solution so now here

2016:31

is my solution so what I'm going to do

2016:33

is that I'm going to create a file with

2016:34

the name of like Matthew tales. TS not

2016:37

TS but JS and here we're going to be

2016:39

starting from the factorial and by the

2016:42

way if you guys don't know what a

2016:43

factorial is and recurs is and all of

2016:46

that kind of stuff so you should

2016:47

definitely watch my JavaScript course

2016:49

and also my data structure and algorithm

2016:51

course and you don't even have to know

2016:53

all of that stuff to follow along with

2016:55

this course but I'm just creating these

2016:57

functions so that we can test there so

2016:59

I'll just uh first of all create my

2017:00

factorial it's going to be taking a n as

2017:03

a perimeter and now inside there let's

2017:05

just check if the number is less than

2017:07

zero so in that situation we are going

2017:08

to be throwing new error in which will

2017:10

say like number must be non negative and

2017:14

now underneath that we have just return

2017:16

like if the number is equal to zero so

2017:18

in this situation we are going to be

2017:19

setting there to one but if that's not

2017:21

the case so we are going to be just

2017:22

multiplying there by using this

2017:25

recursion pattern so if you guys don't

2017:27

know what this is you don't even have to

2017:29

worry about that but if you care about

2017:31

it so you can definitely watch my data

2017:33

structure and algorithm course and you

2017:35

know we also have to export this so we

2017:37

can use that in other file case know is

2017:39

create our gcd function it's going to

2017:41

also Take the A and B and now inside

2017:43

there we are going to be first of all

2017:45

check

2017:45

if B is equal to zero so in this

2017:48

situation we're going to be returning

2017:49

the a so now let's just use that

2017:51

recursion once again and we have to

2017:53

password b as a prator like is the first

2017:55

value and then a mod b okay so now here

2017:59

we also have to export that so we can

2018:01

use that in another file and I can

2018:03

totally bet that this function which I'm

2018:05

about to write you already at least

2018:08

heard the name of that which is called

2018:09

the Fibonacci series so I'll just give

2018:11

it the name of like f i b o n a cou c i

2018:15

Fibonacci and here it's going to take a

2018:17

number as a perimeter and inside there

2018:19

first of all we have to check if the

2018:21

number is less than zero so in this

2018:23

situation we are going to be throwing

2018:25

that same error like come on throw new

2018:28

error which will say like number must be

2018:30

non negative EG I and now need that if

2018:34

that's not the case we're going to be

2018:36

creating a sequences so sequin and now

2018:39

for the first index we're going to be

2018:40

providing zero and for the second one

2018:42

we're going to be providing a one okay

2018:44

so now we have to over through this so

2018:46

like let I is equal to 2 I is less than

2018:49

that number which we are now taking as a

2018:51

perimeter and then we have to just

2018:53

increment there so let's just use like

2018:55

i++ and now we have to get the sequence

2018:58

and then we have to push that new number

2019:00

to there so we are going to be using

2019:02

like that same sequence and here we have

2019:04

to provide like i- minus1 plus the

2019:07

sequence and then I minus two in this

2019:10

case now underneath we just have to

2019:12

return the sequence s our file and these

2019:14

are all the functions that we are about

2019:16

to test okay so now let me just hide

2019:18

there hide this function and also this

2019:21

function so now let me go ahead and

2019:23

create my test folder so test and now

2019:26

inside there we're going to be creating

2019:27

our math UT tails. test.js file and

2019:31

let's start from the first one let's

2019:33

just grab first of all the describe

2019:34

function then the it function then the

2019:36

expect function from the v test and now

2019:38

we have to grab our factorial function f

2019:41

t o r i f a t o r i from from where from

2019:47

uh let's just go into the SRC folder and

2019:50

now inside the SRC folder we have our

2019:51

math modules we have to grab the

2019:53

factorial then gcd and also the

2019:56

Fibonacci series now we have to grab

2019:59

that now that we successfully grabbed

2020:00

that the next thing that we have to do

2020:01

is that we have to describe our test

2020:03

Suite so I'll just give it the name of

2020:04

like Matthew tails and now here let's

2020:07

just remove them and I'm going to be

2020:08

providing my first test case which will

2020:10

be like it should come on it should

2020:13

calculate and here we are going to be

2020:15

our expectation so let's just pass our

2020:17

factorial today and if we specify five

2020:20

we want the result to be

2020:22

120 and now let me provide another

2020:25

expectation like if you got some sort of

2020:26

error so I'll just use like factorial

2020:29

once again and provide my minus one and

2020:31

we want to throw a new error so let's

2020:33

just use like to throw and here we are

2020:36

going to be passing like number must be

2020:38

come on let's just go ahead and go to my

2020:40

Matthew tails and I'm going to copy

2020:43

there from there so let me just copy

2020:45

this entire thing from there now let me

2020:47

just paste it right here s our file and

2020:50

I'm going to be using npm to run my test

2020:52

suite and here you can see all of our

2020:54

test are now successfully passing so

2020:56

that's done now let me test this gcd

2020:58

function okay so now underneath there we

2021:00

going to be creating another test Suite

2021:02

which will be like it should calculate c

2021:05

c uh greatest devis right here and we

2021:08

have to provide our expectation call our

2021:10

gcd function Prov 56 and 98 is a WI

2021:15

vales and we want it to be 14 I'm going

2021:18

to duplicate this line of code once

2021:19

again and I'm going to change it to like

2021:22

101 and also 10 so we want there to

2021:25

gives us like one let me just save there

2021:27

test there once again so here you can

2021:29

see this function is also passing or

2021:31

this test Suite is also passing so now

2021:34

let me just hide there and the final

2021:35

thing that we have to do is that we have

2021:36

to test this Fibonacci series okay so

2021:40

let's just create our another test suite

2021:42

and it should Bonacci sequence sequence

2021:46

s EQ U nce and inside they provide our

2021:50

expectation and then call our Fibonacci

2021:52

function and pass Five to there and we

2021:55

want it to be equal if you guys don't

2021:57

know what equal to and then the throw

2021:59

means we're going to be learning all of

2022:01

that in a lot of great details so now

2022:04

let me just pass like if this is five so

2022:06

we are going to be getting like 0 comma

2022:08

1 comma 1 and then two and then three

2022:11

okay and now let me just create another

2022:14

expectation for the error so we are

2022:16

going to be passing like little Nai

2022:17

series and if you pass like minus one so

2022:20

we want to throw a new error like throw

2022:22

an error and we want to say like uh let

2022:25

me just copy there from there like

2022:27

number must be non negative I'm going to

2022:29

copy that and now let me just place it

2022:30

right here I'm going to save this file

2022:32

right now and here you can see all of

2022:34

our tests are now successfully passing

2022:36

and that was it about our math module

2022:38

test cases let's talk about the AAA

2022:42

pattern in testings so what do I mean by

2022:44

AAA a a mean arrange a mean act a mean

2022:48

assert so how that's going to look like

2022:51

this is how it's going to look like so

2022:52

the first step that we have is a arrange

2022:54

and in this step we set up everything

2022:56

needed for the test like variables mock

2022:58

data and Etc you don't know where a mock

2023:01

data is but we are going to be covering

2023:03

that in a lot of great detail in this

2023:05

course then the next thing that we have

2023:07

is a act so act perform the action that

2023:10

you want to test like for example

2023:12

calling a function or doing something

2023:15

and the final step that we have is

2023:16

assert so it verifies that the result of

2023:19

the action is what you expect so you

2023:22

know let me just put the in more simple

2023:24

word so imagine you are baking a cake so

2023:26

in the arrange part you're going to be

2023:28

gathering all the ingredients and tools

2023:30

you need like for example the floor

2023:32

sugar eggs mixing bow Etc and in the egg

2023:36

phase you're going to be mixing those

2023:38

ingredients together and putting the

2023:40

cake in the on and then finally we have

2023:42

the assert so in this phase we are going

2023:44

to be checking if the cake is baked

2023:46

properly by cutting it and then testing

2023:48

it so if the test good and is fully bed

2023:51

you know your steps work so that was

2023:53

just a quick analogy about the a AA so

2023:56

now let me just explain that in the

2023:57

coring so range is when you gather

2023:59

everything you need for the test and act

2024:01

is when you do the action you are

2024:03

testing like calling a function or doing

2024:05

something and then assert is when you

2024:07

check if the result is what you expected

2024:09

like testing the cake to see if it's

2024:11

perfect or not so the first step that we

2024:14

have is arrange range and in this step

2024:16

we going to be collecting or set uping

2024:18

the data so we have two variables Like A

2024:20

and B and both of them have the value of

2024:22

one and then we have the ACT phase and

2024:24

in the ACT phase we're going to perform

2024:26

the action like calling a function here

2024:28

you can see we're now just combining

2024:30

both A and B and storing the inside the

2024:32

result variable and then finally for the

2024:35

assert we have to verify the result so

2024:37

we are going to be just providing what

2024:38

expect and then we can specify our

2024:40

result variable and then finally we we

2024:42

want to expect some sort of a value from

2024:44

there so you want to expect the value of

2024:46

two and this is how it's going to look

2024:48

like so you know what let me just write

2024:49

some code then you'll get to know what

2024:51

I'm talking about I will just remove all

2024:53

of their code and by the way you can

2024:55

find all of their code in my kab

2024:57

repository so I'll also remove them and

2025:01

here I'll just provide like my test or

2025:03

it I'm going to use my it right here or

2025:05

you know let's just provide our test

2025:06

what the hell so it adds numbers

2025:10

correctly come on num numbers correctly

2025:14

in the first part that we have is AR

2025:16

range and in this part we are going to

2025:18

set up the data like so so first of all

2025:21

let's just create our variable like a

2025:23

and a will be equals to one and then

2025:25

let's just create another variable with

2025:26

the name of B and B will be set to one

2025:29

as well okay so now outside from there

2025:31

the next thing that we have to do is

2025:32

that we have to act so like perform the

2025:35

action for example like call the

2025:37

function or combine the value so I'll

2025:40

just use that con result and here is

2025:42

going to be equals to A and B okay and

2025:45

now finally we have to provide our

2025:46

assert so I'll use like assert and here

2025:49

we have to verify the result so I'll

2025:52

just use like my expectation let's just

2025:54

use our expect and we want to provide

2025:56

the result variable and we want the

2025:58

value to be two and now let's just say

2026:00

our file test this out we are now

2026:03

getting an error that's because we have

2026:04

to import the test right here so I'll

2026:07

just use test comma and now here you can

2026:09

see all of our tests are now

2026:10

successfully passing so that was our a

2026:13

AA pattern in testing so you know what

2026:17

let's just undo every single step so let

2026:20

me just undo the God damn it that was a

2026:23

lot of code and let's just undo that

2026:27

there we go so now let's just save our

2026:29

file and there was it about for our math

2026:31

utilities let's just close there and now

2026:33

we are going to be creating yet another

2026:35

file with the name of string utilities

2026:37

or string utils so I'll just give it the

2026:39

name of like string U tales. JS and I'm

2026:42

going to also create a test file for

2026:44

this so give it the name of like string

2026:45

U Tails uh dot. test.js there we go and

2026:50

now here inside this string UT Tails

2026:53

we're going to be creating a few

2026:54

function once again and which will focus

2026:56

on the string so I'll just go ahead

2026:58

first of all and Define my con to upper

2027:01

case and it's going to be equals to the

2027:03

string and here inside there let's just

2027:05

use our string. two upper case let's

2027:08

just say our file and I'll just

2027:10

duplicate that and change that to like

2027:12

to lower case and and I'm going to also

2027:15

change the to lower case and here we are

2027:18

going to be creating yet another

2027:20

function for the reverse so I'll use

2027:21

like cons reverse r e v RS e and it's

2027:25

going to take the string and then

2027:27

outside from there we have to use like

2027:28

st. split we have to split this out then

2027:31

reverse it out and finally we have to

2027:33

join there so we can see all of our

2027:35

result and now we have to create another

2027:37

function for the capital or for the

2027:39

capitalization so I'll use like con

2027:43

capitalize and and I hope the spelling

2027:45

is correct I'm not quite sure about that

2027:48

but here we have to use our or you know

2027:50

what I'm not going to provide that Curly

2027:52

braces so I'm going to use like start do

2027:54

charart add or character at zero and now

2027:57

we have to use the dot two uppercase and

2028:00

execute then I'm going to just add my

2028:02

st. slice off one and then the dot to

2028:06

lower case right here let me just sell

2028:08

my file and that's only done finally

2028:10

let's just export this so we can use the

2028:12

another file okay so this is how we are

2028:14

going to exporting there let's just sve

2028:16

our file and let's just go into our

2028:18

string utilities the first thing that we

2028:20

have to do is that we have to import the

2028:22

describe then we have to import the

2028:24

expect function and then we have to

2028:26

import the it that's done we have to

2028:28

also import our two upper case and also

2028:31

two lower case and all of that stuff so

2028:33

two lower case and then capitalize come

2028:36

on not caption

2028:39

capitalize and also a reverse function

2028:41

from theis Ser file now underneath we

2028:44

have to create our described so let's

2028:46

just provide our described right here

2028:48

and string utilities would be fine and

2028:52

inside there let's just put our test

2028:53

Suite so I'll use like it should return

2028:56

string in uppercase there we go and

2028:59

let's just put our expectation and first

2029:01

of all we are going to be using our two

2029:03

uppercase and pride in lower case hello

2029:06

and we want the value to be upper case

2029:09

Hello so now let me just save my file

2029:11

and everything is running let me test

2029:13

this out so here you can can see we have

2029:15

another test Suite which means like we

2029:17

are now working with this file and which

2029:19

is totally running now if I go ahead and

2029:21

go to my string utilities to upper case

2029:25

if I change that to like um to lower

2029:28

case maybe lower case so my file here

2029:31

you can see where test is now failing

2029:33

and you already know why it is failing

2029:35

it is failing because now we change this

2029:38

code and function does not behave as it

2029:40

used to be so now let me just bring it

2029:42

back and now it is working to only f I'm

2029:44

going to also duplicate that and change

2029:46

that to like word and here let's just

2029:48

change that to word s file yep it is

2029:51

working once again and now underneath

2029:53

there uh we have to create yet another

2029:55

test Fed so it should return string in

2029:57

lower case and now let's just expect uh

2030:01

to lower case or function and here we

2030:03

are going to be passing a hello in

2030:05

uppercase and we want to expect there to

2030:07

be uh lower case hello and I'm going to

2030:10

also duplicate that and change there to

2030:11

like lower case word like so and we want

2030:15

to P the word in upper case there we go

2030:17

so let's just sa our file and here you

2030:19

can see our test is now successfully

2030:21

passing and nothing is going wrong if I

2030:24

go there and change that to like uh to

2030:28

upper case come on upper case there we

2030:31

go s our files you already know this

2030:33

going to give us that error right here

2030:35

because we change this one line of code

2030:37

inside there so yeah that was it about

2030:39

for our expectation now let me just test

2030:42

that capitalized function so it

2030:45

should

2030:46

capitalize first first letter of string

2030:52

there we go Prov our expectation one

2030:54

more time and here let's space our

2030:56

capitalize function and provide our

2030:59

hello inside there and to B and we want

2031:02

the first letter to be uppercase and the

2031:04

rest of them will be lower case so

2031:06

that's exactly what a capitalize mean

2031:08

I'm going to duplicate there and change

2031:10

the to W in upper case and word in lower

2031:14

case I mean like o r l d in lower case

2031:17

and here I'm going to just only past the

2031:18

word and let's just save there character

2031:21

a is not a function what do you mean let

2031:23

me go ahead and go to my T Suite oh J

2031:27

add it should be car add character at

2031:31

and now we test is spacing did you just

2031:33

saw that I just made a typo and told me

2031:36

that you are doing something wrong H you

2031:38

got to fix that so this is exactly what

2031:41

uh unit testing does for us so it should

2031:44

return string reversed there we go and

2031:48

provide our expectation one more time

2031:50

and here we have to call our reverse

2031:51

function M or hello and we want the

2031:54

value to be o like the reverse of the so

2031:59

here you can see it is also ping but if

2032:00

I just provide like a hello it will not

2032:04

pass because the expected value is hello

2032:07

and we are providing ol okay so now let

2032:09

me just change that to o one more time

2032:11

and I'm going to also provide the final

2032:13

expectation so let's just provide a

2032:14

reverse and provide a word inside there

2032:17

and we want that to be DL r o w draw and

2032:23

yeah our test is now successfully

2032:25

passing and this is how we are going to

2032:27

be testing a string utilities and we

2032:29

already saw that this is how we are

2032:31

going to be testing a math utilities

2032:33

like addition subtraction multiplication

2032:35

and you name it next we are going to be

2032:37

testing arrays and that's going to be a

2032:40

lot of fun okay so that's done now let

2032:42

me go ahead and create another f for the

2032:45

string so string UT tails and once again

2032:48

if you are curious like how in the world

2032:50

all of their functions work you should

2032:52

definitely watch my data structure and

2032:54

algorithm course in that we already

2032:56

covered like how we can reverse our

2032:58

string how we can capitalize the word

2033:00

what is a palum and reverse pandrum and

2033:03

so on and so forth so you know let's

2033:05

start from the first one which is called

2033:07

the reverse strings so I'll just export

2033:09

there and then we are going to be

2033:10

creating a reverse string function it's

2033:13

going to take a St as a perimeter and

2033:15

inside there we only have to return the

2033:17

string. split method first of all we

2033:19

have to convert that to the array then

2033:21

we have to reverse that array like all

2033:23

of the content inside that array we have

2033:26

to reverse that and then finally we have

2033:28

to join it back so it's going to gives

2033:29

us the reverse string now let me just

2033:31

save my file and now underneath we have

2033:33

to create here another function which

2033:35

will capitalize our word like Capital Li

2033:39

words and it's going to be equals to

2033:41

this start like it's going to take a

2033:42

string and we have to return or string.

2033:45

replace and come on replace and here

2033:48

we're going to be pasing a Rex which

2033:50

should look something like this now it's

2033:51

going to take a call back function so we

2033:53

are going to be passing our character

2033:55

and then character come on char. two

2033:58

upper okay so we have to just execute

2034:00

our function on there now underneath

2034:02

there we have to use our export cons and

2034:04

then is pum and it's going to be taking

2034:06

a string and inside there we have to

2034:08

first of all create our clean string so

2034:11

I'll just uh create my clean St and here

2034:14

we have to use our start. replace and

2034:16

then we have to use our Rex right here

2034:18

and by the way if you guys don't know

2034:20

what a Rex is you don't even have to

2034:21

worry about that you can just definitely

2034:23

ask CH gbt and it's going to give you

2034:25

all of their rejects okay so now we have

2034:27

to just call over two lower case on

2034:29

there then finally we have to just

2034:30

return like if our clean string is

2034:33

equals to the clean string dos split

2034:35

come on clean string dosit method and

2034:38

now we have to convert there to the

2034:40

array and then we have to reverse It Out

2034:42

by using this reverse function and then

2034:44

finally we have to join that array back

2034:47

so now let's say s our file and these

2034:48

are all the functions that we are going

2034:50

to be testing right now okay so I'll

2034:52

just go ahead and create a new file with

2034:54

the name of string UT tails.

2034:57

test.js okay so now inside there we're

2034:59

going to be importing our describe

2035:01

function we will also import the it and

2035:03

also the expect function and now here we

2035:05

have to import our functions from where

2035:08

from or let's just go ahead and go to

2035:10

the SRC folder and then the string utils

2035:13

folder so just first of all grab the

2035:15

reverse string and also the capitalize

2035:17

word and Isel andrum from there Isel

2035:20

andrum there we go now let me just s

2035:22

there and underneath there we have to

2035:24

create our test Fe by using this

2035:25

describe I'm going to give it the name

2035:27

of like string U Tails U LS there we go

2035:31

and now we have to Define our first test

2035:32

case for reversing our string so I'll

2035:35

just give it the name like it should

2035:36

reverse a string there we go and now we

2035:39

have to provide our expectation and

2035:41

reverse the string which is that

2035:43

function which we just created so we are

2035:45

going to be ping like hello and we want

2035:47

there to gives us the result of uh what

2035:50

do you call it all o there we go now if

2035:54

I save my file and here you can see our

2035:56

test is now successfully passing right

2035:58

here and everything is working the way

2036:00

exp him to work so that's totally done

2036:02

I'm going to hide there and now

2036:03

underneath there we have to create

2036:05

another test Suite so I'll just uh P

2036:07

like it should

2036:09

capitalize uh the words like the first

2036:11

letter will be uppercase and the rest of

2036:13

them will be in lower case I'm going to

2036:15

just P my expectation and then the

2036:17

capitalized word function and we're

2036:19

going to be faing like hello and then

2036:21

word so we want it to giv us like this

2036:24

first letter will be uppercase and the

2036:27

rest of them will be lower case and same

2036:28

will apply for this one like the first

2036:30

letter will be upper case and the rest

2036:32

of them will be lower case so now we are

2036:33

going to be using like to be and here we

2036:35

have to just P like hello and then word

2036:38

let's just say our file check this out

2036:40

here you can see all of our test are now

2036:42

successfully working but now if I change

2036:44

that to like in lower case h here you

2036:46

can see our test will Now fail so that's

2036:49

totally done finally let's just test our

2036:52

palum so it should check come on it

2036:55

should check for pandrum and here we're

2036:59

going to be passing our expectation like

2037:01

is pum and now we are going to be

2037:03

providing this pum like r car and we

2037:06

want it to be true okay just a true and

2037:10

now let's just say our file and here you

2037:12

can see it's going toes St true right

2037:13

here and if I just pass like maybe Apple

2037:17

Apple so so it should fail or test now

2037:20

let me just convert there to the RAR

2037:22

once again and now we're going to be

2037:23

passing like another one is SP and R and

2037:26

I'm going to past like hello in this

2037:27

situation and we want it to be false now

2037:31

if I save my file and all of our test

2037:33

are now successfully passing so that was

2037:36

I don't know what the hell am I doing

2037:38

right now there was or string utils test

2037:42

cases Okay so so let's talk about how we

2037:45

are going to be testing array so I'll

2037:47

write like array UT tales. JS and here

2037:50

we are going to be writing a lot of your

2037:52

Tails so I'll just use first of all

2037:53

export consum it's going to be equals to

2037:56

this array and here let's just use our

2037:58

array. reduce uh yeah reduce function

2038:02

and it's going to take the accumulated

2038:03

value and also the current value so for

2038:06

the rer it's going to giv us the

2038:08

accumulated Value Plus the current value

2038:11

and the result I mean like the starting

2038:12

point will be from the zero so it's

2038:14

going to gives us the sum of that array

2038:16

and also let's just export one more so

2038:18

find maximum value inside your array

2038:22

it's going to take that array and let's

2038:23

just use our math. Max function and

2038:26

spread out our array so it's going to

2038:27

give us the maximum value from that

2038:29

array we going to be also using the find

2038:33

uh Min value as well like find the

2038:35

minimum value inside your array so we

2038:37

are going to be using like meth. Min and

2038:40

spread out our array inside there

2038:42

finally let's just use our con filter E1

2038:45

okay so it's going to also take the

2038:47

array and we are going to be filtering

2038:49

our array by using the filter method and

2038:52

here let's space our call back function

2038:54

and the perimeter we're going to be

2038:55

passing a num and if num mod 2 triple

2038:59

equals to zero so which means like it's

2039:01

going to gives us the E1 value okay so

2039:03

now that's to done and these are going

2039:05

to be all of the function that we are

2039:07

going to be testing right now close

2039:09

there close this file close that file as

2039:11

well and create our test file which will

2039:13

be array

2039:15

yours. js. test.js there we go now

2039:19

inside there let's just do our magic the

2039:22

first thing we would need is a describe

2039:23

function we would also need the it and

2039:25

also the exper now underneath that let's

2039:27

just import our some function come on

2039:30

some from where from the let's just go

2039:32

into the

2039:33

SRC and inside there we have our array

2039:36

array U Tails we're going to be

2039:38

importing the sum the find maximum the

2039:40

find minimum and also the filter E1

2039:43

let's just say our file and let's just

2039:45

Define or describe function okay so here

2039:49

what the hell did I just do provide the

2039:51

name of or not the name but the label of

2039:53

array utilities there we go and let's

2039:56

just provide our first test case we are

2039:58

going to be testing the sum function so

2040:00

it should return uh correct sum of array

2040:06

there we go and provide our expectation

2040:08

and let's just WR our sum value and here

2040:10

we're going to be passing array so let's

2040:12

just use like 1 comma 2 2A 3 and if we

2040:15

combine all of them or sum all of them

2040:18

the result will be 3 + uh 3 so it's

2040:22

going to give us six so we are going to

2040:23

be using like to b six like so and I'm

2040:27

going to also provide another array so

2040:29

I'm going to use like Su and here let's

2040:30

just space like -1 comma - 2 comma -3 so

2040:34

it's going to gives us the6 so let's

2040:37

just use to be 6 minus uh 6 so now if I

2040:40

save my file and test this out so here

2040:42

you can see this is going to to be our

2040:44

string utilities let's just go into our

2040:46

array utilities everything is now

2040:48

successfully passing and you already

2040:50

know why it is passing it is spacing

2040:53

because the resulted value is correct

2040:55

but if I change that to like maybe seven

2040:57

freak out and it's going to gives us an

2040:59

error like wasen what the hell are you

2041:01

doing fix this error God damn it so okay

2041:04

fixing it boss so you know let's just

2041:08

test or another function which is a find

2041:10

maximum value function so we going to be

2041:13

using like should return the

2041:16

maximum value from the array okay so

2041:19

let's just SP our expectation and find

2041:22

the maximum value and our array so 1

2041:25

comma 2 comma 3 and the maximum value we

2041:28

want to expect it to be third value

2041:30

because that's the maximum value inside

2041:32

our array okay so we're going to be also

2041:35

providing our expectation find the

2041:36

maximum value once again and use 10

2041:39

comma 5 comma 100 comma 50 so once again

2041:44

the maximum value you want to expect

2041:46

that to be 100 so let's just s our file

2041:49

and still everything is passing and we

2041:52

already know why it is passing it is

2041:54

passing because the resulted value is uh

2041:56

100 but if I change that to like five

2041:58

save my file and now it's going to freak

2042:00

us out okay so now let's just test those

2042:02

final one I mean like not the final one

2042:05

but the find minimum one so it should

2042:08

return the

2042:09

minimum m i n i m u m minimum min Min

2042:14

and then my mom so it should return the

2042:17

minimum value from array so how that's

2042:20

going to look like well we have to

2042:22

provide our expectation and find the

2042:24

minimum not the maximum find the minimum

2042:26

value and provide our 1 comma 2 comma 3

2042:29

and we already know that the minimum

2042:31

value is one so let's just use comma I

2042:34

mean like do 2b 2B if I can type that

2042:37

today so the minimum value is one and

2042:40

provide our expectation once again find

2042:42

the minimum value once again by using

2042:45

this array so 10 comma 5 uh comma 2

2042:50

comma 100 so I'll just proide like 2 B

2042:54

and -2 so let's just say our file and it

2042:58

is giving us an

2043:02

error oh it is coming from this one so

2043:04

we have to change that to uh 100 I don't

2043:08

know why I forgot that but yeah

2043:10

everything is now passing the way we

2043:12

expect him to pass and that's done so

2043:14

next we're going to be working with

2043:17

objects okay so that was our string util

2043:20

T now let me go ahead and create another

2043:22

file with the name of array UT Tails do

2043:25

uh not TS but JS and here inside there

2043:28

we're going to be creating three

2043:29

function which will be the flaten array

2043:31

intersect array remove duplicates array

2043:34

and then it's going to be add so I'll

2043:36

just start from the first one which is a

2043:38

flat array and basically we're going to

2043:40

be using this function in the upcoming

2043:42

video and uh in which we going to be

2043:44

covering something called the design

2043:46

pattern and we are going to be even

2043:48

building our own design system inside

2043:50

there so we are going to be using this

2043:51

function to flatten our array so we are

2043:53

going to be returning like array. reduce

2043:56

function come on let's just use the

2043:57

reduce and here we have to just pass the

2043:59

accumulator and also the value inside

2044:02

there and now we can use like array do

2044:05

is array which is a built-in function

2044:07

and here we have to just space the value

2044:09

if there is the case in this situation

2044:10

we're going to be getting like

2044:12

accumulated value and then we be

2044:14

concatenating so concat this flat in

2044:17

Array so let's just use the recursion

2044:19

which is called the FL come on F L A TN

2044:22

flat array and here we are going to be

2044:24

placing the value but if that's not the

2044:27

case in this situation we are going to

2044:28

be getting that array and we're going to

2044:30

be concatenating this value inside there

2044:33

and now outside from there we're going

2044:34

to be just passing this array and that's

2044:36

going to be it so that was our first

2044:38

function now let me just collapse there

2044:40

and now we have to create another

2044:41

function which will just intersect our

2044:43

array so we are going to be using like

2044:44

con uh intersect arrays it's going to

2044:48

take the array of one and the array of

2044:50

two inside there we have to return the

2044:52

array of one and use the filter on there

2044:55

and password item as a perimeter now we

2044:58

have to get the array two and then we

2045:00

are going to be checking if it includes

2045:03

that item which we are now taking as a

2045:04

perimeter okay so it's going to

2045:06

intersect our array so now let me just

2045:07

hide there and the final function which

2045:09

we going to be creating will be just to

2045:11

remove the duplicates so I'll use like

2045:13

cons and then remove duplicates and here

2045:16

it's going to take the array and here we

2045:19

have to pass or return and then let's

2045:21

just make a clone off or new and here we

2045:23

have to just use the set data structure

2045:25

which will only gives us the unique

2045:27

values from our list or array okay so it

2045:30

should

2045:31

rmve remove duplicates and now let's

2045:33

just sa our file and now we have to

2045:35

create our test suit for there so now we

2045:38

are going to be using like array UT

2045:39

tails. test.js and inside there we have

2045:42

to first of all import the described

2045:44

function then the it function then the

2045:46

expect function right here underneath

2045:48

that we are going to be importing a lot

2045:50

of stuff from where from let's just go

2045:52

ahead and go to the SRC I'm going to go

2045:55

ahead and go to the SRC then go to the

2045:57

array UTS and now we are going to

2045:59

importing the flatten array we're going

2046:01

to be also importing The Intercept array

2046:03

and finally the remove duplicates array

2046:06

now let me just save my file and now

2046:08

underneath them we have to provide our

2046:09

describe and here I'm going to give it

2046:11

the name of like array U

2046:13

and inside they create our first test

2046:16

case which will be it should flaten l a

2046:19

t and plattin nested nested array and

2046:23

inside there we have to P our

2046:24

expectation like plat in the array

2046:27

inside there we have to just P like

2046:28

nested array so we want provide like one

2046:31

and then two and three now outside from

2046:34

there we going to be providing a four

2046:36

and then like maybe five and then six

2046:39

and we want it to give us the result of

2046:42

this like let's just split in there so

2046:44

we're going to be getting like 1 2 3 4 5

2046:48

and six and now let me test this out so

2046:50

here you can see our test are now

2046:52

successfully passing and now it's going

2046:53

to gives us the same result right here

2046:55

like it will flat in our array now let

2046:57

me just hide there and the next thing

2046:59

that we have to do is that we have to

2047:00

create another test suite for the

2047:02

intersect array so I'll just go ahead

2047:04

and write like it should find

2047:07

intersection of arrays and here inside

2047:10

they provide our expectation and provide

2047:12

our intersect AR array execute there and

2047:14

now we are going to be passing like 1

2047:16

comma 2 comma 3 and then outside from

2047:19

there we are going to be passing yet

2047:20

another array and we are going to be

2047:22

placing like 3 comma 4 comma 5 and we

2047:25

want it to be equal to only three so

2047:28

it's going to give us the intersection

2047:30

of the

2047:32

intersection CCT TI o n there we go now

2047:36

let me just sve my file and here you can

2047:38

see all of our test are now successfully

2047:40

passing I'm going to also hide there and

2047:42

finally we are going to just removing

2047:44

the duplicates from the array so we are

2047:46

going to be using like it should remove

2047:48

duplicates from the array and here let's

2047:51

just SP our expectation and remove

2047:53

duplicates and now we are going to be

2047:54

ping some sort of duplicates like one

2047:56

comma 2 comma 2 once again and then 3

2047:59

comma 4 comma 4 and we want it to gives

2048:02

us the result which will look something

2048:04

like this like 1 2 3 and four now let's

2048:07

just save our file and test this out so

2048:09

here you can see all of our test are now

2048:11

successfully passing and that was our

2048:15

array test cases so now let's talk about

2048:18

how we are going to be testing the

2048:19

object uh tails. JS file so let's just

2048:24

write object U Tails we're going to be

2048:26

also creating uh object ua.

2048:30

test.js okay so I'm going to go ahead

2048:32

and go to my object UTS and create a few

2048:35

UTS functions so I'll use like cons

2048:37

merge objects and it's going to allows

2048:39

us to just merge two objects so I'll use

2048:41

like object one and object two

2048:44

and here inside there let's just use our

2048:46

spread operator and just provide our

2048:48

object one and every single thing inside

2048:51

the object two we want to just combine

2048:54

both of them and it should be uh just

2048:58

obj not with the E so that's done now

2049:02

let's just create yet another one for

2049:03

the Deep clown and if you guys don't

2049:06

know what Json pars and json. string if

2049:08

I means well you don't have to worry

2049:10

about that so I'll use like Json pars

2049:13

and provide my json. string if I inside

2049:15

there and provide my object value inside

2049:18

there which we are now taking as a

2049:19

perimeter I'm going to also create one

2049:21

for the Deep equal and it's going to be

2049:23

equals to this object one and object two

2049:26

and inside there let's just use what

2049:28

jason. string ify and provide our object

2049:31

one inside there if that is equal to the

2049:33

json. stringify and object two let's

2049:38

just proide our object two so it's going

2049:39

to gives us the Deep equal now I'm going

2049:42

to just provide my export so that we can

2049:44

use that in other file that's done now

2049:46

let me go ahead and go to my test file

2049:49

and start testing but first of all we

2049:51

would need to import the describe

2049:53

function and also the it function and

2049:55

also the expect function okay so first

2049:57

of all we have to also import the merge

2049:59

object uh come on

2050:02

m i you can get there today okay there

2050:05

we go so we have our merge object we

2050:07

have our deep clone and we also have our

2050:09

deep equal okay so now we are going to

2050:11

be also importing there now let's just

2050:12

create for test Suite so I'll just

2050:14

proide like object

2050:17

utilities u t i l i t i s there we go

2050:21

and remove this second from there and

2050:23

provide my it statement right here

2050:25

inside there and it should correctly or

2050:28

it should merge two objects would be

2050:30

fine and inside there let's just create

2050:32

our object so I'll use like object one

2050:35

and it's going to just take like a and

2050:37

this going to be set to one and it's

2050:39

going to also take like B and this going

2050:41

to be set to two let me just duplicate

2050:43

there and I'm going to just change the

2050:45

value to like I don't know this one will

2050:46

be three and this one will be set to

2050:48

four and this should be object two now

2050:51

you want to merge there so if you want

2050:52

to merge there for there we are going to

2050:54

be using our merge object function and

2050:56

we are going to be placing our object

2050:57

one and object two inside there and now

2051:00

let's just store the inside some sort of

2051:01

a variable with the name of like merged

2051:03

it's going to be equals to this value

2051:05

now let's just provide our expectation

2051:07

so we want to expect the merged come on

2051:09

m e r g e d there we go merged to be

2051:12

equal

2051:14

to this object like uh it's going to

2051:16

have come on let me just save there so

2051:18

it's going to have like a and a will be

2051:19

set to one and B will be set to three

2051:22

and c will be set to four okay so it

2051:25

will just merge both of these values now

2051:28

you might be thinking like where a

2051:29

second it will not combine them well of

2051:31

course not because we use the spread

2051:33

operator and it's going to overwrite

2051:34

those values so a will be set to one b

2051:38

in this case is now set to two so now we

2051:40

are just merging them so in this case we

2051:43

now changing the B value to four so

2051:45

that's why we are going to be getting oh

2051:47

I just realized that I made a mistake so

2051:49

it's going to be set to B and this one

2051:51

is going to set to C okay so that's

2051:54

totally done so we have a which is now

2051:56

set to one then we have B which is now

2051:59

set to three now we have C which is now

2052:01

set to four now you might be thinking

2052:03

like husan what the hell are you talking

2052:04

about B is not equal to Three B is equal

2052:07

to 2 so we are now merging these both

2052:11

objects so in this case b is to two but

2052:14

now we are merging there so now we are

2052:16

overwriting that value from the B so you

2052:19

know what this is going to be our

2052:20

expectation now let me just save my file

2052:22

and here you can see all of the tests

2052:24

are now successfully passing so now we

2052:25

are working with the object test if I

2052:28

expand there so these are my code and

2052:30

this is my report so also that's toly

2052:32

done so now let's just create another

2052:35

test Suite so what I'm going to do is

2052:36

that I'm going to Define like it should

2052:38

be clown an object and inside there

2052:42

let's just create our object object so

2052:43

I'll give it the name of like original r

2052:45

i o r i g i n a l there we go original

2052:49

IND this can be equals to the A and A

2052:51

will be set to one and B will be set to

2052:53

a nested object which will have the C

2052:55

property and which will be set to two

2052:57

now underneath there let's just make a

2052:58

CL of there by using our deep clown

2053:00

function which we Define so we have to

2053:03

specify our original inside there and

2053:05

I'm going to store that inside the clown

2053:07

variable like so and now here we are

2053:10

going to be providing our expectation so

2053:12

we want to expect the original b. C

2053:14

value which means like that two value to

2053:18

B2 so I'll use like to B and here we

2053:20

have to specify to sem my file and here

2053:23

you can see our test are now

2053:24

successfully passing as you can see

2053:26

there right here okay so that's all

2053:29

you're done but now if I want to like

2053:31

modify that original value okay so if I

2053:33

use like um

2053:36

clown dob do c value if that is equal to

2053:40

three and here we want to use our expect

2053:42

St

2053:43

so let's just remove the and expect that

2053:46

import or expect and here we have to

2053:48

specify our clone. B.C value to B3 as we

2053:53

already know that we are now changing

2053:54

that value right here and we are now

2053:56

changing that from 2 to three so that's

2053:59

why we want to expect that to be three

2054:01

so as you can see right here all of our

2054:03

test are now successfully passing and

2054:05

that is something that we expected so

2054:07

now underneath it I'm going to use like

2054:09

it should uh correctly check deep

2054:14

equality between two objects and now

2054:18

let's just provide a few objects right

2054:19

here so I'll use like cons obj1 and

2054:22

that's going to be set to the a property

2054:23

and a will be set to one and B will be

2054:26

set to the C property and that's going

2054:28

to be the value will be set to two I'm

2054:30

going to duplicate that like three times

2054:31

and change that to like object two and

2054:33

this one to object three and the values

2054:36

will be exactly the same but expect from

2054:38

this one I'm going to change that to

2054:39

three that's done now what I want to do

2054:43

that I want to use like expect

2054:46

expct and provide my deep equal function

2054:49

right here and then we are going to be

2054:50

passing the object one and then the

2054:52

object two inside there and there to be

2054:55

true so it's going to gives us the True

2054:56

Value okay and now let me just duplicate

2054:59

that and change that to false and here

2055:01

we are going to be passing the three

2055:03

value because here we're now changing

2055:05

the three the C value to three so we are

2055:08

now expecting that to gives us the false

2055:10

value so as you can see right here all

2055:12

of our test are now successfully passing

2055:14

change that to true and now let me just

2055:16

save there so it's going to just fail

2055:18

our test and that is something that we

2055:20

don't want so yeah that was just the

2055:23

basics of test so we learn about the

2055:25

describe it expect and we learn about

2055:28

the objects we also learn about arrays

2055:30

math uh in strings and so on and so

2055:33

forth next we are going to be learning

2055:35

about the tdd now we are going to be

2055:37

working with the object UT tails. JS

2055:42

okay so let's start from the first one

2055:44

we have to export cost the Deep merge

2055:47

and it's going to take the object one

2055:50

and it's going to also take the object

2055:52

obj2 and here inside there first of all

2055:54

we are going to be spreading out all of

2055:56

that object so object one and we're

2055:59

going to be storing the inside the

2056:00

result variable and and it should look

2056:02

something like this now we going to be

2056:04

iterating over through our keys so I'll

2056:06

just use like const key inside the

2056:08

object two and let's just check if the

2056:11

object come on object two and now we

2056:14

have to pass our key inside there and

2056:16

the instance of instance of object and

2056:21

the key in object one so in this

2056:24

situation we have to get the result and

2056:26

pass our key inside there and that's

2056:29

going to be equals to our deep merge

2056:30

function now we are calling our function

2056:32

inside our function so this is a

2056:34

recursion and pass our object one and

2056:36

pass our key inside there now we're

2056:38

going to be using our object two and

2056:40

pass our key inside that okay so now for

2056:43

the else class that's not the case in

2056:45

this situation we're going to be getting

2056:47

like the result key that's going to be

2056:48

equals to the object two and pass our

2056:50

key inside there now let me just save my

2056:53

file and I'm going to close there and

2056:55

now underne this full loop we are going

2056:56

to be just returning our result so we

2056:58

can get the result of there now let me

2057:00

just hide there and now we are going to

2057:01

be creating another function which will

2057:03

be our deep Cloud it's going to take the

2057:05

object as a perimeter and now we are

2057:07

going to be only returning our json.

2057:09

parts and here we have to pass our json.

2057:12

string I and only pass our object inside

2057:15

there so that's our deep clone and

2057:17

finally we have to create our flatten

2057:19

object so which will be F A TN that an

2057:22

object and it's going to take the object

2057:23

as a perimeter it's going to also take

2057:25

the prefix like how you want to let in

2057:28

there so now the initial value will be

2057:30

set to empty string and now let me just

2057:32

save there so now inside there we have

2057:34

to first of all create an empty object

2057:36

and store the inside the result variable

2057:38

and next we have to itate over through

2057:40

the key so I'll just use like con key

2057:42

inside the object and inside there let's

2057:44

just first of all get the new key so how

2057:46

in the we're going to be getting there

2057:48

we're going to be checking if we have

2057:49

the prefix in this situation we are

2057:52

going to be just rendering this prefix

2057:55

right here and then Dot and then that

2057:57

key but if that's not the case we are

2057:59

going to be only returning the key and

2058:01

I'm going to store the result of there

2058:03

inside the new key variable which will

2058:04

look something like this and now we have

2058:06

to check if our object and now let's

2058:09

just space our key inside there if our

2058:11

object. key and the type of object come

2058:15

on object key is equal to is equal to

2058:20

the objects in this situation we're

2058:22

going to be making first of all the

2058:23

clone of our result and then we're going

2058:25

to be attaching this Splat in object and

2058:27

this is a recursion now we are using and

2058:29

now let's just pass our object and passw

2058:31

our key inside there and now let's just

2058:33

use our new key like so and I'm going to

2058:36

store the result of there inside the

2058:37

result variable and now let's just save

2058:39

our file we already defined this result

2058:41

right here and now we're assigning this

2058:42

new value to this result variable but if

2058:45

that's not the case in this situation we

2058:47

are going to be getting the result and

2058:48

then the new key and that's going to be

2058:51

equal to the object then key okay now

2058:54

let me just save my file and finally

2058:56

from this for Loop underneath there uh

2058:58

we are going to be returning the result

2059:00

like so and now let's just say our file

2059:02

I'm going to collapse that and now the

2059:04

next thing that we have to do is that we

2059:05

have to test this code I'm going to go

2059:07

ahead and go to my test file and create

2059:09

my object uh UT tails. test. TS or JS

2059:14

rather now let me just save this file

2059:15

and the first thing that we have to do

2059:17

is that we have to get the describe the

2059:18

it and also the expect and now need that

2059:20

we have to get a few function which we

2059:22

just created from the SRC folder and we

2059:26

have to grab that from the object utils

2059:28

so we are going to be getting the Deep

2059:29

merge the Deep clone and also the

2059:32

plattin object so now let's just save

2059:34

there and underneath we have to provide

2059:36

our describe or describe our test weite

2059:39

so I'll just give the name of like

2059:40

object utilities or TS would be fine and

2059:44

Define my first one with like it should

2059:46

deep merge objects and now inside there

2059:49

let's just uh create a few objects I'll

2059:51

just create like a and a will be set to

2059:53

one and then create a b b will be set to

2059:55

a nested object and I'm going to P like

2059:57

the x value of two and I'm going to

2059:59

store that inside the object one

2060:01

variable like so next we have to create

2060:04

another object two it's going to be

2060:06

equals to like B and B will have this

2060:08

nested object with the property of Y and

2060:11

the value of three and I'm going to also

2060:12

pass a c value and this going to be set

2060:15

to four now we going to be providing our

2060:17

expectation like deep merge and here

2060:19

let's just space for object one and also

2060:21

the object two inside there and we want

2060:24

it to be equal to this result like a

2060:27

will be set to one and then B will be

2060:29

set to this nested object like x value

2060:31

will be set to two and the Y value will

2060:34

be set to three outside from there we

2060:36

are going to be passing the C value and

2060:38

that's going to be set to four and now

2060:39

let me just save my file test this out

2060:41

and here you can see our test is now

2060:43

successfully passing and it is working

2060:45

the way we expect him to work so now let

2060:47

me just collapse there and now

2060:48

underneath there we have to test this

2060:50

deep clown function so I'll just go

2060:52

ahead and Define my it like it should

2060:55

deep clown and object and here inside

2060:59

there we are going to be creating first

2061:00

of all our object like the a property

2061:02

will be set to one the B property will

2061:04

be set to nested object and now we're

2061:06

going to be ping a c as a three and yeah

2061:09

I guess that's going to be fine and here

2061:11

let's just store the inside the object

2061:13

variable and we should look something

2061:14

like this now we are going to be

2061:16

clowning there so to clown there we

2061:17

going to be using our deep clone

2061:19

function and pass our object which we

2061:21

just Define right here inside there okay

2061:24

so I'm going to store the inside the

2061:25

clown variable and we should look

2061:27

something like this now we're going to

2061:29

be passing our expectation and P my

2061:31

clone and we want it to be equal I'm

2061:34

going to have to copy this clone and

2061:36

place it right here or you know what it

2061:38

should be just clone so now let me just

2061:41

change that to clone and to be equal to

2061:43

this object underneath that we have to

2061:45

pass our expect word our clone and not

2061:49

to be object so now let's just sa our

2061:52

file and here you can see our test is

2061:54

now successfully passing and this is how

2061:56

our code should work now let me just

2061:58

hide there and the next thing that we

2061:59

have to do is that we have to test our

2062:01

final function which will be a flat in

2062:03

object function so I'm going to go there

2062:05

and here let's just pass or uh test like

2062:08

it should flatten an object and here

2062:11

inside the we going to be first of all

2062:13

creating our object like a will be set

2062:15

to one B will be set to uh yeah the C

2062:18

property of two and I'm going to also P

2062:20

like D and D will be set to this nested

2062:22

e nested object like e will be set to

2062:24

three okay so I'll just P like object

2062:27

and it's going to be not object one but

2062:28

object would be fine and now we have to

2062:30

pass our expectation call our PL object

2062:33

and pass our object inside there and we

2062:35

want that to be equal to this object

2062:38

like a will be set to one and then we're

2062:41

going to be getting like do c property

2062:44

which will be set to two and now we are

2062:45

going to be getting b. d. e property and

2062:49

which will be set to three okay so now

2062:51

let me just proide like three right here

2062:53

and now let me just save my file and

2062:54

test this out so here you can see all of

2062:56

our test are now successfully passing

2062:58

and that was it about our first

2063:00

challenges and that was the basics of

2063:03

testing in v test so we already learned

2063:05

about the AAA now let's talk about the

2063:08

tdd so what is a tdd and why should

2063:11

everyone care about there so TTD or test

2063:14

development is a way of writing your

2063:16

code where you first write a test for

2063:18

your code then write the code to make

2063:20

the test pass and finally refactor your

2063:23

code while keeping your test passing I

2063:26

know there was a lot of gibberish but

2063:27

now let me just break this down for you

2063:29

so how that's going to look like first

2063:31

of all you're going to be writing your

2063:32

test so think about what you want your

2063:34

code to do and then write a test for

2063:37

your code after then run your test but

2063:40

in this case your test will fail because

2063:42

you don't even have your actual code so

2063:44

your test will fail after that you would

2063:46

need to write some code so just write

2063:48

enough code so it will make your test

2063:50

passed after that you have to run your

2063:53

test again and in this case your test

2063:55

should pass because your code works as

2063:57

expected then you have to refactor your

2063:59

code so clean up your code if needed and

2064:02

make sure your test still passed after

2064:05

that repeat that process again and again

2064:07

and this is what we call a tdd if you

2064:09

still don't get it so here is the final

2064:12

definition you would first of all write

2064:14

your test then you would write your code

2064:17

then you would make your test pass

2064:19

refactor your code and repeat there so

2064:21

there was the entire flow of tdd or test

2064:24

driven development so now let me just

2064:26

write some code then you will get to

2064:27

know what I'm talking about okay so now

2064:30

let's just implement the tdd in action

2064:33

so I want you to imagine a scenario

2064:35

where you will create a function which

2064:37

will add two numbers so we already know

2064:40

that how we are going to be doing there

2064:41

we can write a code for there we can

2064:43

write our test cases for there but I

2064:45

want you to just imagine for a second

2064:47

like this is something that we can do uh

2064:50

if you want to do there by using the tdd

2064:52

approach so first of all we going to be

2064:53

creating a test case for there then we

2064:55

are going to be writing a code for there

2064:57

so I'm going to go ahead and go to my

2064:58

test and create my math ut. test.js file

2065:03

so what do we want to do we want to

2065:04

create a function that uh adds two

2065:09

numbers okay so this is what we are

2065:11

going to be doing right now so first of

2065:13

all let's just write a test cases for

2065:14

there so we are going to be importing

2065:16

the describe also the it and also the

2065:18

expect cases so now you need we are

2065:20

going to be using our describe we are

2065:22

now describing the add function and now

2065:24

for the second value let's just remove

2065:26

there and inside there provide our test

2065:28

case right here like it should should

2065:31

add two numbers yeah that would be fine

2065:34

now let's just save there and inside

2065:36

there we are going to be providing our

2065:38

expect case and here let's just say like

2065:40

we are going to be passing our add

2065:41

function which will take like one and

2065:43

two and the result we want to expect

2065:45

there to be three okay so these are just

2065:48

our expectation and of course our test

2065:50

will fail and why is there because we

2065:52

don't even have our add function we did

2065:55

not write any code for that so that's

2065:57

why our test will successfully

2065:59

fa okay so yeah this is just our testing

2066:02

scenario and now let's just write a code

2066:04

for there I'm going to go ahead and go

2066:06

to my SRC file and Define my math

2066:10

.js file right here now we are going to

2066:12

be writing our code and let's just hope

2066:15

it works so we are going to be using

2066:17

like cons and then add will be the name

2066:19

of my function which will take a and b

2066:21

as a perimeter and now we are going to

2066:23

be using Like A and A plus b so it's

2066:26

going to give us the result of the I'm

2066:28

going to export there let's just say our

2066:29

file and import there right here so I'll

2066:32

use that import add from where from

2066:35

let's just go ahead and go to my SRC

2066:37

directory and inside there we have our

2066:39

Matthew Tails check this out yep or test

2066:42

is now successfully passing and it is

2066:44

also passing right here but all of that

2066:48

Cod should be gone let's just refresh

2066:49

there and yeah our test is now

2066:51

successfully passing which means like

2066:53

everything is working the way we expect

2066:54

him to work our test is passing our code

2066:57

is working now it's time to refactor our

2066:59

code that's going to be the third step

2067:01

okay so sometime we would need to

2067:03

refactor our code but in a majority of

2067:06

time we would not so I'll just remove

2067:08

that from here and I'm going to just

2067:10

return like that A plus b but here we

2067:12

are going to be also checking the edge

2067:14

cases that was the only reason I choose

2067:17

JavaScript over the typescript because I

2067:19

want to show you these cases okay so if

2067:21

you weren't using JavaScript I mean like

2067:23

if you weren't using typescript so this

2067:25

is what you would have to do okay so

2067:27

first of all you would have to check

2067:28

like if the type of a is not equals to

2067:32

the number so let's just write the or

2067:35

the type of B does not equals to the

2067:38

number so in this situation we have to

2067:41

throw an error Sol use like throw new

2067:42

error and I'm going to say like both

2067:44

arguments must be numbers and now let's

2067:47

just say our file okay now that we

2067:50

successfully refactor our code so I'm

2067:51

going to go ahead and go to my test

2067:53

cases and provide a bit of test to this

2067:55

so this is going to be our expectation

2067:57

but now let's just provide another test

2068:00

case so it should throw an come on an

2068:04

error if arguments are not numbers and

2068:08

now let's just provide our expect cases

2068:10

so here we already know that we are

2068:11

going to be throwing an error so which

2068:13

means like we have to use our call back

2068:15

function and use our add function and

2068:17

let's suppose we have like one and then

2068:20

two as a string value and we want the

2068:22

result to throw uh th both arguments

2068:27

must be numbers and now let's just say

2068:30

there I'm going to duplicate there a few

2068:31

times so let's just change the first one

2068:33

to be a string so I'll just write like

2068:36

one as a string and I guess that's going

2068:38

to be fine and I'm going to also change

2068:40

that to like uh you know that's going to

2068:41

be fine but I'm going to change this

2068:43

value to now check out my test cases so

2068:45

which means like everything is working

2068:47

the way we exper him to work and yeah

2068:49

everything is now successfully passing

2068:51

so this is how we are going to be

2068:52

performing the tdd and if you want to

2068:55

perform that challenge by yourself you

2068:57

can definitely go ahead and do that

2068:58

challenge by yourself but first of all

2069:00

we are going to be writing a test case

2069:02

then we will write a bit of code to pass

2069:04

that test after there we are going to be

2069:06

writing uh I mean like after that we are

2069:09

going to be checking our test if our

2069:11

test are now successfully passing then

2069:13

if you wanted to refactor our code we

2069:15

can definitely do that but if you don't

2069:18

so we don't have to now let's talk about

2069:20

the matches so far we've been using only

2069:23

the 2B but now we are going to be

2069:25

learning about a lot of matches like

2069:27

we're going to be learning about the

2069:29

equality match truthiness Mech number

2069:32

string object matches and so much more

2069:35

so let's start I'm going to go ahead and

2069:37

Define a file I mean like create a file

2069:39

with the name of matches. test.js

2069:42

and here we are going to be learning

2069:43

about a lot of measures first of all we

2069:46

have to import the expect we also have

2069:48

to import the it okay so we're not going

2069:50

to be writing any describe because we're

2069:51

going to be only learning about the

2069:53

measures and now let's just learn about

2069:55

them so I'll just write like uh it and

2069:59

2B Mech so let's just start from the

2070:01

first one which is called the 2B so you

2070:04

know let me just write a definition of

2070:05

there first of all so we have a 2B and

2070:08

the definition will look something like

2070:10

this it will check for the strict

2070:12

equality like you can think about there

2070:14

is like triple equal to operator as we

2070:17

use in JavaScript so meaning both values

2070:20

must be the same type and value we

2070:24

already discussed that inside the

2070:25

JavaScript so whenever we use like

2070:27

triple equality operator which means

2070:29

like um the value and the type should be

2070:33

the same otherwise it's going to gives

2070:34

us an error so that's exactly what this

2070:37

2B will do for us so I'll just use like

2070:39

con result it's going to be set to f and

2070:42

here we have to just write like expect

2070:44

and then here we have to pass our result

2070:46

right here to be five so now in this

2070:49

case our test will successfully pass as

2070:51

we see there and here you can see let's

2070:53

just refresh there our test will now

2070:55

successfully pass and why is there

2070:58

that's because the value and also the

2071:00

types are totally equal so that's why we

2071:03

are now getting the passing test but now

2071:05

if I change that to like I don't know

2071:06

maybe a string save this file so here

2071:08

you can see where test will Now fail so

2071:11

that was or 2B now let's talk about

2071:13

another one which is called the two

2071:15

equal so let's just write two equal and

2071:18

I'm going to also change the definition

2071:19

of there so I'm going to just remove

2071:21

there and the definition will look

2071:23

something like this it will check for

2071:25

the Deep equality and which means like

2071:27

it compares the values by checking the

2071:32

content of object objects or arrays not

2071:36

just their reference so how that's going

2071:37

to look like let me just change that to

2071:39

like uh 2 equal and I'm going to just

2071:42

remove that from here and I'm going to

2071:44

Define two objects so I'll use like

2071:46

object one it's going to be equals to

2071:48

the name and the name will be set to un

2071:49

my own name and also the ede will be set

2071:52

to 22 I'm going to duplicate there and

2071:54

change the name of there to like two and

2071:56

here we have to pass our object one to

2072:00

be not to be like but to equal to equal

2072:03

as object two so now if I save there

2072:06

let's just refresh there okay now now

2072:08

it's working as you can see our test are

2072:10

now successfully passing because we are

2072:12

now checking both the reference and also

2072:14

the values of these objects right here

2072:17

so we are now checking like expect the

2072:19

object one value or content to be as the

2072:22

object two or to be equal to the object

2072:24

two so let's suppose if I change that to

2072:26

like I don't know maybe 12 and here you

2072:28

can see our test will Now fail and why

2072:30

is that because the content is now

2072:33

different from this object two so that's

2072:35

why we are now getting an error so that

2072:37

was the two equal and now let's talk

2072:39

about the two strict equal Okay so we

2072:41

have another one which is called a too

2072:43

strict and I'm going to also remove the

2072:44

definition of the so it will check for

2072:47

deep equality just like to equal which

2072:51

we just saw a few seconds ago but also

2072:56

consider properties like undefined

2073:00

function and others and other types

2073:04

there are not strict equal in certain

2073:08

cases and now let me just change there

2073:10

to like two strict equal and it will

2073:13

work exactly the same but now let's

2073:15

suppose if I want to change like I don't

2073:16

know maybe the type of the I'm going to

2073:18

change the type of there to like string

2073:21

now let me just save my file and refresh

2073:23

there and here you can see our test will

2073:25

fail and let's suppose if I just add

2073:27

something else like I don't know maybe a

2073:30

something save this file still our test

2073:33

will fail okay so that was it about four

2073:36

the equality measures and you don't even

2073:38

have to worry about that because all of

2073:39

them are now available inside the the

2073:41

vest so you have to just search for

2073:43

there click on the vest and they are

2073:46

available right here so if I go to the

2073:48

guide and we have to go to API and here

2073:52

inside this API uh we have a lot of

2073:55

matches but if I click on there and now

2073:57

we can see those matches right here you

2073:59

have to be to be close and to be defined

2074:02

truthy falsy none and there are a lot of

2074:06

Mees that you can explore by yourself

2074:08

but I'm going to show you those which

2074:10

you will use like a lot of times okay so

2074:13

you know what I'm going to just why did

2074:14

I just delete there I'm going to have to

2074:16

only delete there and also there now

2074:20

let's talk about another one which is

2074:21

called the to be truth so to be t r u t

2074:25

h y this me will check if the value is

2074:28

truthy or falsy if you guys don't know

2074:31

the concept of truthiness and fals in

2074:33

JavaScript so well let me just explain

2074:35

that right here but if you do so you

2074:37

already get the idea so in JavaScript

2074:40

only these way values which I'm about to

2074:42

write are falsey values and other than

2074:45

that every single thing is truthy so

2074:48

these are now the falsey values so false

2074:51

is a falsy value zero is a falsy value

2074:54

uh null is a falsy value empty string is

2074:58

also a faly value and it doesn't matter

2075:00

if you use like uh single quotes or

2075:03

double quotes or B ticks but if they are

2075:05

empty so which means like they are a

2075:07

falcy values uh we have undefined

2075:10

undefined is also falsey and n a n is

2075:13

also a falsey so basically this measure

2075:15

will check whether the value is truthy

2075:17

or falsey if our value gives us the

2075:20

result of any of these so which means

2075:22

like our value is falsy but if our value

2075:25

is not inside this L which means like

2075:28

our value is truth here so now let's

2075:30

just use there so what I'm going to do

2075:32

is that I'm going to use like const

2075:33

value and that's going to be set to like

2075:35

one maybe and now we are going to be

2075:36

expecting the value uh to be truthy and

2075:40

here let's just not pass anything so we

2075:43

already know what a truth in this and

2075:45

false in this means and let me just go

2075:47

ahead and check this out so here you can

2075:49

see our test are now successfully

2075:51

passing and why is then and it should be

2075:54

to be match or to be truthly mat and why

2075:57

is there because one is a truthy value

2076:00

that's why it's going to giv us the

2076:02

passing test but if I change that to

2076:04

like either empty string now our test

2076:06

will fail or if I change that to like

2076:08

zero still our test will fail if I

2076:11

change that like n n and now let's just

2076:13

refresh this still our test will fail

2076:16

okay so that was our to be truthy value

2076:18

or meure whatever you want to call it so

2076:21

that was the to be truthy we also have

2076:24

the to be faly come on to be false C

2076:29

there we go I'm going to select there

2076:31

now it's going to password test and why

2076:33

is there because n n or not number is

2076:36

also a falsy value so that's why our

2076:39

test is now passing and if I just set

2076:41

there to like null maybe let me just

2076:43

change that to null and here you can see

2076:45

still what this is now passing and why

2076:47

is there okay what the hell I just look

2076:50

at those fa icons and I thought like I

2076:52

open the in two times so that's why I

2076:54

Clos them so if I change that like maybe

2076:56

once now our test will fail because one

2076:59

is not a falsey value one is a truthy

2077:02

value that's why we're now getting this

2077:04

error right here now let's talk about

2077:06

the greater and less than and all of

2077:08

that measures so they are a math related

2077:11

matures so what I'm going to do is that

2077:14

I'm going to just write like 10 and here

2077:16

we are now passing that 10 but I'm going

2077:18

to change that to like uh result maybe

2077:20

and here let's just use the to be

2077:23

greater okay so to be greater than five

2077:26

so what are we doing we are now taking

2077:27

this 10 value and we are now passing

2077:29

that right here and we are now checking

2077:31

like is 10 greater than or less than

2077:34

five okay so if it is greater than five

2077:37

so it's going to gives us check but if

2077:39

that's not the case so it's going to

2077:40

gives us F our test is now successfully

2077:43

passing because 10 is greater than five

2077:46

that's why our test is now successfully

2077:48

passing but if I change that to like to

2077:50

be less than five less than yeah so our

2077:54

test will Now fail so we have like uh to

2077:57

be less than or equal to and we also

2077:59

have to be greater than or equal to so

2078:01

let me just use like to be less than

2078:05

come on less than or equal oh I'm using

2078:08

H en should be a n to be be less than or

2078:13

equal to 5 so now we are checking like

2078:16

is 10 greater than I mean like 10 less

2078:18

than or equal to 5 or not and here you

2078:21

can see it's going to fail because 10 is

2078:23

not less than 5 or equal to 5 10 is 10

2078:27

10 is not neither less nor equal to five

2078:30

so that's why our test is now failing so

2078:31

if I use like to B greater or equal now

2078:35

if I save my file and now if you check

2078:37

this out so our test are now

2078:38

successfully passing and why is there

2078:40

because 10 is greater than or equal to

2078:43

five okay so that's them and there are a

2078:46

lot of measures that you can explore by

2078:48

yourself and now let me show you one

2078:50

more which is called the two content and

2078:52

which is related to the string so I'm

2078:54

going to go ahead and remove that and

2078:56

I'm going to just Define that result uh

2078:58

variable once again and I'm going to

2079:00

only provide like hello comma word right

2079:02

here and now we are going to be using

2079:04

the mech which is called the two contain

2079:07

and here let's just provide our hello

2079:09

right here so what is this two contain

2079:11

contain does these two contains will

2079:13

check the result and it's going to check

2079:15

for a specific value inside that string

2079:19

so is this value available inside the

2079:21

string or not yes of course hello is

2079:24

already available inside the result so

2079:26

it's going to pass our test as you can

2079:28

see right here so now our test is now

2079:30

successfully passing but now if I just

2079:32

WR like my own name maybe husan and here

2079:35

you can see the test is now failing why

2079:37

is there because hosan is not available

2079:40

inside the string and that's why it will

2079:42

not gives us the value of there there is

2079:45

also yet another one which is called the

2079:48

to match so I'm going to use like to

2079:50

match it's going to take a regular

2079:51

expression or Rex for short if you guys

2079:54

don't know what a Rex means you don't

2079:56

even have to worry about it so I'm going

2079:58

to just write like uh search for this

2080:00

entire string and search for only this

2080:03

word and I'm going to also provide I if

2080:05

that is either lower case or upper case

2080:08

then pass or you know we don't have to

2080:09

provide this I right here so I'm going

2080:11

to just uh provide this word so we want

2080:14

you to search for this entire string and

2080:17

inside that string we want to search for

2080:19

the word and our test will fail why is

2080:21

that because here you can see the W is

2080:24

lower case but if you just put there as

2080:26

a upper case and refresh there and here

2080:28

you can see we're now ping uppercase W

2080:31

and it should be World there we go God

2080:34

damn it now here you can see our test is

2080:36

now successfully passing so that's done

2080:39

now let's talk about the two equal one

2080:42

we have another one which is called the

2080:43

to have the property and we usually use

2080:46

that for the objects like is the object

2080:48

have a certain property or not so what

2080:51

I'm going to do is that I'm going to

2080:52

just remove that from here and I'm going

2080:53

to use like const object and here inside

2080:56

this object I'm going to put like name

2080:58

and name will be my own name so I'm

2081:00

going to use like hosan age of 22 let's

2081:03

just save this file and now Neath there

2081:06

here we have to provide our expectations

2081:07

so I'll use like expect C expect there

2081:10

we go go and provide our objects inside

2081:13

there and now let's just use to have

2081:15

property and then here we have to

2081:17

provide the property name like name is

2081:20

this name property available inside this

2081:23

object or not if it is available so it's

2081:25

going to gives us I like it's going to

2081:27

pass our test but if it is not available

2081:29

so it's going to fail our test here you

2081:31

can see our test is now passing but if I

2081:33

let's suppose search for the location

2081:35

and save this file and now it's going to

2081:37

gives us an error because location

2081:39

property is not available inside this

2081:41

object and we also have a few more

2081:43

methods like to be defined and to be

2081:45

undefined so let's suppose you want to

2081:47

search for this value is this value

2081:50

defined or undefined so I'm going to use

2081:52

like do name and here I'm going to use

2081:55

like to be undef or to be defined rather

2081:58

and I'm going to execute there and it

2081:59

will pass our test because this name

2082:02

value is defined inside this object and

2082:05

now here you can see our test is now

2082:07

successfully passing but if I change

2082:09

that to like to be UND find and save my

2082:12

file and now it's going to gives us an

2082:13

error so yeah that was a lot of meches

2082:17

and once again you can check all of

2082:18

these out by yourself and they are a lot

2082:22

and I mean they are a lot okay now let's

2082:25

talk about the positive and negative

2082:27

testing so let's start from the first

2082:29

one which is called the positive testing

2082:31

so it will check if the system behaves

2082:32

as expected when provided with the valid

2082:35

inputs so in positive testing you are

2082:37

testing the system with correct or valid

2082:39

inputs ensuring that the system function

2082:41

as expected when used correctly so on

2082:44

the other hand we have a negative

2082:45

testing so it will check if the system

2082:47

handles invalid or unexpected inputs

2082:50

correctly in negative testing you are

2082:52

providing an incorrect or invalid inputs

2082:54

to ensure that the system can handle

2082:56

error scenarios gracefully and it

2082:59

doesn't crash or behaves unexpectedly so

2083:02

that was just the definition of a

2083:03

positive and negative testing so how

2083:05

that's going to look like first of all

2083:07

we have our add function which takes

2083:09

like a and b as a perimeter and now we

2083:11

are checking like if a is not number or

2083:13

if the type of B is not number so in

2083:15

this situation we want to throw an error

2083:17

which will say like both input must be

2083:19

numbers and then finally we are just

2083:21

returning a plus b and that's our

2083:23

function now if you want to provide a

2083:25

positive testing for there so we are

2083:27

going to be providing a valid inputs

2083:29

like passing three and five and we are

2083:31

now expecting that to gives us the

2083:33

result of ADD and 3 + 5 will gives us

2083:36

add and then we are providing a 10 and

2083:38

20 n is going to gives us 30 now we

2083:41

providing 0 and zero so it's going to

2083:42

gives us zero and that was our positive

2083:45

testing but now let's talk about the

2083:47

negative testing so here you can see we

2083:49

are now providing a negative values like

2083:51

three and also five but five is now a

2083:54

string value but if that is the case so

2083:57

we want to just throw an error which

2083:58

will say like both inputs must be

2084:00

numbers and here you can also see like

2084:02

we're now providing a as a string and we

2084:05

are providing a five as a second value

2084:07

so still we are going to be saying like

2084:09

both inputs must be number numbers and

2084:11

now here you can see for the third one

2084:13

we are now providing an undefined know

2084:15

so in that situation we going to be

2084:17

throwing an error once again so that was

2084:19

just a quick theory about the positive

2084:21

and negative testing so now let me just

2084:23

write some code then you'll get to know

2084:25

what I'm talking about let me go ahead

2084:27

and go to my math and here you can see I

2084:29

have exactly that same function which is

2084:32

now checking like the a perimeter and

2084:34

also the B perimeter and also just

2084:36

finally returning a plus b now let me

2084:38

provide a few test cases for the like

2084:40

the valid and invalid or positive and

2084:42

negative testing so I'll just use like

2084:44

math. test.js file and now let's just

2084:47

import our describe function or it

2084:50

function and also our expect function

2084:52

expect there we go and we would also

2084:54

need to import our add from where and

2084:58

from our math module let's just go to

2085:00

our SRC and math now here we are going

2085:03

to be describing our function so I'll

2085:05

just give it the name of like math and

2085:07

here let's just provide where it should

2085:09

add valed number numbers come on valid

2085:12

numbers now here in this case we are

2085:14

providing uh you know what let's just

2085:16

remove there and now here in this case

2085:18

we are working with the Positive testing

2085:21

so you want to expect so let's just

2085:23

provide our add and provide our three

2085:24

and five to be add okay so let's just

2085:29

come on if I can type that today so it's

2085:31

going to gives us the result of add now

2085:33

let me just duplicate that two more

2085:34

times and we want to P the value of like

2085:37

10 and also 20 to this one and we want

2085:40

the expect expected value to be 30 now

2085:42

here let's just provide another

2085:44

expectation like 0o for the first

2085:45

perimeter and 0 for the second one and

2085:48

the result will be zero okay so now if I

2085:50

save there and my test is running and I

2085:53

can see all of the test successfully

2085:55

passing so that was our positive testing

2085:58

but now let's talk about how we can

2086:00

specify a negative testing for that so

2086:02

I'll just use another it and it should

2086:05

add invalid input fields or inputs uh

2086:09

rather and here we are going to be

2086:11

expecting if add and here we have to

2086:13

specify uh three value and five as a

2086:16

string value if that is the case we are

2086:18

going to be throwing a new error so

2086:21

throw error and here we will just say

2086:23

like both inputs must be numbers okay

2086:26

let's just go back one go back oh my God

2086:29

go back there we go and I'm going to

2086:31

duplicate there and for the second input

2086:33

I'm going to just convert there to a and

2086:36

inside the string a and also here let me

2086:39

just convert there to five and also this

2086:41

one to undefined and null okay so I'm

2086:44

going to just convert that to null same

2086:46

my file and test this out so here you

2086:48

can see both of my tests are now

2086:50

successfully passing so this is how we

2086:52

are going to be providing a positive

2086:53

test and this is how we are going to be

2086:55

providing a negative test now let's talk

2086:57

about the boundary testing so boundary

2086:59

testing focuses on testing the edges or

2087:02

boundaries of an input values so the

2087:04

primary idea behind the boundary testing

2087:06

is that errors are more likely to occur

2087:09

in the boundaries in the extreme end of

2087:11

the input ranges by testing the

2087:13

boundaries of an input values you can

2087:15

find effects that occur when the system

2087:17

handles these hge cases I know that was

2087:20

a crazy definition of boundary testing

2087:22

but trust me it's not that hard so now

2087:26

let's talk about the types of boundary

2087:27

testing so the first type we have is a

2087:30

minimum boundary which will test the

2087:32

smallest possible valid value then we

2087:35

have a maximum boundary which will test

2087:37

the largest possible valid value then we

2087:39

have a just in inside the boundary and

2087:42

it will test above the minimum or just

2087:44

below the maximum then we have a just

2087:46

outside the boundary so it will test

2087:49

just below the minimum or just above the

2087:51

maximum to ensure the invalid values are

2087:54

correctly rejected so that was just a

2087:56

types of um boundary testing but now let

2087:59

me just give you example of there so

2088:01

just consider a simple function that

2088:03

accepts a username and a password where

2088:06

the username must be at least three

2088:08

characters and the password must be at

2088:10

least six characters so this is how we

2088:12

can solve there by using the boundary

2088:14

testing so for the username boundary we

2088:16

can provide the minimum valid username

2088:18

like three characters and the minimum

2088:20

invalid username will be two characters

2088:23

and just inside the valid will be three

2088:25

characters and just outside the invalid

2088:28

will be set to one character so that was

2088:30

just it about for the username boundary

2088:33

but we can also provide for the pen

2088:35

World boundary so the minimum valid pord

2088:37

will be six characters the minimum

2088:40

invalid password will be set to Five

2088:42

Characters just inside the valid will be

2088:45

set to six characters and just outside

2088:47

the invalet will be set to four

2088:49

characters okay so if you guys don't get

2088:52

it you don't have to worry about the

2088:54

boundary testing but now let me just

2088:55

write some code then you will get to

2088:57

know what I'm talking about okay so now

2088:59

let's see that boundary testing in

2089:01

action so what I'm going to do is that

2089:03

I'm going to create a file inside the

2089:05

SRC so I'll use like valid or validate

2089:10

on valid password. JS and here we are

2089:15

going to be creating our function inside

2089:17

this I'll use like password or you know

2089:20

validate password and it's going to take

2089:23

a password as a perimeter and now inside

2089:26

this function first of all we are going

2089:27

to be checking if the password which we

2089:29

are now taking as a perimeter. length L

2089:32

GTH is less than 8 characters or

2089:36

password. length is greater than 16

2089:40

character so in this situation you want

2089:42

to throw in error so I'll use like new

2089:44

error and it's going to say like

2089:46

password must be between ADD and 16

2089:51

characters 16 16 characters there we go

2089:56

so now let me just save my file but if

2089:58

that's not the case what do you want to

2089:59

do in that situation then we just want

2090:01

to return like password is valid there

2090:04

we go and now let's just sa our file I'm

2090:06

going to close there now let me go ahead

2090:08

and go to my test folder and here we're

2090:10

going to be creating our validate

2090:12

password. test.js file and inside there

2090:15

let's just import our describe function

2090:18

or it function and also our expect

2090:20

function and also we want to import our

2090:24

validate validate

2090:26

password from where from our SRC folder

2090:31

and then we have our validate password

2090:33

now underneath that let's is pro where

2090:35

describe and I'm going to give it the

2090:37

name of like valed password and inside

2090:39

there let's just use our it should allow

2090:42

a password with exactly add characters

2090:47

and now let's just use this so I'm going

2090:48

to use like validate password and here

2090:50

I'm going to use like a b CDE E F G H so

2090:55

it is I guess add characters we have 1 2

2090:58

3 4 5 6 7 eight characters yeah so I'm

2091:01

going to also store the inside the

2091:02

variable so I'm going to use like result

2091:04

is going to be equals to this validate

2091:06

password and now we have to provide our

2091:08

expectations so provide our expect and

2091:10

here we have to passw our result inside

2091:12

there to be um password is valid okay so

2091:17

now let me just say my file let me go

2091:19

ahead and go to my file and password is

2091:21

valid I'm going to copy this in exact

2091:24

string and now let me just paste it

2091:26

right here s my file and we are getting

2091:30

an

2091:31

error I don't know why but we are now

2091:33

getting this error oh that's because we

2091:35

are not exporting there so now let me go

2091:37

to the top and Export there save my file

2091:40

and now everything should be fine here

2091:42

you can see we're now providing add

2091:44

characters so that's why um our test is

2091:47

now passing but if I just provide like

2091:49

maybe three characters our test is now

2091:51

failing and now we are getting like

2091:53

password must be between eight and 16

2091:56

characters so now let's just go back and

2091:58

that's done let me create another test

2092:00

Suite so I'm going to use like it should

2092:02

throw an error if password has less than

2092:08

add characters there we go so in that

2092:10

situation it's going to just throw an

2092:12

error go back and here let's just

2092:13

provide our expectation because it's

2092:15

going to throw an error so in that

2092:17

situation let's just use our Arrow

2092:19

function and put our validate password

2092:21

and here we have to put like ABC right

2092:23

here and to throw uh and it's going to

2092:26

throw this error like password must be

2092:29

between it and 16 characters let me just

2092:33

save my file and now we are providing a

2092:35

ABC right here and let's just test this

2092:38

out and here you can see it's also

2092:40

passing right here which means like

2092:41

everything is working the way we expect

2092:43

him to work and these are just the

2092:45

boundaries which we are now providing

2092:47

right here the boundary test so let's

2092:49

just create another one it should allow

2092:53

a password with exactly 16 come on

2092:58

16

2092:59

characters okay so I'm going to use like

2093:02

valed password and I'm going to put a

2093:05

lot of stuff to here so maybe a b c d e

2093:08

f g h i j k l l m n o p and how many

2093:13

characters is this 1 2 3 4 5 6 7 8 9 10

2093:19

11 12 13 14 15 16 yep that's fine so I'm

2093:23

going to store the inside the result

2093:25

variable and now let's just use our

2093:27

expectations so provide our result to be

2093:30

password is valid and save my file and

2093:34

Yep this test is also passing because we

2093:36

are now providing 16 characters I can't

2093:39

even speak today so if I just remove it

2093:42

and here you can see our test will fail

2093:44

so let me just provide that 16

2093:45

characters right here and we are going

2093:47

to be also providing one more for it so

2093:49

I'll use like uh it should throw an

2093:53

error if password has more than 16 come

2093:57

on

2093:58

16 characters there we go our

2094:02

expectation and here inside the provide

2094:04

our validate password and let's suppose

2094:07

if you have more than these stuff so I'm

2094:09

going to copy that

2094:10

place there and I'm going to just

2094:13

provide like

2094:14

PQ and it's going to throw an error and

2094:18

error will say like

2094:20

password must be between eight and 16

2094:25

characters now let me just save my file

2094:27

and here you can see all of our test are

2094:29

now successfully passing so that was

2094:31

just example number one but now let me

2094:33

also give you yet another example so

2094:35

which will be validate index so I'm

2094:37

going to go ahead and create another

2094:39

file with the name of

2094:40

is valid or valid index.js file and here

2094:45

inside there uh we will just create a

2094:48

function I'm going to also export it

2094:49

because I always forget there and is

2094:51

valid index we're going to be just

2094:53

checking for the array and index inside

2094:56

the array okay so here let's just check

2094:59

if our index is less than zero or our

2095:03

index is greater than or equal to array.

2095:06

length Okay r a y length so in that

2095:11

situation what we have to do we have to

2095:13

throw new error which will say like

2095:15

index out of bounds like for the

2095:19

boundaries and now underneath there if

2095:22

there isn't the case we are going to be

2095:24

returning like invalid is or index is

2095:28

valid there we go and now let's just say

2095:30

our file and also don't forget this

2095:33

explanation mark you have to provide the

2095:35

I'm going to remove the remove all of

2095:37

them and provide my test case right here

2095:40

so it should be is valid index. test.js

2095:45

file I'm going to go ahead and first of

2095:46

all import my describe it and also the

2095:50

expect and then we are going to be

2095:52

importing the is um where index from

2095:57

where from or SRC go to the SRC and then

2096:01

ised index right here now this just

2096:04

Define or describe our function site so

2096:06

is valid index and here let's just

2096:10

remove that second from there and use

2096:12

cons array and Define our array right

2096:15

here like 10 20 30 40 and semi file and

2096:19

then we are going to be checking our

2096:21

site so it should allow index zero first

2096:26

element okay so yeah you provide zero so

2096:29

it's going to giv us the first element

2096:31

from our array so I'm going to use like

2096:33

not index DB what the hell am I doing

2096:35

I'm going to have to copy this name

2096:37

place it right here and wi my array

2096:40

inside there which we are now creating

2096:42

right here and zero like so and I'm

2096:45

going to use cons result it's going to

2096:48

be equals to this function call and

2096:50

provide my expectation and here let's

2096:52

just provide our result to be index is

2096:56

valid if that is the case so we want to

2096:57

provide like index is valid check this

2097:00

out yep it is working the way we expand

2097:02

to work and also create a few more

2097:04

boundary test for it so I'm going to use

2097:06

like it should allow index so that's

2097:09

going to be the last one last element

2097:11

there we go and here we can use like con

2097:14

result and here let's just use is Ved

2097:17

index and put my array inside then in

2097:19

four okay so toide my expectation for

2097:23

the result to be index is valid if that

2097:27

is the case you check this out yep it is

2097:30

also passing and I'm going to just maybe

2097:32

duplicate that two times and here change

2097:35

the values inside the or even the

2097:37

messages okay so this one should be uh

2097:41

come on it should throw an error for

2097:45

index minus one okay out of bounds and

2097:49

here I'm going to just specify a few

2097:51

things because here we are going to be

2097:53

using our expect and pro our callback

2097:56

function today because we are going to

2097:57

be throwing an error so let's just use

2097:59

our ised index provide our array and

2098:01

minus one so out of bound to throw and

2098:04

here we have to provide like index out

2098:07

of bounds like for the boundaries

2098:10

underneath them uh I'm going to just

2098:12

remove all of them from here and it

2098:15

should draw an eror for index five Comm

2098:20

on five and it should be out of bounds

2098:23

as well and what I'm going to do is that

2098:26

I'm going to just remove both of them my

2098:28

expectation here we have to provide our

2098:30

function is ver index and Prov our array

2098:33

and five inside the to th so in this

2098:36

situation we're going to be using index

2098:39

out of pounds and semi file check this

2098:42

out okay so we are getting some sort of

2098:45

error uh index out of pound But Here we

2098:48

are now providing this dot so that's why

2098:51

we have to remove this dot s file and

2098:53

now here you can see all of the tests

2098:55

are now successfully passing so yeah

2098:58

that was our boundary testing let's talk

2099:01

about the parameterized testing and this

2099:03

one is super hard to pronounce but I'm

2099:05

going to do my best so parameterized

2099:07

test allow you to run the same test with

2099:09

multiple set of of inputs without

2099:10

duplicating the test logic instead of

2099:12

writing multiple similar test cases for

2099:14

different inputs you define the inputs

2099:16

as a set of perimeter and the test will

2099:18

automatically run for each combination

2099:20

of those values so that was just a quick

2099:22

definition but here you can see I have a

2099:24

function which will allows us to

2099:26

multiply two numbers so if you want to

2099:28

write a lot of test cases for there so

2099:30

we can like Nothing is Stopping Us but

2099:33

if you want to use the parameterized

2099:35

testing so this is how we are going to

2099:36

be using there first of all we have

2099:38

already described and now in inside the

2099:40

describe we are not calling over it

2099:42

function we are now calling over each

2099:45

method on our it function so here we can

2099:47

pass our array and inside that array we

2099:50

can pass our value of for our perimeters

2099:52

here you can also see we have a

2099:54

placeholder of percent D it will take

2099:56

those values from those test and it will

2099:58

put it right there if you don't get it

2100:01

you don't have to worry about that

2100:02

because now I'm going to show you the

2100:04

inaction okay so now let's see that

2100:06

parameterized testing in action so first

2100:08

of all I'm going to create a file with

2100:09

the name of m. JS and I'm going to also

2100:12

create a test file for that so I'll use

2100:14

like m. test.js and I'm going to close

2100:17

this get ignore file and now let's just

2100:19

create our multiply function inside this

2100:21

so I'll use like uh con multiply it's

2100:23

going to take A and B as a perimeters

2100:25

and now we are going to be using a * B

2100:28

okay so let's just use the I'm going to

2100:29

save this file and now we have to import

2100:32

that right here first of all we are

2100:33

going to be importing the uh describe

2100:35

function so let's just use the describe

2100:38

then the it and also the expect function

2100:40

and now we are going to be using the

2100:41

multiply from our math module so I'm

2100:44

going to just describe my set and I'm

2100:46

going to give it the name of like multip

2100:49

multiply and now inside there we are

2100:51

going to be using our it but we are not

2100:52

going to be calling there I'm going to

2100:54

just use Dot and here you can see we

2100:56

have a lot of function like we have

2100:58

apply bind and so on and so forth I'm

2101:00

going to only call this each function

2101:02

okay so now let me just execute there

2101:05

and here you can see it takes a test

2101:06

cases and which will be a read only okay

2101:09

so I'm going to p my array inside there

2101:11

and now here we're going to be passing

2101:12

our test cases like uh value for our

2101:15

test cases so use like for the first

2101:17

preter I'm going to pass two and for the

2101:19

second one I'm going to pass three and

2101:21

for the result I'm going to pass six so

2101:23

it's going to gives us like 2 * three is

2101:26

equal to six okay so it's going to gives

2101:29

us that result so now let me just remove

2101:31

that from here I want to p a few more

2101:33

ones so I'm going to provide my comma

2101:35

and I'm going to just duplicate that a

2101:36

few times okay so you know what let's

2101:38

just change there to like

2101:40

four maybe and this one to five and this

2101:43

one to 20 so it's going to giv us the

2101:45

result of 20 and also I'm going to P 7

2101:48

here eight and here the result will be

2101:50

set to 56 okay so now let's just proide

2101:53

over one and zero come on zero so we

2101:57

already know this going to gives us zero

2101:58

value let me just duplicate for the

2102:00

final time and here I'm going to P like

2102:02

minus 2 here three and here Min - 6 so

2102:06

let's just past there I'm going to save

2102:07

this file right now but also so we have

2102:10

to call our function like immediately

2102:12

invoke function expression like ify if

2102:15

you guys don't know what if is in

2102:16

JavaScript you don't even have to know

2102:18

that but yeah if you want to call that

2102:20

function so this is how we are going to

2102:22

be calling there so for the first

2102:23

parameter we are going to be providing

2102:25

our description so I'll just say like

2102:26

should return uh correct result when

2102:30

multiplying now we going to be using

2102:32

this placeholders percent symbol and

2102:34

also D and I'm going to use and and once

2102:36

again percent D and then the expected

2102:39

and here we have to use that percent d

2102:41

one more time let's just go back let me

2102:43

just save my file so this is how it

2102:45

looks like so basically it's going to

2102:47

take that two is going to put that right

2102:49

here then it's going to take that three

2102:51

it's going to put that right here inside

2102:53

this placeholder and then finally it's

2102:55

going to take this six it's going to put

2102:57

there right here same will goes for the

2102:59

4 520 and so on and so forth so this is

2103:02

what's going on right now so I'm going

2103:04

to provide a comma here and now we have

2103:06

to provide our functions for our

2103:08

function now that we know that it takes

2103:10

three perimeters so we are going to be

2103:12

passing two and then three and then six

2103:15

okay so for there let's just pass like a

2103:18

comma B and then here we have to specify

2103:20

or expected you can basically give it

2103:22

any name that you prefer but in my case

2103:24

I just give it the name of like a b and

2103:26

expected result now here we have to pass

2103:28

or expect and I'm going to be passing my

2103:30

multiply inside there and pass my a

2103:32

comma B which is now coming from these

2103:35

parameters and now we have to use the to

2103:37

be and let's space What expected result

2103:39

right here now let me just save my file

2103:41

and now let's just run our test so I'm

2103:43

going to use like npm run test and then

2103:45

UI so let's just run and here you can

2103:48

see our test are now successfully

2103:49

passing right here okay as you can see

2103:52

there um multiplying two okay here you

2103:56

can see so we are now getting that

2103:58

result and as I said like those

2103:59

placeholder will be replaced by those

2104:01

actual values so here you can see for

2104:04

this pound symbol not pound symbol but

2104:06

percent symbol with d it is now replaced

2104:09

with these two and then same will goes

2104:11

for this one as you can see there right

2104:13

here and same will goes for this one as

2104:15

well okay so yeah this is how we are

2104:17

going to be providing a parameterized

2104:19

test for our code but that was our first

2104:22

example now let me give you one more

2104:23

example I'm going to go ahead and go to

2104:25

my SRC file once again and I'm going to

2104:27

create another file with the name of

2104:28

string

2104:30

validator DJs okay I hope the spelling

2104:33

is correct so let's just write like

2104:35

string validator do test.js file here

2104:40

I'm going to go into my string validator

2104:41

file and let's just create what is valid

2104:44

valid string length and here is going to

2104:48

take a string as a perimeter now inside

2104:51

there first of all let's just export

2104:52

there because I always forget there

2104:54

let's just check if our string. length

2104:57

come on L GTH if our string. length is

2105:00

less than five or our string. length is

2105:03

greater than 10 so in this situation we

2105:05

are going to be throwing this new eror

2105:08

which will say like string length must

2105:10

be between 5 and 10 characters if that

2105:15

is not the case then we're going to be

2105:16

returning like um string is valid and

2105:20

provide this pound symbol right there so

2105:22

this is our function now we have to

2105:24

provide a test cases for this I'm going

2105:25

to go into my test file and the first

2105:27

thing that I want to do is that I want

2105:28

to uh import the describe and also the

2105:31

it and

2105:38

also

2106:08

e

2106:38

e

2107:08

e

2107:38

e e

2108:30

now let's talk about how we are going to

2108:31

be testing an asynchronous code like

2108:33

those code which will take some time so

2108:36

let me just give you example of there

2108:37

first of all we are going to be creating

2108:38

our with the name of fetch data we're

2108:40

not going to be actually fetching our

2108:42

data but this is just example so I'm

2108:44

going to also go to the test file and

2108:46

create my fetch data. test.js file okay

2108:49

so first of all let's just go to our

2108:51

fish data file and here we're going to

2108:53

be creating our function so I want you

2108:55

imagine like we have some sort of

2108:56

asynchronous function PCH data function

2108:59

that will simulate the API request and

2109:01

return the promise so how that's going

2109:03

to look like this is how it's going to

2109:05

look like so I'll just export this

2109:06

function because I always forget that

2109:09

and now let me just use like fish data

2109:11

I'm going to give it the name of like

2109:12

fish data and there going to be an

2109:13

innous function which means like it's

2109:15

going to take some time and now we're

2109:16

going to be returning a new promise from

2109:18

there and it's going to take the result

2109:20

and it's going to also take the reject

2109:22

even though we are not going to be using

2109:23

the reject but yeah we are going to be

2109:25

providing there right there and I'm

2109:27

going to also use like set timeout and

2109:29

it's going to take a while to run so

2109:31

here inside therefore the duration I'm

2109:33

going to give it like maybe 1 second

2109:35

would be fine here we're going to be

2109:37

calling our resolve function and it's

2109:38

going to say like this data ped

2109:41

successfully Fu l y there we go s OU s s

2109:46

u c eou s there we go oh God damn it s u

2109:51

c s uou c eou s f u l y now this is

2109:55

looking better so this is just our basic

2109:58

asynchronous function and it returns a

2110:00

promise so how in the world we are going

2110:02

to be testing this code let me go ahead

2110:04

and go to my P file and here we are

2110:06

going to be importing first of all to

2110:08

describe the it and so they expect and

2110:10

now underneath that we are going to be

2110:11

also importing our fet data function and

2110:13

now let's just use our describe okay so

2110:16

I'm going to use the and I'm going to

2110:17

give it the name of like fetch data and

2110:19

let's just remove there and inside there

2110:21

let me just save this file and inside

2110:23

there let's just create our test here so

2110:25

it should return the correct message

2110:29

after the promise is resolved or the

2110:32

promise resolves there we go and let's

2110:34

just sa our file and now inside there

2110:36

first of all we are going to be calling

2110:38

our function but the main thing is that

2110:40

we are now testing this asynchronous

2110:43

function so which means like we also

2110:44

have to mark this function as

2110:46

asynchronous so I'll use like asyn right

2110:48

here as YNC and now let me just save my

2110:51

file and now that we made our function

2110:53

as asynchronous function so which means

2110:55

like we can now use our a inside there

2110:58

so I'm going to just use like a and here

2110:59

let's just use our fetch data and

2111:02

execute this function and I'm going to

2111:03

store the inside the result variable and

2111:05

now here we are going to be using the

2111:07

expect and pass my result inside there

2111:09

and we want that to be data fetched

2111:12

successfully so you know let me just

2111:14

copy this entire thing from here and now

2111:16

let me just place it right here say my

2111:19

file and now let's just check this out

2111:21

I'm going to refresh there and yep

2111:23

everything is working the way we expect

2111:24

him to work but imagine if I just remove

2111:27

this sing function from there and also

2111:29

this a and now if I save my file now our

2111:32

test will fail and why is that because

2111:34

our code takes some time to run and our

2111:37

test file does not so that's why we have

2111:40

to provide this a in this async right

2111:42

here whenever we are testing a as

2111:44

synness function so that was example

2111:46

number one let me give you one more

2111:47

example so I'm going to create a file

2111:49

with the name of pitch user um

2111:52

data.js and I'm going to also create a

2111:54

test file for this so I'll use like

2111:56

fetch data. test. or fetch user data.

2112:02

test.js file and I'm going to go into my

2112:04

fetch data fetch user data what am I

2112:07

saying today and here we are going to be

2112:09

just exporting this function and create

2112:11

that right here with the name of which

2112:13

user data and it's going to be an asnr

2112:15

function it's going to take the user ID

2112:17

and based on that ID we are going to be

2112:19

fishing our data so if our user ID is

2112:23

equal to invalid so in this situation we

2112:25

are going to be returning promise.

2112:27

reject reject there we go and I'll just

2112:30

say like user not found or something

2112:32

like that because if the user ID is not

2112:35

vared which means like we would not be

2112:37

able to find the user so let's just

2112:39

return to our promise. resolve resolve

2112:41

and here we have to pass our object and

2112:43

we are going to be passing the ID come

2112:45

on the ID is going to be set to user ID

2112:48

and also we are going to be passing a

2112:50

name and name will be set to our my own

2112:51

name like H webd and now let me just

2112:54

save my file okay so as soon as I save

2112:56

my file now and now let's go into our

2112:58

pitch user data. test file and here we

2113:01

have to import our describe function we

2113:03

also have to import our it and also our

2113:06

expect and now underneath that we have

2113:07

to import our fet users data from our

2113:10

user data function or file whatever you

2113:13

want to call it and here let's just

2113:15

create our fetch user data and inside

2113:18

there let's just use our it function it

2113:20

should resolve with the user data when

2113:24

come on the user data when the user ID

2113:29

is valid okay so if I save my file here

2113:33

you can see I just forgot that we have

2113:35

to provide that ASN right here because

2113:37

we're now testing an as synness function

2113:39

so we have to provide that ining there

2113:41

and now we can use our a and then fetch

2113:43

user data and now we have to execute

2113:45

this I'll just pass like valid user ID

2113:48

and I'm going to also store the inside

2113:50

the variable like C result it's going to

2113:51

be equals to this response and here

2113:53

let's just pass for expectation so I'll

2113:55

just provide my result come on there we

2113:57

go and to equal equal there we go and

2114:01

here we have to past the ID and the ID

2114:02

will be set to valid user ID which we

2114:05

are now passing there and also hen web

2114:09

dev and now let me just save my file yep

2114:11

our test is now successfully passing if

2114:14

I check this out so this is the test

2114:17

that I'm looking for let me just expand

2114:20

there yep our test is now successfully

2114:21

passing and now let's create another

2114:23

test suit for there so it should reject

2114:26

with user not found message or user not

2114:30

found when the user ID is inid okay so

2114:34

we are going to be using a but first of

2114:36

all we have to use our SN for here and

2114:39

then we are going to be using a and here

2114:41

we have to provide our expect and fetch

2114:43

user data and now let's just provide

2114:45

like invalid ID or something like that

2114:48

and then we are going to be just

2114:49

rejecting This Promise so I'll use like

2114:50

Rejects and then to be and here let's

2114:54

space like us not found and now if I

2114:56

save there and here you can see our test

2114:59

is now successfully passing run there

2115:02

and you know what let me just expand

2115:04

there so we have these two test which is

2115:07

it should resolve with the user data

2115:09

when the user ID is valid and on the

2115:11

other hand it should gives us user not

2115:13

found when the user ID is not valid or

2115:16

invalid so yeah this is how we are going

2115:18

to be testing our as synness code by

2115:20

using ASN and aware The Witcher 4

2115:22

trailer just came out like an hour ago

2115:24

and I have to say it was one of the most

2115:27

goodlook game I have ever seen so I'm

2115:31

dying to play that game as soon as

2115:33

possible but let's just hope that they

2115:34

release it very soon anyway so now that

2115:36

we completed the unit testing part of

2115:38

this course so now let's get into the

2115:40

react testing so I'm going to open my

2115:42

terminal and now let's make a set of

2115:43

four there so let me just make that a

2115:46

bit bigger so you guys can see

2115:47

everything a bit

2115:49

clear just like that so what I'm going

2115:52

to do is that I'm going to be using npm

2115:54

Create on Create and then we at latest

2115:58

and I'm going to give it the name of

2115:59

like my react testing or something like

2116:02

that I'm going to choose reactjs with

2116:04

typescript because we are going to be

2116:06

using a TSX now let me go into that

2116:08

folder and I'm going to install all of

2116:09

the dependencies inside there so then

2116:11

successfully done so I'm going to open

2116:13

that in my vs code and this is how it

2116:15

looks like so I'm going to go ahead and

2116:16

remove the public folder I'm going to go

2116:18

to the SS folder and remove the app. CSS

2116:21

and then I'm going to go into the app.

2116:23

TSX and I'll just write my RFC inside

2116:25

there let's just close there and now we

2116:28

have to install a lot of dependencies

2116:29

for our testing so the first thing that

2116:31

we have to do is that we have to install

2116:33

or test runner in assertion library in

2116:35

which is the v test so I'm going to be

2116:37

using npmi in then DD and v test so it's

2116:40

going to install that in my project and

2116:42

this is our test Runner and our

2116:44

assertion Library so now they

2116:46

successfully install the next thing that

2116:47

we have to do is that we have to install

2116:49

the react testing library for testing

2116:51

our component so I'm going to just use

2116:53

like npmi and then DD at testing D

2116:57

Library for/ react so it's going to

2117:00

install reactjs in my machine and also

2117:03

we would need the JS Dom so now let's

2117:05

just use npmi and then ddjs Dom JS Dom

2117:08

so I know a lot of you will ask me hus

2117:10

what is a JS Dom we've been testing our

2117:13

code and we are seeing the result of our

2117:15

code inside our terminal but now we are

2117:17

going to be testing our components so we

2117:19

would need some sort of a Dom okay so

2117:21

this JS Dom will allows us to work with

2117:23

a virtual Dom so that's why we are now

2117:25

installing there so now let me just

2117:27

install there and you will see there in

2117:28

a few second by the way you don't have

2117:30

to worry about that so that's toally

2117:31

done now we have to install something

2117:33

called the custom matchers which is

2117:35

called the just Dom okay so I'm going to

2117:37

use like npmi and then- D for/ not for

2117:41

add testing and then- library for slj

2117:46

come on just and then Dom so it will

2117:48

allows us to test our code just like a

2117:50

custom Mech like to be in the document

2117:52

and so on and so forth something which

2117:55

you don't know already but you will see

2117:57

that in a few second so this Library

2117:58

will just gives us a custom matchers you

2118:01

just have to keep that in mind and

2118:03

finally we also have to provide a types

2118:05

for there so I'm going to use like npmi

2118:07

and then DD types and install a types

2118:10

for that just so let's just install

2118:12

there and this is the library which I'm

2118:14

about to install you don't need that but

2118:16

sometime you will get an error inside

2118:18

your vs code so I also want you to

2118:20

install this so I'm going to use like

2118:22

npmi and then at uh testing come on uh

2118:26

testing library and then just Dom okay

2118:30

just Dom so install there so now we're

2118:32

installation is now successfully done

2118:34

the next thing that we have to do is

2118:35

that we have to go ahead and go to our

2118:37

package.json and Pro IDE or UI case or

2118:40

script so I'm going to provide a comma

2118:42

here and I'm going to say like test and

2118:43

then UI and give it any name that you

2118:46

prefer and I'm going to just write like

2118:48

vest and then d-i so now let's just save

2118:50

there and I'm going to also close there

2118:52

next we have to provide a configuration

2118:54

forward v test so inside our root not

2118:57

inside the SRC folder but inside this

2118:59

root I'm going to right click on there

2119:01

and create a new file with the name of

2119:03

vest. config come on config dots because

2119:07

inside this file we going to be

2119:09

providing our custom configuration for

2119:11

our we test so I'll first of all import

2119:13

something called the Define config come

2119:15

on uh let's just import the Define

2119:17

config from where from or vest and then

2119:21

let's just go to the config file so I'm

2119:22

going to sve my file right now you will

2119:24

also export that so we can use it in

2119:26

other file so I'll use like export

2119:28

default and I'm going to say like Define

2119:30

config and here we have to provide our

2119:32

object and inside this object we have to

2119:34

provide our test object inside that

2119:36

object first of all we have to specify

2119:38

the inv envirment currently we are now

2119:40

testing our code inside this terminal or

2119:42

nodejs environment so we don't want that

2119:45

we want to test our component inside the

2119:47

JS Dom so we will have to specify our

2119:50

environment and we have to set there to

2119:52

that JS Dom Library which we just

2119:54

install a few seconds ago next we have

2119:56

to also set the globals and don't worry

2119:58

about the globals so I'll just write

2120:00

like globals and set the to true and I'm

2120:02

going to also for the set of files and

2120:04

that's going to be set to test and then

2120:06

setup. TS file now that we know what

2120:08

this environment is now let's talk about

2120:11

this Global so whenever we are testing

2120:13

our component I mean like whenever we

2120:15

are testing our function so we usually

2120:17

import the describe function we also

2120:19

import the it function and we also

2120:21

import the expect function but now that

2120:23

we set this Global so we no longer have

2120:26

to import all of that stuff like in all

2120:28

of our component so we are going to be

2120:30

testing a lot of component and inside

2120:32

those component we are going to be using

2120:34

the describe it and expect but we don't

2120:36

have to import there so that's why we

2120:39

are now providing this Global and we are

2120:40

now setting that to true and finally we

2120:43

just providing this setup file because

2120:44

this is going to be for our custom match

2120:46

so now let's just say our file I'm going

2120:48

to go into my route and here inside

2120:50

there we're going to be creating a

2120:52

folder with the name of test and by the

2120:54

way you can either uh give it the name

2120:55

of like double underscore and then test

2120:57

and and then double underscore like

2120:59

Dunder but in my case I'm not going to

2121:01

do that I'm going to just write like

2121:02

test and hit enter right here so first

2121:04

of all we have to create our component

2121:06

then we are going to be testing our

2121:07

component so I'm going to right click on

2121:09

there and create a folder with the name

2121:11

of components and inside there we are

2121:13

going to be creating our hello word. TSX

2121:15

file okay so let's just use our RFC

2121:18

inside this save my file and this is how

2121:20

our component looks like but now let's

2121:22

just go ahead and create a file for

2121:24

there so here inside this test file

2121:27

first of all we are going to be creating

2121:28

our setup file then we are going to be

2121:30

testing our component so I'll just use

2121:32

like setup. TS and here I want you to

2121:35

notice this is this should be test by

2121:38

the way I made a mistake so this should

2121:40

be test with s and inside this test

2121:43

folder we have our setup. TS file okay

2121:46

so here I want you to notice that we are

2121:48

now providing the tests which is a

2121:50

folder which we just created right here

2121:52

and then inside this folder we have our

2121:54

setup. test file as you can see right

2121:56

here and now here inside the setup. TS

2121:59

file we are going to be pasing something

2122:01

called the custom match so I'll just

2122:03

import first of all um the testing

2122:05

Library come on let's just use our

2122:07

testing library and we're going to be

2122:09

importing there from the J and then Dom

2122:12

okay so it's going to allows us to use

2122:13

our custom measures so that's everything

2122:16

that you have to do for now and now I'm

2122:18

going to just provide a bit of uh basic

2122:20

test right here so you know what first

2122:22

of all we have to create our components

2122:23

folder if you want to create this

2122:25

components folder you can but if you

2122:27

don't want to use the components folder

2122:29

you can write your test inside the setup

2122:31

file but in my case I prefer the

2122:33

components folder so I'll just give it

2122:35

the name of like components and inside

2122:37

there let's just create what hello word.

2122:40

test. TSX file right here okay so now

2122:43

inside this file let's just test this

2122:46

component which we just created right

2122:48

here okay so I'm going to go ahead and

2122:49

go to my hello Word file and here we are

2122:52

not going to be importing the describe

2122:53

function and also the it function and

2122:55

also that expect function because we

2122:57

already declared that inside our weest

2123:00

config file so what we have to do inside

2123:02

this file the first thing that we have

2123:03

to do is that we have to import

2123:05

something called the render function so

2123:07

let's just import the the render and

2123:08

also the screen and you don't have to

2123:11

worry about them because I'm going to

2123:12

explain that in a few seconds right now

2123:14

here so I'll just import that from the

2123:16

testing Library not from the Dom but

2123:18

from the react J so now let me just save

2123:20

there so what in the word is this render

2123:23

and what in the word is this screen this

2123:25

render will allows us to render our

2123:27

component to the virtual Dom and this

2123:30

screen will allows us to select a

2123:31

certain element to test that specific

2123:34

component if you don't get it you don't

2123:36

have to worry about that but the next

2123:38

thing that we have to do is that we have

2123:39

to import our component so that we can

2123:41

test there so I'll just import like

2123:43

hello word as you can see it will not

2123:45

help us to Auto Import our components so

2123:47

how can we solve that I'm going to cut

2123:49

that from here and you just have to grab

2123:53

this folder and you have to put that

2123:55

inside this SRC folder just for a second

2123:58

and then you have to grab it back and

2124:00

now it will start working I promise it

2124:03

will start working just check it out so

2124:06

uh here you can see I guess they

2124:07

provided some configuration I'm not

2124:08

quite sure about there but now let me

2124:10

just save there and now if I just use

2124:12

import hello and as you can see right

2124:14

here it will allows us to a to import

2124:17

our component so now if I click on there

2124:19

so it's going to import our component

2124:21

from this file so I want you to hold

2124:22

control and click on there so it's going

2124:25

to bring you to this file and this is

2124:27

our component I'm going to save this

2124:29

file right now and the next thing that

2124:30

we have to do is that we have to use our

2124:32

describe and inside there I'll say like

2124:34

hello word component or something like

2124:36

that and now inside this describe we are

2124:38

going to be implementing over it and it

2124:41

should render a hello word maybe

2124:44

component be fine and now let me just

2124:46

save them okay so now the first thing

2124:48

that we have to do is that we have to

2124:50

render our component then we would be

2124:52

able to interact with our component we

2124:54

are not just testing our functions now

2124:57

we are testing our jsx and we have to

2124:59

render that to our virtual Dom so if you

2125:02

want to render that to our virtual Dum

2125:04

so for that we are going to be using

2125:05

this render method or function from this

2125:08

testing library and reactjs okay so we

2125:10

will just use that friender and inside

2125:13

the as you can see right here it

2125:14

requires the UI and the react node so

2125:18

now in this case I'm going to just P my

2125:19

hello word component and now I'm going

2125:21

to close there so now it's going to

2125:23

render my component to the virtual Dom

2125:25

so the next thing that we have to do is

2125:27

that we have to provide our expect and

2125:29

also our screen so I'll just use like

2125:31

expect right here and now I'm going to

2125:33

be using their screen and as I said that

2125:36

this screen will allows us to interact

2125:37

with a certain element inside our

2125:40

component then we would be able to test

2125:42

that specific functionality or behavior

2125:44

okay so I'll just use like screen and

2125:46

then this screen has a lot of matches so

2125:48

it has uh find all by Alt and there are

2125:52

a lot of things and I promise you're

2125:54

going to learn a lot of them by the end

2125:56

of this course so what I'm going to do

2125:58

is that I'm going to just use like get

2125:59

by text and now let me just hit not ID

2126:02

but just a get by text and now let me

2126:05

just execute there and we are going to

2126:07

be testing or fetching or getting or

2126:10

element by using that specific text what

2126:13

am I talking about so you know let me

2126:14

just copy this entire text and now let

2126:16

me just place that right here so

2126:18

essentially we are telling that first of

2126:20

all we want you to render our component

2126:22

then we only want to get that specific

2126:25

element which has this content like

2126:27

hello word and we want there to be so

2126:30

let me just choose like to be in the

2126:32

document come on in the document there

2126:34

we go and now let me just save my file

2126:35

and this is something called the

2126:37

measures which we already set up inside

2126:39

the setup. TS file right here okay so

2126:42

let's suppose if I just comment this

2126:43

line out s my file as you can see right

2126:46

here it's going to gives us an error so

2126:47

now let me just uncomment there save my

2126:50

file and now that error is now gone if

2126:52

you don't get this scoring you don't

2126:54

have to worry about that I mean like

2126:56

it's not that much difficult code to be

2126:57

honest but the only thing which is

2127:00

difficult is this line of code and I

2127:03

guess 90% of this testing course is

2127:06

based on this screen because we going to

2127:08

be learning about how we can PCH our

2127:10

element by using area by using get roll

2127:13

and so on and so forth and this screen

2127:15

is one of the difficult part of this

2127:18

entire testing and you guys already know

2127:20

all of their stuff like first of all you

2127:21

have to import all of your uh render and

2127:24

screen from your testing library then

2127:25

you have to import your component then

2127:28

you have to use the describe and

2127:29

describe your test suite and inside

2127:31

there you just have to use your it to

2127:33

Define your test and then we are going

2127:35

to be rendering our component to the

2127:37

virtual Dom and here is the hardest part

2127:40

which we are going to be covering in

2127:41

this course today is a weird day The

2127:44

Witcher Four trailer just came out and

2127:46

also guess what the Deon just came out I

2127:50

just watched the Fire Ship video about

2127:51

the Deon like the first look of the de

2127:54

it requires like I don't know maybe $500

2127:57

per month or something like that and it

2127:58

was hilarious everybody was telling me

2128:00

like huz is going to take our jobs and

2128:02

this and that anyways I am getting

2128:04

sidetracked so now we are going to be

2128:05

learning about how we can test a

2128:07

component with props so a component

2128:09

which takes a prop how can we test this

2128:11

so what I'm going to do is that I'm

2128:13

going to Define another component uh

2128:15

with the name of user status. uh TSX and

2128:19

inside they I'll just use my RFC and I'm

2128:22

going to just remove it from here and

2128:24

it's going to take a few props so it's

2128:26

going to take the email and it's going

2128:27

to only take one prop which will be an

2128:29

email so I'll just write like email I'm

2128:31

going to also inate that right here like

2128:33

email will be a string now let me just

2128:34

save my file and here we are going to be

2128:36

just rendering our email so what I'm

2128:38

going to do is that I'm going to just

2128:39

write like if we have the email so in

2128:42

that situation we are going to be just

2128:43

rendering like welcome um come on

2128:46

welcome and there specific person email

2128:49

but if that's not the case like if the

2128:50

user did not qu their email so then we

2128:52

are going to be just using like sign up

2128:54

now let me just save my file and this is

2128:56

how our component looks like now let's

2128:58

get into the test and test this

2129:00

component so I'll just create a file

2129:02

with the name of user status. TS I mean

2129:04

like test. TSX and inside this file we

2129:07

we are going to be doing all of that

2129:09

stuff once again so like first of all we

2129:10

are going to be importing all the uh

2129:13

necessary and then uh it should be

2129:16

packages and then we have to describe

2129:20

our test suite and after that uh you

2129:23

know what my spelling is horrible but

2129:25

let me just copy and paste there so

2129:27

first of all we have to import all the

2129:28

necessary packages then we have to

2129:30

describe all the test Suite then we have

2129:31

to write the test then we have to render

2129:33

our component to the virtual Dom for

2129:35

testing then select the element from the

2129:37

Dom for the testing and finally we have

2129:39

to specify our assert so now let me just

2129:41

remove there and the first thing that we

2129:43

have to do is that we have to import the

2129:44

render and also the screen from our

2129:47

react testing Library so I'll just use

2129:48

like a testing library from the react

2129:52

now underneath that we have to import

2129:53

our user status from our components

2129:56

folder now I'm going to be using a

2129:57

describe and here I'll just write like

2129:59

user status component or something like

2130:02

that okay so I'll just change there to

2130:04

component there we go and now inside

2130:07

there uh we are going to be using our it

2130:09

and it should display a welcome message

2130:12

when an email is provided okay so how in

2130:16

we're going to be doing there well first

2130:18

of all we have to render our component

2130:19

to our virtual Dom so I'll just provide

2130:21

my uh user status and here we are going

2130:24

to be passing our email because it was

2130:26

required and I'll just provide like I

2130:27

don't know maybe John gmail.com or

2130:29

something like that now underneath there

2130:31

first of all we have to select this area

2130:34

where we are going to be rendering our

2130:36

content so how in the word we are going

2130:37

to be doing them well we are going to be

2130:39

using some kind of me so I'm going to

2130:41

use that screen once again and by the

2130:43

way we are going to be learning a lot

2130:45

about this screen but not right now and

2130:47

if I just use a DOT here you can see we

2130:49

have a lot of methods but I only want to

2130:52

select their specific element by their

2130:53

text so I'll just use like get by text

2130:57

okay so if I just use that come on it

2130:59

should be a text there we go and here we

2131:01

can specify our regular expression or we

2131:03

can also write our text right here but

2131:05

I'm going to just provide my Rex like we

2131:07

are only searching for the welcome and

2131:09

we only want to select there and if I

2131:11

just write the I which means like select

2131:13

this specific element which have the

2131:14

content of welcome and it doesn't matter

2131:16

if that is lower case or upper case okay

2131:19

and I'm going to store them in some sort

2131:20

of variable so I'll give the name of

2131:22

like uh welcome message or something

2131:24

like that this going to be equals to

2131:25

this method and now we have to provide

2131:27

our expectation so let's just use our

2131:29

welcome message and I'm going to be

2131:31

using the dot to be in the document now

2131:34

let me just execute there okay and

2131:36

finally we have to run our code so we

2131:38

can see there so I'll use like npm run

2131:40

test UI and hit enter and yeah we also

2131:43

have to install this so I'll just use y

2131:45

to install it then done so I'm going to

2131:47

use npm run test UI once again and it's

2131:50

going to open that right here so here

2131:52

you can see all of our tests are now

2131:53

successfully passing like uh as you can

2131:56

see this component test is passing which

2131:58

is like hello word and inside they we

2132:00

are just providing these two test and we

2132:02

also have our user component and this

2132:04

test is also passing so you know what

2132:06

let me just go ahead and remove that

2132:07

there so if I just remove there as you

2132:09

can see our test will Now fail so this

2132:11

is how we are going to be testing our

2132:13

component with the prop and now let me

2132:15

just provide there once again we can

2132:16

also provide another test suite for

2132:18

there so I'm going to hide there and now

2132:21

underneath there we're going to be using

2132:22

our it once again so it should display

2132:25

the sign up button when no emails is

2132:29

provided okay so now let me just render

2132:32

my component once again and I'm going to

2132:34

past my user status and close there now

2132:36

let me just save my file

2132:38

and why are we oh we are now getting

2132:40

this error that's because we are not

2132:42

providing anything so I'll just write

2132:43

like email and I'm not going to past

2132:45

anything to there so what I'm going to

2132:47

do is that I'm going to select my sign

2132:48

up button which you can see right here

2132:50

now you want to select this button so

2132:52

how can you go about doing there like

2132:53

how can we select this button well we

2132:56

can still use that same method from our

2132:58

testing Library which is this get by

2133:00

text so I'm going to use that for now

2133:02

but later we are going to be learning

2133:03

about a lot of them so I'll use like

2133:05

screen once again and I'm going to just

2133:07

use like. get by text and here we can

2133:10

just pass it should be text and here we

2133:13

can just pass our regular expression

2133:14

like uh sign up and I'm going to also

2133:17

provide the I for the lower and upper

2133:19

cases so I'll just use like sign up

2133:21

button and I'm going to store my content

2133:23

inside there now let me provide my

2133:25

expectations so I'll just use like sign

2133:26

up button and we want it to be in the

2133:29

document so now we have to execute this

2133:32

this our file and now let me just

2133:34

refresh that and as you can see both of

2133:36

our test are now successfully passing so

2133:38

like display come on display a welcome

2133:41

message when an email is provided and

2133:43

display a sign up and display a sign up

2133:45

button uh when the email is provided

2133:48

when the email is not provided so it

2133:50

should be button okay so it is correct

2133:53

so like when no email is provided as you

2133:55

can see right here both of the test are

2133:56

now successfully passing but now if I

2133:59

specify something inside there and sa my

2134:01

file and here you can see one of our

2134:03

test is now failing and why is there

2134:05

because it is not looking forward email

2134:07

and now we are providing that email so

2134:10

our test will fail so this is how we are

2134:12

going to be testing our component with

2134:13

the props so we just have to create our

2134:16

component then we have to call our

2134:18

component right here or P our component

2134:21

and we can specify our props right here

2134:24

and then based on those props we can

2134:25

test our component so now let's talk

2134:28

about how we are going to be testing

2134:29

those component which will iterate over

2134:31

through some content and then it will

2134:33

render there which means like a list

2134:35

content component so what I'm going to

2134:36

do is then I'm going to close all of

2134:38

them and I'm going to go into my

2134:40

component folder and inside there I'm

2134:42

going to Define my programming languages

2134:45

list. TSX component and I'll use my RFC

2134:48

inside there and it's going to take a

2134:50

languages as a prop so I'll provide like

2134:52

languages l n g g s there we go and I'm

2134:55

going to also annotate this component

2134:57

like languages l n g g s and I'm going

2135:00

to specify string of array now let's

2135:02

just sa sell that I'm going to go back

2135:04

so you guys can see everything a bit

2135:05

better and now let's just remove this

2135:07

level and first of all we are going to

2135:09

be checking if the languages which we

2135:12

are now taking as a perimeter length is

2135:14

equal to Z in this situation we are

2135:16

going to be returning this UI so I'll

2135:18

just say like da and inside this D I'm

2135:20

going to just render a paragraph which

2135:22

will say like no

2135:24

programming languages come on l n g a g

2135:28

s languages found and now let me just

2135:30

save there but if that's not the case

2135:32

like if we have some languages so in

2135:34

that situation we have to render our ul

2135:36

and then in inside this UL we have toate

2135:39

over through all of our languages so

2135:40

I'll use like languages. map and provide

2135:44

my language right here and also the

2135:46

index and it should be just a singular

2135:48

language not a languages okay so now

2135:51

inside there come on let me just close

2135:53

what the hell am I doing today I can't

2135:56

want type today so let's just write our

2135:57

Ali and inside this Ali we are going to

2136:00

be rendering our language and I'm going

2136:01

to also paste my key and the key will be

2136:03

set to index so now let's just save

2136:05

there and this is how it looks like

2136:07

right here so if we don't have any

2136:09

languages then we are going to be

2136:10

showing this message to our user but if

2136:12

we have some languages then we're going

2136:14

to be showing this uh message or showing

2136:17

those languages to be precise so now

2136:18

let's just close there I'm going to go

2136:20

ahead and go to my test components and

2136:22

inside there we are going to be creating

2136:24

our file with the name of programming

2136:26

list. test. TSX okay so now inside there

2136:30

the first thing that we have to do is

2136:31

that we have to render I mean like we

2136:32

have to import the render and also the

2136:34

screen from where from we testing

2136:36

Library reactj and now underneath that

2136:39

we also have to import our programming

2136:41

languages list okay it is super long and

2136:45

also we have to use our describe and now

2136:48

I'll just give it the name of like Pro

2136:50

come on programming

2136:52

languages list component there we go I'm

2136:57

going to use like it should render a

2137:00

list of pro come on programming

2137:04

programming languages there we go so now

2137:07

inside there let's just create or array

2137:08

so that we can iterate over through

2137:10

there so I'll just create a few

2137:11

programming languages like JavaScript

2137:14

the king and python ah yeah so yeah cool

2137:19

then we have a ruby ah yeah Ruby and

2137:22

then we have

2137:24

jav jav and then we have a the Guard the

2137:28

guard which is a goinging and then I'm

2137:30

going to just use like const languages

2137:32

and I'm going to store them inside this

2137:34

variable so now let me just save them

2137:36

and now we are going to be p there to

2137:38

our virtual Dom so first of all we have

2137:40

to render our component to our virtual

2137:42

Dom so I'll use like programming

2137:43

languages and render my component like

2137:45

so and here is going to take a languages

2137:47

as a perimeter and we are going to be

2137:49

passing that languages as a prop right

2137:53

here there we go the next thing that we

2137:55

have to do is that we have to iterate

2137:56

over through this list and then we're

2137:58

going to be providing our expectations

2138:00

so I'll just use like languages. for

2138:02

each and here let's just put one

2138:04

language right here and inside then um

2138:07

let's just close there come on what the

2138:09

hell am I doing today and inside there

2138:11

we have to provide our expectations so

2138:12

I'll just provide like screen and then

2138:15

dot but here is the question how in the

2138:18

world we are going to be selecting like

2138:20

each language Let me just go ahead and

2138:21

go to my uh component right here like

2138:24

how in the world we are going to be

2138:25

selecting this Li well it is simple when

2138:28

you know the solution so yeah it is

2138:30

simple but if you don't know the

2138:31

solution so it is not so I'll use like

2138:33

get by text and here we just have to

2138:36

copy this this language and we have to

2138:38

place it right here so it's going to

2138:40

select the specific language and then

2138:42

we're going to be providing like to be

2138:44

in the document now let me just execute

2138:46

there save my file go there and now let

2138:48

me just refresh there and here you can

2138:50

see our test is now successfully passing

2138:52

which is this uh programming languages

2138:54

so now let me just expand there and also

2138:56

expand this one so yeah our test is now

2138:59

successfully passing if I just remove

2139:02

that from here and sa my file and here

2139:05

you can see we are now getting this

2139:06

error right here because our test is now

2139:08

failing so this is how we are going to

2139:10

be testing a component with the props so

2139:13

I'm going to also collapse there and now

2139:15

let me just provide a languages empty

2139:17

array so I'll just use like it should

2139:19

come on should render a message when

2139:23

list is empty so in this situation what

2139:26

we have to do uh we have to first of all

2139:29

render our programming languages

2139:31

component and here I'm going to execute

2139:34

that and I'm going to provide my

2139:35

languages but tot empty languages

2139:39

nothing inside there so I'm going to

2139:41

just provide my expectation right here

2139:43

so I'm going to say like expect and it

2139:44

should get the screen. getet by text not

2139:47

R but text and then we have to provide

2139:50

like no programming and why am I

2139:53

providing that that's because when we

2139:55

don't have any languages so in that

2139:57

situation which means like we're going

2139:58

to be getting this error message so

2140:00

that's why we are now getting this

2140:02

paragraph with this message like no

2140:05

programming language is found so I'm

2140:06

going to only select this portion like

2140:07

no programming but if you want to select

2140:09

that by this entire message you can

2140:11

totally do that so I'll just provide

2140:13

like no programming that's it and I want

2140:16

it to be in the document and now let me

2140:18

just execute that and save my file and

2140:20

check this out and here you can see all

2140:22

of our test are now successfully passing

2140:25

and this is our final test if you want a

2140:27

broke test I'll just provide like a sa

2140:29

my file and here you can see where test

2140:31

is now failing so yeah this is how we

2140:33

are going to be testing a component

2140:35

which takes a list of items

2140:37

Or List component now let's talk about

2140:40

the king the heart of react testing

2140:42

component which is called get by roll so

2140:45

what it is and why should anyone care

2140:47

about that so get by role is a query

2140:49

method used to find Dom Elements by

2140:51

their area rol so what is that area or

2140:55

area role that simply means accessible

2140:58

Rich internet application so area roles

2141:00

explain what an element does or its

2141:02

purpose especially for accessibility

2141:05

this method is a part of a set of tools

2141:07

used to test how accessible and

2141:09

interactive your application is it helps

2141:11

to understand how users with the screen

2141:13

readers or other assitive Technologies

2141:15

would use your app so that was just a

2141:18

quick definition of get by ro but now

2141:20

let's talk about how in the what we are

2141:21

going to be using there well this is a

2141:24

method so first of all we are going to

2141:25

be using a screen and then we are going

2141:27

to be using the dot get by rule and then

2141:30

we can specify the rule and also the

2141:32

option but now let's talk about what is

2141:34

a role it is a string representation of

2141:36

a re Ro for which we are looking for

2141:39

like for example if you want to select

2141:40

the button we going to be providing a

2141:42

button if you want to select the link or

2141:44

text box or heading and so on and so

2141:46

forth which I'm about to show you in a

2141:48

few seconds but we are going to be first

2141:50

of all providing our role as a string

2141:53

and then we have optional option object

2141:55

which can include some additional

2141:56

configuration if it only can but we

2141:58

don't have to so yeah that was get by

2142:01

rule so how that's going to work suppose

2142:03

we have this component and inside this

2142:05

component we have our Dev and inside

2142:07

that D we have our button which will say

2142:09

like click me so how we are going to be

2142:11

selecting there first of all we are

2142:12

going to be writing our test and then we

2142:14

will render our component to the virtual

2142:16

Dom if you want to select this we are

2142:18

going to be using a screen and then do

2142:20

get by Ru and here we can specify our

2142:23

area or area label and then we can

2142:26

provide like additional options if you

2142:27

wanted to and finally we can just

2142:29

provide our expectation and this is how

2142:31

we are going to be testing there so like

2142:32

why get by rooll like there are a lot of

2142:35

other methods which you can choose from

2142:37

so why is this get by ro so special

2142:40

first of all it provide accessibility it

2142:42

encourages developer to think about the

2142:44

accessibility of their component that's

2142:46

the first thing secondly this allows us

2142:48

to provide a reliability like queries

2142:50

based on AA role are less likely to

2142:52

break when the internal structure of

2142:54

their component changes finally it

2142:56

allows us to use best practices it helps

2142:59

align test with how user interact with

2143:00

your application like screen readers

2143:03

keyboard navigation and clicking and so

2143:05

on and so forth so so that was just a

2143:07

quick definition of get by roll so now

2143:10

let's get into the coding and then you

2143:11

will get to know what I'm talking about

2143:13

so now let's talk about get by roll and

2143:15

we are going to be learning about area

2143:17

labels in a lot of great detail so what

2143:19

I'm going to do is that I'm going to go

2143:20

ahead and go to my components folder and

2143:23

now I'm going to create another file

2143:24

with the name of finding Elements by Ru

2143:28

or something like that roles I guess Ru

2143:31

would be find. ESX and now inside there

2143:33

I'll just use my RFC inside there and

2143:35

let's just remove them from here and

2143:37

first of all I'm going to be creating

2143:39

first of all the element and I'm going

2143:41

to also mention the accessibility role

2143:43

or the area role or area role whatever

2143:46

you want to call that so first of all we

2143:48

want to select the anchor tag so to

2143:51

select the the area role for there so

2143:52

I'll just use like uh you know let me

2143:54

just provide a link because the area

2143:56

rule for that is a link and I'm going to

2143:57

provide an anchor tag and we're not

2143:59

going to be going to anywhere so the

2144:01

accessibility role it has is a link and

2144:03

now let me just save my file okay so

2144:05

what I'm going to do is that I'm going

2144:06

to go ahead ahead and uh go to my

2144:09

components folder and Define my finding

2144:12

Elements by row. test. TSX file right

2144:16

here and first of all we have to import

2144:18

our render and also our screen from the

2144:21

react testing Library like so from the

2144:24

react there we go and we will also

2144:26

import our finding Elements by R and now

2144:28

let's just sa there here let's just Prov

2144:30

where describe and we will just describe

2144:32

there like finding or find elements or

2144:36

finding elements and I'm going to

2144:38

provide my first case which will be it

2144:40

should quy the link element so how are

2144:43

we going to be doing that well we just

2144:45

have to render our component which will

2144:47

be finding Elements by R and now let me

2144:50

just execute there now we're going to be

2144:52

providing our expectation and let's just

2144:54

use our screen and now if I just use dot

2144:57

here you can see we have a lot of

2144:58

methods so one of the best method which

2145:00

we are going to be using is is get by R

2145:04

okay so now let me just execute them and

2145:06

as you can see right here it takes a rle

2145:08

and it also take the optional options

2145:11

object right here okay so if you want to

2145:13

select that we already know that we are

2145:15

going to be selecting this anchor tag

2145:17

and this anchor tag has the area label

2145:20

of link so now let's just provide a link

2145:22

right here and that's it and finally we

2145:25

want that to be in the document and now

2145:27

let me just execute my file and let's

2145:29

just fresh that you know what I'm going

2145:31

to have to delete those other components

2145:33

or maybe I'm going to leave them so we

2145:36

we are only interested in this one

2145:38

component like finding Elements by R let

2145:40

me just expand there yep our test is now

2145:43

successfully passing let me just zoom in

2145:45

a bit and yeah that's working the way we

2145:46

expect him to work so this is how we're

2145:48

going to be finding a specific Dom

2145:50

element by their area label okay so

2145:53

that's done now let's talk about how are

2145:55

we going to be selecting a button so

2145:56

I'll just write a button with the label

2145:58

of button and we already know that if

2146:00

you want to select there so the area

2146:02

label for there will be button so now

2146:04

let me just save my file and I'm going

2146:06

to just duplicate my test once again and

2146:09

here let's just change them it should

2146:10

query the button element and if I just

2146:13

write a button right here so it will not

2146:15

complain so now let me just save my file

2146:17

and here you can see the button is now

2146:19

successfully retrieved so which means

2146:21

like everything is working the way we

2146:23

expect them to work suppose if you want

2146:24

to get the fer so let's just use a fer

2146:27

and I'm going to provide a label which

2146:29

will be a Content info unfortunately

2146:32

this is the area label for there so we

2146:34

are going to be using a content in Ino

2146:37

so now let me just save my file and I'm

2146:39

going to duplicate there once again

2146:41

let's just duplicate there and provide

2146:43

my enter and select the footer it's all

2146:46

Ed like footer and here we have to

2146:48

specify our content info and it should

2146:51

be a lowercase content info like so so

2146:54

now if I save my file it's going to also

2146:56

select and everything is working the way

2146:58

we expect them to work so that's totally

2147:00

done suppose if you want to select like

2147:02

H1 so I'll just write like this H1 and

2147:04

the area or area label there will be a

2147:07

heading okay so I'll just provide like

2147:09

uh heading right here so now let's just

2147:12

say our file and I'm going to duplicate

2147:15

there once again and I'm going to change

2147:16

that to H1 and here we're going to be

2147:18

selecting there by the area level of

2147:21

heading so now let's just provide this

2147:23

say our file and here you can see where

2147:25

component is rendering and selecting our

2147:27

H1 so which means like everything is

2147:29

working let's suppose if you want to

2147:30

select the header so I'll just use like

2147:33

header and I'm going to provide my

2147:36

banner

2147:37

and let's just provide a banner right

2147:39

here so Banner s file and I'm going to

2147:41

go a bit fast because I know the rest of

2147:43

them is just a theory it should quer the

2147:45

head header element and it is a banner

2147:47

so now let me just provide this on my

2147:49

file and here you can see it is now

2147:51

selecting there let me go ahead and

2147:53

create an image so I'll use like image

2147:55

and I'm going to also provide some sort

2147:57

of alternative text to this so let's

2147:58

just remove there and it should be a

2148:01

description d s c come on d s c r i p t

2148:04

i o n for the area level for there will

2148:06

be image and now let's just select them

2148:09

I'm going to duplicate there once again

2148:11

I know I'm repeating myself and my code

2148:13

again and again that's because I want to

2148:15

show you those area labels I know you

2148:18

are a lazy person you don't want to do

2148:20

that by yourself so now you're watching

2148:22

this video so you will learn this so now

2148:24

let me just save my file and here you

2148:25

can see it's going to also select our

2148:27

image right here suppose if you want to

2148:29

select an input field with the type of

2148:31

number so the accessibility or area

2148:33

level for there will be spin button okay

2148:36

so now let me just save my file now let

2148:38

me duplicate this line of code and here

2148:40

let's just provide our number element or

2148:43

number input and it should be a spin

2148:46

button so now let's just save there and

2148:47

here you can see it is now selecting

2148:49

there successfully and let's suppose if

2148:51

you want to select like the UR which

2148:53

will be a list item and here let's just

2148:56

C our list item say my file and I'm

2148:59

going to just duplicate this line of

2149:00

code and change that to the UL so it

2149:05

should query the UL

2149:07

and I'm going to provide my list item

2149:09

right here list item let's say our file

2149:12

and my test is failing that's because it

2149:14

is not a list item it is just a list let

2149:17

me just save there and here you can see

2149:19

our test is now successfully passing and

2149:21

now let me show you the final one and I

2149:23

promise that's going to be the final one

2149:25

okay so let's just use our lii suppose

2149:28

if you want to select the LI so then it

2149:30

is a list item this is going to be just

2149:32

a list so I'm going to make it as a list

2149:35

and these are a list item so I'll use

2149:37

like list item and now let me just save

2149:40

my file and I'm going to paste like a

2149:43

list come on I'm going to duplicate

2149:45

there first of all and now let me

2149:47

provide my li and Li will be just a list

2149:52

itm and now let me just save my file

2149:54

test this out so yeah it will also

2149:55

select that lii so this is how we are

2149:57

going to be selecting The Elements by

2149:59

using the get by roll and also the area

2150:02

level in the beginning of this course I

2150:04

mentioned that we are going to be

2150:05

spending a lot of work over time on the

2150:07

screen object and its properties so now

2150:10

let's talk about it so what are we

2150:11

talking about we are now talking about

2150:13

the buy placeholder text by display

2150:15

value by label text by all text by T ID

2150:18

by rule by tiies by Title by text so we

2150:22

are going to be learning about all of

2150:24

them but now let's just break them down

2150:26

one by one now I know a lot of you will

2150:28

say like hus there a lot of methods but

2150:31

don't worry I have a formula which will

2150:33

help you master all of them so what is

2150:36

the that formula well first of all we

2150:39

are going to be categorizing all of that

2150:41

methods in three category so the first

2150:43

category we have is a get bu then we

2150:46

have a find by and then we have a query

2150:48

by so whenever you see those method with

2150:50

get that simply means that the purpose

2150:53

of them will be when the element must be

2150:55

found in the Dom and the behavior will

2150:58

be it will throw an error if the element

2151:00

is not found in the use case will be

2151:03

when you are sure that the element will

2151:04

be present during that test so this is

2151:07

how we are going to be using all of them

2151:09

with get now let's talk about how we can

2151:11

use them with query so whenever we see

2151:14

that method with queries so that simply

2151:16

mean that the purpose of them will be

2151:18

when the element may or may not be found

2151:21

and the behavior will be it will return

2151:23

no if the element is not found and it

2151:25

will not gives us error like no error

2151:27

whatsoever so it's going to gives us no

2151:29

in the use case will be when you need to

2151:31

check for the non-existing of an element

2151:33

or it is okay if the element is in there

2151:36

okay so this is how we going to be using

2151:38

those method with query and now let's

2151:40

talk about the final one which is called

2151:42

the find so the purpose will be we use

2151:44

them for asynchronous element those

2151:46

element that will appear after some

2151:48

delay like after some time so we usually

2151:51

use find with some asynchronous code and

2151:54

then we have the behavior so it will

2151:55

just return a promise that results when

2151:58

the element is found or reject after the

2152:00

default timeout which can be also

2152:02

configured by the way and the use case

2152:04

will be when you are testing something

2152:06

it will appear asynchronously like for

2152:08

example API call or user interaction or

2152:11

database call or something like that so

2152:14

then we can use all of them with all so

2152:16

like we have get all by then we have a

2152:19

find all by and then we have a query all

2152:21

by so we can use all of them for

2152:24

handling multiple element of the same

2152:26

time and the behavior will be this query

2152:28

return array or list of elements and the

2152:31

use case will be when you expect

2152:32

multiple element and want to interact

2152:34

with all of them so that was about the

2152:36

get by find by query by and get all by

2152:40

find all by and query all by so let me

2152:43

just show you all of them in diagram so

2152:45

the first one we have is a get by and

2152:47

the use case for there is like when you

2152:49

expect the element to be in the dome and

2152:51

it return single element and it throws

2152:54

an error if the element is not found

2152:56

then we have a query by and the use case

2152:58

for there will be when the element may

2153:00

or may not be exist in the Dom and it

2153:02

will return a single element or no and

2153:05

it will not throw a an error okay so if

2153:07

the element is not found so it's going

2153:08

to gives us null but not errored then we

2153:11

have a find by so when the element is

2153:13

asynchronous like it will appear later

2153:15

it will take some time so it will return

2153:18

promise like single element and yeah it

2153:20

will throw us an error if the element is

2153:22

not found then we have a get all by when

2153:24

you expect multiple element like for

2153:26

example array of elements and it will

2153:29

throw an error if the element is not

2153:31

found and then we have a query Al by and

2153:34

it is exactly the same like as the

2153:35

previous one so when multiple element

2153:38

may or may not exist and it will return

2153:41

array of element or empty array and it

2153:43

will not gives us an error like it will

2153:45

not throw us an error then we have a

2153:47

find all by so when multiple element

2153:49

appear asynchronously so it will return

2153:52

promise array of element and if the

2153:54

element is not there yet so it's going

2153:56

to gives us an error so that was all of

2153:58

them so now let's get into the coding

2154:00

and you will master all of them okay so

2154:03

now let's start from the first one which

2154:05

is a get by so I'm going to go ahead and

2154:08

create my component with the name of get

2154:10

by queries. ESX and first of all we are

2154:13

going to be writing our code and then we

2154:15

will get into that testing part so let

2154:17

me just remove that label and I'm going

2154:18

to just write my H1 and I'll say like my

2154:21

component there we go now underneath

2154:23

there we going to be creating a button

2154:25

which will say like submit and I'm going

2154:26

to also specify the area label label

2154:29

like so and that's going to be set to

2154:31

submit now underneath there we have to

2154:33

create our button and it's going to say

2154:35

like cancel Maybe c n c there we go and

2154:38

we're going to be passing the ID and ID

2154:40

will be set to cancel button and now

2154:43

underneath we have to create our input

2154:45

field and this input field will have the

2154:47

type of text and we're going to be also

2154:49

placing a placeholder which will say

2154:50

like enter the text and now let's just

2154:52

also provide our anchor tag and here we

2154:55

can just P like some I don't know maybe

2154:57

https and then uh maybe example.com

2155:00

would be fine just write like example or

2155:02

test.com or something like that I'm

2155:04

going to also provide the target and the

2155:06

target will be set to blank and I'm

2155:09

going to put the rail and rail will be

2155:11

set to this thing which I can't

2155:13

pronounce so that's why I didn't even

2155:15

bother okay so let me just provide a

2155:17

label like visit uh viit example now

2155:22

need let just cre word div and I'm going

2155:24

to past like custom element and here I'm

2155:27

going to also paste the data past ID and

2155:30

it's going to be set to now let me just

2155:32

s my file and go back so this is all the

2155:35

stuff that you have to write right and I

2155:36

want you to also provide these attribute

2155:39

as well because now we are going to be

2155:40

selecting all of them inside our test

2155:42

file so what I'm going to do is that I'm

2155:44

going to go ahead and go to my

2155:45

components and let's just create word

2155:47

get by

2155:49

queries. test. TSX right here and the

2155:53

first thing that we have to do is that

2155:54

we have to render I mean like import our

2155:56

render and also our screen from where

2155:58

from our testing library reactjs and we

2156:01

also have to import or come on import or

2156:05

get by queries from that component

2156:07

folder and we also have to provide our

2156:09

describe and describe our code which

2156:11

will be get by queries and inside there

2156:14

I'm going to provide my it and it should

2156:16

should render the component with the

2156:19

correct so let's just start from the

2156:21

heading which is this H1 right here so

2156:24

how the what we are going to be using

2156:25

there well first of all we have to

2156:26

render our component then we will think

2156:29

about this so I'll use like get by

2156:30

queries now underneath we're going to be

2156:33

using that screen and here if I hit done

2156:36

as you can see right here we have

2156:37

millions of them not Millions but we

2156:40

have a lot of them so I'm going to be

2156:42

using like get by text and now let's

2156:44

just provide like my uh my component

2156:48

there we go and I'm going to also store

2156:49

that inside the heading variable and now

2156:51

let me provide my expectation so expect

2156:54

and let's just provide my heading to be

2156:56

in the document to be in the document

2156:58

there we go and now I'm going to save my

2156:59

file and now if I sve my file and here

2157:02

you can see we are now getting this

2157:04

check result right here like everything

2157:05

is successfully passing so yeah that's

2157:08

looking cool and this is how we are

2157:09

going to be selecting our H1 by using uh

2157:14

get by text so that's done the next

2157:16

thing that we have to do is that uh we

2157:18

have to create another test Suite so

2157:20

I'll use like it uh should find an input

2157:23

with

2157:24

placeholder text so I'll just select

2157:27

like this placeholder text which is this

2157:29

input field right here so how are we

2157:31

going to be selecting that I'll use my

2157:33

render method and let's just provide our

2157:35

get by queries and clouds there and now

2157:38

underneath we are going to be using our

2157:40

screen and let's just use get by

2157:42

placeholder and here you can see we're

2157:45

now going to be ping this placeholder

2157:46

text right here like enter the text so

2157:49

I'm going to copy that and now let me

2157:51

just come on what the hell am I doing

2157:53

let me just provide that right here and

2157:55

I'm going to store the inside the

2157:56

variable and I'm going to give it the

2157:57

name of like input field it's going to

2157:59

be equals to this function execution and

2158:02

now let me provide my expectation we

2158:04

want there to be uh in the document and

2158:07

now let's just execute this have my file

2158:09

and here you can see everything is

2158:11

passing as we expect them to pass now

2158:14

let's just hide there and I'm going to

2158:15

also provide another test Suite so what

2158:17

I'm going to do is that I'm going to

2158:19

just write like it should find an an

2158:22

anchor tag with specific hre now we are

2158:27

selecting this anchor tag right here

2158:29

with this specific H is that I'm going

2158:31

to be using that screen once again but

2158:33

first of all we have to render or

2158:35

component so which is by queries and I'm

2158:38

going to just render that right here

2158:40

then we have to use our screen and then

2158:42

get by R and provide my link inside

2158:45

there and here we also have to provide

2158:47

our options and option will be name and

2158:49

we want to select for this specific name

2158:51

like uh visit example come on what was

2158:54

there visit example so I'm going to copy

2158:56

the name of there and place it right

2158:58

here and close there and we already

2159:00

discuss about this get by R and mostly

2159:02

you're going to be using this one but in

2159:04

the majority of time maybe you will use

2159:07

that other one so you know what I'm

2159:09

going to store the inside the link

2159:10

variable so I'll use like link is going

2159:12

to be equals to this function execution

2159:14

and provide my expectation and here we

2159:16

have to pass our link and to have

2159:18

attributes and let's just provide our

2159:20

HTF and proide my https and you know let

2159:23

me just copy this attribute from here so

2159:26

I'm going to copy there and let's just

2159:27

paste it right here and now let me just

2159:29

save there and now my test is

2159:31

successfully passing because it has that

2159:33

specific attribute done I'm going to to

2159:36

also close there now underneath there

2159:37

what we have to do we have to create two

2159:39

more test SS so I'll just create my it

2159:42

and it should find a div using data test

2159:46

ID which we already defined right here

2159:49

now we are going to be selecting there

2159:51

so if you want to select them first of

2159:53

all we have to render our component

2159:56

which is a get by queries and now let's

2159:58

just close there God damn it and now

2160:01

underneath there let's just use our

2160:02

screen. getet by test ID and now here

2160:05

we're going to be passing our custom

2160:07

element right here okay so let's just

2160:09

use our custom element it's going to be

2160:11

equals to this function execution or

2160:14

that method so I'll just put like expect

2160:16

in custom element will be in the

2160:18

document and now let me just execute

2160:20

that and here you can see my test is now

2160:22

passing but now if I go ahead and uh

2160:25

let's just say like if I just remove the

2160:27

sa my file and my test will fail and now

2160:30

let me just Pride there once again and

2160:33

it is passing so now let me just hide

2160:35

there once again in and finally we have

2160:37

to provide yet another test case so I'll

2160:39

just use like it should come on should

2160:42

find an element by its row and here

2160:45

let's come on it should be a row and

2160:48

render or get by queries and here we are

2160:52

going to be using our screen get by rle

2160:55

and provide my rle which will be a

2160:56

button now we are going to be passing a

2160:58

name and name will be set to submit so

2161:00

we only want to get that specific button

2161:02

so I'll use like button and semi file as

2161:05

you can see right right here so we have

2161:06

two buttons and we only want to select

2161:09

like this button not their second one

2161:11

okay so for them uh we are going to be

2161:13

using that expect and pride my button

2161:15

inside there and to be in the document

2161:18

now let me just save my file and here

2161:20

you can see everything is passing the

2161:22

way we expect him to pass and that was

2161:24

our get by queries next we are going to

2161:27

be learning about get by all queries so

2161:29

now let's talk about get all by queries

2161:31

so what I'm going to do is that I'm

2161:33

going to create a file with the name of

2161:34

get all by queries. TSX and now inside

2161:38

there we're going to be creating our

2161:40

component first of all so now let's just

2161:41

do there I'm going to go there and

2161:43

inside there first of all we going to be

2161:45

creating our label and I'm going to give

2161:47

it the lbel of input one I'll just say

2161:49

like label for input one and now

2161:52

underneath there we're going to be

2161:53

creating our input field with the type

2161:55

of basically nothing and also I'm going

2161:57

to provide a placeholder to there in

2161:59

placeholder will say like enter text

2162:01

here here and I'm going to also create

2162:04

the ID and ID will be set to input one

2162:06

and I'm going to also provide the value

2162:08

and the value will be set to default

2162:10

value I'm going to also make it disabled

2162:12

so it will look something like this now

2162:14

let me just copy and place that right

2162:17

here just like that and now we are going

2162:19

to be changing this label so I'll just

2162:21

change that to like input two and also

2162:23

label for the input two another a n o t

2162:26

h e r another placeholder like so and

2162:30

another value and let's just also make

2162:32

there as input two now underneath that

2162:34

we going to be finding two input Fields

2162:36

so I'll just write like input with the

2162:38

type of basically nothing and we're

2162:41

going to be providing a placeholder and

2162:42

placeholder will say like enter

2162:44

something come on something oh my God

2162:46

something dot dot dot I'm going to also

2162:48

duplicate and it should be like

2162:50

something else or yeah that's going to

2162:51

be fine I'm going to also create a

2162:53

paragraph which will say like this is a

2162:55

paragraph with some text content dot so

2162:59

now let's just duplicate there and I

2163:00

guess that's going to be fine I'm going

2163:02

to also create an input field once again

2163:04

so that we can select them forward tting

2163:05

so I'll use the uh input field and now

2163:08

let's just remove the I'm going to also

2163:09

proide the value and the value will

2163:10

select some display value and I'm going

2163:13

to duplicate and change it to another

2163:15

display come on display value now

2163:18

underneath let's just create our images

2163:20

and we're not going to be passing any

2163:21

images but I'll just provide like image

2163:23

1.png we don't even have those images

2163:25

but we now providing so that we can

2163:27

provide our test based on this so I'll

2163:29

use like a simple image or something

2163:32

like that and I'm going to also

2163:33

duplicate and change there to like

2163:35

another simple image and this should be

2163:37

the image to right here so now

2163:39

underneath there we're going to be

2163:40

creating a div which will say like uh

2163:42

div come on div content with title

2163:46

attributes and I'm going to also provide

2163:47

a title so like whenever you hover over

2163:49

this is going to show you this message

2163:51

like this is a div with title attribute

2163:54

and I'm going to also duplicate that and

2163:55

change that to another div another div

2163:59

with title attribute and the content

2164:01

will be another D with a Content or

2164:04

another the content there we go so now

2164:07

that's totally done I'm going to also

2164:09

provide one for the button so I'll just

2164:11

provide a button which will say like

2164:12

disable button one and I'm going to

2164:15

provide the rule and the rule will be

2164:16

set to button and here let's just proide

2164:18

our area label come on area label and

2164:22

that's going to be set to this is a

2164:24

button now let me just duplicate that

2164:26

and I'm going to also change that to the

2164:27

button too and this should be button

2164:30

like so and I'm going to also change

2164:32

those labels so that it will look a bit

2164:33

better now underneath there let's just

2164:35

create word which will have the level of

2164:37

uh this div has test ID of one dot and

2164:41

this test will have the ID of two I'm

2164:43

going to also provide the Tera test ID

2164:46

right here so that we can select the

2164:48

forward test so it's going to be set to

2164:49

like custom test ID one or something

2164:52

like that and you know what let me just

2164:53

copy that from here and now let me just

2164:56

place that right here I'm typing a bit

2164:59

fast so now let's just change that to

2165:00

like uh custom test id2 and now let me

2165:03

just sa my file and that's going to be

2165:04

at forward G X now let me go ahead and

2165:07

go to my test components and here we are

2165:08

going to be creating our get all by

2165:11

queries. test. G not jsx but TSX now

2165:16

let's just create our test so the first

2165:18

thing that I want to do is I want to

2165:19

import my render and I'm going to also

2165:21

import the screen from where from our

2165:23

testing Library VJs that's going to be

2165:26

fine and we would also need to get our

2165:29

get all by queries from our component

2165:31

and now is pro our describe so not

2165:34

declare but describe there we go

2165:36

and here I'll just say like um get all

2165:39

by queries and it should first of all

2165:42

let's just provide there for the first

2165:43

one so it should render multiple that

2165:46

can be queried by various v i o us

2165:50

various methods so it should be v a r i

2165:54

o o us there we go v a r i o u s now

2165:58

inside there we are going to be

2166:00

providing all of our test Logics I don't

2166:01

want to create those EDS and also that

2166:03

render again and again I don't want to

2166:05

waste your time so we are going to be

2166:06

doing that right here but you don't have

2166:08

to do that in real world projects as I

2166:10

show you in the beginning of this course

2166:12

so like you don't have to do there I

2166:14

want to save some time so that's why I'm

2166:15

doing it this way so I'll use like get

2166:17

all by query and I'm going to just close

2166:19

that right here sa our file and now

2166:21

underneath there let's just first of all

2166:23

select our input labels as you can see

2166:25

right here so we are going to be

2166:26

selecting this input and also this label

2166:28

so that we can test there so the first

2166:30

thing that I want to do is that I want

2166:31

to use the screen and then get all by

2166:34

label text so me just provide there

2166:36

right here and here we're going to be

2166:38

placing our regular Expressions all

2166:39

select label for input come on input and

2166:42

here let's just provide our I which

2166:44

means like if this is either upper case

2166:46

or lower case we don't care about the we

2166:48

want you to just search for this element

2166:50

and gives us all of them so where in the

2166:52

word is that one available so now let me

2166:54

just copy that and now let me just place

2166:55

it right here so as you can see it's

2166:57

going to gives us this input and it's

2166:58

going to also gives us this second input

2167:00

right here so I'm going to store the

2167:02

inside the variable so I'll just give it

2167:04

the name of like inputs by label X going

2167:07

to be equal to this function execution

2167:10

and now here we can provide our

2167:11

expectation like inputs that variable

2167:13

and then here we can get the length to B

2167:16

two and now underneath there let's just

2167:18

iterate over through all of our input

2167:20

Fields like here we can see we have more

2167:22

than one so which means like we're going

2167:23

to be iterating over through there so

2167:25

we'll use like inputs uh you know what

2167:27

inputs by label text and let's just use

2167:30

our for each right here and we're going

2167:32

to be passing our input Right Here and

2167:34

Now inside there is pro to our

2167:36

expectations so I'm going to pass my

2167:37

input here to be in the document and now

2167:39

I'm going to execute that I'm going to

2167:41

also duplicate the once again and here

2167:43

we want it to be disabled so now let's

2167:46

just save our file so now let me just

2167:47

save my file and now I'm going to run my

2167:49

code so I'm going to use like npm run

2167:51

test UI so it's going to run my as you

2167:53

can see all of our test are now

2167:54

successfully passing and we are now

2167:56

getting every single thing totally

2167:58

passed now we are going to be selecting

2167:59

these input Fields with these

2168:01

placeholder so how can you go about

2168:03

doing that once again I I am not using

2168:06

this it again and again because I want

2168:08

to save some time and you should be

2168:10

doing that so you know what let's just

2168:12

first of all use our screen and we have

2168:14

a get all by Place holder text so it's

2168:16

going to gives us the collection of them

2168:18

so we would use like enter something and

2168:20

I'm going to also paste this I for

2168:22

Rejects and now here let's just store

2168:24

the inside the variable with name of

2168:25

inputs come on inputs by place there we

2168:28

go and now it's going to be equals to

2168:29

this function and I'm going to also

2168:31

provide my expectation right here so

2168:32

that inputs uh you know let's just copy

2168:35

them I'm going to copy there right here

2168:36

and now let me just place there and here

2168:38

we also need the length and we want it

2168:40

to be two now let me paste it right here

2168:43

once again now let's just iterate over

2168:45

through there because we know it's going

2168:47

to gives us a collection so here let's

2168:48

just put our expectation so we want the

2168:50

input to be in the document so this is

2168:53

used to be in the document and now I'm

2168:54

going to also duplicate and change that

2168:56

to be disabled and now let me save my

2168:58

file and our test is failing okay

2169:02

received element is not disabled let's

2169:04

just check check this out so yeah it

2169:07

isn't disabled so now let me just make

2169:08

that disable I'm going to copy that and

2169:10

place it right here and now let's just

2169:12

check this out and here you can see our

2169:14

test is now successfully passing that's

2169:15

cool now let's go ahead and just select

2169:17

this paragraph and now let's just go

2169:20

there and select these paragraphs so I'm

2169:22

going to be using like screen and then

2169:24

get all by text and now let me just hit

2169:26

enter right here and you want to access

2169:28

there by this text so like this is a and

2169:30

let me just copy that from here I'm

2169:32

going to only copy this portion so let's

2169:34

just copy that if you want to copy the

2169:36

entire portion you totally can but in my

2169:38

case I'm not going to so I'll just store

2169:40

the inside the variable with the name of

2169:42

paragraphs by text and it's going to be

2169:44

equals to this text right I mean like

2169:46

this method and now here we have to

2169:47

provide our expectation so paragraph by

2169:50

text and we want to get the length of

2169:51

there and we want there to be only two

2169:54

and now underneath let's just itate over

2169:56

through there so I'll use like for each

2169:58

and for each paragraph what do we have

2170:00

to do uh we have to provide our

2170:02

expectation and let's just provide our

2170:04

paragraph inside and we want there to be

2170:06

in the document so now let's just sa our

2170:08

file and once again all of our test are

2170:10

now successfully passing now that we

2170:11

successfully selected these paragraph

2170:13

the next thing that we have to do is

2170:14

that we have to select these input

2170:16

Fields so I'm going to go ahead and just

2170:18

select them so what I'm going to do is

2170:20

that I'm going to past like screen then

2170:22

dot come on screen. getet all by display

2170:27

value okay so let's just put like some

2170:29

what was that it was some display value

2170:33

I guess so it shouldn't be some display

2170:35

value or you know let me just select

2170:37

this one we don't care about this one so

2170:39

I'm going to just select there I'll use

2170:40

like uh some display value and provide

2170:45

my I there now let's just store the

2170:46

inside the variable with the name of

2170:48

inputs by display value and going to be

2170:50

equals to this function now underneath

2170:52

we going to be providing our expectation

2170:54

and let's just provide our input and

2170:56

yeah that's same thing okay provide our

2170:58

length and we want there to be only one

2171:01

because we only want to select this

2171:02

first one we don't want to select this

2171:04

second one okay so we only want to get

2171:06

there one and now let's just provide our

2171:08

expectations so let's just provide like

2171:10

inputs in their display variable and we

2171:13

only want to get the first one and we

2171:15

want it to be in the document and we

2171:17

also want it to be disabled so let's

2171:20

just Pro our disabled right here and I'm

2171:22

going to also make the disable so let's

2171:24

just use like disable sa our file save

2171:26

this file and all of our test are now

2171:28

successfully passing the next thing that

2171:30

we have to do is that we have to select

2171:31

these images right here so what I'm

2171:33

going to do is that I'm going to go

2171:34

there and now underneath that I'm going

2171:36

to use the screen and then get all by

2171:39

all text so I'll use like all text

2171:42

because we want to get there by this

2171:44

alternative text so that's why I'm using

2171:46

like get get all by all text right here

2171:49

and I'm going to just P like another

2171:52

sample image or something like that and

2171:54

it should be sample sample there we go

2171:58

and I'm going to also store the inser

2171:59

the variable with the name of images buy

2172:02

another R text and it's going to equals

2172:05

to that now here we have to provide our

2172:07

expectation and I'm going to be using

2172:09

that same expectation we want to get the

2172:11

length to be only one and now let us

2172:13

also put another expectation here we

2172:15

have to use our uh variable once again

2172:18

and we are only interested in the first

2172:20

one and we want that to be in the

2172:22

document test this out let's just

2172:23

refresh all of our test are now

2172:25

successfully passing so that's toally

2172:27

done so the next thing that we have to

2172:28

do is that we have to select these

2172:29

buttons right here by either with their

2172:32

role or by this area label so what I'm

2172:34

going to do is that I'm going to select

2172:36

there by these rols right here like both

2172:38

of these button have these roll right

2172:40

here roll with the yeah just a roll with

2172:42

a button I'll just write like screen.

2172:45

getet all by rows we already saw there

2172:48

and here we have to provide our button

2172:50

and we're going to be also providing an

2172:51

optional option array which will be set

2172:53

to name and we want to get there by this

2172:55

is a button and we don't care if the

2172:57

text is uppercase or lower case so now

2173:00

let me just store the inside the

2173:01

variable so I'll just use like buttons

2173:03

by row or row would be fine and now

2173:06

based on that we are going to be passing

2173:07

our expectations so button by row and we

2173:10

want to get the length of there and we

2173:11

want there to be two and now let's just

2173:14

itate over through this so I'll use like

2173:16

buttons by row and for each row you want

2173:19

to pass our button so for each button

2173:22

let's just Pro our expectation of button

2173:24

and we want it to be in the document and

2173:27

we also want it to be disable Okay so

2173:31

are we making it disable or not so let

2173:33

me just make the disable so just provide

2173:35

a disable right here come on disable

2173:37

there we go I'm going to copy that and

2173:39

now let me just place it right here save

2173:40

my file save this file and here you can

2173:43

see we are now getting some error like

2173:44

unable to find accessible element with

2173:46

the r of button I have to check this out

2173:48

so I'll just cut that from

2173:51

here we have to put the inside there we

2173:55

go so let's just put there right here sa

2173:57

our file and now our test is

2173:59

successfully passing finally we have to

2174:02

select this div by using these data test

2174:04

ID ID so how I can do that I'll just use

2174:08

like screen by get all by test ID and we

2174:12

want to get them also I'm going to be

2174:13

using like custom test ID and here we

2174:17

are now providing this data I mean like

2174:19

this one like custom test ID one and

2174:20

custom test ID too so I'm going to

2174:22

select both of them and now let me just

2174:24

store there like dives by test ID and

2174:27

it's going to be equals to this function

2174:29

I'm going to also provide my expectation

2174:30

and let's just provide our dives by test

2174:32

ID and we want to get the length and we

2174:35

want there to be two and here let's just

2174:37

iterate over through this I'll use like

2174:39

this um come on let me just copy there

2174:41

what the hell I am bad at spelling so

2174:44

let's just use our for each and provide

2174:46

my div inside there and provide my

2174:48

expectation for the div and we want

2174:50

there to be in the document and I'm

2174:52

going to also execute this my file and

2174:54

here you can see all of our test are now

2174:55

successfully passing so now that we

2174:58

learn that how we are going to be

2174:59

getting something by get all by label

2175:02

text get all by placeholder text get all

2175:05

by text and get all by display value get

2175:10

all by all text

2175:12

and get all by test ID so yeah that was

2175:16

it about the get all next we're going to

2175:18

be covering the query by so now let's

2175:20

talk about the query by so I'm going to

2175:22

just create a file with the name of

2175:24

query by queries. TSX and here we're

2175:27

going to be creating our component first

2175:29

of all and now inside there uh we have

2175:31

to create a d and inside this I'll just

2175:34

set alert message or something like that

2175:36

and we are going to be also providing a

2175:38

roll of alert and I'm going to also

2175:40

provide the area live and that's going

2175:42

to be set to Asser like this and now

2175:45

underneath there we going to be creating

2175:46

a button which will say like click me

2175:48

and now let's just say our file and now

2175:50

we are going to be creating our label so

2175:51

I'll use like label and it will say like

2175:53

uh input one and here we have to past

2175:56

our label one and I'm going to also past

2175:58

my input field and we're not going to be

2175:59

providing any time today but we are

2176:01

going to be providing our ID it's going

2176:03

to say like input one provide our

2176:05

placeholder which will say like search

2176:07

and now here let's just provide our

2176:09

label once again it's going to say like

2176:11

input two in this case and label and I'm

2176:14

going to provide my input here remove

2176:16

this type of text and provide our ID

2176:19

input two so I'll just use like input

2176:21

two and place Holder will be set to

2176:24

email email there we go and now

2176:27

underneath there let's just create our

2176:28

H1 which will have the content of header

2176:31

text and I'm going to also put a

2176:32

paragraph which will say like this is

2176:35

some paragraph text or something like

2176:37

that finally we have to create our div

2176:39

which will say like custom Element e m n

2176:42

and we are going to be providing our

2176:44

data test ID which will be our custom ID

2176:46

so I'll use like custom Element e m n t

2176:50

and now we are going to be creating our

2176:51

input feeld with the type of now you

2176:53

want to type let's just remove there I'm

2176:55

going to provide the value it's going to

2176:57

say like prefilled X or something like

2177:00

that now let me just save my file and

2177:02

these are all for Content so now let me

2177:04

just close there and now let's just

2177:05

create our test file for there so I'll

2177:08

use like query by queries. test. DSX and

2177:12

the first thing that we have to do is

2177:13

that we have to import our render and

2177:15

also our screen from where from our

2177:17

testing library reactjs and also we have

2177:20

to get our query by queries and now

2177:23

underneath that provide our describe

2177:24

method and I'll select test query by and

2177:28

you know let's just remove there but it

2177:30

shouldn't be just query by but I'm going

2177:31

to also provide the methods like plural

2177:34

and here in inside this we we have to

2177:36

first of all select this alert message

2177:38

you know let me just get my component so

2177:40

let's just get there we're going to be

2177:42

selecting this div and then we're going

2177:43

to be also selecting that button so

2177:45

let's just render our component first of

2177:47

all so I'm going to be using like query

2177:49

by and then our component like so now

2177:52

let me get that screen so I'll use like

2177:54

screen and then query by row and here we

2177:57

can just provide our alert and now we

2177:59

are going to be storing there in the

2178:01

alert variable like so I'm going to also

2178:03

select the B so we are going to be using

2178:05

screen. query by roll and provide my

2178:08

button inside there which will have the

2178:10

roll off button so now we have to just

2178:13

provide our expectation and I'm going to

2178:14

provide the alert to be in the document

2178:17

we don't want to do anything crazy and

2178:19

we also want the button to be in the

2178:21

document so I'll use like button and

2178:23

save my file and once I do that here you

2178:25

can see we are now getting this res

2178:28

right here but should oh we just

2178:31

providing a should so should query by

2178:34

rle would be fine now this is looking

2178:36

better so let me just refresh there

2178:39

that's looking better now we are going

2178:40

to be selecting these labels right here

2178:43

so I'll just use like it once again and

2178:46

I'm going to say like it should query by

2178:48

label text and inside there we have to

2178:51

render our component which will be our

2178:53

uh query by queries and now let's just

2178:55

first of all select our first label

2178:57

which is this one and then we are going

2178:58

to be also selecting this level as well

2179:00

so now let's just our file and I'm going

2179:02

to be using screen by query by label

2179:05

text and I'm going to be passing my

2179:07

label one and store that inside the

2179:10

label one like so and you know let me

2179:13

just duplicate there and change there to

2179:14

like label two and change this one to

2179:16

label label two as well and provide my

2179:19

expectation of label one and we want it

2179:22

to be in the document execute it and we

2179:25

also want the label two to be in the

2179:26

document two I'm going to S my file

2179:28

right now and let's just refresh there

2179:30

and this is how it looks like right here

2179:32

okay so everything is passing the way we

2179:35

expect them to pass so I'm going to hide

2179:37

them for a few seconds now you want to

2179:39

select this header and also this

2179:42

paragraph So This is how we are going to

2179:44

be doing the let me just make the in

2179:45

lower case I'm going to create another

2179:47

test site and it's going to say like it

2179:48

should quy by text and render my

2179:51

component right here query by queries

2179:54

and let's just use our screen by query

2179:57

by text not test ID but query by test

2180:01

and here I'm going to just P like heror

2180:03

text which we we are providing right

2180:05

here I'll store that inside the variable

2180:07

with the name of header and I'm going to

2180:09

also get that paragraph as well so now

2180:12

let me just also get this all use like

2180:14

screen query by text not testt ID but

2180:18

just a text there we go and this is some

2180:20

paragraph text and I'm going to also

2180:23

provide my paragraph come on paragraph

2180:26

is going to be equals to this function

2180:28

execution I'm going to provide my

2180:30

expectation and you want to past that

2180:31

header right here and we want that to be

2180:34

in the document and we also want that

2180:37

paragraph to be in the document as well

2180:39

so now let's just sa our file and now we

2180:41

are getting an error let's just check

2180:43

this out okay let me just get there um

2180:45

you provide a value appr to the field of

2180:48

own change this is not something that

2180:49

I'm looking for you know let me just

2180:51

change there to my Rex so it will start

2180:54

working so now let me just change there

2180:56

to Rex still it is not working let me

2180:58

just check this out I click on

2181:01

there okay so we are now getting query

2181:04

by query

2181:06

hardex I mean Herer

2181:08

Tex oh my God Herer Tex and now it

2181:12

should be passing it should be passing

2181:15

now let me just copy that and place it

2181:19

right here and yeah everything is not

2181:21

working the way we expect them to work I

2181:23

even change this one like I shouldn't

2181:25

have to but I thought it may be a

2181:27

problem right here so let me just change

2181:30

that back and yeah okay so we are

2181:32

getting in air what the hell so we have

2181:34

to change that to this reject so now let

2181:36

me just save my file and refresh there

2181:38

and now everything is passing

2181:39

successfully now that we selected that

2181:42

the next thing that we have to do is

2181:43

that we have to select this D by using

2181:45

this data test ID so I'm going to go

2181:48

there I'm going to also hide there and

2181:50

here this's just word or test ID so I'll

2181:52

use like it should query by test ID and

2181:57

I'm going to past like fer and here

2181:58

let's space for query by queries close

2182:01

them I'm going to first of all use

2182:02

screen by query by test ID and provide

2182:07

my custom element and now let me store

2182:09

the inside the variable with the name of

2182:10

custom element it's going to be equals

2182:12

to there and now we have to use our

2182:13

expectation custom element to be in the

2182:17

document come on to be in the document

2182:19

and now let me just execute the sem my

2182:21

file it is passing next we have to

2182:24

select this input field with the type of

2182:27

value with value so I'll just use like

2182:30

it should query by display value and

2182:35

render our component first of all like

2182:38

this and let's just get our um element

2182:42

by using query by display value d i s d

2182:46

l a y display value rather what the hell

2182:49

query by display value this one put this

2182:53

display value inside this so I'll just

2182:55

copy there from here I'm going to copy

2182:57

there and place it right here and store

2182:59

the inside the input and provide my

2183:01

expectation of input and we want that to

2183:03

be in the document and now let's just sa

2183:05

our file and here you can see all of our

2183:07

test are now successfully passing and we

2183:09

are not getting any errors so yeah this

2183:12

is how we are going to be selecting our

2183:13

Elements by using the query by using

2183:16

query by okay so now that we learn about

2183:19

the query by row we also learned about

2183:21

query by label text we also learn about

2183:24

uh what do we call it query by text and

2183:26

also query by test ID and query by

2183:30

display value now let's talk about the

2183:32

query all by query so I'm going to

2183:34

create file with the name of uh query

2183:36

all by queries. TSX and now inside there

2183:41

I'm going to be pasting a lot of GSX and

2183:43

you can find all of that jsx in my gab

2183:45

repository so now let me just go back

2183:48

first of all we have two buttons then we

2183:50

have a two divs with the role of alert

2183:52

and we also have two section with a ro

2183:54

of region then we have what label then

2183:56

we have a input field label once again

2183:59

and we have a input field for the third

2184:01

time then we have input Fields with the

2184:03

placeholder of search and also the email

2184:06

we have our headers we have the

2184:08

paragraph We have a DAT with the custom

2184:10

data test ID and finally we have three

2184:13

more input Fields so you know let me

2184:14

just test this out I'm going to close

2184:16

them and I'm going to create my

2184:17

component with the name of query come on

2184:20

query all by

2184:22

queries. test. TSX and the first thing

2184:25

that I want to do is I want to import

2184:27

the render and also the screen from

2184:29

where from our testing library reactjs

2184:32

and I'm going to also import the query

2184:34

all by queries from our component and

2184:36

I'm going to also put my describe and

2184:39

test query all by methods would be fine

2184:42

then I'm going to provide my it it

2184:44

should query all by RW first of all we

2184:47

are going to be querying our element by

2184:48

R so I'll use like query all by queries

2184:51

and underneath there we have to first of

2184:53

all get this button so now let me go

2184:55

ahead and go to my component so we are

2184:57

going to be getting these buttons so I'm

2184:58

not going to be going through like each

2185:00

and every single one of them I'll just

2185:02

write a quote so I'll use like screen

2185:04

get all by row and here we have to pass

2185:07

our button and I'm going to store the

2185:09

inside the variable with the name of

2185:10

button now let me select that alert so

2185:12

I'm going to be using screen and then

2185:13

query all by row by row and here r o e

2185:18

and okay so we have a query all by row

2185:22

why it's not working let me just pass

2185:24

alert okay now it's working so here we

2185:26

also have to store the inside the alerts

2185:28

variable and this is how it looks like

2185:30

so now we have to get the region it's

2185:32

going to be equals to the screen do

2185:34

query all by row and here we have to

2185:36

pass our region r e g i o n inside there

2185:39

I'm going to provide my expectation

2185:41

right here so we want it to be first of

2185:44

all let's just space for buttons and we

2185:46

want it to have the length of two and

2185:49

I'm going to also duplicate the like

2185:51

three times and we want the alert to

2185:54

have the length of two and we also want

2185:56

the region to have the come on r e g i o

2185:59

n we also want the regions to have the

2186:02

to have the length of two and and you

2186:04

know what first of all let me just get

2186:05

that alerts and place it right here sa

2186:08

my file and here you can see our test is

2186:10

now successfully placing and why is

2186:11

there because we have two buttons two

2186:13

alerts and two regions inside our jsx so

2186:16

here you can see we have two buttons two

2186:18

alerts and we also have two regions so

2186:21

that's why our test is now successfully

2186:23

passing so now let me just hide there

2186:25

now let me create another test Suite so

2186:26

I'll just go ahead and use my it come on

2186:30

it should query all by placeholder text

2186:34

in this space and I'm going to first of

2186:36

all render my query all by queries and

2186:39

close them now that we have to select

2186:41

these input feeds with the type of I

2186:43

mean like the placeholder of search okay

2186:45

so it's going to gives us these three

2186:47

like the first one and this last one

2186:49

it's going to just skip this one so what

2186:51

I'm going to do is that I'm going to use

2186:53

like screen then query all by

2186:56

placeholder text and past my search

2186:59

inside there and I'm going to store the

2187:01

inside the variable with the name of

2187:02

search input and going to be equals to

2187:05

there and I'm going to also use the

2187:06

screen. query come on query all by

2187:09

placeholder text and past my email

2187:11

inside there and now let me just store

2187:13

there inside the email inputs and it's

2187:15

going to be equals to there okay so I'm

2187:17

going to also past expectation and

2187:19

provide my search element or search

2187:21

inputs rather and we want that to have

2187:24

the length of length of three because as

2187:29

you can see right here so we have this

2187:30

input field like this is one two and

2187:32

this one is three so this T going to

2187:34

pass and I'm going to also proide the

2187:35

expect and email inputs and here we want

2187:38

that to have the length of come on to

2187:42

have length of only one okay so we are

2187:45

now selecting this one email one so now

2187:47

this test is going to pass and as you

2187:49

can see right here this test is now

2187:51

successfully passing and I'm going to

2187:53

also hide them now that we have to

2187:55

select this H ones and also these

2187:57

paragraphs so now let me just go ahead

2187:59

and select them but first of all we have

2188:01

to create our test it should create all

2188:04

by textt so I'll use like first of all

2188:07

the render query by queries and then we

2188:10

have to uh use the screen and query

2188:13

query all by text E EXT and provide my

2188:17

you know let's just use our reject so

2188:19

header text and select there I'm going

2188:22

to also store that inside the her

2188:23

variable and now to need there we have

2188:25

to use the screen query alt or query all

2188:29

by text once again not test ID but just

2188:32

a text once again and we have to use our

2188:34

Rex like paragraph X and here let's just

2188:37

use them right here and now we are going

2188:39

to be selecting them by using our

2188:41

paragraph and now let's just sell and

2188:43

I'm going to also provide our expect for

2188:44

that so we want the headers to have the

2188:47

length to have the length of two now let

2188:51

me just duplicate that and we have to

2188:53

change that to paragraph and we want

2188:55

that to have the length of two now let

2188:57

me just save my file and yep our test is

2188:59

now successfully passing I'm going to

2189:01

close that now we have to select these D

2189:04

which have these custom data ID right

2189:06

here or test IDs to be precise so what

2189:09

I'm going to do is that I'm going to

2189:10

just render my or use my it so it should

2189:13

query all by test ID and provide my

2189:16

render inside this so query by query and

2189:18

I'm going to also close there andne

2189:22

there we are going to be using our

2189:23

screen query all by text text ID and

2189:26

provide my custom element inside there

2189:29

so I'll use like uh cost custom elements

2189:32

it's going to be equals to that okay so

2189:34

we are now getting an error qu all by

2189:36

text ID test ID there we go now let me

2189:39

just call my expectations I'll use like

2189:41

custom um element and we want that to

2189:44

have the length of uh to have the length

2189:47

of two and now let me just sa my file

2189:50

and this test should pass because now

2189:52

that we have only two divs which will

2189:54

have the custom test IDs and now finally

2189:56

let's just select these input field so

2189:58

what I'm going to do is that I'm going

2189:59

to just hide there for a few seconds and

2190:01

we have to write where it is so I'll

2190:03

just use like it should query all by

2190:05

display value and for my render inside

2190:08

this so query all by queries and close

2190:10

them now that we have to use our screen

2190:12

query all by display value and provide

2190:15

my text inside there so you know let me

2190:17

just copy that from here I'm going to

2190:19

copy the place it right here and you

2190:21

know we also have to yeah I guess that's

2190:23

going to be fine and I'm going to store

2190:24

the inside the variable with the name of

2190:26

input or input values v l u s if I can

2190:30

spell that today God damn it input

2190:33

values there we go and now let me just

2190:35

duplicate there and we have input vales

2190:37

to and also change there to two Okay so

2190:40

I'll just put my expectation input

2190:42

values and we want that to have the

2190:45

length of to have the length of two and

2190:48

duplicate and we want the second one to

2190:51

have the length of only one because we

2190:53

only have the text two one time and we

2190:56

have the text one two time right here so

2190:58

that's why our test should pass so as

2191:00

you can see right here now that we learn

2191:02

about um get all by row I mean like we

2191:06

learn about the query all by row we

2191:08

learn about the query all by placeholder

2191:12

we learn about the query all by text

2191:15

query all by test ID and query all by

2191:18

display value okay doie so now let's

2191:21

talk about the find by queries so I'm

2191:23

going to create a file with the name of

2191:24

find by queries. TSX and inside there

2191:27

let me just place all of that content

2191:29

and now let say our file first of all we

2191:31

have our H1 then we have our paragraph

2191:33

in the button with the area label or

2191:36

area label then we have our input Field

2191:38

image input field data div with the data

2191:42

test ID and then we have our label with

2191:44

HTML 4 and finally we have our input

2191:46

field right here so which is looking

2191:48

cool I'm going to go ahead and provide a

2191:49

test cases for them and by the way you

2191:51

can find all of their coding in my

2191:53

GitHub repository so I'll use like find

2191:55

by queries. test. DSX and now let's just

2191:59

hit enter the first thing that we will

2192:01

need is our render method and also our

2192:03

screen from where from or testing

2192:06

Library Dom and underneath that we have

2192:09

to get our uh find by queries and now

2192:12

let me just copy them and the next thing

2192:13

that we have to do is that we have to

2192:15

provide our describe and I'm going to

2192:16

just provide like find by queries

2192:19

component and inside there let's just

2192:21

use our it and it should or you know

2192:23

what in this case I'm going to just use

2192:25

a test rather what the hell I've been

2192:27

using that it again and again now let me

2192:29

just try out the test so it I mean like

2192:32

not it but test finds an element by its

2192:36

text content okay so now inside there

2192:38

I'm going to render my component like

2192:40

find by queries and close it like so let

2192:44

me just save my file and the first thing

2192:46

that we have to do is that we have to

2192:47

select this H1 so how in the world we

2192:49

are going to be selecting there well to

2192:51

select the we already learned about a

2192:53

lot of ways but now we are going to be

2192:55

covering the find by text so which also

2192:57

means there is going to be an

2192:59

asynchronous operation so which also

2193:00

means that we have to mark our function

2193:03

as as function because now it's going to

2193:05

take some time so now we are going to be

2193:07

using aw and screen and then find by

2193:10

text and inside there let's just use or

2193:13

find by uh what was that find by query

2193:16

St so you know let me just copy this

2193:18

entire thing and place it right here and

2193:20

provide my rexs inside there and I'm

2193:22

going to store that inside the heading

2193:24

element and it's going to be equals to

2193:25

that function execution now let me use

2193:28

my expect and pro my heading element and

2193:30

we want that to be in the document let's

2193:32

just say or F and here you can see our

2193:35

test is now successfully passing which

2193:37

means like everything is working the way

2193:40

we expect them to work next we have to

2193:42

select this area label so how what we

2193:44

are going to be doing that well that's

2193:46

quite simple and easy okay so we are

2193:48

going to be using their test once again

2193:50

so we're not going to using that from

2193:51

the gist God damn it so let's just use

2193:53

that it and I'm going to just rename

2193:55

that to test because I know a lot of

2193:58

people will ask me H why aren't you

2193:59

using test instead of that it so now I'm

2194:02

using the so find an element by its area

2194:07

area and I'm going to also Mark the as

2194:09

Asing because this is a Asing component

2194:12

so here we have to provide or find by

2194:14

queries function or component and now

2194:17

underneath that we have to first of all

2194:18

use the a then we can use the screen and

2194:21

then find by label text and here we are

2194:23

going to be passing this label text

2194:25

right here so click me I'm going to copy

2194:28

there and let's just put there and we

2194:30

want there to be either lower case or

2194:32

upper case let's just get what button

2194:34

element it's going to be equals to this

2194:35

function execution provide my

2194:37

expectation and we want to just pass our

2194:39

button element like so and we want it to

2194:42

be in the document I'm going to save

2194:44

this file right now and here you can see

2194:46

our test is now successfully passing now

2194:48

let me just hide there next we are going

2194:50

to be selecting this input field so how

2194:53

we are going to be doing there I'll just

2194:54

use that it and now let me just rename

2194:56

that to like test and I'm going to say

2194:58

like finds an element by its placeholder

2195:02

text and I'm going to also Mark there as

2195:05

async so that we can see the so is use

2195:08

our render and find by queries and I'm

2195:11

going to close there like this now

2195:13

underneath there we're going to be using

2195:15

the aw screen find by Place holder come

2195:19

on find by Place holder text there we go

2195:23

now we are going to be placing that same

2195:25

text uh so I'll just copy there now let

2195:28

me just place it right here and provide

2195:30

my I now we are going to be using like

2195:32

input element it's going to be equals to

2195:34

this value now let's just try our

2195:36

expectation and we have to P our input

2195:38

element and we want that to be in the

2195:40

document and now let a Ser file and our

2195:43

test is now successfully passing because

2195:45

it should be I'm going to also hide

2195:47

there the next thing that we have to do

2195:49

is that we have to select this image by

2195:51

using this alt or alternative text so

2195:54

let's just use our test case once again

2195:57

Yep this is working so I'll just change

2195:58

that to an element on element by its r

2196:04

and hit tab remove them and first of all

2196:06

you're going to be rendering or find by

2196:08

queries close this semi file hit Tab and

2196:11

now underneath them uh we have to use

2196:13

the aw and Screen find come on find by

2196:16

all text like so and here we have to

2196:19

just past that alternative text so I'm

2196:21

going to just copy there which is just a

2196:23

test image and we have to place it right

2196:26

here and I'm going to be using like

2196:27

image element it's going to be equals to

2196:29

that value and we also have to mark the

2196:31

as sing because this is an s synchronous

2196:33

component so now we are going to be

2196:35

using our expect image element and now

2196:38

we have to use to be in the document

2196:41

server file everything is passing and

2196:44

this is what we expect that's done next

2196:46

we have to select there by using this

2196:48

display value so I'm going to go ahead

2196:50

you know let's just undo that so I'm

2196:53

going to go ahead and provide my other

2196:55

test case so I'll use like uh test and

2196:59

here just just P my test case so test

2197:03

finds an element by its default value

2197:07

and I'm going to change them and first

2197:09

of all you also have to mark the as SN

2197:11

so that we can provide our asynchronous

2197:13

operation inside there I'm going to use

2197:15

the render and provide my find by

2197:17

queries and execute this component right

2197:20

here save this file and now we are going

2197:23

to be using a and then screen find by

2197:26

display come on display oh my God find

2197:29

by uh display value there we go now

2197:33

inside there we are going to be placing

2197:35

that same display value so you know let

2197:37

me just copy this entire thing and place

2197:39

it right here and provide my I there now

2197:42

let's just use our input elements and

2197:45

store the inside this variable and now

2197:47

we are going to be placing our

2197:48

expectation like input element and we

2197:50

want it to be in the document and now

2197:53

let's just say our file and our test is

2197:55

now successfully passing this is

2197:57

something that we expected now we are

2197:59

going to be selecting this div by using

2198:01

this test ID so how in the world we are

2198:04

going to be doing there this is exactly

2198:07

how we are going to be doing there so

2198:08

I'll just use the test once again and

2198:11

choose the second one and now let me

2198:12

just remove the and find uh an element

2198:16

come on element by its data test ID and

2198:21

now inside there what we have to do we

2198:23

have to render our component first of

2198:24

all so like find by queries and save

2198:26

this file now underneath that we have to

2198:28

use our a but first of all God damn it

2198:32

we have to use this s Inc syntax right

2198:34

here and then we are going to be using

2198:36

like screen come on screen find by test

2198:39

ID and now let's just P that same test

2198:42

ID inside there I'm going to copy that

2198:44

from here place there and provide my I

2198:47

there for our rejects now let's just use

2198:49

our test element it's going to be equals

2198:51

to that same element and now let me

2198:53

provide that expect test element and use

2198:56

that to be in the document yep our test

2198:59

is now successfully passing and this is

2199:01

what we expected and now the final thing

2199:04

that we have to do is that we have to

2199:05

select this label so now we are going to

2199:07

be selecting this label right here by

2199:09

using this HTML 4 so now let me just

2199:12

hide there from there now we are going

2199:14

to be passing our test and choose there

2199:16

I'm going to use like finds an element

2199:19

by it's HTML 4 in this case because we

2199:22

are going to be selecting our element as

2199:24

our HTML 4 remove there and P our as

2199:27

sync inside there and now inside this

2199:29

component first of all we have to render

2199:32

our find by by queries and execute there

2199:35

right here and now we are going to be

2199:37

using a and then screen find by label

2199:41

text and here let's space for label text

2199:44

which is uh this this label text so I'm

2199:47

going to copy that right here place

2199:49

there and proide my I there now I'm

2199:51

going to be using like uh label element

2199:54

it's going to be equals to there and now

2199:56

let's just provide our expectation and

2199:58

inside this expect for our label element

2200:00

and we want it to be in the document and

2200:03

our file and yeah that was our entire

2200:06

test case find by label text find by

2200:10

placeholder text find by all text and

2200:14

find by display value find by test ID

2200:18

and finally we just learned about the

2200:19

find by label text right here so yeah

2200:21

that was it about the find by and this

2200:24

is an asynchronous operation you know

2200:26

what I just Chang my mind like whether

2200:27

you like it or not but I'm going to

2200:29

still cover there so what I'm going to

2200:31

do is that I'm going to just create a

2200:32

component with the name of find all by

2200:34

queries q e r i s. TSX I'm going to copy

2200:39

and place all of that content right here

2200:41

so first of all we have R H1 then we

2200:43

have three paragraphs then we have three

2200:45

buttons with area labels then we have

2200:47

three placeholders then we have three

2200:49

images three input field with dis I mean

2200:52

like default value then we have a three

2200:54

D with the data test ID so now let's

2200:57

just provide our test cases for there

2200:59

now I'm going to do something special

2201:01

okay so we are going to be creating a

2201:03

component with the name of find all by

2201:06

queries. test uh come on test. ID what

2201:11

the hell am I doing today TSX there we

2201:13

go the first thing that we have to do is

2201:15

that we have to import our render and

2201:17

also our screen from our component which

2201:19

is a testing Library for/ react and now

2201:22

we have to import the find all by

2201:25

queries and yeah that's then we have to

2201:28

provide our describe right here so I'm

2201:29

going to be using their describe I'm

2201:31

going to select find all by

2201:33

queries component component there we go

2201:37

and here I'm going to be using something

2201:39

called the setup and tier down so this

2201:43

is a concept which we are going to be

2201:44

covering later but now we have to use

2201:46

this hook which is a before each okay so

2201:49

we want to run this function before each

2201:52

test case so this is just exactly what

2201:54

they mean so we are going to be just

2201:56

spacing this function and here we are

2201:58

going to be just spacing our render and

2202:00

find by all queries which we just

2202:02

created this component

2202:03

and we want this function to run every

2202:06

single time or test case run okay so

2202:08

this is why we are now passing like run

2202:10

before each test case so now let's just

2202:12

save our file and by the way we are

2202:14

going to be learning about the setup and

2202:15

here down a bit later or maybe not I

2202:18

guess we are going to be learning about

2202:20

that I'm not quite sure about that but

2202:21

you know this is space or test cases so

2202:23

I'm going to use like finds all the

2202:25

elements by text so now we are going to

2202:28

be using like a w and Screen let's just

2202:31

use our find come on find find oh my God

2202:34

find all by text and here we have to

2202:36

pass our item right here which we are

2202:39

providing so let me just go ahead and

2202:41

select them so I'm going to just use

2202:43

like item one I'm going to copy there

2202:45

but we cannot p a one right here just

2202:48

like the instead we have to first of all

2202:50

write this back slash and then D and

2202:52

then for Slash and now we have to also

2202:55

Mark there as our asness component or

2202:57

async function now let's just store the

2203:00

inside the paragraph it's going to be

2203:01

equals to the and and I'm going to use

2203:03

like expect case place my paragraph

2203:05

inside there to have the length to have

2203:09

the length of only three so now let's

2203:12

just sa our file and our test is now

2203:14

successfully ping now let me just expand

2203:16

there and yeah it is totally working and

2203:19

why is there that's because it's going

2203:20

to select for each of the paragraph it's

2203:23

going to just select them so now it's

2203:25

going to give us like more than one

2203:26

element which means like three elements

2203:28

now we have to it over through there so

2203:30

I'll use like for each password

2203:32

paragraph

2203:33

like so and for each paragraph what do

2203:35

we have to do uh or you know let me just

2203:37

change there with s so I'll just select

2203:40

all of these three and provide my S

2203:42

inside there and I'm going to select

2203:44

expect provide my paragraph and we want

2203:47

that to be in the document and now let's

2203:48

is s our file still all of our test are

2203:51

now successfully passing and now let me

2203:53

just hide there the next thing that we

2203:55

have to do is that we have to find out

2203:56

all of that buttons and then we can test

2203:59

this so let's just use that I'm going to

2204:00

use that it finds all The Elements by

2204:04

row so now we are going to be selecting

2204:06

those buttons by roll and I'm going to

2204:07

also Mark my component or function or

2204:10

test Suite whatever you want to call

2204:12

there by using the Asing syntax so I'll

2204:14

use like a w and Screen find come on

2204:17

find find all by row and here we just

2204:22

have to pass our button inside there and

2204:24

let's just store that inside the buttons

2204:26

variable let me just put my expectation

2204:28

and that buttons we want to have the

2204:32

length of of three and also it's going

2204:34

to gives us that lens so we just have to

2204:36

use like buttons. for each element uh we

2204:39

want to just pass our button and for

2204:41

each button in this case what we have to

2204:42

do we have to provide our expect and for

2204:45

this expect we are going to be passing

2204:46

our button and we want that to be in the

2204:48

document and now let's just our file and

2204:50

here you can see all of our test are now

2204:52

successfully passing and this is

2204:54

something that we want now that we

2204:55

selected the buttons the next thing that

2204:57

we have to do is that we have to select

2204:58

these inputs with these placeholders so

2205:01

let me just hide there and provide

2205:04

another test case so I'll use like it

2205:06

finds all the elements by placeholder

2205:10

text and mark the as as synness

2205:12

component so async and here inside there

2205:15

I'm going to be using a w screen find

2205:18

all by placeholder text and I'm going to

2205:21

just paste their text inside this so I'm

2205:23

going to copy there place them and you

2205:26

want to store the inside the inputs

2205:29

right here and underneath it we're going

2205:31

to be using the expect provide my input

2205:33

inside there and we want that to have

2205:35

the length of uh only three and and

2205:39

underneath we are going to beting over

2205:41

through there once again so I'll use

2205:42

like for each and pass my input inside

2205:45

there and pro my expect input to be in

2205:48

the document and execute there let me

2205:50

just sa my file and refresh there and

2205:52

still all of our test are now

2205:54

successfully passing and which is

2205:55

something that we want and now we are

2205:57

going to be selecting these images by

2205:59

using these all text so how the what

2206:01

we're going to be doing there let me

2206:03

just show you how we can do that so we

2206:05

done that like 1,000 time in this course

2206:07

so it should find all the elements by

2206:11

all text in this case and I'm going to

2206:13

also Mark the as asnc inside there let's

2206:15

just use our aw screen find all by all

2206:19

text right here and provide my test IDs

2206:22

which is this test image so now let me

2206:25

just place there and we are going to be

2206:27

using the images and now underneath to

2206:29

provide what expectation of images to

2206:31

have the length

2206:33

and we want it to be three of them and

2206:35

we're going to be also itting over

2206:37

through all of that images by using

2206:38

these four each let me just P the images

2206:41

so I'll just use like expect the image

2206:44

to be in the document and execute my

2206:47

function but okay here we have to pass

2206:49

our arrrow right there let's just sa our

2206:51

file and our test are now successfully

2206:53

passing next we have to find out all of

2206:56

that Elements by using this default

2206:58

value so I'll just go ahead and hide

2207:01

there for a second and now now we have

2207:03

to create where it so it should finds

2207:06

all the elements by display value and

2207:11

Mark as or sing function I'm going to be

2207:14

using aw in screen find all by display

2207:19

value and P my test value inside the

2207:22

which is a input test one and so on and

2207:25

so forth so you know let's just God damn

2207:27

it I can't even copy it so let's just

2207:30

copy there and place it right here and

2207:32

we want to be like this so instead of

2207:36

providing this one we want to select

2207:38

like all of them so I'll just use like

2207:40

inputs and this is provide there right

2207:42

here and now let me provide my

2207:44

expectation provide my inputs inside the

2207:47

inputs

2207:48

PS it should be inputs like so and it

2207:52

should have the length of only three WI

2207:56

our inputs dot for each input we have to

2207:59

provide our input inside the provide our

2208:02

expectation of input and we want that to

2208:05

be in the document SA or file and our

2208:08

test is now successfully passing and the

2208:11

final thing that we have to do is that

2208:12

we have to select this div which will

2208:14

have this uh data test ID so you know

2208:17

let's just do that and that's going to

2208:18

be the final thing about these query

2208:20

methods so let me just go ahead and qu

2208:23

it it should finds all the elements by

2208:26

test ID and I'm going to just first of

2208:29

all use the aware but first of all we

2208:31

have to mark the as asnc and now we are

2208:35

going to be using a screen find all by

2208:37

test ID and here we have to pass the

2208:40

test IDs inside there so let's just copy

2208:42

there and now let me just place it right

2208:45

here and I'm going to be using con test

2208:47

element it's going to be equals to there

2208:49

now underneath there we going to be

2208:50

using what expect my test element and we

2208:53

want that to have the length of only

2208:56

three and now let's just use our test

2208:58

element dot for each element uh what do

2209:01

we have to do we just want to provide

2209:03

this expectation like for each element

2209:06

we want that to be in the document save

2209:08

our file and finally or all of our test

2209:12

are now successfully passing and there

2209:15

was a lot of query methods that we cover

2209:18

in this section so what do we learn uh

2209:22

okay we learn about the find all by text

2209:25

we learn about find all by ro and then

2209:28

we learn about the find all by

2209:30

placeholder text find all by by all text

2209:33

find all by display value and find all

2209:36

by test ID okay that was a lot of stuff

2209:40

now let's talk about how we are going to

2209:41

be testing the user interaction like

2209:43

whenever the user types something or the

2209:45

user clicks on something and so on and

2209:47

so forth so let's just test this so the

2209:49

first thing that I want to do is that I

2209:51

want to create a component with the name

2209:52

of not here but here I want to create a

2209:56

component with the name of toggle

2209:59

message. ESX and now inside there we're

2210:02

going to be just is creating a simple

2210:03

Toggler so I'll just import first of all

2210:05

the use St and now underneath there we

2210:07

have to create our component with the

2210:08

name of toggle message and now let me

2210:10

just initialize my state so I'll just

2210:12

use like use State and I'm going to

2210:14

provide the false initial value inside

2210:16

there and I'm going to also destructure

2210:18

is visible insert is visible it's going

2210:20

to be equals to this Us St now here let

2210:23

me just remove that from there and I'm

2210:24

going to be just creating a button which

2210:26

will allows us to toggle our message so

2210:28

I'll use like toggle message and here

2210:30

let's just render that message so if

2210:32

this is visible let me just write like

2210:34

if this is visible so in this situation

2210:37

we want to show this paragraph which

2210:39

will say like this is a or this message

2210:43

is visible or something like that and

2210:45

now I'm going to also attach the event

2210:46

handler on there like when somebody

2210:47

clicks on this button so we want to F

2210:49

this function which is a toggle message

2210:52

and now let me just copy the name of

2210:53

there and create this function right

2210:54

here so I'll use like cons tole message

2210:57

and here we are going to be just using

2210:59

the set is toggle or set is visible and

2211:01

we want to Pro our previous St and not

2211:04

previous St okay so now let me just save

2211:06

my file and this is how our component

2211:08

looks like so now let's just go ahead

2211:09

and test that I'm going to create a file

2211:11

with the name of toggle message. test.

2211:15

DSX but first of all whenever we are

2211:17

testing the user interaction we have to

2211:19

install another Library so now let me

2211:21

just stop there and here you know let me

2211:24

just delete that from here and here now

2211:26

we are going to be installing the user

2211:27

event so I'll use like npmi and then DD

2211:31

as a Dev dependency and I'm going to use

2211:33

like testing D Library user event and

2211:36

now let me just hit enter so it's going

2211:37

to install that right here and now let

2211:39

me use my npm run test UI so it's going

2211:41

to run my test Runner inside the test UI

2211:44

so yeah now let's just import all of our

2211:46

stuff so I'm going to be importing the

2211:47

render and also the screen from our

2211:49

testing library reactjs and we would

2211:52

also need to import the user event from

2211:56

where from the testing library and now

2211:58

in this case we are going to be

2211:59

importing there from the user event May

2212:02

because we want to listen to the user

2212:04

events and now let's just import also

2212:06

our toggle message component so that we

2212:08

can work with the I'm going to use the

2212:10

describe right here and I'll say like

2212:12

toggle message component and here inside

2212:15

there I'm going to use like it should

2212:18

toggle the message visibility when

2212:21

button is clicked c i c Ked and we would

2212:25

also make the SS in right here and now

2212:28

first of all we have to render our

2212:29

component which is a toggle message

2212:31

component and I'm going to save that

2212:32

right here the first thing that we have

2212:34

to do is that we have to get that button

2212:36

then we would be able to click on that

2212:38

button so I'll just use like screen.

2212:39

getet by roll and I'm going to provide

2212:41

the button and which button we want to

2212:43

select we want to select this button

2212:45

right here so I'm going to just copy

2212:46

this message and I'm going to also

2212:48

provide the options and here let's space

2212:50

our message and I'm going to provide the

2212:52

as a Rex and it shouldn't be

2212:56

I and now let me just thr the inside the

2212:59

B variable and this is how it looks like

2213:01

the next thing that we have to prod that

2213:02

we have to make sure that initially our

2213:04

message will not be shown inside the UI

2213:07

so I'll just use like expect and then

2213:09

let's just use our screen do query by

2213:11

text and here let's just space the

2213:14

message visible what was that I'm going

2213:17

to copy there or this message is visible

2213:20

I'm going to just place it right here as

2213:21

a Rex and I want it to be no so like

2213:25

initially we want this to be hidden and

2213:27

now here we are going to be testing the

2213:29

user interaction so I'm going to just

2213:31

grab my user event from this Library

2213:33

which we already imported right here and

2213:35

now here inside there we have a lot of

2213:37

method so if I just hit dot here you can

2213:39

see we have a clear click copy cut and

2213:42

so on and so forth like all of the user

2213:44

interactions so I'm going to just choose

2213:46

like click so like whenever the user

2213:49

clicks on this button first of all we

2213:51

are now selecting this button this

2213:53

button from the Dome then we are telling

2213:56

it that initially we want this message

2213:58

to be hidden and now we are providing

2213:59

like whenever we click on this button so

2214:02

in this situation what do we have to do

2214:04

let me just write like a r right here

2214:05

because there going to be an

2214:06

asynchronous operation then we want this

2214:09

message to be shown so I'll just use

2214:10

like expect and here let's just space

2214:12

over screen and then get my text and I'm

2214:15

going to just P this text inside there

2214:17

so I'm going to copy that from here this

2214:19

entire thing and now let me just place

2214:22

that right here and I'm going to provide

2214:24

my I there and we want there to be in

2214:26

the document and I'm going to execute

2214:28

there and after that whenever we click

2214:30

on there once again so use like user

2214:33

event and whenever we click on there

2214:34

once again so in that situation we want

2214:37

to hide there okay so I'm going to just

2214:39

copy this entire thing and now let me

2214:41

just place it right here and that was it

2214:43

so now let me just save my file and now

2214:44

let me explain there first of all we are

2214:46

going to be selecting this button from

2214:48

the Dom and then initially we want this

2214:51

message as you can see right here we

2214:53

want there to be hidden and when

2214:55

somebody clicks on that button this

2214:58

button so we want this message to be

2215:00

visible and whenever they click on there

2215:02

once again so we want this message to be

2215:04

hidden okay so you know let me just run

2215:07

my test cases and as you can see right

2215:09

here all of our tests are now

2215:11

successfully passing right here which

2215:12

means like everything is working the way

2215:14

we expect him to work so that was

2215:17

example number one now let me give you

2215:18

yet another example so I'm going to

2215:21

create a file with the name of too list.

2215:23

DSX and inside there basically we are

2215:26

going to be just creating a simple to-do

2215:27

list so I'll use my rafc inside there

2215:30

and the first thing I want to do is that

2215:31

I want to just my todos and set todos

2215:34

and it's going to be equals to the used

2215:35

St and the initial value I'm going to

2215:37

just put empty string inside there and

2215:40

I'm going to also create an interface

2215:41

for my type so I'll use like interface

2215:43

to do and inside there let's just Pro

2215:45

our text and that's going to be set to

2215:47

string and the completed flag will be

2215:49

also set to Boolean okay so now let's

2215:52

just copy there and I'm going to also

2215:54

inate my component with these to do okay

2215:57

just like that and let's just provide

2215:59

our empty array inside there and I'm

2216:01

going to also get the new new too and

2216:03

set new too is going to be equals to the

2216:06

U state so let's just use the UST State

2216:08

and the initial VAR will be set to empty

2216:10

string now let me go ahead and go to my

2216:12

UI and I'll just use like uh to do app

2216:15

or something like that and I'll also

2216:17

proide my input field with the type of

2216:19

text and also I'm going to past my value

2216:21

so let's just paste that value inside

2216:24

there and I'm going to select new to do

2216:27

and when somebody clicks on this so then

2216:28

we want to F this function which we are

2216:30

going to be creating in a few seconds so

2216:32

let's just provide there and I'm going

2216:33

to also provide the placeholder which

2216:35

will say like enter new too new too like

2216:38

that and now let's just s file now

2216:40

underneath we are going to be able to

2216:42

create a too by just clicking on this

2216:44

button so I'll just use like a too and

2216:46

here let's just space or on click event

2216:48

handler and when somebody clicks on

2216:50

there so we just want to F this function

2216:52

so which is a handle add to do now

2216:54

underneath there we are going to be

2216:56

rendering over todos so I'll use like ul

2216:58

and inside this UL we are going to be

2217:00

using too. map and here let's space our

2217:03

to-do and also our index inside there

2217:05

and now let me just space my Ali and for

2217:07

each lii I'll provide my key and the key

2217:09

will be set to index and you know what

2217:11

I'm going to also provide a bit of I'm

2217:13

not going to do that I'm not so let's

2217:15

just provide our input field inside

2217:17

there and the type will be set to

2217:18

checkbox in this case and we are going

2217:20

to be also providing a checked and here

2217:22

is going to be set to to do do completed

2217:25

on change and here let's space or Arrow

2217:28

function which will say handle uh toggle

2217:30

to do handle toggle to do and here let's

2217:34

just space our index inside there and by

2217:36

the way we are going to be creating all

2217:37

of their functions in a few seconds okay

2217:39

so now underneath this input we have to

2217:42

render our too. text so that we can see

2217:44

there and finally our button which

2217:47

allows us to delete the to-do okay so

2217:49

I'm going to past like on click when

2217:50

Handler and let's just pass our function

2217:53

which will be handled delete too and P

2217:56

or index inside there now let me just go

2217:58

ahead and just create these functions

2218:00

the first thing that I want to do is

2218:01

that I want to just create or add too so

2218:04

how in the world I can do that I can

2218:05

just use like cons handle add to-do and

2218:08

inside there I'll just use like if new

2218:11

too. trim we just want to trim it out

2218:14

and then set to-dos and here first of

2218:16

all we want to make a clone off for

2218:17

existing to-dos if we have there so I'll

2218:20

use like to-dos and then I'm going to

2218:21

use like text and that's going to be set

2218:23

to my new to-do and also the completed

2218:25

flag will be set to false okay and now

2218:28

underneath I'm going to be using like

2218:29

set new too and I'm going to make the a

2218:31

store empty now let me go ahead and just

2218:34

create this handle input change so I'm

2218:36

going to create the right here I'm going

2218:38

to create like handle input change and

2218:40

it's going to take that event and I'm

2218:42

going to also annotate as change event

2218:44

from the reactj and here we have to tell

2218:47

that that we want to use the inside the

2218:48

HTML input element and I'm going to also

2218:51

close it like so and inside I'm going to

2218:53

use like set new too and event. target.

2218:57

value value like this now let's just

2218:59

create this function uh which is a hand

2219:01

handle toggle too I'm going to go to the

2219:04

top and I'm going to create there right

2219:05

here so I'll use like con uh handle

2219:08

toggle too and I'm going to pass my

2219:10

index which will be set to a number and

2219:12

inside there let's just first of all

2219:13

make a clone or for existing to and I'm

2219:16

going to store that inside like con

2219:17

updated too and it's going to be equals

2219:19

to this variable and now I'm going to

2219:21

use that updated todos and P my index

2219:24

inside there and now we are going to be

2219:26

getting that completed flag and if that

2219:28

is not equals to that updated to do and

2219:30

let's just space or index inside there

2219:32

the completed one and now we have to use

2219:34

our Set uh come on set todos and provide

2219:37

our updated come on updated todos now

2219:41

let me just save my file and finally we

2219:43

just have to take care of this handle DD

2219:45

to-do so I'm going to create the maybe

2219:48

right here I'll use like cons handle DD

2219:51

to do I'm going to paste the index and

2219:53

that's going to be set to a number and

2219:55

I'm going to S like to do. filter and

2219:58

provide uh basically nothing but we are

2220:01

only interested in the index so I'll

2220:03

just use like if index is not equal to

2220:05

that specific index and I'm going to

2220:07

also store the inside the variable with

2220:09

the name of updated to-dos that's going

2220:11

to be set to their to-dos I'm going to

2220:13

use the set to-dos and provide my

2220:15

updated to-dos right here so it's going

2220:17

to push there to this set to do there we

2220:19

go and I guess we are totally done with

2220:21

the component so you know let me just go

2220:23

ahead and go to the not this one to the

2220:25

app and I'm going to render this

2220:27

component so that we can see there so

2220:29

I'll use like to-do list semi file and

2220:31

I'm going to use npm run uh Dev let's

2220:34

just copy this link and I'm going to

2220:36

place it right here so yeah we are now

2220:38

getting what to do I write something

2220:40

come on uh something and click on this

2220:43

addir too so it's going to add there I

2220:45

can also Mark the as a complete and I

2220:47

can also delete there so yeah these are

2220:51

my to-dos and let's just test them so

2220:53

I'm going to stop there right here and

2220:55

I'm going to be using npm run test UI in

2220:58

this case so it's going to run my test

2220:59

Runner and as you can see we are now

2221:02

getting there so let's just hit refresh

2221:03

I already have those components so maybe

2221:06

I'm going to delete them like toggle

2221:08

message and I'm going to also remove the

2221:10

strle message component now I'm going to

2221:11

go here and I'm going to create my to-do

2221:14

list. test. TSX component right here the

2221:17

first thing that you want to do is that

2221:19

you want to get the render also the

2221:20

screen and also from where from our

2221:23

testing library reactjs now underneath

2221:26

we are going to be also getting the user

2221:28

event okay so I guess yeah we already

2221:31

installed it but it it is not helping us

2221:33

to import this so we are going to have

2221:34

to import them manually and I'm going to

2221:36

import it from the user event there we

2221:38

go we would also need to get our to-do

2221:40

list s our file and underneath we have

2221:43

to describe our uh test site so I'll

2221:45

just give it an out like to-do list

2221:47

component or something like that and

2221:49

here let's just provide our first test

2221:51

like it should renders to do list with

2221:55

an input and a button okay so I'll just

2221:59

first of all render my component which

2222:00

is a too list and I'm going to close

2222:02

there underneath there we're going to be

2222:04

using our expectation and here let's

2222:06

just Prov our screen. get by placeholder

2222:08

text and now inside there I'm going to

2222:11

just paste this placeholder text inside

2222:13

there so I'm going to copy there now let

2222:16

me just place a right here and that is

2222:18

our expectation and we want it to be in

2222:21

the document and we also want let me

2222:24

just put another expectation screen. get

2222:27

by text and we want and we want to get

2222:29

that button okay which is this add to do

2222:31

so I'm going to copy there now let me

2222:33

just place it right here and we want

2222:35

that to be in the document s file so yep

2222:38

our test is now successfully passing so

2222:41

that's St done now we are going to be

2222:42

creating another test for adding word to

2222:44

do so I'll just use like it can add a

2222:47

too item maybe and I'm going to also

2222:51

Mark the S sing because now we are going

2222:53

to be interacting with our component so

2222:55

I'll just use like render and to-do list

2222:58

uh component now underneath that the

2223:00

first thing that we have to do is that

2223:01

we have to get or input field and then

2223:03

we can interact with the so I'll use

2223:05

like screen. get by placeholder text and

2223:08

here I'm going to just P like that place

2223:10

holder I'm going to copy it and place it

2223:13

right here and I'm going to store that

2223:15

inside the input right here but it

2223:17

shouldn't be inputs but it should be

2223:19

just input now you want to get that

2223:21

button like whenever somebody clicks on

2223:22

this button then you want to capture

2223:24

those interactions I'll use like screen.

2223:26

get by text and now we going to be

2223:28

getting the not test ID but just text

2223:31

now we going to be getting there by this

2223:33

text so I'm going to copy there and

2223:34

place it right here and I'm going to use

2223:36

cons button and it's going to be equals

2223:37

to this button right here so now the

2223:40

Moment of Truth like whenever the user

2223:42

type inside this input field what do you

2223:45

want to test and also whenever the user

2223:47

click on this button so what do you want

2223:49

to test in that situation so I'll use

2223:51

like a and user event okay so inside

2223:54

this user event we have our type okay

2223:56

like whenever the user types something

2223:58

inside this so we're going to be passing

2224:00

our input which is going going to be our

2224:02

place where we are going to be typing

2224:04

something and I'll just type like uh new

2224:07

too or something like that and we would

2224:09

also need to click on this button right

2224:11

here okay so I'll use like await and

2224:13

user event and we have our click method

2224:15

right here and now we're going to be

2224:16

passing this button so like whenever we

2224:18

click on this button so when we click on

2224:21

this button what do you want to see you

2224:23

want to see that new to-do which we now

2224:25

providing inside this input field to be

2224:28

rendered to the Dom that's it so I'll

2224:30

just use like expect and here I'm going

2224:32

to be using like screen get by text and

2224:34

let's just provide our new to-do which

2224:36

we are now providing right here and we

2224:39

want it to be in the document so I'll

2224:41

use like to be in the document save my

2224:43

file now let's just refresh now we are

2224:44

failing I don't know why but we are

2224:46

failing let's just go ahead enable to

2224:48

find the element with the all text it

2224:51

shouldn't be goddamn all text it it

2224:53

should be just a get by text there we go

2224:55

now let me just save my file and now our

2224:58

test is now successfully passing now let

2225:00

me go ahead and hide there for for a

2225:01

second now we are going to be able to

2225:03

make it so that we can Mark where to-do

2225:05

as completed so I'll just create a new

2225:07

suite for there and it can Mark a to-do

2225:11

as completed would be fine and I'll just

2225:14

first of all render my to-do list

2225:16

component right here and underneath them

2225:19

uh first of all we have to get our input

2225:22

field and all of that kind of stuff so

2225:24

you know what I'm going to just copy a

2225:25

few things from here so we would need

2225:27

there I'm going to copy this entire

2225:29

thing from there now let just place it

2225:32

right here and I'm going to also Mark

2225:33

the As snc and now you want to get our

2225:36

checkbox as you can see right here we

2225:39

have this checkbox right here so now we

2225:40

want to get there so what I'm going to

2225:43

do is that I'm going to just get that

2225:45

checkbox by using screen. get by row get

2225:49

by row and I'm going to just place a

2225:52

checkbox inside there because we only

2225:54

have one checkbox inside your screen and

2225:56

I'm going to store the inside the

2225:57

checkbox variable like so so what will

2226:00

be your expectations so I'll just P like

2226:02

expect you want to past that checkbox

2226:04

but initially we want this checkbox to

2226:07

not be checked okay so I'll just use

2226:09

like not and then to be checked and now

2226:12

let me just execute that if I save there

2226:14

right now here you can see our test is

2226:16

now successfully passing like whenever

2226:18

we type something inside our uh input

2226:20

feied and we click on that button so

2226:22

it's going to gives us that checkbox but

2226:24

that will not be checked initially so

2226:26

that's to done but now whenever we click

2226:28

on that check box we want it to be

2226:31

complete or checked so I'll use like

2226:33

screen do come on what the hell screen.

2226:36

get by text and here not test but text

2226:40

and here let's just SP what new to do

2226:41

inside there and const too item is going

2226:45

to be item is going to be equals to this

2226:49

new to-do right here and our expectation

2226:52

will be to- do item do to have the style

2226:56

okay so I'm going to also pass a few

2226:58

style to all use like text declaration

2227:00

EC

2227:01

in and it's going to be set to line

2227:03

three I'm going to save this file right

2227:05

now and obviously our test will fail and

2227:07

that's because we are not providing any

2227:09

style to our LI or our checkbox so now

2227:12

let me go ahead and just provide this

2227:14

text or this style to my checkbox so

2227:17

I'll just select there and here let me

2227:18

just past this uh styling so now we are

2227:20

providing a text decoration of if the

2227:22

to-do is completed in this situation we

2227:24

want there to take a line through text

2227:26

but if that's not the case we want to

2227:28

just provide nothing okay so now let me

2227:31

just refresh there here still we are now

2227:33

getting an error let me check this out

2227:35

oh we are now getting this error Den

2227:37

because we are not even checking the

2227:39

user interaction God damn it so we're

2227:41

going to have to use the AIT and now we

2227:44

can use the user event and now let's

2227:46

just proide the click like whenever we

2227:47

click on there so you want to P for

2227:49

checkbox and now this is pro our

2227:51

expectations so I'll use like expect the

2227:53

checkbox to be checked in this case so

2227:56

now let me just execute there and it

2227:58

should be just expect expect there there

2228:01

we go save our file and now here you can

2228:03

see all of our test are now successfully

2228:05

passing so then stly done we also want

2228:07

to make it so that we can delete

2228:08

something so I'll just provide my it and

2228:12

it can delete a to-do item I'm going to

2228:15

mark it as snc and now let me go ahead

2228:18

and just copy a few things from there so

2228:21

I guess that's going to be fine or you

2228:23

know what I'm not going to do that I'll

2228:25

just copy this line of code now let me

2228:27

just place it right here and first of

2228:29

all you want to get our placeholder so

2228:31

like screen by get by Place holder text

2228:35

and now let me just uh Pro like enter

2228:37

new too and store that inside the input

2228:40

right here so cons input is going to be

2228:43

equals to there and now let me get my

2228:45

button so like whenever we click on

2228:47

there so I'll use like screen. get by

2228:49

text and here let a space we add to do

2228:52

inside there so whenever we click on

2228:54

that button so I'll use like user event.

2228:57

type and here let's just pass for input

2228:59

field and new to do and and then we are

2229:02

going to be clicking on that button so

2229:03

use like user event do click event and

2229:06

now let's just space our button inside

2229:09

there and now we are going to be getting

2229:10

the delete button which we have right

2229:13

here so we have this delete button and

2229:15

now let's just get there so I'll use

2229:17

like uh screen by get by text and

2229:20

provide my delete inside there and I'm

2229:22

going to be carrying this so I'll use

2229:23

like delete button it's going to be

2229:26

equals to that and now whenever we click

2229:28

on that so in that situation we just

2229:31

want want to delete our button so let's

2229:32

just space our delete button sa our file

2229:35

and we also want to provide our

2229:36

expectations so it's going to take a bit

2229:38

of time so for there we are going to be

2229:39

using something called the wait for so

2229:41

we are going to be waiting there for so

2229:44

first of all we have to import there

2229:45

from the react testing Library so I'll

2229:47

use like weit for one W AIT T4 there we

2229:51

go so it's going to allows us to wait

2229:53

for a specific thing okay so here now we

2229:56

are going to be passing there and now

2229:57

this is go our expectation screen do uh

2230:00

quick

2230:01

by text and let's just use a new to do

2230:04

inside there and not to be in the

2230:07

document okay so then we want to just

2230:09

remove this so now I'm going to save my

2230:11

file and that was a so now let me just

2230:14

refresh my uh file and yeah all for test

2230:17

are now successfully passing and this is

2230:19

how we are going to be testing the user

2230:21

interaction by using the user event

2230:23

library from the testing Library so what

2230:26

is a design system there is no actual

2230:28

definition to where a design system is

2230:31

and why is that that's because if you

2230:33

ask a designer they will say it's a UI

2230:35

kit or it's a color palette or

2230:37

typography Grid or iconography but if

2230:40

you ask a developer they will say it's a

2230:42

component Library style guides or some

2230:44

sort of a documentation but the truth is

2230:46

a design system is all of there a little

2230:49

design and a little engineering so what

2230:51

do I mean by that well according to

2230:53

google a design system is a

2230:54

comprehensive set of standard guidelines

2230:57

and components that ensure consistency

2230:59

and cohesion in the design and

2231:01

development of a digital product it

2231:02

serve as a shared language and resource

2231:04

for design teams developers and other

2231:06

stakeholders to create a cohesive user

2231:08

experience across various platforms and

2231:11

products so that was a bit weird

2231:13

definition of what a design system is

2231:15

but now to put that as simple as

2231:18

possible you can think about the design

2231:19

system is like a toolkit for building a

2231:22

digital products it includes everything

2231:24

you need to make sure the design is

2231:25

consistent and looks the same across

2231:27

different screens or Pages now let's

2231:30

talk about the basic comp components of

2231:31

a design system the first one we have is

2231:33

a design principle and it's a high level

2231:36

guidelines or philosophies that inform

2231:38

design decisions like Simplicity

2231:40

accessibility or usability the second

2231:42

one is a UI component and they are a

2231:44

reusable element such as buttons forms

2231:47

model navigation bar and other common

2231:49

interface element often designed with

2231:51

responsiveness and accessibility in mind

2231:53

third one we have is a patterns and they

2231:55

are repeated design solution to common

2231:57

problems such as card layout grade or r

2232:01

down menus and so on next we have is a

2232:03

style guide and there are a collection

2232:05

of visual design rules such as

2232:07

typography uh color pallet and there are

2232:10

a lot of them which we are going to be

2232:11

covering in this course next we have a

2232:13

branding they ensure the design system

2232:15

aligns with the company brand identity

2232:17

tone and value then we have a

2232:19

documentation and they are a clean

2232:21

instruction and best practices on how to

2232:24

use a component and pattern correctly as

2232:26

well as how to maintain the system

2232:27

overall time and then we have a code

2232:30

which is every everyone's favorite topic

2232:32

so for technical consistencies this

2232:34

includes frontend code like component or

2232:36

UI framework such as react components or

2232:39

css Frameworks that developer can

2232:41

integrate into their application

2232:43

something which we are going to be

2232:44

building by ourselves the final piece of

2232:46

the puzzle we have is accessibility and

2232:48

their recommendation for creating a

2232:50

product they are usable by people with

2232:52

disabilities ensuring that the design

2232:54

system support complains with

2232:55

accessibility standards as well so now

2232:57

let me give you a practical example of a

2232:59

design system so let's say you are

2233:00

building bu a shopping app for a brand

2233:02

and you want everything like buttons

2233:04

colors fonts iconography layout and so

2233:08

much more to look consistent across the

2233:10

app a design system would help you

2233:12

achieve this so how that's going to look

2233:14

like well in your design system you

2233:16

would already have your colors like gray

2233:18

gray alpha blue red Amber green teal

2233:22

purple pink and so much more something

2233:24

which we are going to be covering in

2233:25

this course so you would already have

2233:27

your colors you would also have

2233:30

different typography like different

2233:32

fonts which you are going to be using

2233:34

inside your app also you would have

2233:36

different icons for your brand finally

2233:38

you would also have different components

2233:40

which you can use inside your design

2233:42

system so now that you have every single

2233:44

thing set up inside your design system

2233:47

now you just have to grab it and use the

2233:49

inside your app that's it so now your

2233:52

app will look consistent and it will

2233:54

match the design system so those are

2233:56

about the theory of design system and

2233:58

now we are going to be building a design

2234:01

system in figma and that's going to be a

2234:04

lot of fun but before we jump into this

2234:06

section I want to preface this by saying

2234:08

if you are not a designer you can

2234:10

definitely skip this section but hear me

2234:12

out if you are working for a company or

2234:15

a super new company they will ask you to

2234:18

build a design I mean like they will ask

2234:19

you to design a design system for them

2234:22

that's the first thing secondly if

2234:24

you're building your own company just

2234:26

like I have then you would need to

2234:28

design your design system inside figma

2234:31

or some other tools so that's the only

2234:33

reason I'm including this figma design

2234:35

system in this course because I know

2234:37

this is not a designing course this is a

2234:39

advanced reactjs course so you shouldn't

2234:42

be watching that if you want to skip

2234:43

this section you can definitely go ahead

2234:45

and just skip this section you don't

2234:47

even have to watch there but for those

2234:49

who are interested in building a design

2234:51

system in figma this is what you have to

2234:53

do the first thing that you have to do

2234:54

is that you have to just download a

2234:56

figma dcom or you can just use the

2234:57

inside your browser by just clicking on

2235:00

this icon and then provide your email

2235:02

and there you go and if you want to

2235:03

download there you just have to search

2235:05

like pigma download and here the first

2235:08

link will bring you to the download page

2235:10

so you can install or download there for

2235:12

Mac OS you can also download there for

2235:15

Windows and so much more so if you're a

2235:17

Windows user you can just click on this

2235:19

download app for Windows and that's

2235:21

going to be it okay so I already

2235:23

downloaded it and I already sign in

2235:26

because I've been using figma for about

2235:28

three or four years now so yeah I

2235:31

already set up every single thing and

2235:32

this is how the interface should look

2235:34

like I'm now hiding these stuff because

2235:36

you don't supposed to see them so what

2235:38

you have to do is that you have to just

2235:40

go ahead and click on this create new

2235:42

and they change this layout again and

2235:43

again if you're watching this course in

2235:45

the future you should definitely check

2235:47

out like some tutorial about the figma

2235:49

or something like that okay so I'm going

2235:51

to just click on this design file and

2235:53

here you can see it's going to gives us

2235:54

this new design file I'm going to rename

2235:56

that to uh my small design system or

2236:01

something like that okay so now let's

2236:03

begin our design system but before I do

2236:05

that I want to mention one thing that we

2236:07

are not going to be building the biggest

2236:09

design system in the planet Earth or

2236:10

something like that we going to be just

2236:12

creating a simple portion of there so

2236:14

what we have to do the first thing that

2236:16

we have to do is that we have to decide

2236:18

the colors come on the colors which we

2236:20

are going to be using inside our design

2236:22

system secondly we have to generate a

2236:25

style for those colors and thirdly we

2236:29

have to convert those Style colors to

2236:32

variables there we go so these are the

2236:34

three things that you have to keep in

2236:36

mind the first thing that we have to do

2236:37

is that we have to decide a color

2236:38

Forward Design system then we have to

2236:40

generate a style for there and finally

2236:42

we have to convert there to the variable

2236:44

so now let's start from the first one

2236:46

like decide the colors which you are

2236:47

going to be using inside your design

2236:49

system and there are a few resources

2236:51

that I want to share with you but I want

2236:53

to say like I am not sponsored by any of

2236:56

these companies there are just a few

2236:58

websites that I personally like if you

2237:00

want to use that you can if you don't

2237:02

want to use there you don't have to so

2237:04

now what I'm going to do is that I'm

2237:05

going to just uh first of all you have

2237:07

to go to the co o l o r s and I am not

2237:11

going to provide the links of them in

2237:12

the description why well I just don't

2237:15

like to if you want to go to there you

2237:17

can if you don't want to go there you

2237:19

don't have to so c o l o r s.co that's

2237:23

the first website just click on this

2237:24

button and once you do that here you can

2237:27

see it's going to generate a lot of

2237:28

colors for you and yeah here you can

2237:31

they're already sponsoring some other

2237:33

companies and dum like that yeah

2237:35

just hit space every time and it's going

2237:36

to give you a lot of colors and yeah

2237:39

that's the first website that I want to

2237:41

show you and the second website is this

2237:44

um cana.com and I can totally guarantee

2237:46

like you guys probably know this one and

2237:49

you can here you can choose different

2237:51

kind of color combinations and stuff

2237:53

like that so that's the second place for

2237:54

colors yeah you can definitely just

2237:56

upload some sort of image and going of

2237:58

just extract a few colors from there and

2238:00

you can also go to this color. ad.com

2238:03

probably you've heard about this one

2238:06

before you can just go to the explore

2238:08

and you can explore different colors if

2238:10

you like some pette you can just

2238:12

download that or you can just copy that

2238:13

or store the inside your library or

2238:15

something like that that's the third

2238:17

place and the fourth place is this uh

2238:20

Cana once again

2238:22

can okay so that's going to be just for

2238:25

one time you can explore colors or

2238:27

different combination inside this Cana

2238:29

yeah there are are a lot of colors the

2238:32

final place that I really like is this

2238:34

color hunt because it has a lot of

2238:36

flavors uh to choose from so let's

2238:38

suppose if you want to create some sort

2238:40

of a golden design system so you can

2238:42

just click on there it's going to give

2238:43

you a golden color right here if you

2238:45

want to choose some dark just like worel

2238:48

you can just click on that it's going to

2238:49

give you worel uh kind of colors and if

2238:52

you want to choose cold so it's going to

2238:54

give you cold color if you want to

2238:55

choose summer or fall happy or kids Sky

2238:59

there are a lot lot of them let me just

2239:01

choose this kids one and it's taking a

2239:03

lot of time but yeah these are the color

2239:05

for the kids so now that you know where

2239:08

to find the colors now you have to

2239:10

generate the style for your colors so

2239:12

I'm going to just remove that from I'm

2239:13

going to hit o so it's going to gives us

2239:15

ellipse tool there we go and now I'm

2239:16

going to just create a few portion of

2239:18

this so and then I'm going to hold alt

2239:20

and shift and duplicate there one time

2239:23

and now I'm going to just do the hit

2239:24

control D so it's going to duplicate the

2239:26

three um four five and six so I'm going

2239:29

to just duplicate that like six times

2239:31

and now you can just click on there then

2239:33

go to this fil and choose your favorite

2239:36

color inside there so let's suppose if

2239:38

you like like this color or maybe you

2239:40

like some sort of a red color you can

2239:42

definitely provide there but for this

2239:44

code I already selected a color palette

2239:46

you may not like it but I like it okay

2239:49

so I'm going to also name them you know

2239:52

let me just name them I'm going to give

2239:54

it the name of like primary come on

2239:56

primary I'm going to just choose this

2239:58

one that one and put that right right

2240:00

here so that's going to be my primary

2240:02

color now I'm going to just move them

2240:05

around come on what the hell I'm going

2240:07

to just move them around and this one

2240:10

will be neutral color now let me create

2240:12

one more so I'm going to just duplicate

2240:14

that put that right here and we're going

2240:17

to be also creating a color or

2240:19

generating a color for we warning uh

2240:22

next next let's just create for the

2240:24

danger so I'm going to just change that

2240:26

to like danger and this is going to be

2240:28

my danger color and now finally uh not

2240:33

finally but we still have two more left

2240:35

so I'm going to just change that to

2240:36

success and now finally we have to

2240:39

create one more for the gray scale c a l

2240:44

e there we go and now I'm going to just

2240:46

provide my hexi decimal values if you

2240:48

have your own color already selected you

2240:50

can just specify there but in my case

2240:52

I'm going to just only provide my color

2240:54

so now let me go ahead and just choose

2240:56

this one and the first color that I have

2240:58

is hh1 4 F0 D6 so that's going to be my

2241:03

primary color then for the neutral I'm

2241:05

going to just use this color which is

2241:07

hh14 2 ef0 hit enter so that's going to

2241:11

be my neutral color for the warning I'm

2241:13

going to choose this color which is 1 d

2241:15

d B70 e that's going to be my warning

2241:19

color kind of a yellowish color for the

2241:20

danger we're going to be using this

2241:22

reddish kind of color which is a hash

2241:26

f014 for the success we're going to be

2241:28

using this color which is a hash same

2241:30

one e f014 hit enter so that's going to

2241:33

be my success color and finally for the

2241:36

gray scale we are going to be just using

2241:37

this one which is a h 7 d8 C8 B so

2241:42

that's going to be my gray scale color

2241:45

okay cool now we have to create a pallet

2241:47

for our color so I'm going to just

2241:49

choose the second icon yeah you just

2241:51

have to uh hit F so it's going to give

2241:52

you this Frame one and just like grab it

2241:56

how much you like and now inside there

2241:59

we're going to be defining work color

2242:00

pette now I'm going to hit R so it's

2242:02

going to gives us this rectangular icon

2242:04

right here or this rectangular tool I'm

2242:07

going to just Define that right here and

2242:08

I'm going to duplicate the 11 times so

2242:10

I'm going to hold alt and shift and then

2242:13

we're going to be duplicating there one

2242:15

time 2 time 3 4 5 6 7 8 9 10 and let me

2242:21

just create the for the final time which

2242:23

will be the 11 time and now let me make

2242:26

the a bit bigger so you guys can see

2242:28

everything a bit better I'm going to

2242:29

also make it a bit smaller because yeah

2242:32

and I'm going to name the as primary so

2242:34

let's just name the primary now we are

2242:36

going to be also providing the opacities

2242:38

today so I'm going to just hit T so it's

2242:41

going to activate my text tool and I'm

2242:43

going to just rename that to like 50 I'm

2242:45

going to make it a bit smaller like so I

2242:48

guess that's going to be fine now let me

2242:50

just duplicate this so the next one we

2242:52

would have is like 100 then 20 300 let

2242:55

me just activate that change it to 300

2242:58

then we have a 400 VAR iation let's just

2243:01

change there to 400 500 change this one

2243:04

to 600 700 800

2243:08

900 come on 900 and then

2243:12

950 let's just change there to

2243:15

950 there we go now that we successfully

2243:18

selected our color and we also Define

2243:20

our pets so now we are going to be

2243:22

duplicating there for the neutral color

2243:24

for the warning danger success and gr

2243:26

scale so I'm going to just choose there

2243:28

hold shift and ALT and then click on

2243:31

there and duplicate there once once

2243:33

again change there to like neutral and

2243:35

I'm going to also duplicate there one

2243:36

more time change there to warning so

2243:39

let's just change that to warning and

2243:41

I'm going to also duplicate there one

2243:43

more time and what was that danger is

2243:46

success and gray scale so danger next we

2243:48

would have is a success change that to

2243:52

success and finally we are going to be

2243:54

creating for the gray scale as well so

2243:57

let's just create a gray scale and

2243:58

that's done so now that we successfully

2244:00

created our pet the next thing that we

2244:02

have to do is that we have to go to this

2244:04

website which is a t NTS T.D now I'm

2244:08

going to hit enter right here and now

2244:10

I'm going to just copy this hexi decimal

2244:12

from the primary I'm going to copy there

2244:15

and now let me just place there right

2244:16

here and as soon as I do that it's going

2244:18

to gives us all of that variations right

2244:20

here you can take a screenshot of there

2244:23

you know let me just show you there so

2244:24

if you're using a windows so you can

2244:25

just take a screenshot of there now let

2244:27

me take a screenshot save there inside

2244:29

my desktop top and I'm going to just

2244:31

rename that to like colors or something

2244:33

like that and now I'm going to grab that

2244:36

right here inside my design tool and now

2244:38

I can just select my element and I can

2244:41

hit I and then choose my color from

2244:44

there there the first way I can choose

2244:46

these colors but this is not efficient

2244:48

way because the hexadecimal code will be

2244:50

changed so I'm not going to do that I'm

2244:52

going to just delete it from here I'm

2244:54

going to undo there let's just undo

2244:56

there and I'm going to just delete there

2244:58

the second way is to waste a bit of of

2245:00

your time and just copy this hexi

2245:03

decimal so I'm going to just face

2245:04

forward the video right now I'm going to

2245:06

copy you know let me just show you this

2245:08

first one and then for these next I'm

2245:10

going to just fast forward this video so

2245:12

I'm going to go ahead and copy this

2245:14

first one copy there now let me just

2245:17

choose the first one and then I'm going

2245:18

to place it right here copy the second

2245:20

one place it right here third one place

2245:23

it here fourth one select that and place

2245:27

it right here for the fifth one which is

2245:31

this 400 variation I'm going to choose

2245:34

the and place it right here then for the

2245:37

sixth one copy that pleas I know I'm

2245:40

taking a bit of your time because this

2245:42

is important and I'm going to face

2245:43

forward the video for the next one so

2245:45

maybe it will confuse some of the people

2245:47

so I'm going to have to uh just do the

2245:50

like copy and place there and you have

2245:52

to bear with me please bear with me I'm

2245:55

going to just choose there I wish I had

2245:57

a lot of time to tell you a story about

2245:58

my ex like how she ch she Dr me and how

2246:01

she left me but I don't have a lot of

2246:04

time and we are now at two colors so

2246:06

there's not a lot of time to explain or

2246:09

the story of my ex like how she cheated

2246:11

on

2246:13

me you know what that's done now I'm

2246:16

going to copy this second color and I'm

2246:18

going to Face Forward there right now

2246:20

I'm going to place it here and bang

2246:35

okay so now then St done and it took me

2246:37

a lot of time while I was listening to

2246:39

some John Wick theme music uh so now the

2246:43

next thing that we have to do is that we

2246:45

have to create a variation I mean like

2246:46

not variation but now next we're going

2246:48

to be renaming each layer so here you

2246:50

can see that's going to be the first one

2246:52

I'm going to just do that for the first

2246:54

one and now for the next one I'm going

2246:55

to fast forward the video once again so

2246:58

that's the first layer you just have to

2246:59

click on there and then double click on

2247:01

this layer and change there to like 50

2247:04

okay so I'm going to just click on there

2247:06

the next one come on let me just hit

2247:08

iscape click on the next one and then we

2247:10

have a 100 I'm going to choose this next

2247:13

one then we have H 200 then we have a

2247:18

300 so let's just uh do that for this

2247:21

one we have a 400 I'm going to choose

2247:23

this next one which is a 500 then we

2247:26

have a 600 come on 7 100 I wish there

2247:31

was some other way that I can do that

2247:32

very quickly but this is not a vs code

2247:35

baby this is figma so we have to write

2247:38

800 then

2247:40

990 9900 950 there we go

2247:45

950 I'm going to hit enter right now so

2247:48

all of these layer are now successfully

2247:49

rename and I'm going to do that for

2247:52

these next one and you should do the

2247:54

same but I'm going to face forward this

2247:56

video right now

2248:04

okay so that's to done now we are going

2248:06

to be grouping there so I'm going to

2248:08

just select these first variations and

2248:10

then I'm going to hold control or

2248:12

command R and once I do that here you

2248:15

can see it's going to ask us to provide

2248:16

some sort of a name today so I'm going

2248:18

to just give it the name of like primary

2248:20

and now I'm going to hit space and click

2248:22

on this current name so it's going to

2248:24

choose like uh primary 950 900 and 800

2248:28

700 and so on and so so forth depending

2248:30

on our layer names that's the only

2248:32

reason I rename my entire layers to like

2248:35

from starting from 50 through 950 now

2248:39

I'm going to just click on this rename

2248:41

it's going to just rename there now

2248:43

we're going to be selecting this portion

2248:44

hit control R once again and I'm going

2248:47

to give it the name of like neutral and

2248:49

then I'm going to just click on there

2248:52

and hit enter so it's going to rename

2248:53

that right here now let's just choose

2248:56

this one and hit controlr and that's

2248:58

going to be my one

2249:00

and now let's just hit space and current

2249:02

name and that's my current name let's

2249:06

just choose this one hit control R give

2249:08

it the name of like danger and then the

2249:10

current name choose there and now for

2249:13

the success click on the current name

2249:16

rename the and finally for the gray

2249:18

scale hit control R and I'm going to

2249:21

give it the name of like gray scale and

2249:24

then click on the current name and

2249:25

rename there so now that we successfully

2249:28

rename every single thing and every

2249:29

single thing is now successfully

2249:31

organized and finally we have to make a

2249:33

selection and create uh Styles based on

2249:37

there so what I'm going to do is that

2249:38

I'm going to select this one hit control

2249:41

or shift this one shift with this one

2249:45

I'm holding shift and selecting that

2249:47

right here just like then hold control

2249:50

and then for slash okay and once you do

2249:53

that here you can see we have a plugins

2249:54

and assets and so on and so forth I'm

2249:57

going to click on this plugin right here

2249:59

and I'm going to search for a Styler

2250:01

just search for a styler and then click

2250:03

on there and once you click on there

2250:05

it's going to ask you to like extract

2250:07

the style or generate a style I'm going

2250:09

to choose this generate style so let's

2250:11

just click on there it's going to take a

2250:13

while and now it's going to giv us all

2250:15

of that colors right here so we have a

2250:18

danger primary warning and all of that

2250:21

colors so now that we successfully have

2250:23

all of that colors and now based on

2250:25

these colors we're going to be creating

2250:26

a variable so just click on somewhere

2250:29

and else not on the colors then hit that

2250:32

same command one more time which is a

2250:33

control come on CTR and then plus this

2250:37

for symbol or or what do you guys call

2250:40

that okay so now I'm going to just do

2250:41

that I'm going to hold control and hit

2250:44

that for slash once again and I'm going

2250:46

to search for styles to variable so

2250:48

Styles come on styles to Vari there come

2250:53

on v a r i a b l e okay so here you can

2250:57

see we have this uh bluish kind of icon

2250:59

so I'm going to click on there and here

2251:01

you can see it's going to giv us this

2251:02

box right here and now we're going to be

2251:04

converting there but I'm going to give

2251:06

it the name of like colors maybe I'll

2251:08

just give it the name of colors and I'm

2251:09

going to click on convert Styles into

2251:11

variables let's just click on there it's

2251:13

going to convert 65 colors to the

2251:16

variables so now let's just close there

2251:18

click on somewhere else and now I'm

2251:20

going to click on this icon right here

2251:22

which is a local variable so if I click

2251:24

on there and bang we have all of our

2251:29

color Vari

2251:30

right here so we have a neutral we have

2251:32

a gray scale we have success and so on

2251:35

and so forth so these are all the

2251:37

variables that we can use inside our

2251:39

figma and that was it about how we're

2251:41

going to be generating a color variables

2251:43

or creating a colors inside our design

2251:46

system so this is how we are going to be

2251:48

generating our colors but now let's talk

2251:50

about the number scale and the radius

2251:52

tokens so I'm going to close there I'm

2251:54

going to also remove this text and now

2251:57

I'm not going to click on anywhere else

2251:59

I'm going to just click on there select

2252:01

all of them and delete there from here

2252:04

because we don't need there anymore now

2252:05

let me just click on somewhere else like

2252:07

maybe this area why aren't we getting oh

2252:09

there we go and now if you click on

2252:12

there here you can see we are now going

2252:14

to be still getting all of our colors

2252:15

right here so don't worry about that

2252:18

sidebar so now let me just close there

2252:20

and now we are going to be creating our

2252:21

number scale so I'm going to just click

2252:23

on these three dots and let me just show

2252:25

you how did I just access there you just

2252:28

have to click on this local variables

2252:30

and click on this icons and then click

2252:32

on these three dots and then create a

2252:35

new collections so I'm going to just uh

2252:37

give it the name of like number scale I

2252:40

guess

2252:41

number scale would be fine and now here

2252:44

I'm going to just choose like create

2252:46

variable and now here we are going to be

2252:48

choosing a number right here so now let

2252:50

me just click on there and here we are

2252:52

going to be defining a few numbers like

2252:54

tiny extra extra large and so on and so

2252:57

forth so I'm going to start from the

2252:58

first one which is a tiny t i n y and

2253:01

I'm going to just set there to two maybe

2253:03

I guess that two would be fine okay so

2253:06

now I'm going to click on this create

2253:07

variable once again click on this number

2253:09

once again change that to like extra

2253:12

small and unfortunately you have to

2253:14

watch me I can't fast forward this

2253:16

section because the names are super

2253:19

different so now let me just click on

2253:20

the uh create variable once again and

2253:23

I'm going to give it the name of like

2253:24

small and change that to six let's just

2253:26

create another uh number change that to

2253:29

medium medium small m e d i m and change

2253:33

that to

2253:34

add click on this create variable go to

2253:37

the number scale I'm going to change

2253:39

that to medium and change the value of

2253:41

that to 12 let's just create another one

2253:43

for the large l a r g change there to 16

2253:47

then create another one for the extra

2253:49

large change there to 20 and create

2253:52

another one for super large change there

2253:55

to 24 let me just create another one for

2253:59

the huge and change there to like 32 and

2254:02

now let me create another one for the

2254:04

gigantic and change there to 40 and the

2254:07

final one will be for the full okay so

2254:10

let's just create a full and provide

2254:12

like 99 or you know what 99 would be

2254:15

fine so this is how we are going to be

2254:17

creating our number scale and now let's

2254:18

create another collection for the radius

2254:21

so I'm going to once again click on

2254:22

these three dots then I'm going to

2254:24

choose create collection and now we are

2254:26

going to be creating uh another

2254:27

collection for the numbers and I'm going

2254:29

to start from the excess for the extra

2254:31

small and which I'm going to click on

2254:33

this icon and I'm going to set there to

2254:36

extra small okay now let me create

2254:39

another one for the small just s and now

2254:42

I'm going to connect there to small and

2254:45

now let me create another one for come

2254:47

on let's just create the for the medium

2254:50

and now I'm going to connect it with the

2254:52

medium not a not a medium small but with

2254:55

the medium okay let's just create the

2254:58

another one for for the large for the L

2255:01

and I'm going to connect it with the

2255:03

large so this is a large now we're going

2255:06

to be creating another one for the extra

2255:08

large and I'm going to connect it with

2255:10

the extra large where is there oh there

2255:13

we go so we have a extra large and now

2255:16

finally we are going to be creating uh

2255:18

for the full and now let's just connect

2255:21

with the full full full there we go

2255:24

let's just connect there so this is how

2255:26

we are going to be connecting the and

2255:27

creating our collection so now that we

2255:28

have a number number scale which look

2255:30

something like this we also have a

2255:32

colors which looks something like this

2255:35

and we also have our other collection

2255:37

right here so now let me just close that

2255:39

now our collections are successfully

2255:40

done and let's suppose if you want to

2255:42

use the inside our design system so I'm

2255:44

going to just you know what I'm going to

2255:47

create a frame even and now let me just

2255:50

Define a few rectangles right here let

2255:53

me just make that a bit smaller so you

2255:55

guys can see there and I'm going to

2255:58

duplicate there like a few times I'm

2256:00

going to choose this one and let's

2256:01

suppose if I want to change the radius

2256:03

of there so I can just go ahead and

2256:05

click on this icon and here you can see

2256:07

we have a tiny radius extra small small

2256:10

medium and so on and so forth suppose if

2256:12

I want to change that to like uh I don't

2256:14

know maybe a large radius or maybe

2256:17

medium would be fine so I'm going to

2256:18

just choose medium so it's going to

2256:20

change there right here and now let's

2256:22

suppose if I want to change that to the

2256:25

large one so it's going to change that I

2256:27

guess I choose large like twice but now

2256:30

let me click on there and change that to

2256:32

huge then I'm going to change that to

2256:34

like gigantic which looks something like

2256:37

this and I'm going to also change that

2256:39

to the full it's going to make as a full

2256:42

circle and yeah we can now play around

2256:44

with that if you want it to and now

2256:46

let's suppose if I want to change the

2256:47

color of there so if I just click on

2256:49

there now I can just click on this spell

2256:51

and here you can see we have our

2256:52

libraries if I click on there and inside

2256:55

this Library we have our gray scale and

2256:56

all of our colors and now we can choose

2256:59

color and different variations of them

2257:01

by using this Library which we just

2257:03

created for our design system now let me

2257:05

click on there I'm going to also change

2257:08

the color of them to like something else

2257:10

go to the library once again and we can

2257:12

change that to like warning and so on

2257:14

and so forth now we can create our

2257:16

component like let's suppose if you want

2257:17

to create some sort of a button and we

2257:19

can style there by using our existing

2257:21

design system and that's going to be it

2257:23

so I'm going to just Define a smaller

2257:26

button like this which will just say

2257:29

like

2257:30

uh this is quite like uh learn more or

2257:33

something like that I'm going to make

2257:34

that a bit bigger I'm going to also make

2257:36

it uh

2257:38

borderer and I'm going to change the

2257:40

Border radius of there so let's just go

2257:42

ahead and change that to like maybe

2257:44

small would be fine yeah I guess mod

2257:46

would be fine I'm going to also make the

2257:48

as a success button or not a success but

2257:50

this is a learn more button so this

2257:53

should be some kind of outline button so

2257:55

I'm going to choose

2257:58

maybe this variation and I can also

2258:01

change the color of that to like

2258:02

something else uh you know let me just

2258:05

change that to white or yeah I guess

2258:06

that's going to be fine so yeah this is

2258:08

how we are going to be defining our

2258:10

design system in figma and now we can

2258:12

extract all of that values from this

2258:14

figma file and we can use the inside our

2258:17

app oh I was about to close this entire

2258:19

section but now I realize that I forgot

2258:22

to include One More Design token which

2258:24

is called the obesities so I'm going to

2258:28

delete that

2258:29

and now I'm not going to click on

2258:31

anything let's just click on this local

2258:34

variables once again and now I'm going

2258:36

to go ahead and create a new collection

2258:38

for the opacities so I'll just give it

2258:41

the name of like opacities if I can just

2258:44

rename that to op p a c i t s there we

2258:48

go and now let me just click on this

2258:50

create variable click on the number I'm

2258:52

going to start from the first one which

2258:53

will be OPC op a qu and that's going to

2258:57

be set to $ 100 the complete entire

2259:01

opacity and now let's just create

2259:03

another one for the semi OPAC which will

2259:05

be set to 80 and now we are going to be

2259:08

creating another one for the

2259:12

transparent e r a n s p a r NT and which

2259:16

will be set to 50 and I'm going to also

2259:19

create one more for the light

2259:22

transparent and the value of that will

2259:24

be set to 30 now for the final one which

2259:27

will be set to a very transparent and

2259:30

the value of there will be set to 25 and

2259:33

that's it and I also forgot to rename

2259:36

this one which is the radius I guess so

2259:38

I'm going to just choose that and change

2259:40

that to radius let's just hit enter and

2259:43

now our design system is complete I mean

2259:46

like not entirely complete but you can

2259:48

call it complete so let's suppose if I

2259:50

want to provide some sort of opacity so

2259:52

which we just created right here I'm

2259:55

going to Define that and change the

2259:58

color of there to like

2259:59

black complete Black and now I'm going

2260:02

to duplicate there like a few times like

2260:05

so I'm going to just click on this one

2260:08

now let me go ahead and go to the

2260:10

opacities and click on this local

2260:12

variable and now I can choose like OPAC

2260:15

if I just choose like OPAC or semi OPC

2260:18

it's going to show us this value right

2260:19

here so if I click on the OPC which will

2260:20

be set to full 100 I can also change

2260:23

there to like semi op so semi op it's

2260:27

going to change the uh what do we call

2260:28

it the op of there I can also change

2260:31

this one to

2260:33

transparent and click on there it's

2260:35

going to make it transparent choose this

2260:37

one change that to like very transparent

2260:40

it's going to make it like a bit more

2260:43

subtle create there for the final one

2260:45

come

2260:46

on duplicate right here and just change

2260:50

this value uh I'm going to have to un

2260:53

link there and now let me just create

2260:55

right like very transparent right here

2260:58

so just going to make it like very

2260:59

transparent so yeah this is how we can

2261:01

use all of that design system values

2261:04

inside our figma but now we have to

2261:07

extract all of that values and use

2261:09

inside our design system which we are

2261:10

going to be creating right now all right

2261:13

guys now we are preparing ourself for

2261:14

the design system of this course but

2261:16

before we get into the design system

2261:18

first of all we have to learn about

2261:19

something called the story book and

2261:21

trust me you're going to love this one

2261:24

and also before I give you a definition

2261:25

of what a story book is I want to

2261:27

mention a few things you can not use a

2261:29

story book for a smaller application

2261:31

like maybe you are building your own I

2261:33

don't know portfolio or just a small

2261:36

application or something like that story

2261:38

book can be useful for a huge Enterprise

2261:41

application like suppose you're working

2261:43

with a bigger company or you want to

2261:45

build your own SS application or

2261:47

something like that then you would be

2261:49

able to use story book you cannot use

2261:51

that I mean like you totally can use

2261:53

there like nobody can stop you from

2261:55

using there but it will not be that much

2261:57

useful for your small application so now

2262:00

let me just give you a definition of

2262:01

what a story book is so story book is an

2262:03

open source tool used for developing and

2262:05

testing the UI components in isolation

2262:08

it allows developer to create a UI

2262:10

components outside of their main

2262:13

application making it easier to build

2262:15

test and showcase individual part of the

2262:16

UI before they are integrated into your

2262:19

overall application so as I said this is

2262:21

not a tool that you are going to be

2262:23

using like day to-day and also this is

2262:25

another a tool that uh you are going to

2262:28

be using there for a smaller application

2262:29

so it provides a lot of benefits the

2262:32

first thing it provides is a component

2262:34

isolation so story book Let's developer

2262:36

work on the UI component in isolation

2262:39

meaning you can build and test component

2262:41

without the need to run the entire

2262:43

application and this helps in focusing

2262:45

purely in the individual component

2262:47

functionality rather than just focusing

2262:49

on the entire application it also

2262:51

provides something called the visual

2262:53

testing so it provides a visual

2262:54

interface to view different state of the

2262:56

UI component such as various

2262:58

configuration themes or data inputs and

2263:00

so on and so forth something which we

2263:02

are going to be covering in this course

2263:04

so this helps identify issues with the

2263:06

component visual appearance or behavior

2263:08

early in the development process it also

2263:10

provides the documentation and I've seen

2263:12

a lot of developers they use story book

2263:14

just for their documentation not for

2263:17

anything else but just for the

2263:18

documentation so story books serve as a

2263:20

living documentation tool for the UI

2263:22

component you can write stories like

2263:24

individual use cases for each component

2263:26

and we are going to be also covering the

2263:28

stories in later in this course and they

2263:30

are automatically display in the story

2263:32

book interface something which you're

2263:34

going to be seeing in a few seconds it's

2263:35

easy to maintain and update

2263:37

documentation is the component evolves

2263:39

it also provide the support of add-ons

2263:41

or you can say the extensions so story

2263:44

book has a wide array of add-ons that

2263:46

can help with task like accessibility

2263:48

checks responsive design testing or

2263:50

adding a control to multiple components

2263:52

St dynamically something which we're

2263:54

going to be also covering in this course

2263:56

and now let's talk about the design

2263:58

system I mean like not the actual

2264:00

definition of a design system but it

2264:02

also help us with the design system so

2264:04

story book is commonly used in the

2264:05

development of design system as it helps

2264:08

ensure the component are reusable and

2264:10

adhere to design guidelines design teams

2264:12

can also use story book as a tool to

2264:14

communicate design specification to

2264:16

developers so this is also something

2264:19

which we are going to be seeing in this

2264:20

course so now let's get into the

2264:22

installation of the story book so if you

2264:23

already created your react application

2264:25

by either using the create react app or

2264:28

if you use like weat so you just have to

2264:30

type that in your terminal like npx SB

2264:33

in it it's going to just take a bit of

2264:35

time and it's going to install story

2264:37

book inside your application so now

2264:38

let's just do that so here is the

2264:40

official page of the story book and now

2264:42

we are at the version add so you know

2264:45

let me just show you something this is

2264:47

how we can develop our component in

2264:48

isolation this is how we can test our

2264:51

component and we can also provide a

2264:53

visual testing and we can also document

2264:56

our component like this and that's going

2264:59

to be a lot of fun so yeah their landing

2265:01

page is super amazing super duper

2265:04

amazing okay so I'm going to go back let

2265:07

me just go back and install story book

2265:10

inside our application so I'm going to

2265:11

copy that from here now let me open my

2265:13

terminal so let's just open there and

2265:16

I'm going to zoom in a bit so you guys

2265:18

can see everything a bit better and by

2265:19

the way you are not just limited to use

2265:21

reactj you can use story book with swell

2265:23

and different projects so I'll just use

2265:25

like npm create we at latest and install

2265:29

there right here so I'll just give it

2265:30

the name of like story demos or sto yeah

2265:33

I guess that's going to be fine I'll

2265:35

choose reactjs with typescript let's

2265:37

just go into the story book demos and

2265:39

install every single thing inside there

2265:41

and our react setup is now successfully

2265:43

done I'm going to open that by using my

2265:45

vs code and this is how it looks like so

2265:47

I'm going to go ahead and remove this

2265:49

public from here I'm going to go to the

2265:51

SRC remove the Assets app.css Now let me

2265:54

go ahead and go to my f. TSX file remove

2265:56

every single thing from there and I'm

2265:58

going to just use my rfcu to create my

2266:00

component and also remove every single

2266:02

thing from the index.css file as well so

2266:04

now that we successfully install our

2266:06

react JS the next thing that we have to

2266:08

do is that we have to initialize our

2266:10

story book inside there I'm going to go

2266:12

there and here you can see this is how

2266:13

we are going to be initializing or

2266:15

installing story book inside our

2266:17

existing project so I'm going to just

2266:18

copy there and now let me just place it

2266:20

right here so you just have to write

2266:22

like npx story book at latest and in it

2266:25

or you can just use like this command

2266:27

which is npx SB in it or something like

2266:29

that you can also use there but in my

2266:31

case I'm going to just I already copied

2266:33

it from the documentation so now let me

2266:35

just place there and hit enter so now

2266:36

it's going to gives us a few folders

2266:39

right here so I want you to focus on

2266:40

this area now let me just provide why to

2266:42

proceed there and yeah it's going to

2266:44

gives us a few folders right here I

2266:47

guess it's going to ask us a few

2266:48

question first of all I'm not quite sure

2266:49

about that but yeah let's just see and

2266:52

as you can see it added this do story

2266:54

book folder and also add these stories

2266:56

right here something which we are going

2266:57

to be discussing in in a few seconds so

2267:00

yeah my application is now successfully

2267:02

running but if you want to run there I

2267:04

just close my application I don't know

2267:06

why but I just did so now let me just uh

2267:09

restart my story book once again so

2267:11

let's just delete there and I'm going to

2267:12

just restart my story book by using npm

2267:15

run story book so if I just use the it's

2267:17

it's going to run my story book right

2267:19

here in a few second and this is how my

2267:21

story book will look like so there are a

2267:23

lot of stuff going on so now let me just

2267:25

explain there so first of all it's going

2267:26

to giv us these instruction like what we

2267:28

can do with the story book and so on and

2267:31

so forth and they are talking about the

2267:32

chromatics and so on and so forth so

2267:35

this is going to be just our

2267:36

instructions then we have a few

2267:38

components so this pattern is called the

2267:40

compound component which we're going to

2267:42

be seeing in a few second but not right

2267:43

now so here you can see we have our

2267:45

buttons folder now let me just zoom in a

2267:47

bit oh you know what I'm not so if I

2267:49

click on there we have our documentation

2267:51

for our component like what we can do

2267:54

with this component like we can uh

2267:56

whenever we click on there was going to

2267:57

happen and we have our primary label

2267:59

background color sizes like we can

2268:02

change there let me just go back we can

2268:04

change there so if I change that to like

2268:05

small so it's going to make this button

2268:06

small if I click on the medium so it's

2268:08

going to make it medium if I click on

2268:10

the large so it's going to make it large

2268:11

and we can also change the color of our

2268:13

button like this if you wanted to and

2268:16

this is also something which we are

2268:17

going to be covering in a few seconds we

2268:19

can also change the text to be something

2268:21

else we can also make their disable or

2268:24

enable and so on and so forth so yeah we

2268:27

have our primary button we have we have

2268:28

a secondary large and small buttons so

2268:31

these are the docks or the documentation

2268:33

for our component and then we have a few

2268:36

component or a few variation of our

2268:38

component so if I click on this primary

2268:40

so it's going to show us this primary

2268:42

and it also has these controls so when

2268:44

we click on there what's going to happen

2268:46

so this action will happen and we also

2268:49

have these primary and secondary and

2268:51

this area is called the control area

2268:53

where we are going to be controlling the

2268:55

behavior of our component okay so we can

2268:58

also change there to like uh blah blah

2269:01

blah and also we can change the color of

2269:03

there and as we already saw that we can

2269:05

set there to medium or small then we

2269:07

have a secondary component which will

2269:09

look something like this then we have a

2269:10

large button small button and so on and

2269:13

so forth then we have a Herer like you

2269:15

are not just limited to create a simple

2269:17

uh what do we call a simple button

2269:19

component you can create the entire hers

2269:21

and also the entire Pages if you wanted

2269:24

to so this is how header component will

2269:26

look like and we can also provide these

2269:28

documentation for our header component

2269:30

and we can also see the inaction so if I

2269:32

click on there and here you can see this

2269:34

is how we can interact with our

2269:36

component and there are a lot of stuff

2269:38

so yeah you I'm just saying like you are

2269:40

not just limited to um style your button

2269:43

component or you can also provide the

2269:45

header you can also even provide your

2269:47

entire Pages like as you can see right

2269:49

here this is the entire page that you

2269:51

can test and you can also visualize the

2269:53

inside the story book and now if I click

2269:55

on there once again you can also see

2269:57

there so where in the world is all of

2270:00

that stuff coming from like what are we

2270:02

even doing here so now let me just hide

2270:05

there and all of that stuff are now

2270:06

coming from these stories right here so

2270:08

first of all we have like all of their

2270:10

assets like as you saw these screenshots

2270:12

a few seconds ago so now let me just

2270:14

remove there and we also have that

2270:16

button so here you can see we have our

2270:18

button. TSX file so if I click on there

2270:20

this is how they created their component

2270:22

and they provide a bit of styling to the

2270:24

and so on and so forth but this is how

2270:27

they are now testing their component by

2270:29

using story book and also typescript so

2270:33

yeah and this is how they are creating

2270:35

their header component This Is How They

2270:36

are providing a stories for their heror

2270:39

component This Is How They are creating

2270:40

their entire Pages This Is How They are

2270:43

creating their entire pages and this is

2270:45

how they are providing stories for their

2270:47

pages and also their own CSS if you want

2270:50

to use tman CSS you totally can if you

2270:52

want to use like the module CSS you

2270:54

totally can you can use anything that

2270:57

you prefer and story book will work for

2271:00

you so now let me just close there and

2271:02

what in the world are we going to be

2271:03

even doing I'm going to just select

2271:05

every single thing or even this entire

2271:07

stories I'm going to right click on

2271:09

there and I'm going to delete there say

2271:11

bye-bye to the stories because now we

2271:13

are going to be creating our own stories

2271:15

so now let me just click on yes delete

2271:18

this permanently and now we are going to

2271:20

be creating or recreating their stories

2271:22

folder from scratch so I'll use like

2271:24

stories and now let me just hit enter

2271:26

right here and inside the stories folder

2271:28

we can just create our components and

2271:30

yeah you know let me just create another

2271:32

components folder right here so you know

2271:34

let me just create that stories right

2271:36

here so I'll just use like button. TSX

2271:39

and I'll use my rafc inside there so my

2271:41

file close there and now we are going to

2271:43

be creating a story file for this button

2271:46

right here so now if I just create a

2271:48

file I'm going to give it the same name

2271:49

like button and then now in this case we

2271:52

are going to be using a stories and

2271:54

then. TSX so as soon as I do that here

2271:57

you can see my I is now successfully

2271:59

changed so this is how we are going to

2272:01

be creating a stories file forward

2272:03

button component so now if I hit ENT

2272:05

right here we're going to be doing a lot

2272:07

of magic but now here I'm going to just

2272:08

write a simplest quote so first of all

2272:10

we are going to be importing our button

2272:12

component so that we can see there in

2272:14

action then we're going to be using

2272:16

export default and now let's just

2272:18

provide the and by the way for now we

2272:20

are not going to be focusing on the

2272:22

typescript we are going to be using

2272:24

typescript with story book in a few

2272:26

seconds but not right now because first

2272:29

of all I want you to focus on the story

2272:31

book syntax then we are going to be

2272:33

implementing the typescript with the

2272:35

story book but not right now so we going

2272:37

to be using a title and I'm going to

2272:38

just give it the name of like title and

2272:40

I'm going to also provide a comma and

2272:42

provide a component right here and by

2272:43

the way we are going to be like learning

2272:44

about all of that coding in a few

2272:46

seconds and the component we want to see

2272:48

or test will be that one component which

2272:51

we are now importing right here and

2272:52

finally we just have to export cons

2272:54

primary and this going to be equals to

2272:56

this Arrow function now let let me just

2272:58

use the button right here and close

2273:00

there so as soon as I do that save my

2273:02

file and now let me just rerun my story

2273:04

book once again so I'm going to be using

2273:05

npm run story book and now it is running

2273:08

so now let's just refresh there it's

2273:09

going to gives us this error and why is

2273:11

there that's because our URL is changed

2273:14

as you can see we are now inside this

2273:16

page component which is no longer

2273:18

available so now let me just remove and

2273:20

hit enter right here so now it's going

2273:21

to gives us that button component by

2273:23

which we are not even providing any

2273:25

styling and nothing today so here you

2273:26

can see we have our button fold

2273:28

which is now coming from this title

2273:31

right here so if I just write like my

2273:32

own name husan uh components or

2273:35

something like this my file here you can

2273:37

see it's going to change the name of

2273:38

that to hosan components and now if I

2273:41

expand there now we are getting this

2273:43

variation or flavor of this component so

2273:46

where in the word is that coming from it

2273:48

is coming from this line of code now

2273:50

that we learn about how we are going to

2273:51

be creating a button component and how

2273:53

we can create a story file for there but

2273:55

there is also another folder which is

2273:57

called the do story book and inside

2274:00

there we have our main.ts and also

2274:02

preview. TS file so now let's just

2274:05

explore that what in the word is this

2274:07

main.ts file and what in the word is

2274:09

this preview. TS file so the first one

2274:11

we have is a main.ts file so the main.ts

2274:14

file is a configuration file used to

2274:16

customize the setup and behavior of the

2274:18

storybook instance and here we can

2274:20

configure file locations a on something

2274:22

which we're going to be covering web P

2274:24

configuration and so much more the next

2274:27

one that we have is a preview .ts file

2274:29

so the preview. TS file is another

2274:31

configuration file used to customize the

2274:33

preview aspect of a story book for

2274:35

example like how the stories are

2274:36

rendered and displayed in the story book

2274:38

UI so that was it about the main and

2274:40

preview files now let's talk about the

2274:42

nesting renaming and also variation

2274:45

inside the story book so what I'm going

2274:47

to do is that I'm going to make this

2274:48

component so that it can take a lot of

2274:50

props so I'm going to just first off all

2274:52

uh get my props and I'm going to also

2274:54

otate the as any because we don't know

2274:56

like which kind of props we are going to

2274:58

be taking so now let me just spread all

2275:00

of that prompts right here so now let me

2275:02

just save my file and now here inside

2275:04

there let's just talk about the nesting

2275:05

as you can see first of all we have our

2275:07

husan components folder and now inside

2275:10

there we have our primary component

2275:12

variation I'm going to just change that

2275:14

to uh products maybe so I'll just write

2275:16

like and then if I just write like

2275:18

buttons and now let me just save my file

2275:20

here you can see first of all we have

2275:21

our products folder and now if I expand

2275:24

there then we have another folder which

2275:25

will be four buttons and now if I expand

2275:28

this one now finally we have our primary

2275:30

button right here the variation of our

2275:32

button so yeah this is how we can uh

2275:35

provide the nesting forward folders and

2275:37

yeah that was there so if you want to

2275:39

change there to like maybe something

2275:40

else like I don't know maybe spatial or

2275:43

I guess special will be fine so now if I

2275:45

save there now this is our parent folder

2275:47

but now if I expand there so this is how

2275:49

our children folder will look like and

2275:51

now if I even expand there this is how

2275:53

our component will look like so yeah

2275:55

that was about the nesting so now let me

2275:57

just remove the from here and now let's

2275:59

talk about how we are going to be

2276:00

creating a different variation forward

2276:02

button so like we don't have to copy and

2276:04

paste our component again and again and

2276:06

we can provide different variation for

2276:07

our component so what I'm going to do is

2276:10

that I'm going to just uh remove that

2276:11

from here and I'm going to be using like

2276:13

button and now let me just close there

2276:16

like so and inside there I'll just write

2276:18

like primary and now let me create a few

2276:20

more variation like a flare whenever I

2276:22

say variation I mean a flavor of this

2276:25

button so I'll use like uh export and

2276:27

then con secondary it's going to be

2276:29

equals to this button and now we are

2276:31

going to be using that button once again

2276:33

let's just close there and we have a

2276:35

secondary button so now let's just save

2276:37

there finally we are going to be also

2276:38

creating one more so I'll use like cons

2276:40

danger and it's going to be equals to

2276:42

this aror function and now let's just

2276:44

provide our button right here and I'm

2276:45

going to put my danger inside there and

2276:48

now we can also provide different props

2276:50

to there we're going to see that in a

2276:51

few second but now if I just refresh

2276:53

there here you can see we have our

2276:54

product spoiler and now inside there we

2276:56

have our buttons spoiler now inside our

2276:59

buttons we have a few uh flavors right

2277:01

here so first of all we have our primary

2277:03

then we have our secondary and then we

2277:04

have our danger so now let's suppose if

2277:07

I want to change like I don't know maybe

2277:08

the names of them so how in the world we

2277:10

are going to be doing there well now

2277:12

this button is now accepting all of our

2277:14

props so now we can successfully provide

2277:16

those props I'll just use like I don't

2277:18

know maybe variant and it's going to be

2277:19

equals to like primary and now I'm going

2277:23

to also provide the variant here and

2277:24

that's going to be it for the secondary

2277:26

now let me just provide here another

2277:28

variant and that's going to be set to

2277:30

like danger so now let's just sa our

2277:32

file and here you can see this is our

2277:34

primary button if I click on this one

2277:36

this is our secondary button and now if

2277:38

I click on this one so this is our

2277:40

danger button right here so this is how

2277:42

we can provide or create different

2277:43

variation of our component without just

2277:46

copying and pasting our component so we

2277:48

just have to take all of that props and

2277:50

this is how we're going to be providing

2277:51

a different prps or values for our

2277:53

component and this is how we can test it

2277:56

in isolation now finally let's just talk

2277:58

about the renaming like how we can

2278:00

change the names of our components so

2278:02

you know let me just write a comment

2278:04

like renaming stories I'll just first of

2278:07

all access my primary primary and by the

2278:10

way there are a lot of ways we can do

2278:12

there but this is just the older way I'm

2278:14

showing you right now later in this

2278:15

course we are going to be learning about

2278:16

the arcs and also the arc types but we

2278:19

are not there yet so we're not going to

2278:20

be talking about them right now so now

2278:22

if I just head down here you can see we

2278:23

have a lot of properties but the one I'm

2278:26

interested in is just a stone in name

2278:28

and now I'm going to set there to like

2278:29

some basic random name so I'll just

2278:31

write like blue button and now let me

2278:33

just duplicate there like three times

2278:35

and now here we're going to be accessing

2278:37

the secondary uh story so I'll use like

2278:40

secondary story now let me just change

2278:42

the color or the name of this I'll just

2278:45

change that to like green and I'm going

2278:46

to also select my danger button and I'm

2278:49

going to set that to I don't know maybe

2278:52

a red button and now let's just save our

2278:53

file and here you can see now the labels

2278:55

are successfully changed so this one is

2278:57

a the blue button then we have a green

2278:59

button then we have a red button right

2279:01

here so if I click on there yeah

2279:03

everything is still working the way we

2279:04

expect them to work so if I just change

2279:06

the name of that to like Alex meron and

2279:09

if I change this name to uh I don't know

2279:13

my own name like husan webd and I'm

2279:16

going to also change this name to uh

2279:19

Jordan

2279:20

Peterson now let me just save my file

2279:22

and here you can see this is how we are

2279:24

going to be changing the names of our

2279:26

component or variation so this is how we

2279:29

are going to be creating our folders or

2279:30

subfolders this is how we are going to

2279:32

be providing a props for our component

2279:34

and this is how we are going to be

2279:35

renaming or variation of our stories or

2279:38

you can just select the stories there we

2279:40

go so that was example number one so now

2279:42

let me just create another component and

2279:44

this is going to be my example number

2279:46

two and I'll just give it the name of

2279:47

like my input. TSX and I'll use my RFC

2279:50

inside there let's just remove this

2279:52

element from here now it's going to take

2279:54

a prps as a perimeter and I'm going to

2279:55

also initate the as any and now here let

2279:58

me just provide my input field now we

2280:00

are going to be passing like or

2280:01

spreading out those props save this file

2280:04

and now let's just go ahead and create a

2280:05

story a file for there so I'll just go

2280:07

ahead and create like my input come on

2280:10

input. stories. TSX and Define the story

2280:15

of my life so just first of all import

2280:18

what do we call it my input field now

2280:20

underneath there we are going to be

2280:22

exporting default so that we can create

2280:24

work uh story and I'll just give it the

2280:26

name of like my in put field or inputs

2280:29

here let's just or I'm going to use like

2280:32

input fields and inside there I'm going

2280:34

to provide like my input there we go WR

2280:37

a comma there and now we are going to be

2280:38

rendering our component so I'll use like

2280:41

component my input and semi file now

2280:44

underneath there I'm going to just go

2280:46

ahead and create a variation of there so

2280:48

I'll just give it the name of like small

2280:50

input and here now let's just use our

2280:52

aror function now inside there I'm going

2280:54

to be using like my input and here let's

2280:56

just close there and as you can see it

2280:58

takes all of the props I'm going to go

2281:00

ahead and just Define like a placeholder

2281:03

prop and it's going to say like uh enter

2281:05

your name and now let's just sa our file

2281:08

as you can see we have our inputs folder

2281:10

inside there we have another folder with

2281:12

the name of my inputs and now inside

2281:14

there we have a variation of our

2281:16

component we don't want that so I'll

2281:18

just remove the sem my file now we are

2281:20

getting just one folder and now inside

2281:22

there we have only one input field so

2281:25

yeah that's cool now let me just undo

2281:27

this

2281:28

and let's just undo there once again I'm

2281:30

going to remove this inputs from here

2281:32

and now we are going to be providing a

2281:34

size prop today so I'll just go ahead

2281:36

and provide the size and size will be

2281:38

set to like 10 Ram I'm going to go ahead

2281:40

and go to my component and here we're

2281:42

going to be placing our size inside the

2281:44

style okay so based on that prompt we

2281:47

going to be providing or increasing the

2281:48

width of our component so I'll use like

2281:51

width and I'm going to just access that

2281:52

size property or prop from this props do

2281:55

size now let me just save my file and

2281:57

save this file as well and here you can

2281:59

see we are now getting our small input

2282:01

field right here but now let's suppose

2282:03

if you want to create like a bigger or

2282:05

intermediate size of those input field I

2282:07

me the what we are going to be doing

2282:08

there well that's quite simple and easy

2282:10

we just have to create our variation so

2282:12

we use like export cons and then medium

2282:15

input and going to be equals to this

2282:16

Arrow function and inside there let me

2282:19

just pass my input field right here and

2282:23

close there just like that and I'm going

2282:24

to also past the size and the size will

2282:26

be set to 20 r

2282:28

in the placeholder come on just a

2282:30

placeholder will be set to enter your

2282:32

name come on enter oh my God enter your

2282:34

name God damn it save my file once again

2282:37

and now we have two stories or two

2282:39

variation so this one will be a small

2282:41

input and now if I click on this one

2282:43

this one is a bit larger input right

2282:46

here and why that's because we are now

2282:47

providing this size prop today and now

2282:50

you know let me just duplicate for the

2282:51

final time now we are going to be

2282:53

creating our large input so I'll use

2282:55

like large input and here let's just

2282:57

pass or 40 Ram save this file and now if

2283:00

I click on this large input and now we

2283:02

are getting this large input right here

2283:04

that was example number one which was

2283:07

about the button and that was example

2283:09

number two which is my input field so

2283:12

that was example number two and now we

2283:13

are going be discussing something called

2283:15

the combo stories so like here you can

2283:17

see we have Story number one which is a

2283:19

button story then we also have a input

2283:21

story and now if you want to combine

2283:23

both of them at once so for that we are

2283:25

going to be using a combo or a

2283:27

combination story or you can say a story

2283:30

within another story so I'm going to

2283:32

just right click on there and I'm going

2283:33

to create a new file with the name of

2283:35

combo do stories. TSX and now we have to

2283:39

import those stories which we are going

2283:41

to be combining so I'm going to just

2283:42

import first of all my large input and

2283:45

I'm going to also import the primary

2283:47

button so now let's just combine this so

2283:49

first of all we're going to be using

2283:51

export defon and inside there let's just

2283:53

provide some sort of a title and I'm

2283:54

going to give it the name of like combo

2283:56

come on combo and uh components would be

2284:00

fine so I'll use like components now

2284:01

Jita if you want to combine both of

2284:03

these component we not going to be

2284:05

placing that to our component prop

2284:07

instead we are going to be creating

2284:08

another separate component for there

2284:10

which will combine both of that

2284:12

component so I'll just use like export

2284:14

con and basically you can give it any

2284:16

name that you prefer but in my case I'm

2284:17

going to only give it the name of like

2284:18

combo and now let's just return our

2284:20

component from there so I'll just use

2284:22

like uh large input and I'm going to

2284:25

close there and here we're going to be

2284:26

pring the prop off like um placeholder

2284:30

and I'm going to say like enter whatever

2284:32

you prefer and I'm going to also provide

2284:34

the primary so let's just put there and

2284:37

close this sem my file it should be I

2284:40

don't know why we are getting this error

2284:41

but I'm going to just ignore that for a

2284:42

few seconds and I'll use npm run not

2284:45

test part uh story book and here you can

2284:48

see we have our combo component and now

2284:50

if I expand there we have our combo so

2284:52

as you can see we have our input field

2284:54

and we also have our primary button so

2284:57

let's suppose if you want to get like I

2284:58

don't know maybe secondary or maybe some

2285:01

other input field like uh medium one so

2285:03

I'm going to copy a name up there let's

2285:04

say first of all import the and place it

2285:06

right here and here you can see we are

2285:08

now getting our medium input and we also

2285:10

getting our primary button right here

2285:12

now let's talk about the arcs in story

2285:14

book so arcs are essentially a way to

2285:16

define the values of a prop that are

2285:18

passed to a component in your story so

2285:20

they allow you to control the component

2285:21

interactivity they also allow you to

2285:23

share common props across the story and

2285:25

they also allow you to doent your

2285:28

component props so this was the older

2285:30

way of creating a variation for our

2285:32

component and also passing a prop to our

2285:35

component so what is the newer way well

2285:38

the newer way will look something like

2285:39

this first of all we are going to be

2285:41

using export then con we will still able

2285:43

to give it any name that we prefer and

2285:46

now we are not going to be providing a

2285:47

function we are going to be only

2285:48

providing an object and now inside this

2285:51

object we are going to be providing

2285:52

something called the ARs and there

2285:54

allows us to P prop to our component

2285:57

also they will allows us to control the

2285:59

behavior of our component and also we

2286:02

can document our component so I'll just

2286:04

put like primary and I'm going to set

2286:05

that to true and I'm going to also

2286:07

provide another prop which will be set

2286:08

to label and I'm going to also provide

2286:10

like label of button and finally I'm

2286:12

going to also provide the on click like

2286:13

when somebody clicks on there so we just

2286:15

want to fire this function which will

2286:17

not do anything but it's going of just

2286:18

console log like you click me or

2286:20

something like there and here you can

2286:22

see this is the newer way of creating a

2286:24

variation forward component and you know

2286:27

let me just go ahead and go to my button

2286:28

and now first of all we have to

2286:30

destructure a few things from there so

2286:32

I'm going to just remove this so we are

2286:33

going to be destructuring the label

2286:35

which we are now providing right here we

2286:37

would also need to restructure the

2286:39

primary and I'm going to also provide

2286:40

the initial value of false today and

2286:42

also the own click event handler so now

2286:45

let me just save my file now it's going

2286:46

to gives us a lot of Errors because we

2286:48

also have to provide a type for there so

2286:50

I'll use like button promps and now I'll

2286:53

provide first of all the label let me

2286:54

just put equal to sign right here that's

2286:56

going to be a we're going to be also

2286:58

providing a primary and primary will be

2287:00

set to a Boolean and it should be

2287:02

totally optional and when somebody

2287:04

clicks on there so we also want to just

2287:06

provide a wi for the PO ID there we go

2287:10

and this is going to be also totally

2287:11

optional so now let me just copy there

2287:13

from there now let me place there right

2287:15

here just like that now let me save my

2287:18

file and this is how our component looks

2287:19

like but now we have to use those props

2287:22

so I'll just go ahead and uh create my

2287:24

button and close there and here let me

2287:26

just render first for my label and now

2287:29

uh I'm going to also provide the own

2287:30

click event handler and now let me just

2287:32

copy this prop from there paste it right

2287:34

here and now we are going to be also

2287:36

providing some sort of a style and let's

2287:38

just do that so I'm going to provide the

2287:40

background color property and if this is

2287:43

set to primary which we are now setting

2287:45

there to false if our prop is set to

2287:47

Primary in this situation we are going

2287:49

to be Chang changing there to Blue but

2287:51

if that's not the case we want to set

2287:53

that to Gray and also I'm going to put a

2287:55

bit of color and color will be set to to

2287:57

to White and also ping ping will be set

2288:00

to 10 pixel and Al order will be set to

2288:03

totally none like that and finally the

2288:06

Border radius will be set to only five

2288:09

pixels so now let me just save my file

2288:11

and now let me go ahead and go to my

2288:13

components there we go and now let me

2288:14

click on the buttons and here you can

2288:16

see now we are getting this button and

2288:18

now I know a lot of you will ask me like

2288:20

Huzan nothing just happen and yeah you

2288:22

are right and I want you to go ahead and

2288:24

just click on this icon or you can just

2288:26

hold art and hit a so it's going to open

2288:29

this test area for you or control area

2288:32

to be precise so now let me just close

2288:34

there if I click on there once again I

2288:36

can also move that to the right and I

2288:38

can also move that to the bottom right

2288:40

here so as you can see these are the

2288:42

control forward component like I'm now

2288:44

providing a primary and I can totally

2288:46

set there to false or true and based on

2288:49

this primary prop I can now visually see

2288:51

the behavior of my component and I can

2288:54

also provide the level and this level

2288:56

can be basically anything so can just

2288:57

write like something else and also if I

2289:00

click on this button so here you can see

2289:02

now let me just go ahead and go to my

2289:04

inspect element go to my console let's

2289:06

just refresh there click on this button

2289:08

once again and here you can see we are

2289:09

now getting that you click me right here

2289:12

so yeah this is how we're going to be

2289:14

controlling the behavior of our

2289:15

component by passing arcs today so that

2289:18

was just a bit simple example now let me

2289:20

give you a bit difficult example so now

2289:23

let me go ahead and go to my story once

2289:24

again so now that we provided a primary

2289:26

the label and also the on click and now

2289:29

let me just change the to alert so that

2289:31

we can see that on the screen so that's

2289:33

looking better I'm going to also put the

2289:35

loading St today so now let me just go

2289:37

ahead and put the loading and loading

2289:38

will be now set to false and I'm going

2289:40

to also put the size and the size will

2289:42

be set to medium and also I'm going to

2289:45

put the color and color can be this

2289:47

color so I'm going to use like 007 BFF

2289:50

I'm going to also put a comma there and

2289:52

provide my full width and this can be

2289:54

set to false initially and we're going

2289:56

to be also providing even the icon so

2289:58

I'll use like fa home so now let me just

2290:00

install the react Library so that we can

2290:02

get this phone so I'm going to go ahead

2290:04

and you know let me just stop that so

2290:06

I'll just stop it right here and I'm

2290:08

going to use npmi and then react icons

2290:12

was that react icons I'm not quite sure

2290:15

but now let me just install that yep it

2290:17

is react icons I hope so yep it was so

2290:21

now that successfully done I'm going to

2290:23

use npm run story book once again it's

2290:25

it's going to start there now we have to

2290:27

import there so I'm going to go ahead

2290:28

and just import this font from our react

2290:31

icon so let's just import there right

2290:33

here so it's going to import there at

2290:35

the top and now here I'm going to past

2290:37

the icon position and let's just set

2290:40

there to left and I'm going to also

2290:41

provide the area label here let's just

2290:43

provide a primary button now let me just

2290:46

save my file so this is how we are going

2290:47

to be providing a different props for

2290:49

our component and now let's just use

2290:51

that inside your button component so now

2290:53

let me go ahead and go there and the

2290:55

first thing that I want to do is that I

2290:56

want to just remove this type and I'm

2290:58

going to replace that with this new

2291:00

interface so here you can see we have

2291:01

our button interface and now we are

2291:03

providing a label the on click primary

2291:06

disable lading size color full width

2291:08

icon icon position and area label so if

2291:11

you want to provide there you definitely

2291:13

can but if you are not using typescript

2291:15

you don't have to now let me go ahead

2291:17

and remove all of these stuff from here

2291:19

and now I'm going to just uh destructure

2291:21

the label the on click event handler the

2291:23

primary and I'm going to set that to

2291:25

false and the loading and I'm going to

2291:27

also set that to false size will be set

2291:30

to medium as initial value and I'm going

2291:33

to also provide and full width will be

2291:35

set to false initially and we're going

2291:37

to be also getting that icons and also

2291:40

the icon position and the area label and

2291:43

that's going to be it so now let's just

2291:44

save our file and this is how it looks

2291:46

like so now that we already used these

2291:48

stuff now let's just also use these so

2291:50

what I'm going to do is that I'm going

2291:52

to just remove every single thing from

2291:54

this component let's just remove the and

2291:57

now here let's just provide our button

2291:58

save our file and this is how it looks

2292:00

like and now we are going to be creating

2292:02

a few classes so I'll use like cons

2292:05

button class and it's going to be equals

2292:07

to this back text and inside there first

2292:09

of all we going to be providing a class

2292:11

and now we have to render that other

2292:13

classes totally Dynamic so now let me

2292:14

just render there right here totally

2292:16

dynamically so I'll just provide their

2292:18

primary which you are now getting from

2292:19

these props right here so if that is

2292:21

primary so in this situation we want to

2292:23

just provide like button uh primary

2292:25

color which we are going going to be

2292:27

providing in a few second but if that's

2292:29

not the case we are going to be

2292:31

providing like a button in secondary and

2292:34

this should be double dashes because we

2292:36

already set the inside our styling which

2292:38

you're are going to be seeing in a few

2292:39

seconds now let me also provide the size

2292:41

so if you are getting the size in this

2292:43

situation we want to change that to a

2292:45

button and then Dash Dash and here let's

2292:47

just render our size from our props

2292:50

right here okay so if that's not the

2292:53

case so in this situation we're going to

2292:54

be just rendering like uh Dash Dash and

2292:57

also the medium button right here also

2293:00

we are going to be working with the

2293:01

colors so now let's just get the colors

2293:03

if we have the in this situation we are

2293:05

going to be using like button d d uh

2293:07

come on custom color and if that's not

2293:10

the case then we're not going to be

2293:11

providing nothing at all and also this's

2293:14

say render our full width if we got the

2293:16

full width so in this situation we're

2293:18

going to be using button Das Das full

2293:20

width like this but if that's not the

2293:22

case we're going to be setting there to

2293:23

totally empty string and also finally we

2293:27

have to provide the loading state so if

2293:28

you are getting some sort of a loading

2293:29

state in this situation we are going to

2293:31

be just writing like uh Das Dash uh

2293:34

loading and if that's not the case we're

2293:36

going to be setting there to empty

2293:38

string so now let me just save my file

2293:40

and now let's use these button classes

2293:42

inside our button I'm going to go ahead

2293:44

and go to my button right here and first

2293:46

of all uh I'm going to provide those

2293:48

classes so I'll just use like classes

2293:50

remove there and provide my button

2293:52

classes and outside from there when

2293:54

somebody clicks on this button then you

2293:56

want to just that other prompt which

2293:58

will be that on click prop so I'm going

2293:59

to copy there and place it right here

2294:02

and also on the area label come on area

2294:05

label like so we're going to be

2294:07

providing our area label which you also

2294:09

destructuring and also for the styling

2294:12

you know let me just save that right

2294:13

here I'm going to also provide a styling

2294:14

so if we got the color in that situation

2294:17

we are going to be changing the

2294:18

background color to something else I'll

2294:20

just use like background color and now

2294:23

let me just provide like color right

2294:24

here and also the text color will be set

2294:27

to totally white but if that's not the

2294:29

case then we are not going to be

2294:30

providing nothing today so now let me

2294:32

just save my file so this is how we

2294:33

going to be providing our props now let

2294:35

me go ahead and go inside this button

2294:37

and first of all let's just take care of

2294:39

that loading state so if we got the

2294:41

loading state in this situation we are

2294:43

going to be creating our spin come on

2294:45

what the hell was that so let's just

2294:47

create our Spin and I'm going to provide

2294:49

like lowering dot dot dot and I'm going

2294:51

to also provide a class name to this so

2294:53

I'll just use like button and then

2294:55

lowering spinner but if that's not the

2294:58

case then we're not going to be getting

2294:59

nothing at all and here let's just also

2295:01

take care of that icon so if you got the

2295:03

icon in this situation we're going to be

2295:05

providing the icon position and if that

2295:07

is set to left come on SO in that

2295:09

situation we going to be setting that

2295:12

icon to the left side of the button so

2295:14

I'll just go ahead and use like the span

2295:17

and now let me just provide those icon

2295:19

right here just like that and I'm going

2295:20

to also put the class name which will be

2295:22

set to button and then icon and now let

2295:24

me just save there but if that's not the

2295:26

case then we are going to be also

2295:28

providing our label and here let's just

2295:30

render our label which we now

2295:31

restructuring from our props and provide

2295:33

my class name which will be set to

2295:35

button and then D Das label and by the

2295:37

way I'm now providing these classes and

2295:40

you also have to do that because we are

2295:42

going to be copying and placing a few

2295:44

CSS classes so that's the only reason

2295:46

I'm now providing these uh what do we

2295:48

call it these classes right here so we

2295:49

going to be essentially working with the

2295:51

CSS styling for a bit okay so now

2295:54

finally let's just Pride our icon to the

2295:56

right so if we have like icon and also

2295:58

our icon position is equal to the right

2296:01

so which means like we are going to be

2296:02

pushing that icon to the right okay so

2296:05

I'm going to go ahead and provide my

2296:06

span come on let's just provide our span

2296:09

right here and I'm going to just render

2296:11

my icon and we are going to be also

2296:13

providing a class name of button and

2296:14

then D Dash icon there we go let's just

2296:17

sa our file now that we successfully

2296:19

created our button the next thing that

2296:20

we have to do is that we have to provide

2296:21

a styling for that so I'm going to go

2296:23

ahead and go to my stories and let's

2296:25

just zoom in a bit I'm going to create

2296:26

new file with the name of style. CSS and

2296:29

here let's just render all of our CSS

2296:31

right here and you can find all of that

2296:33

CSS in my gab repository so first of all

2296:35

we are just selecting our button we're

2296:37

providing a display of inline flex and

2296:39

also the items will be set to Center

2296:40

justify Center heading on the xaxis will

2296:43

be set to 10 pixel on the y axis will be

2296:45

set to 20 pixel then we have a border

2296:47

radius font size cursor will be set to

2296:49

pointer we're also proing a bit of

2296:51

transitions to the and the position will

2296:52

be set to relative then we have our

2296:54

primary button which we are now styling

2296:56

like this this then we have a secondary

2296:58

button which we now styling like this

2297:00

and finally we have a full width and

2297:01

which will be set to totally 100% And

2297:04

then we also have our uh button loading

2297:06

which is now initially set to relative

2297:08

the position is set to relative and now

2297:10

we are also providing our loading

2297:11

spinner and we are just sitting there at

2297:14

the middle and also we have a margin

2297:16

icon we are now providing a margin right

2297:18

to there then we have a level also we

2297:21

have button small button medium and

2297:24

button large so that's our styling and

2297:26

if if you want to provide there you can

2297:27

definitely go ahead and go to my

2297:29

repository and I'm going to go to the

2297:31

top of my uh button component let's just

2297:34

import those styling so I'll just go

2297:35

ahead and use like style. CSS s file and

2297:39

the Moment of Truth okay so let's just

2297:42

refresh the oh I guess we lost

2297:44

connection no we didn't let's just check

2297:46

this out here you can see we have only

2297:48

one flavor of our button which is a

2297:50

primary but now if I click on this icon

2297:53

here you can see now we can successfully

2297:55

control the behavior for component so

2297:58

here you can see it is initially set to

2297:59

primary if I click on there so it's

2298:01

going to make it it is no longer set to

2298:03

primary if I click on there once again

2298:05

it's going to just remove those borders

2298:07

so I can also change the label of there

2298:09

to like a button or something like that

2298:11

and when somebody clicks on this button

2298:13

so it's going to gives us that alert

2298:14

like you clicked me and also we have a

2298:16

loading spinner if I click on this it's

2298:18

going to gives us that loading text

2298:20

right here and now let me just close

2298:21

there if you want to change the size of

2298:23

this button like if you want to see like

2298:24

how our button will look like I can

2298:26

click click on the small so it's going

2298:27

to make it small I can click on the

2298:29

medium it's going to make it medium I

2298:30

can also click on the large it's going

2298:32

to make it large I can also change the

2298:34

color of my component so I'll just use

2298:36

like some other color and here you can

2298:38

see it's going to reflect the back and

2298:40

also we can make our button totally full

2298:43

width if I click on there bang it's

2298:45

going to make it full width if I click

2298:47

on there once again so it's going to

2298:48

make it normal and then we have our icon

2298:50

which we are now providing right here

2298:52

and we can also change the position of

2298:54

this icon so this is now initially set

2298:56

to left but we can also push there to

2298:59

the right and we can see like how our

2299:00

component will look like uh if you set

2299:03

the icon to the right so now let me just

2299:04

click on there and this is how it's

2299:06

going to look like and yeah we can also

2299:07

provide the area label which is just for

2299:09

the accessibility so I'll just write

2299:11

like something cool come on something

2299:14

cool and yeah we can also make their

2299:16

disable if you wanted to so if I click

2299:18

on this set Boolean now it's going to

2299:19

gives us like a false if I click on

2299:21

there it's going to make it disabled

2299:23

right here you cannot see that because I

2299:25

already provide a styling today but is

2299:27

going to make it disabled so this is how

2299:29

we are going to be testing our component

2299:31

or the UI of our component in isolation

2299:33

now that we've seen arcs let's talk

2299:35

about the arc types so Arc types are

2299:37

used to define and control how the props

2299:40

or arcs which we just saw a few seconds

2299:43

ago of a component are displayed and

2299:45

interacted with inside the story book UI

2299:48

and they provide metadata about the ARs

2299:50

and allows us to specify how each prop

2299:52

should behave in the controls panel

2299:55

something which we are going to be

2299:56

seeing in a few seconds which is a part

2299:57

of a story book UI okay so now let me

2300:00

show you those Arch types in action so

2300:02

what I'm going to do is that I'm going

2300:04

to just remove this primary variation

2300:06

from here and I'm going to Define my own

2300:08

one so let's just also remove this fa

2300:11

icon or fa home from there so I'm going

2300:13

to just use like export cons primary and

2300:16

it's going to be equals to uh this

2300:18

object and now inside this object we're

2300:20

going to be defining our arcs so now

2300:23

inside this Arc now let me just provide

2300:24

a few arcs like label so label will be

2300:27

set to click me and also let me just

2300:30

provide a comma there okay now we are

2300:32

going to be also providing a background

2300:34

color today which will be essentially

2300:35

our props so I'll just use like 007 BFF

2300:39

I'm going to also provide the size and

2300:41

size will be set to medium initially and

2300:43

provide the Border radius and it's going

2300:46

to be set to four I'm going to also

2300:48

provide the font size and font size will

2300:51

be set to 16 pixel initially and also

2300:54

the text color will be set to totally

2300:56

FFF like totally white color and now if

2300:59

I save my file and I'm going to also go

2301:00

ahead and go to my button and remove

2301:02

every single thing from there and I'm

2301:04

going to use my RFC right here I'm going

2301:06

to also remove the style. CSS from there

2301:09

because we're not going to be using

2301:10

there anymore and now here what we have

2301:12

to do well we're not going to be doing

2301:13

anything n right now first thing first

2301:16

uh we have to restructure all of those

2301:17

props which we just defined so I'll just

2301:19

destructure the label the background

2301:21

color the size border radius XT color

2301:25

now let's just save there I'm going to

2301:26

also Define an interface for there so

2301:28

that we can use our typescript so I'll

2301:30

use like interface and I'll use like

2301:32

button props and here inside there I'm

2301:34

going to use my level and level will be

2301:36

set to string I'm going to also provide

2301:38

the background color and background

2301:39

color will be set to string the size

2301:41

will be set to either small size come on

2301:44

small size uh or medium size or large

2301:49

size and now need that we going to be

2301:51

providing our border radius it's going

2301:53

to be set to a number initially I'm

2301:54

going to also provide the font size

2301:56

there and font size will be set to

2301:58

string and provide my text color and

2302:00

text color will be set to string I'm

2302:02

going to copy the name of there and

2302:04

annotate my component with those props

2302:06

so let's just annotate this our file now

2302:09

we have to create our own size styles so

2302:11

I'll use like size tiles and inside

2302:14

there I'm going to provide first of all

2302:15

the small and small will be set to 5

2302:17

pixel and 10 pixel for the top and

2302:19

bottom and also I'm going to put the

2302:21

medium and medium will be set to 10

2302:23

pixel and also 20 pixel in this case and

2302:25

then we are going to be providing what

2302:27

large and large will be set to 15 pixel

2302:29

and 30 pixel so now let's just sa our

2302:31

file now let me go ahead and go to my UI

2302:34

and remove there from here and change

2302:36

there to the button and render my label

2302:38

inside there I'm going to also provide

2302:40

my style now for this style we going to

2302:43

be providing our background color I'm

2302:45

going to also provide the piring and

2302:46

piring will be set to the size style

2302:48

which we also defined a few seconds ago

2302:50

and we're going to be rendering our

2302:51

sizes inside there let's just provide

2302:53

our border radius and for this border

2302:56

radius Rus we're going to be rendering

2302:57

our border radius and then pixel that

2303:00

much pixel percent and we are going to

2303:03

be also providing a font size and font

2303:04

size will be set to font size which is

2303:06

coming from the props and finally let's

2303:08

just set the color and color will be now

2303:10

set to text color I'm going to go back

2303:13

and this is how my component looks like

2303:14

so now let's just refresh there go to my

2303:16

products and then I'm going to go into

2303:18

my component and yeah you can see like

2303:20

we are now getting all of the results

2303:21

right here and everything is working the

2303:22

way we expect them to work but now let's

2303:24

use our Arc time right here here you can

2303:27

see this is how we are going to be

2303:29

passing our props forward component but

2303:32

now we want to tell our story book like

2303:35

how each prop will look like so here you

2303:37

can see we're now passing like

2303:39

background color and now we're providing

2303:40

some sort of a specific color today but

2303:43

we want to tell our story book that we

2303:44

want you to use this value as our

2303:47

initial color but we also want you to

2303:49

provide our Color Picker so we can

2303:51

choose those color from forward

2303:53

component okay so how what we're going

2303:55

to be doing there this is how we are

2303:57

going to be doing there so first of all

2303:58

we have to just write like Arc types and

2304:01

inside these Arc types we can now

2304:03

specify our Color Picker and so on and

2304:05

so forth so I'll just select my

2304:07

background come on background color and

2304:10

I'm going to set that to the control and

2304:13

the control will be set to color and now

2304:15

if I save there now let me just refresh

2304:17

there and here you can see now we can

2304:19

totally select this Color Picker and we

2304:21

can change the values from here just

2304:23

like that so this is how we are going to

2304:25

be essentially providing our Arch type

2304:27

for our prop and not only that here you

2304:30

can see we have our come on our size so

2304:32

we can also provide different sizes for

2304:34

there so I'll use like size and here

2304:36

inside this size I'm going to put the

2304:38

control and not continue but control so

2304:41

let's just use the control and the

2304:43

control come on control will be set to

2304:45

select state you want to get the select

2304:47

statement right here you can also

2304:48

provide the options and here let me just

2304:50

put those option like we can have a

2304:52

small button and we can also have the

2304:54

medium button and we can also have the

2304:56

large button and now let me just save my

2304:57

file and as you can see it's going to

2304:59

change this type so now we can get like

2305:00

the small button the medium button and

2305:03

also the large button right here just

2305:05

like that so that's also cool now let me

2305:08

also select this label which we're now

2305:09

providing right here and we can also

2305:12

customize there by using our Arc props

2305:14

so I'll just use like the label and here

2305:16

inside this label I'm going to provide

2305:18

that uh control and controll be set to

2305:20

text I'm going to also Pro a bit of

2305:22

description for there description and uh

2305:26

it's going to be set to like text

2305:27

displayed on the button or something

2305:30

like that and not only that we can also

2305:32

change the Border radiuses if you wanted

2305:34

to like here you can see we're now

2305:35

specifying this border radius and now we

2305:38

can also change this so I'll just go

2305:39

ahead and provide my border radius which

2305:41

we are also providing right here so I'll

2305:43

use like border radius and inside this

2305:45

border radius uh I'm going to first of

2305:47

all provide the control so let's just do

2305:49

that uh not continue but control and the

2305:53

control will be set to number and also

2305:55

let's just put like the minimum value is

2305:57

going to start from zero the maximum

2305:58

value is going to go through 50 and for

2306:01

the step we only want to proide like one

2306:04

and yeah I guess that's going to be fine

2306:05

so now let me just save my file now let

2306:07

me just refresh there and here you can

2306:08

see we're now getting this input field

2306:10

and now we can totally change there like

2306:13

so okay so now if I just write like 30

2306:15

it's going to make it 30 if I just write

2306:17

like 40 it's going to make it 40 if I

2306:19

just write like 10 it's going to make it

2306:21

10 so yeah this is how it's going to

2306:22

look like and what

2306:26

should be just a border radius in lower

2306:28

case border radius now let me save my

2306:30

file and now this is looking better and

2306:32

we can do all lot sort of stuff with

2306:34

there but I guess that's going to be

2306:35

fine so this is how we going to be just

2306:36

providing our Arc types and now inside

2306:38

the arc types we can just specify our

2306:40

prop and then we can provide different

2306:42

Behavior forward prop like for the size

2306:45

and also for the label for the Border

2306:47

radius and so on and so forth so now let

2306:50

me just create another variation of the

2306:52

like I don't have to but I wanted to and

2306:54

I'm going to give it the name of like

2306:55

secondary

2306:56

and here you can see we have our

2306:57

secondary button right here and we can

2306:59

do all of that stuff with this button as

2307:02

well just like that now let's talk about

2307:04

perimeters in story book so what are

2307:06

perimeters and why should even care

2307:08

about them and I can't even pronounce

2307:10

that word like perimeters so perimeters

2307:13

will allow you to change the look and

2307:14

feel of your story book like here you

2307:16

can see we have this button right here

2307:19

if you want to put this button at the

2307:20

middle of the screen or at the center of

2307:22

the screen so how in the world we are

2307:23

going to be doing there also if you want

2307:25

to change the color of our background

2307:27

like here you can see if I click on

2307:29

there I can choose light I can choose

2307:31

dark and also uh if you want to change

2307:34

like this control settings you can also

2307:36

do that so how in the world we're going

2307:37

to be doing all of there now let me just

2307:39

show you so the first thing that you

2307:40

have to do is that you have to write the

2307:42

perameters uh p a r a m e t e r s and

2307:45

now inside there what do we have to do

2307:48

we have to provide our options so first

2307:50

of all I'm going to just write the

2307:51

layout and I'm going to make that as a

2307:53

center and now let me just save my file

2307:55

here you can see or button will now jump

2307:57

to the middle or at the center of the

2307:59

screen so that's the first thing now let

2308:01

me also show you like how in the world

2308:03

we are going to be providing a label or

2308:05

a description and all of that kind of

2308:06

stuff for our control panel so this is

2308:09

how we are going to be doing there I'm

2308:10

going to just write like the controls

2308:12

and here inside these controls I'll

2308:14

provide my expanded so I'll write like

2308:16

expanded and I'm going to set that to

2308:18

and as soon as I do the in my file and

2308:20

here you can see it's going to also

2308:22

gives us their description and also this

2308:23

default values right here so we already

2308:26

provided this description like text

2308:28

displayed

2308:29

displayed on the button as you can see

2308:33

if I show you there uh okay there we go

2308:36

so displayed I'll write like displayed

2308:38

and now let me just save my file and

2308:40

here you can see this is how it's going

2308:41

to look like and also let's suppose if

2308:43

you want to change the background color

2308:44

to like something else we can totally do

2308:47

that so now let me just hide there once

2308:48

again and here we just have to provide

2308:50

our backgrounds so I'll use like um

2308:53

backgrounds we can provide the default

2308:55

value so I'll just write like the

2308:56

default and the default will be set to

2308:57

light and we can also provide our own

2309:00

values if you wanted to Sol just write

2309:01

like uh first of all the name and the

2309:03

name will be set to light and I'm going

2309:05

to provide the value to there so let me

2309:07

just go out from there and the value

2309:09

will be set to totally white so now

2309:11

let's just sa our file and here you can

2309:12

see we already have this light now let

2309:14

me make that a bit smaller so that you

2309:16

guys can see everything a bit better and

2309:18

now I'm going to provide a few more

2309:19

color so let's just proide the dark one

2309:21

I'm going to even duplicate there and

2309:23

change the name of there to like dark

2309:25

and I'm going to also change the hex

2309:26

value of that to like 333 s file click

2309:29

on there once again we can now change

2309:31

that to dark we can also change that to

2309:33

like sky blue or green or something like

2309:35

that I'm going to place all of that

2309:37

colors in a few seconds but now let me

2309:38

just write this I'll use like sky blue

2309:41

and I'm going to just provide the hexi

2309:42

decimal value of this so I'll use like

2309:44

00 0 BC D4 now let me just save my file

2309:48

and now if I click on there here you can

2309:50

see we have our sky blue if I click on

2309:52

there it's going to change the

2309:53

background color of there and now I'm

2309:55

going to just remove these values and

2309:57

I'm going to replace them with my own

2309:59

one if you care about these values and

2310:01

these colors you can definitely go ahead

2310:02

and go to my GitHub repository and grab

2310:04

all of that colors from there so now let

2310:06

me just refresh there click on there

2310:07

once again and here you can see we have

2310:09

a lot of colors we have a hard pink I

2310:12

can choose there we have like I don't

2310:14

know we have a peach and so much more so

2310:17

yeah this is how we can use the

2310:18

perimeters to change the look and feel

2310:20

of our story book now let's talk about

2310:22

the decorators in story book so

2310:24

decorators are a function that are

2310:26

applied globally or locally to our

2310:28

stories allowing us to rra or modify the

2310:30

story rendering process and decorators

2310:32

enable us to add additional

2310:34

functionality style context or layout to

2310:38

our stories in a reusable way so that

2310:40

was just a theory about the decorators

2310:42

and now let me show you their inaction

2310:44

okay so that was just a theory about the

2310:46

decorators now let's talk about how we

2310:48

are going to be using them inside our

2310:49

projects and also we're going to be

2310:51

discussing three kinds of decorators

2310:54

like the variation decorator then the

2310:56

local decorator and finally the global

2310:58

decorator so now let me just zoom in a

2311:00

bit and I'm going to just remove that

2311:01

from here and create my folder with the

2311:03

name of stories okay so now inside there

2311:05

first of all let me just create my

2311:07

button. TSX file and I'm going to also

2311:09

create my button. stories. TSX and now

2311:12

let me go ahead and go to my button and

2311:14

I'm going to be only using my rafc

2311:16

inside there and now let's just go into

2311:18

our story file and import that button

2311:21

right here so I'll use like button and

2311:23

let's just import them and here I'm

2311:24

going to use like export default come on

2311:26

default and inside there let's just

2311:28

provide our title title and this can to

2311:31

be set to a button just a button and

2311:33

also we are going to be providing a

2311:34

components so let's just provide our

2311:36

component and you want to test the

2311:38

button component right here so now

2311:40

underneath that let's just create or

2311:42

default variation so I'll use like cons

2311:44

default it's going to be equals to this

2311:45

object and we are going to be also

2311:47

providing our ARs and this ARS will have

2311:49

the label and it's going to just say

2311:51

like click me or something like that

2311:52

we're going to be also providing a

2311:54

specific color to that so I'll use like

2311:55

007 BFF and I'm going to also provide

2311:58

the disable flag so d s a b l e d and

2312:02

disable will be now set to false now let

2312:04

me go back and now we are going to be

2312:06

creating another variation of4 button so

2312:09

I'm going to just duplicate there and

2312:11

I'm going to change the name of there to

2312:12

disable button right here and I'm going

2312:14

to just give it the name of like

2312:16

disabled there we go and I'm going to

2312:18

also make it as a disable so that you

2312:20

guys can see there now let me go ahead

2312:21

and go to my component and first of all

2312:24

we are going to be restructuring all of

2312:25

their props and then we would just use

2312:27

this I'll provide my label and the

2312:28

initial value will be now set to like

2312:30

click U me or something like that I'm

2312:33

going to also provide the on click when

2312:34

Handler so like whenever somebody clicks

2312:36

on there so we just want to fire this

2312:38

function and I'm going to also provide

2312:39

the disabled flag so dis a b e and

2312:43

that's going to be equals to initially

2312:44

false and we are going to be also

2312:46

providing the initial color of this

2312:48

exact same color so I'm going to copy

2312:50

that and place it right here sa my file

2312:52

and obviously we're going to be getting

2312:54

some kind of error okay so now let me go

2312:56

ahead and go to the top or you know what

2312:58

we are already providing an initial

2312:59

value for that so let's just use them

2313:01

I'm going to go ahead and just Define my

2313:03

button right here and inside this button

2313:06

we're going to only render the label so

2313:07

I'll just provide the label right here

2313:09

and also we're going to be providing a

2313:11

few a few props today so like when

2313:13

somebody clicks on this we want to fire

2313:15

that function also on the disabled St we

2313:18

want to make the as a disabled and also

2313:20

you want to put a bit of style into this

2313:22

so I'm going to just provide like

2313:23

background color and for the background

2313:26

color we want to use that color which is

2313:28

coming from the props and I'm going to

2313:30

also provide the piring and piring will

2313:31

be set to like 10 pixel on the top 20

2313:33

pixel on the bottom and provide the

2313:36

Border set there to totally none and the

2313:39

final thing that we have to do is that

2313:40

we have to provide a bit of Border

2313:41

radius which will be set to like 4 pixel

2313:43

now let me just save my file and this is

2313:45

how our component looks like let's just

2313:47

close them and now let's talk about how

2313:48

we are going to be working with

2313:50

decorators on the component variation

2313:53

level so this is how we are going to be

2313:54

doing the you know let me just put a

2313:56

comment right here so that you guys

2313:58

don't forget that I'll use like this

2314:00

comment and I'm going to say like

2314:02

variation or variant rather variant only

2314:06

decorator there we go I know the

2314:08

spelling is incorrect but I don't care

2314:11

and now if you want to provide The

2314:12

Decorator first of all we have to just

2314:14

use the word decorator so I'll use like

2314:16

t o d e c o r a t o r s and here let's

2314:20

just make the as array because we can

2314:22

specify more than one item for our

2314:24

decorators and now here we just have to

2314:26

specify our Arrow function but for this

2314:29

Arrow function we are going to be

2314:30

providing the story so I'll just use

2314:32

like story and for now I'm going to just

2314:34

annotate as any so now inside there we

2314:37

can now do anything that we prefer but

2314:39

that's going to be only applied to this

2314:42

variation not to all of that variation

2314:44

and now let me just show you the

2314:45

inaction so what I'm going to do is that

2314:48

I'm going to just create a div and by

2314:49

the way you can like do whatever you

2314:51

want to do right here so in my case I'm

2314:53

going to just only render the story

2314:55

let's just close there and I'm going to

2314:56

also provide a bit of styling to there

2314:58

so I'll just use the styling and provide

2315:00

my pairing inside there and that's going

2315:01

to be set to 20 pixel we're going to be

2315:03

also providing the background color and

2315:05

this going to be set to F0 F0 F0 and I'm

2315:08

going to also provide the Border radius

2315:10

and this going to be only set to like

2315:12

maybe a pixel so now let me just save my

2315:14

file and now let me run this so I'm

2315:15

going to use like npm run Dev or not Dev

2315:18

but but I'm going to use npm run story

2315:20

book there we go and we are not seeing

2315:22

anything because now we are providing

2315:24

these curly braces so so we have to

2315:26

return something from the if I sa my

2315:28

file and here you can see we're now

2315:29

getting this button and also this border

2315:32

around this button but now if I click on

2315:34

this default Button as you can see this

2315:37

decorator will be only applied for this

2315:39

specific variation not for the entire

2315:42

variations of this button so there was

2315:44

just a variation level decorator but now

2315:46

let's suppose if you want to use that

2315:48

same styling or that same decorator for

2315:51

this entire variation of this component

2315:53

how in the world we are going to be

2315:54

doing them to do that that's totally

2315:57

simple and easy all we have to do is

2315:59

that we have to cut that from here and

2316:02

we have to just remove that now let me

2316:03

just save my file then we have to go

2316:05

ahead and go to the top and here we have

2316:07

to just Define now let me just provide

2316:08

there right here I mean like not the

2316:10

variation but or decorator so as you can

2316:12

see now our decorator is available

2316:14

inside this export default metadata and

2316:17

now if I check this out so here you can

2316:19

see that decorator or that styling will

2316:21

be applied to this component variation

2316:23

and now if I click on the other one here

2316:25

you can see it's going to be also

2316:26

applied to this one as well so you know

2316:28

let me just create a few more variations

2316:30

so if I just duplicate them and change

2316:32

that to like uh I don't know maybe

2316:34

primary or something like that and then

2316:36

let me just duplicate that once again

2316:38

and I'm going to change that to like

2316:39

secondary or something like this s my

2316:41

file so here you can see we have our

2316:43

primary if I click on there that same

2316:45

styling will be applied to all of these

2316:47

variation right here so this is how we

2316:49

are going to be providing our decorator

2316:51

for the variation level and this is how

2316:53

we are going to be providing there for

2316:54

the local component like this styling

2316:57

will be only applied to this button

2316:58

component not to all of them but now let

2317:00

me go ahead and create another component

2317:02

so I'll just create like input field.

2317:05

TSX and I'll just write my RFC inside

2317:08

there I'm going to also remove that from

2317:10

here and you know let me just remove

2317:11

this entire thing and yeah I guess

2317:14

that's going to be fine so now let's

2317:15

just save there we're going to be also

2317:16

creating another story for there so I'll

2317:18

use like input field. stories come on

2317:23

stories. TSX and now inside there the

2317:25

first thing that we have to use we have

2317:27

to import the input field also we have

2317:29

to use the export default and inside

2317:31

there let's just provide like my inputs

2317:34

or something like that I'm going to also

2317:36

P my component which will be the input

2317:38

field so let's just pass the input field

2317:41

there we go I'm going to save my file

2317:43

and I'm going to also create a variation

2317:45

of this so default input so now inside

2317:48

this one I'm going to just only past

2317:50

like the arcs and I'm going to past a

2317:51

label or maybe a placeholder and it's

2317:54

going to say like enter this is s file

2317:56

as you can see if I click on there

2317:58

nothing will happen it's going to gives

2318:00

us an error this because we have to go

2318:02

ahead go ahead and just uh import all of

2318:04

their prompts I'll just use like those

2318:06

prompts and I'm going to also annotate

2318:08

the is any and let's just destructure

2318:10

all of their prompts s file now let me

2318:13

just uh refresh there and here you can

2318:14

see we are now getting that enter

2318:16

something and I made a typo which should

2318:19

be enter something and now those

2318:22

decorator styling are not applied to

2318:23

this component why that's because now we

2318:27

made this DEC eror as local to this

2318:29

component only so if you want to make

2318:31

the AS Global so that it can be

2318:33

accessible to all of the component

2318:34

inside your project so this is how we

2318:36

are going to be making the global so I'm

2318:38

going to cut that from here so let's

2318:40

just cut the s file and now I'm going to

2318:42

go ahead and go to my story folder which

2318:44

is a d story let's just zoom in a bit

2318:46

let me just zoom in a bit and now we are

2318:48

going to be creating another folder I

2318:49

mean like file and I'm going to give it

2318:50

the name of like decorator come on DC o

2318:53

r at R S.T X and you can give it any

2318:57

name that you prefer and by the way you

2318:58

don't even have to create this file you

2319:00

can definitely go ahead and go to your

2319:01

preview and just provide your decorator

2319:03

there I am now creating this file

2319:06

because later you're going to be

2319:07

creating a lot of decorators so for that

2319:09

this is the best practice to create a

2319:11

decorator so the first thing that we

2319:12

have to do is that we have to import the

2319:14

react from the reactjs the next thing

2319:16

that we have to do is that we have to

2319:17

import something called The Decorator d

2319:19

e c o r a t o r from where from the

2319:22

story book so let's just import there

2319:24

from the story book not from the aons

2319:26

but from the reactjs so now let's just

2319:28

save there and now we are going to be

2319:30

creating our decorator so I'll just use

2319:32

like export with background come on with

2319:35

background color and this is how the

2319:37

convention of The Decorator looks like

2319:39

anytime you want to create your

2319:40

decorator first of all you have to write

2319:42

this with I mean like you don't have to

2319:44

you like you can totally give it any

2319:46

name that you prefer but this is the

2319:47

convention like you have to provide this

2319:49

with and then you can give it any name

2319:51

that you prefer and now we are going to

2319:52

be taking this annotation and now let me

2319:54

just place it right here now it's going

2319:56

to take something called the story

2319:57

function so I'll use like story FN and

2320:00

now inside there uh we have to just

2320:02

return our stories or our styling to be

2320:05

precise so what was our styling let me

2320:07

just go back and I'm going to just cut

2320:09

all of that styling from here I'm going

2320:11

to cut there and remove this entire

2320:13

decorator from this local component sa

2320:16

my file and now let me place all of

2320:17

their styling right here okay so let's

2320:19

just go back I'm going to copy the name

2320:21

of this story FN place it right here sem

2320:24

my file and also this should be export

2320:27

so this is how you're going to be

2320:28

defining your Global decorator inside a

2320:31

separate file and now if you want to use

2320:32

that you have to go ahead and go to the

2320:34

preview. TS file and you have to import

2320:37

that right here so I'm going to go ahead

2320:39

and just import my with background color

2320:42

and now let me just copy there and this

2320:43

is how we are going to be providing

2320:44

there or making there as a global to all

2320:47

of the components so use like export

2320:49

cons and then

2320:50

decorators and I'm going to just provide

2320:52

my name which is a with background

2320:54

decorators and it should be a equal to

2320:56

sign so now let me just save my file and

2320:58

now hopefully it should be available to

2321:00

all of our component so as you can see

2321:02

right here let's just refresh there it

2321:03

is available right here also here here

2321:06

and now let me just check this component

2321:08

out and yeah it is also available right

2321:11

here so this is how we going to be

2321:12

working with the decorators so first of

2321:14

all we saw is that you can provide a

2321:16

decorator inside your component

2321:18

variation you can also provide there for

2321:20

your entire component variations which

2321:23

is called the local decorators by the

2321:24

way and this is how you're going to be

2321:26

creating a separate file for your

2321:28

decorators and you can put anything that

2321:30

you prefer if you want to reuse the

2321:31

again and again either for the component

2321:34

or for the global and this is how you're

2321:36

going to be importing there and this is

2321:38

how you're going to be using there

2321:39

inside your preview. file okay so now

2321:41

that we've seen a lot about the story

2321:43

book syntax but now let's talk about how

2321:45

we are going to be providing a types

2321:46

forward stories so which means like we

2321:49

are going to be learning about the

2321:50

typescript with story book so this is

2321:52

how our component will look like first

2321:54

of all we just creating our interface

2321:56

and now we are expecting the label the

2321:58

on click color and disable we are also

2322:00

destructuring there and we're also

2322:02

providing a default values for there and

2322:04

then finally we are just using the

2322:05

inside our button component as simple as

2322:08

there so now let me just close there and

2322:10

now let me go ahead and go to my stories

2322:12

folder and I'm going to be defining the

2322:13

button do stories. TSX and now let me

2322:16

just hit enter so the first thing that

2322:18

we have to do is that we have to grab

2322:19

our button component and we also need uh

2322:22

this styling right here that's the only

2322:24

reason I me like not styling but also

2322:26

these types uh that's the only reason we

2322:29

are now exporting there so that we can

2322:30

use the in other file okay so now let me

2322:32

just provide my comma there and I'm

2322:34

going to be also importing the button

2322:36

props okay so let's just sa our file and

2322:38

this is how we are going to be importing

2322:39

the button and also it's props now

2322:42

anytime you want to use types forward

2322:44

story book so story book provide two

2322:46

types so the first one we have is the

2322:49

meta and the second one we have the

2322:50

story object which will be essentially

2322:53

forward storybook object so now we have

2322:55

to import there from the story book not

2322:57

add-ons but from the reactjs so now let

2322:59

me just save my file and The Meta will

2323:02

be responsible for all of the metad data

2323:04

which we are going to be providing for

2323:05

the initial values of our stories and

2323:08

then we have a story object and that's

2323:10

going to be responsible and also will

2323:12

provide us objects or interfaces for our

2323:15

story book variations so now let me just

2323:17

show you there here you can see we've

2323:19

been creating our uh stories like this

2323:21

first of all we have to write the export

2323:23

and then we have to write uh d F and

2323:25

then we are providing some values but

2323:27

we're not going to be doing that anymore

2323:28

so now let's just close them instead we

2323:30

are going to be creating something

2323:32

called The Meta object so I'll use like

2323:33

cons meta and then we also have to

2323:36

annotate there with our prop so I'll

2323:38

just use like meta which is now coming

2323:40

from the story book reactjs and then we

2323:43

also have to tell it that we also want

2323:45

to use our own types which is called the

2323:48

uh button prop so I'm going to copy the

2323:49

and place it right here so essentially

2323:51

by this code we simply means that we

2323:54

also want to use the story book types

2323:56

but we also want to provide our own ones

2323:59

okay so now let me just uh provide my

2324:01

equal to sign and now let's just create

2324:03

or story like this now I want you to

2324:05

hold control and click on this meta so

2324:08

it's going to bring you to this public

2324:09

Dash types and then some sort of a

2324:11

random ID and these are decoration files

2324:14

so here you can see we have our type

2324:16

then which is coming from The Meta and

2324:17

which is using something this weird

2324:19

sentex I don't even know what the hell

2324:21

this is but yeah this is how we are

2324:23

going to be getting these typ

2324:25

from our story book you want to use

2324:27

these types and we also want to use

2324:29

these button props which are our own

2324:31

types so this is how we are going to be

2324:33

providing our title so I'm going to just

2324:35

write like components come on component

2324:38

components and inside there we want to

2324:40

create our button right here now

2324:41

underneath there we're going to be also

2324:43

providing our AR types and inside there

2324:45

I'll provide my color and that's going

2324:46

to be set to control come on control and

2324:50

we're going to be setting there to color

2324:52

now outside from there let me just

2324:53

duplicate like a few times we're going

2324:55

to be also providing the label and also

2324:57

the disable as well okay so I'm going to

2324:59

change that to text and I'm going to

2325:01

also change this one to Boolean now

2325:03

finally we have to export that so that

2325:05

we can use that in other file okay so

2325:08

this is how we are going to be exporting

2325:09

this I'll use like export default and

2325:11

then meta and now let's just save there

2325:13

and this is how we are going to be

2325:14

creating our story but now let's create

2325:16

a variation for the story so now

2325:18

underneath there uh we are going to be

2325:20

defining our variation so I'll use like

2325:22

export cons and then default and now

2325:25

here inside they we are going to be

2325:26

using their story object which is now

2325:28

coming from the story book and by the

2325:31

way these are also a typescript type so

2325:33

if I hold control and click on there

2325:35

it's going to also brings us to this. D

2325:38

or Declaration file. typescript so as

2325:41

you can see there are a lot of crazy

2325:43

stuff going on right here okay so yeah

2325:46

we also have to use them and now you

2325:47

have to set that to as a equal and

2325:50

inside there we are going to be using

2325:51

the ARs and let's just provide our label

2325:53

and for the label I'll just say click me

2325:55

and I'm going to also provide the color

2325:57

so the initial color is going to be set

2325:58

to like 007 bff or something like that

2326:01

and I'm going to also make it as a

2326:03

disable only false so file now let me

2326:06

create a few more so I'm going to also

2326:08

duplicate there and make the as a

2326:11

disabled button so I'll use that

2326:12

disabled and I'm going to make the

2326:14

disabled to and I'll just say like this

2326:17

should be the disabled button or

2326:20

something like that now let me just

2326:21

create the final variation so I'm going

2326:23

to duplicate and change the name of that

2326:26

to like some sort of a red button and

2326:27

I'm going to also write like red and

2326:29

change that to like FF uh 00 or I guess

2326:33

four zeros yeah that's going to be fine

2326:36

and I'm going to also make as a totally

2326:37

false s file check this out now let me

2326:40

just refresh there click on the button

2326:42

and now we are getting some sort of

2326:44

error story component button default

2326:48

annotation is not defined so we are now

2326:50

missing something missing the button let

2326:52

me just copy there and we also have to

2326:55

render there right here God damn it so

2326:58

let's just sa our file now let's check

2326:59

this out so here you can see we have our

2327:01

button we also have the disabled one and

2327:03

we also have the red button right here

2327:05

if I hold alt and hit a so now it's

2327:08

going to gives us the label color

2327:09

disable and also the on click so yeah

2327:11

this is how we can use the types for our

2327:14

story book okay so now let's talk about

2327:16

the add-ons inside the story book so

2327:19

what are addons and why you should want

2327:21

care about that so now once again I'm at

2327:24

the official page of the story book

2327:26

because I love their landing page and

2327:29

now let me just go ahead and click on

2327:30

these dogs and whenever we click on

2327:32

there here you can see we have a section

2327:34

called aons or you can also hit control

2327:37

K and you can also type the aons right

2327:39

here if you wanted to but in my case I'm

2327:41

going to only click on these aons and if

2327:43

I click on them there are a lot of

2327:45

addons right here now you might be

2327:47

asking hosan what the hell are add-ons

2327:49

add-ons are just basically the extension

2327:52

that you can use to make your story look

2327:55

amazing and also a lot of more useful

2327:58

things so now let me go ahead and go to

2328:00

the vs code uh extension area right here

2328:02

as you can see we have a lot of

2328:04

extension for the vs code so we can type

2328:07

for a specific uh theme or maybe

2328:09

something okay so if you type this so

2328:11

it's going to gives us basic em and all

2328:13

of that kind of stuff for the vs code

2328:15

and add-ons are exactly the same thing

2328:18

inside the story book so there are a lot

2328:20

of them you can choose different popular

2328:22

ones and story book also comes with a

2328:24

default add-ons as well so we have a

2328:26

chromatic we have a mock service worker

2328:29

and which is by this amazing person Yan

2328:32

why a Ann and I love this guy to be

2328:35

honest I swear to God I love him I try

2328:37

to message him on uh Twitter but he only

2328:40

accept those accounts who are verified

2328:43

and I'm broke so that's why I can't even

2328:45

message him bad for me anyway so there

2328:48

are themes there are Design Story book

2328:50

story source and there are a lot of

2328:52

things right here so you know what let

2328:54

me just show you the dogs air on so I'm

2328:56

going to just search for there I'm going

2328:58

to only write the dogs and hopefully it

2329:00

will gives us their dogs and if I click

2329:02

on there or it was docks or autod dos

2329:04

let's just write autod dos let me just

2329:07

type there and tellin autod dos no this

2329:10

is not something that I am interested in

2329:12

now let me just search for the dogs as

2329:14

well and now let me click on this one

2329:16

and this is how you're going to be

2329:17

installing that specific airons and

2329:19

basically this is just a specific

2329:21

landing page for that addon once again

2329:24

Yan PF okay so now let me just copy

2329:27

there now let me show you how we are

2329:28

going to be installing there but first

2329:30

of all let me just go ahead and go to my

2329:32

storybook and if I click on the main

2329:34

here you can see story book also comes

2329:36

with a default addon so we have the on

2329:38

boarding we also have the essentials we

2329:40

also have the story book and we also

2329:42

have the add-on interaction so you can

2329:44

explore there by yourself if you wanted

2329:45

to but now let me just close there and

2329:47

now we have to install our own addons so

2329:50

now let me just control C now let me

2329:52

place that Command right here which is

2329:54

npx install uh story book aons docs or

2329:57

yeah now let me just use the could not

2330:00

determine I guess we have to use the npm

2330:02

I guess so now let me just try there

2330:05

with npm I'll just use the npm install

2330:08

story book and now it will work totally

2330:10

fine it's going to install it inside our

2330:13

project so now let me use npm run story

2330:15

book come on story book but before I do

2330:18

that I want to show you something here

2330:20

you can see we only have our uh Bund TSX

2330:23

uh file and now let me go ahead and go

2330:24

to my button. storage. TSX so this is

2330:27

how we are just importing our typescript

2330:29

types this is how we importing our

2330:31

button and this is how we are just

2330:32

creating a story for there and this is

2330:34

how we are just creating our variations

2330:36

for word button so what I'm going to do

2330:39

is that I'm going to also provide the

2330:40

tags right here so I'll use like tags

2330:42

and now let me just specify something

2330:44

called the auto do so I'll use like Auto

2330:47

come on auto docks and now let me just

2330:49

save my file and now as soon as I do

2330:52

that let me just open my uh terminal and

2330:54

I'm going to just hit enter so it's

2330:56

going to run my story book right now now

2330:58

let me just refresh there and here you

2330:59

can see we are now getting something

2331:01

called the dogs which is new for us so

2331:03

now let me just click on there and as

2331:05

soon as I click on there we are now

2331:06

getting a documentation for our

2331:08

component so now this is how our

2331:10

component will look like this is how the

2331:12

coding of my component looks like this

2331:15

is how we are now providing these props

2331:16

like label disable on click we can also

2331:19

see that if I click on this it's going

2331:20

to make it disabled we can also change

2331:22

the um come on level of there to like

2331:25

something come on something oh my God

2331:28

something else and also we can click on

2331:31

the and so much more so this is how our

2331:33

story will look like and you can

2331:35

generate all of that dogs by first of

2331:37

all installing that auto dogs and also

2331:40

and this is how you have to specify

2331:41

their Texs and make the as autod dos

2331:44

okay so that was about the documentation

2331:46

and also about the addons inside the

2331:48

story book so what is a style dictionary

2331:51

and why should anyone care about that so

2331:53

style dictionary is a build system and

2331:55

tool that allows designers and

2331:57

developers to Define organize and manage

2331:59

design tokens in a Json format so these

2332:02

tokens Can Be mapped to different

2332:04

formats such as CSS variables sense

2332:06

variables or even JavaScript objects so

2332:09

what are the benefits of using a style

2332:11

dictionary well the F benefit is a

2332:13

centralized management so design tokens

2332:15

are stored in a single source of Truth

2332:17

typically in Json file making them easy

2332:19

to maintain and update it is also a

2332:21

crossplatform it can output design

2332:23

tokens in different formats like CSS

2332:26

Json SS L and and even Android iOS

2332:29

specific formats extensibility you can

2332:31

extend and customize how tokens are

2332:34

processed enabling you to create complex

2332:36

design system with calculated values

2332:38

custom Transformations and so much more

2332:40

which we are going to be covering in a

2332:42

short period of time and finally

2332:43

automation so style dictionary automates

2332:45

the process of transforming design

2332:47

tokens into usable formats for the

2332:50

development so how all of this going to

2332:52

work so first of all you would have our

2332:53

input. Json file and inside there we

2332:56

would have our design token and once we

2332:58

use a style dictionary on there so it's

2333:00

going to gives us the output like so in

2333:02

this case we are now using a CSS

2333:04

variables but if you want to get like a

2333:06

JavaScript version of there or a SS

2333:08

version of there you can totally do that

2333:10

and we're going to be also doing there

2333:12

so how are you going to be installing

2333:13

there you just have to write npmi to

2333:15

install there and then you have to

2333:17

specify style dictionary and also style

2333:19

dictionary utilities so what is that

2333:21

style dictionary thing and what is that

2333:23

style AR utils thing so style dictionary

2333:26

is a core Library used to manage and

2333:28

transform design tokens it provides a

2333:30

primary functionality to Define process

2333:32

and output design tokens in different

2333:34

formats like uh CSS SS Json and so much

2333:38

more which we just discussed a few

2333:39

seconds ago and what is that style

2333:42

dictionary UIL thing so style dictionary

2333:44

utils is a supplementary utilities

2333:47

package that provides additional helper

2333:49

functions and tools that can be used

2333:51

alongside with the main style dictionary

2333:53

Library to make a certain task easier so

2333:56

that was about the theory and now let's

2333:58

get into the coding then you'll get to

2333:59

know what I'm talking about all right

2334:01

guys so now let's Implement that style

2334:03

dictionary in action so FYI this is the

2334:06

official page of a style dictionary so

2334:08

you just have to type like style

2334:10

dictionary.com and let me just show you

2334:13

there this is how you're going to be

2334:15

defining your tokens as a Json format

2334:18

and it's going to give you the output as

2334:19

a CSS variables and don't worry I'm

2334:22

going to also show you like how you can

2334:24

get the SS output and also the

2334:26

JavaScript output so you can learn more

2334:28

about that if you wanted to so you can

2334:30

go to their GitHub and these are the

2334:31

people who know what they're doing okay

2334:34

so now let me just click on the

2334:35

documentation if you want to watch like

2334:37

their documentation architecture and so

2334:39

on and so forth but the thing which you

2334:41

are going to be interested in uh is here

2334:44

so you can just go to the hooks uh then

2334:46

the Transformer and then the transform

2334:48

group and you just have to like check

2334:50

out this documentation and that's going

2334:52

to be everything that you have to know

2334:53

but you don't even have to worry about

2334:55

that because now you're going to be

2334:56

using there so what I'm going to do is

2334:58

that I'm going to right click on there

2335:00

and open my terminal let me make that a

2335:02

bit bigger so you guys can see

2335:04

everything a bit better like so first

2335:07

thing first I'm going to create a new

2335:08

folder with the name of style dick demos

2335:12

and now let me go into that style dick

2335:14

demos and here inside there uh you know

2335:17

let me just open there in the vs code so

2335:19

let's just open there and now let me go

2335:21

ahead and create a new folder with the

2335:22

name of tokens uh and inside this folder

2335:26

we are going to be defining our tokens

2335:28

so now let me just right click on there

2335:29

and create a new file with the name of

2335:31

color and you have to specify this

2335:33

tokens. Json because whenever we are

2335:36

building our design system we are going

2335:38

to be using this format so now let me

2335:40

just hit enter so basically this is just

2335:42

a Json file nothing special inside there

2335:44

but now we are going to be providing our

2335:46

tokens as a Json valos so now let me

2335:49

open and close my object and inside

2335:51

there let's just provide our colors uh

2335:53

ke key and inside there we are going to

2335:55

be starting from the violet color so v o

2335:58

l t and now let me just provide some

2336:00

sort of a value to there and the value

2336:02

will be set to like 7 C3 a d so that's

2336:05

going to be my one color now let me

2336:07

provide a comma and I'm going to

2336:09

duplicate that a few times so that's

2336:11

going to be first one second third and

2336:13

fourth color let's just go to the top

2336:15

and change this color value to Blue I'm

2336:17

going to also change the hexad decimal

2336:19

value of the 3 D 5 a let me change that

2336:23

to Green

2336:25

uh and I'm going to also change the hexy

2336:26

decimal of there to one B uh 981

2336:31

981 I'm going to also change this value

2336:35

to the red one okay so I'm going to also

2336:37

change that the hex value of there to

2336:39

like EF 4 4 4 4 like four times I'm

2336:43

going to also close there now let me

2336:44

just save my file and this is how our

2336:47

design tokens looks like and now we are

2336:49

going to be using a style dictionary to

2336:51

transform there to a CSS variables then

2336:54

we're going to be transforming there to

2336:55

a SS and then finally to a JavaScript

2336:58

and you can also transform there to like

2337:00

Android code if you want it to but in my

2337:01

case I'm not going to so now let me open

2337:04

my terminal and now we are going to be

2337:05

installing like both of those packages

2337:07

which we just Define or which we just

2337:09

discussed a few seconds ago so we're

2337:11

going to be installing a style

2337:12

dictionary and also a style dictionary

2337:14

util so now let me just hit enter so

2337:16

it's going to install there right here

2337:19

this is right for there so then St

2337:20

you're done now we are going to be

2337:21

telling a style dictionary to transform

2337:23

or tokens to some other format so what

2337:26

I'm going to do is that I'm going to

2337:28

just create a new file inside the root

2337:29

and I'm going to give it the name of

2337:30

like config.js and inside this config.js

2337:34

we are going to be providing a few

2337:35

configurations so the first thing that

2337:37

we have to do is that we have to provide

2337:38

the source we want to get or design

2337:40

tokens like we want you to go to the

2337:42

tokens folder which is this tokens

2337:45

folder right here and every single thing

2337:48

inside their tokens folder which ends

2337:50

with the tokens. Json okay so here you

2337:54

can see we're now providing our token

2337:55

file is like uh color. token. Json so we

2337:59

have to just specify there so that's

2338:01

going to be our source the next thing

2338:02

that we have to do is that we have to

2338:04

provide our platform so I'll just write

2338:06

like platform and here inside there we

2338:08

are going to be only transforming there

2338:09

for a CSS just for now and I'm going to

2338:12

show you that other ways in a few

2338:13

seconds so now you want to transform

2338:15

that to a CSS and now we are going to be

2338:17

using a transform t r NS f o r m

2338:20

transform group and we want to get like

2338:22

a CSS transform

2338:24

and we're going to be also providing a

2338:26

path where we want to get the build okay

2338:28

so I'll just write like build path and

2338:30

here let's just change that to like

2338:32

build and then CSS and then inside that

2338:34

CSS we want to get all of that results

2338:37

now underneath we are going to be also

2338:38

providing our files so here inside let

2338:41

me just space my array and inside this

2338:43

array we're going to be providing our

2338:44

destination and also the format now let

2338:47

me just provide like t d s t i n a t i o

2338:50

n destination and the destination will

2338:52

be set to very variables. CSS okay now

2338:56

let me just provide a comma and I'm

2338:57

going to also provide the format like

2338:59

for which format you want to get your

2339:01

values okay so we want to get as a CSS

2339:03

variables like so now let me just save

2339:06

my file and go back so this is how we

2339:08

are going to be providing a source this

2339:10

is how we are going to be specifying

2339:11

different platforms but for now we are

2339:13

only providing the CSS but later we are

2339:16

going to be also providing that other

2339:17

stuff okay so we are also providing a

2339:20

transform group we are also providing a

2339:22

build path like where you want to get

2339:24

our items to be like the build item then

2339:27

we are providing a file inside that we

2339:29

are providing a destination and also the

2339:30

format and that's going to be it now let

2339:33

me go ahead and go to my package.json

2339:35

file right here and here we are going to

2339:37

be providing our own script so now let's

2339:39

just provide our comma there and I'm

2339:41

going to provide my scripts right here

2339:42

and inside the scripts we're going to be

2339:44

providing a build script which will

2339:46

allows us to build our file so now we

2339:48

are going to be using a style dictionary

2339:50

not dependency but Di i d i o n a r y

2339:53

dictionary and build now let me just

2339:54

save there close there open my sidebar

2339:58

open my terminal and I'm going to be

2339:59

using npm run build and as soon as I do

2340:03

that and if I just hit enter so watch

2340:05

what happens it's going to gives us the

2340:07

build off there and here you can see

2340:09

this is now check like we not getting

2340:11

any errors nothing whatsoever if I click

2340:14

on this build so now we are getting a

2340:16

CSS folder and now if I click on this uh

2340:18

variable start CSS bang we are now

2340:21

getting all of that colors right here so

2340:23

now we are getting like uh the violet

2340:25

color blue color green color red color

2340:28

and so much more okay so this is how we

2340:31

are going to be creating our tokens this

2340:34

is how we are going to be creating a

2340:35

configuration for there and this is how

2340:37

we are going to be building there so now

2340:39

let me just delete this folder from here

2340:41

and now we are going to be providing a

2340:42

few more tokens and we are going to be

2340:44

also providing a few more configurations

2340:47

right here let me just space my spacing

2340:49

and also the typography so we already

2340:51

saw this color one now let me go ahead

2340:53

and go to my spacing so we have this

2340:55

spacing right here so we have a extra

2340:57

small we have a small we have a medium

2341:00

and large now let me also go to my

2341:02

typography so inside there we have a

2341:03

small Bas large then we have a font wet

2341:06

like normal medium and bold and so on

2341:09

and so forth so if you want to provide

2341:10

there you can definitely just provide

2341:12

there or if you want to go to my gab

2341:13

repository and grab that from there you

2341:15

totally can now let me just rebuild it

2341:18

once again so if I just rebuild it here

2341:20

you can see it's going to gives us all

2341:21

of that values as a CSS variable

2341:24

so now we are getting like the colors we

2341:26

are also getting the spacing and we are

2341:28

also getting the font sizes and also the

2341:30

font weights right here now let me just

2341:32

delete this folder once again and now we

2341:34

are going to be providing a few more

2341:36

configuration for other platforms so now

2341:39

let me just hide there next up I'm going

2341:40

to provide the SS configuration so I'll

2341:43

just provide like scss and inside there

2341:46

uh we're going to be providing our

2341:47

transform group in this transform group

2341:50

we'll take scss SCS there we go

2341:54

if I can speak there today next we're

2341:56

going to be providing our build path and

2341:58

here for this build path uh we're going

2342:00

to be still going once again to that

2342:03

buildt folder and now we are going to be

2342:04

creating a new folder with the name of

2342:06

scss and then outside from there we are

2342:09

going to be specifying our files and

2342:11

inside these files we're going to be

2342:13

providing an object and here let's just

2342:15

provide our destination and for the

2342:17

destination we want to go into the

2342:20

variables do SCS come on scss file okay

2342:24

and we're going to be also providing a

2342:25

format for there and the format we want

2342:27

to get there like SCS and then variables

2342:31

there we go okay I forgot to include my

2342:34

colon there now let me just save my file

2342:36

and these are all the configuration that

2342:38

you have to specify for the scss so now

2342:41

let me just close there I'm going to

2342:42

zoom in a bit once again and now let me

2342:44

just rebuild there once again now it's

2342:46

going to gives us the CSS and also the

2342:48

scss so let's just go into the build

2342:51

folder so now we have a CSS and we also

2342:53

have this SCS if I click on there once

2342:56

again so now we are getting all of our

2342:58

CSS or S variables right here so we are

2343:01

getting the for the colors for the

2343:03

spacing and also for the font sizes and

2343:05

font wids now let me just close there

2343:08

and finally let me just show you there

2343:09

for the JavaScript I'm going to also

2343:12

hide there and now let me just show you

2343:14

there for the JavaScript I'm going to

2343:15

provide my Js and inside there we are

2343:17

going to be providing my transform group

2343:20

and here we going to be setting that to

2343:22

the J JavaScript and now let's just

2343:24

provide our build and here let's just

2343:26

provide our build and then JavaScript

2343:28

you want to go into that folder provide

2343:30

a comma there uh we are going to be also

2343:33

specifying our files inside there we

2343:35

have to provide the object destination

2343:38

and the destination will be set to that

2343:40

variables not CSS where in this case

2343:43

JavaScript we're going to be also

2343:45

providing a format and the format will

2343:47

be set to JavaScript and then es6 let's

2343:50

just go back save my file and finally

2343:54

let's just build it and I'm going to

2343:57

just remove this folder once again and

2343:59

rebuild there by using npm run Dev so

2344:03

I'll use like npm run Dev or not Dev but

2344:05

build once again and now let me just hit

2344:07

enter so it's going to gives us the

2344:09

output of CSS SS and also the JavaScript

2344:12

let me click on the build and we are

2344:14

also getting this JavaScript so now let

2344:15

me just click on there we have a

2344:17

variables. JS file right here now we

2344:20

have all of our JavaScript variables so

2344:22

we're now getting there for the for the

2344:24

spacing for the font size and for the

2344:27

font WID and that was it about the style

2344:31

dictionary and next we are going to be

2344:33

covering the clsx now let me show you

2344:35

another super important package for

2344:37

building a design system and a component

2344:39

Library which is called the clsx so what

2344:42

is a clsx and why should everyone care

2344:45

about that so clsx is a small utility

2344:48

for conditionally joining class names it

2344:50

helps you dynamically add or remove CSS

2344:52

classes based on a condition without

2344:55

having to worry about manual string

2344:56

concatenation or complex logic so that

2344:59

was it about the basic definition of

2345:01

clsx and now let me show you the

2345:03

inaction all right guys so now let me

2345:05

show you that clsx package inaction so

2345:08

I'm going to open my terminal and let me

2345:10

just zoom in a bit so you guys can see

2345:12

everything a bit better like so there we

2345:16

go now I'm going to use mkd to make a

2345:18

new directory with the name of

2345:20

clsx uh demos and now let me go into

2345:23

that clsx demos and now I'm going to

2345:26

open that in my vs code so the first

2345:28

thing that I want to do is that I want

2345:30

to open my terminal I'm going to be

2345:31

using npmi not I but npm inet Dy to

2345:36

initialize our package.json right here

2345:38

now let me go into that package.json

2345:40

file and here inside there we are going

2345:43

to be only providing one script which

2345:45

will be set to type and then Mo let's

2345:49

just provide there and by the way we are

2345:50

going to be also creating a script for

2345:52

ourselves so I'll just write a d and

2345:54

here I'm going to only provide like node

2345:56

and then SRC and then index.js because

2345:59

we are going to be only testing this

2346:01

index.js file which we're going to be

2346:03

creating in a few seconds so you only

2346:04

have to specify this type modu and then

2346:07

this Dev package right here so now let

2346:08

me just close there and here we're going

2346:11

to be creating a SRC folder and inside

2346:13

there let's just create our index.ts or

2346:15

not TS but JS now we have to install the

2346:18

clsx so I'm going to use like npmi and

2346:20

then clsx so it's going to install it

2346:23

inside our existing project so that's

2346:24

all done let's just go into our project

2346:26

and here you can see we have our clsx

2346:29

dependency right here so the first thing

2346:31

that we have to do is that we have to

2346:32

import the clsx from where from the clsx

2346:36

and let me just give you the basic usage

2346:40

of of a clsx so you can basically pass a

2346:42

class names or conditional expressions

2346:44

like true and false and it returns a

2346:46

string of valid class name so what do I

2346:48

mean by that you know let's just remove

2346:50

that from here and I'm going to just

2346:51

write like clsx right here and I'm going

2346:53

to pass a button right here and I'm

2346:55

going to also past like button primary

2346:57

and now it should be just a primary

2347:01

there we go and now let me store there

2347:03

inside the variable with the name of

2347:05

button class and it's going to be equals

2347:07

to the clsx and now let me just log

2347:09

there to the console like button classes

2347:11

right here or yeah I guess button class

2347:13

would be fine let me just sell there and

2347:15

I'm going to use like npm run Dev and

2347:17

once I do this so what am I getting I'm

2347:19

now getting button and button primary so

2347:21

basically it's going to con reate this

2347:24

string with this one right here but we

2347:26

are not done there are a few things that

2347:28

you also have to keep in mind we can

2347:30

also pass a conditional expression so

2347:31

now let me just remove there and I'm

2347:33

going to create a variable with the name

2347:35

of is primary it's going to be set to

2347:37

true and now underneath there we are

2347:39

going to be using our clsx right here

2347:41

and now let me just spride my button

2347:43

right here and now we are going to be

2347:44

checking like is primary and primary so

2347:48

if this is true it's going to gives us

2347:50

this value but if that's not true so

2347:52

it's going to only gives us this button

2347:53

right here okay so what I'm going to do

2347:55

is that I'm going to just write like

2347:56

primary uh button class or something

2347:59

like that and now let me just log there

2348:01

to the console like primary button class

2348:03

I'm going to save this file right now

2348:05

now let me just rerun there so it's

2348:06

going to giv us like button and also

2348:08

button primary but now let me just

2348:10

change that to like false and now let me

2348:13

just save my file once again and run

2348:14

that so now it's going to only use us

2348:16

that button and not this button primary

2348:19

right here so that's the second thing we

2348:21

can also P AR raise of values so if the

2348:23

item is true so it's going to include

2348:25

there as a final class string but if

2348:27

that's not the case so it's not going to

2348:29

include there as a final string so what

2348:31

what I mean by all of their gibberish so

2348:33

we just have to write like is primary

2348:35

primary and it's going to be set to true

2348:37

and now let me just close there now we

2348:39

are going to be using our clsx here we

2348:41

have to just specify our button and now

2348:43

let me just provide like um button

2348:46

primary I'm going to also specify is

2348:48

primary and this is right and and then

2348:52

active active but we have to provide

2348:55

that as array okay so now let me just

2348:58

convert there to array and now let me

2349:00

store that inside the classes variable

2349:02

right here I'm going to also log these

2349:04

uh classes and now let me just save my

2349:06

file I'm going to use that npm run and

2349:08

now it's going to give us like button

2349:10

button primary and then this active

2349:12

class right here and why is that that's

2349:14

because primary is set to true so that's

2349:16

why we now getting this active but now

2349:18

if you change that to like false come on

2349:20

false and now let me just save my file

2349:22

and rerun that there so now it's going

2349:23

to only gives us that button and button

2349:26

primary and not the active one we can

2349:28

also use that with object so now let me

2349:30

just remove that and I'm going to Define

2349:32

two variables with the name of like is

2349:34

primary it's going to be set to true and

2349:36

I'm going to also Define another

2349:38

variable with the name of is disable and

2349:40

that's going to be set to false now

2349:41

underneath we are going to be using our

2349:43

clsx and here we have to specify our

2349:46

object right here so I'm going to past

2349:47

like button and the value will be set to

2349:49

true I'm going to also provide like

2349:51

button primary and that's going to be

2349:54

set to this is primary so if this value

2349:57

is true it's going to include this class

2349:59

but if this value is false so it's not

2350:01

going to include this value right here

2350:03

I'm going to provide a comma there

2350:05

primary comma I'm going to provide yet

2350:07

another one like is disabled and here

2350:10

let's just set that two is disabled

2350:12

right here so once again if this value

2350:14

is true it's going to include this

2350:16

button disable but if this value is

2350:18

false so it's not going to include this

2350:20

value right here and now let me just

2350:21

store the inside the classes variable

2350:25

and now let's just log that classes to

2350:26

the console there we go now let me just

2350:29

save my file and I'm going to open my

2350:30

terminal and use npm run Del now we are

2350:33

getting like button and also button

2350:35

primary as you can see right here

2350:37

because this value is true so that's why

2350:39

we are now getting this value now uh we

2350:41

are not getting this uh what do we call

2350:44

this button disabled and why is there

2350:46

that's because this value is set to

2350:47

false so that's why we not getting that

2350:50

value but now if I convert that to like

2350:52

true and now let me just save my file

2350:54

and rerun there now here you can see

2350:56

we're now getting button button primary

2350:58

and button disabl but now if you convert

2351:00

like both of them to like false convert

2351:03

this one to false as well let's just say

2351:05

our file and now let me just reun there

2351:07

here you can see we are only getting the

2351:09

button and nothing else than there so

2351:12

that was our small package which is

2351:15

called the clsx so now let me show you

2351:17

yet another useful utility package which

2351:19

we are going to be using for building

2351:20

our component library and which which is

2351:23

called a CVA so what is a CVA and why

2351:26

should even care about that so CVA or

2351:29

class variance Authority is a utility

2351:31

that helps manage and apply conditional

2351:34

CSS class names in a structured and

2351:36

reusable way often used with utility

2351:39

first CSS Frameworks like tailn CSS it

2351:42

allows you to Define class variations

2351:44

based on a component props or states to

2351:46

maintain the consistent styling so that

2351:49

was just a quick theory about the CVA

2351:51

and now let me show you there in action

2351:53

so now let me show you that class

2351:55

variance Authority in action so I'm

2351:57

going to open my terminal and I'm going

2351:59

to make that a bit bigger so you guys

2352:01

can see everything a bit clear like so

2352:05

so I'm going to use npm create and then

2352:07

we we at latest and now uh I'll just

2352:11

give it the name of like CVA demos and

2352:14

now I'm going to choose react just with

2352:16

typescript let's just go into that CVA

2352:18

demos folder and install every single

2352:20

thing inside there while it's installing

2352:22

I'm going to go ahead and go to my tman

2352:24

CSS and then I'm going to click on this

2352:27

getting started go to the framework and

2352:29

guides click on the weat and let's just

2352:31

wait for that to finish then we're going

2352:33

to be making a tan CSS setup that's to

2352:36

done I'm going to open that in my vs

2352:38

code and this is how it looks like so

2352:40

I'll just remove this public folder

2352:41

let's just go to the SRC remove this

2352:43

assets app. CSS remove every single

2352:46

thing from the f. TSX and I'm going to

2352:48

use my RFC inside there and now I'm

2352:51

going to copy this command open my

2352:53

integrated terminal place it right here

2352:55

so it's going to take a bit of time to

2352:57

install the tailin CSS the post CSS in

2353:00

Auto prefixer right here okay that's

2353:02

totally done I'm going to also hit enter

2353:04

to initialize my tailman CSS that's also

2353:06

done now let me copy every single thing

2353:09

from there to my tving config file and

2353:13

place it and replace it with this new

2353:15

content right here let's just remove

2353:17

there I'm going to also copy this index.

2353:19

CSS and place there right here now let's

2353:23

just remove them and now I'm going to

2353:24

open my terminal once again and I'm

2353:26

going to use npm run Dev to run my

2353:29

server and this is how it looks like

2353:30

right here so the first thing that I

2353:32

want to do is that I want to create a

2353:33

components folder and inside there I'm

2353:35

going to create my button come on TSX so

2353:39

this is how we are going to be creating

2353:40

our folder and inside that we are now

2353:41

creating our but. TSX file and I'll just

2353:44

use my RFC just for now I'm going to

2353:46

save this file right now and the first

2353:48

thing that we have to do is that we have

2353:50

to import something called the CVA let's

2353:52

just just import the CVA from where from

2353:55

the class variance Authority but we did

2353:58

not install there so we have to first of

2354:01

all install the then we would be able to

2354:03

use this so I'm going to use like npmi

2354:05

to install the class variance aor if the

2354:10

spelling is correct so it's can install

2354:11

there right here that's all done now let

2354:14

me import the CVA CV from where from the

2354:18

class variance Authority that's to done

2354:20

now let me just save my file and here

2354:22

here we have to Define class variations

2354:27

okay so variation you know we don't even

2354:30

have to right there so this is how we

2354:32

are going to be defining a different

2354:33

variation for our button component so

2354:36

I'll use my CVA and I'm going to execute

2354:38

there so it's going to first of all take

2354:40

the Bas class names and it's going to

2354:42

also take the configuration which we are

2354:43

going to be providing in a few seconds

2354:45

so first of all I'm going to specify

2354:47

some sort of Base classes like pairing

2354:49

for the x-axis will be set to four

2354:51

pairing for the Y AIS will be set to to

2354:53

and round it totally medium and also

2354:56

Focus f o c us Focus will be set to

2354:59

outline and then none okay so now

2355:02

outside from that here we are going to

2355:04

be providing our configuration right

2355:06

here so now let me just hit enter I'm

2355:07

going to go back and this is how it

2355:09

looks like and inside this object we're

2355:11

going to be providing our variants so v

2355:13

r v r i NTS and inside these variants

2355:17

we're going to be providing different

2355:19

variation for work component so I'll

2355:21

just provide like color for instance

2355:23

and inside this color we would have two

2355:25

flavor of our color so we would have a

2355:27

primary and I'm going to specify like

2355:30

background to Blue of 500 I'm going to

2355:32

also change the text to totally white

2355:34

and here we are going to be also

2355:36

providing a secondary it's going to be

2355:37

set to like background totally gray of

2355:39

500 and also the text will be totally

2355:43

black so that's going to be the first

2355:45

variation forward color inside our

2355:48

component okay so now underneath there

2355:50

we're going to be using the size and for

2355:53

this size we're going to be providing a

2355:54

like small and large size so I'll just

2355:57

write like text only small and I'm going

2355:58

to also provide like pairing on the Y

2356:00

AIS of one pairing for the xaxis of

2356:03

three now underneath we are going to be

2356:04

also providing a large and the large

2356:06

will be set to Tex large and pairing for

2356:09

the y axis will be set to three pairing

2356:10

for the xaxis will be set to six I'm

2356:13

going to save this file right now and

2356:14

now underneath this size I'm going to

2356:16

also provide different state for my

2356:18

button like the active State the

2356:19

disabled state so I'll just write like

2356:21

State and here we going to be providing

2356:23

like active if my button is active so

2356:25

we're going to be using background

2356:27

totally blue of 700 but if that's not

2356:30

the case and if the button is set to I

2356:34

can type there today if the button is

2356:35

set to disable so we're going to be

2356:37

providing background to freay of 300 and

2356:40

also cursor will be not allowed in that

2356:43

situation so now let me just save my

2356:45

file go back and here we're going to be

2356:47

also providing a default values so there

2356:50

should be underneath this one it's all

2356:52

we just write like default values and

2356:55

here inside there we're going to be

2356:56

providing a default value for the color

2356:58

like primary and I'm going to also

2357:00

specify the size and the size default

2357:03

value will be set to small I'm going to

2357:05

save this file right now I'm going to

2357:07

also store this entire thing inside the

2357:09

variable with the name of uh what do we

2357:12

call it buttons or yeah button Styles

2357:15

would be fine okay so let's just say

2357:18

they I'm going to copy a name of there

2357:19

but it should be button styles okay now

2357:23

let me copy the name of them now we are

2357:25

going to be going into our button

2357:26

component and here we're going to be

2357:28

using this so now let me just remove

2357:30

that from here I'm going to also change

2357:31

there to the button so this button will

2357:33

take a few props so now let me just

2357:35

destructure there first of all so we're

2357:36

going to be providing a color it's going

2357:38

to also take the size and it's going to

2357:40

also take the state and we're going to

2357:41

be also providing our content which will

2357:43

be set to a children so I'm going to

2357:45

also create a button props interface for

2357:48

there I'm going to copy a name of there

2357:49

and Define my interface right here so

2357:51

I'll use like face button props inside

2357:54

there we're going to be optionally

2357:56

providing a color forward button so if

2357:58

the user want to provide this uh color

2358:01

they totally can but if they don't want

2358:02

to provide that they don't even have to

2358:04

so I'll just provide like primary either

2358:06

use primary or use a secondary because

2358:10

we already set this up now we're going

2358:12

to be also providing a size and that's

2358:13

going to be also totally optional so

2358:15

either small size or large size now we

2358:19

are going to be also providing a state

2358:20

and the state will be set to active

2358:23

or disabled and finally we're going to

2358:25

be providing a children but why am I

2358:27

providing a

2358:29

comma these are not objects so I'll just

2358:32

write like children and we are going to

2358:34

be getting a react node from the react

2358:36

node now let me just hit enter just

2358:37

going to import that react node right

2358:39

here that's tot done now we have to use

2358:42

these props inside our component so I'll

2358:45

just uh first of all render my children

2358:47

right here so I'll just write like

2358:48

children for the class names now we

2358:51

going to be using our button St FES

2358:53

which we already defined right here okay

2358:55

so now let me just hide there I'm going

2358:57

to also hide this one now we are going

2358:59

to be using this button classes right

2359:01

here for the class names and now here

2359:03

we're going to be passing that color

2359:05

which we are now taking as a perimeter

2359:07

right here we're going to be also

2359:09

specifying the size and also the state

2359:12

which we are now taking as a perimeters

2359:14

so that's to done now let me just save

2359:16

my file but we are going to be also

2359:17

providing a disable state if the state

2359:19

is equal to disable so in this situ

2359:22

which means like our button will be

2359:24

disabled so that's totally done now let

2359:26

me go ahead and go to my app and here we

2359:28

have to use the right here so let's just

2359:30

remove there and first of all you know

2359:33

let me just put a bit of classes to

2359:34

there so I'll use like spaces on the Y

2359:36

AIS of four and here inside there we're

2359:38

going to be using that button component

2359:40

which we just defined okay so now let me

2359:43

just close there right here and I'm

2359:44

going to specify like primary large

2359:47

button or something like that and here

2359:49

we're going to be passing a color so the

2359:52

color will will be now let me just hold

2359:53

control and hit space so here you can

2359:55

see we only have two options like

2359:57

primary or secondary so in this

2359:59

situation I'm going to only choose like

2360:01

primary I'm going to also provide the

2360:03

size of there and size will be set to

2360:04

large okay so that's totally done we can

2360:07

also specify that other one which was

2360:10

was that state so I'll just write like

2360:12

State and State will be set to active

2360:15

Okay so as soon as I do that now the

2360:17

error will be gone now let me run that

2360:19

by using npm run Dev and check this out

2360:21

so here you can see we now getting our

2360:23

button we can also change that to like

2360:24

disable or

2360:27

B and now let me just save my file so

2360:29

now my button is disabled right here so

2360:31

you know what we're not going to be

2360:32

providing the state for this one let me

2360:34

even make the as a optional so now let

2360:38

me just make the optional so that we

2360:39

don't get the typescript error we're

2360:41

going to be also using that button once

2360:43

again and here we are going to be

2360:44

providing like secondary small button

2360:47

and here let's just pass our color

2360:49

inside there and the color in this case

2360:51

I'm going to pass like secondary color

2360:53

I'm going to also provide the size of

2360:55

totally small today okay so now let me

2360:57

just save my file so here you can see

2360:58

we're now getting a secondary button and

2361:01

also smaller button than this one okay

2361:03

so there's the second button and now let

2361:05

me just create the final one which will

2361:07

be for the disable so I'll just use like

2361:08

button and disable button like so and

2361:12

I'm going to past like the color and the

2361:15

color will be set to primary I'm going

2361:17

to also provide the state come on and

2361:18

the state will be set to disabled I'm

2361:21

going to also provide the size and the

2361:23

size will be set to small I'm going to

2361:25

save this file right now so here you can

2361:27

see this is how we're going to be

2361:28

defining a different variation for our

2361:31

components by using this CVI package

2361:34

right here so these are going to be

2361:35

basically our base classes and then we

2361:38

can specify different variation like uh

2361:41

the for the color we can use like

2361:43

primary secondary for the size we can

2361:45

use like small and large for the state

2361:47

we can use like active and disable and

2361:50

if we did not specify any color or size

2361:52

so it's going to also take this default

2361:54

variations right here so yeah that was

2361:57

it about the CVA in action all right

2361:59

guys so now we are going to be building

2362:01

our own custom component library from

2362:03

scratch by using tools like reactjs

2362:06

typescript tman CSS roll upjs story book

2362:10

react testing Library vest clsx CVA and

2362:14

so on and so forth so what I'm going to

2362:17

do is that I'm going to open my terminal

2362:19

and now I'm going to zoom in a bit so

2362:20

you guys can see everything a bit better

2362:22

like so and I'm going to create a new

2362:24

folder with the name of my

2362:26

components uh library or something like

2362:29

that now let me go into that my

2362:31

components library and I'm going to open

2362:33

that in my vs code and this is how it

2362:35

looks like so first of all I'm going to

2362:37

initialize my GitHub repository by using

2362:39

get in it so let's just use the hit

2362:42

enter so it's going to initialize my

2362:43

GitHub repository and now I'm going to

2362:45

be using npm in- Y to initialize my

2362:48

package. jsn file okay so now let me go

2362:51

into that package. Json file and now

2362:53

here you can see we don't have anything

2362:54

special inside there but we only have

2362:57

this boiler plate of uh package.json

2362:59

file so now let me just close there and

2363:01

now the next thing that we have to do is

2363:02

that we have to install a reactjs and

2363:05

also typescript so I'm going to use like

2363:07

npmi and then reactjs typescript and

2363:10

also types for the reactjs as well so

2363:13

now let me just hit enter so it's going

2363:14

to install the inside this packages and

2363:17

that's totally done and now I'm going to

2363:19

also create a new file with the name of

2363:21

get ignore Sol just use like get ignore

2363:24

and inside there we're going to be only

2363:25

ignoring the node modules folder and now

2363:28

let me just save there and here we can

2363:30

see that's going to be gone it should be

2363:32

gone now there we go so that's to done

2363:35

now we're going to be creating a folder

2363:37

structure and then we are going to be

2363:39

writing our code inside there so now let

2363:41

me just create a new folder with the

2363:42

name of SRC inside this SRC folder we

2363:46

are going to be creating a new file with

2363:47

the name of index.ts so let's just write

2363:49

like index.ts also we are going to be

2363:52

creating a new folder with the name of

2363:53

components so I'll just use like

2363:55

components and inside there we're going

2363:57

to be creating a new file with the name

2363:58

of index.ts once again and now inside

2364:01

this components folder we are going to

2364:03

be creating yet another folder with the

2364:05

name of buttons so let's just use like

2364:07

buttons or just a button would be fine

2364:10

and now I'm going to create a new file

2364:11

inside this button folder with the name

2364:13

of index.ts now let me just close all of

2364:16

that files and now I'm going to go into

2364:18

that buttons folder and now we are going

2364:19

to be creating yet another file with the

2364:21

name of button m. TSX and now inside

2364:24

there we're going to be just writing a

2364:26

boiler plate for or button component now

2364:28

let me just save there and we would also

2364:30

need to import the react JS so let's

2364:32

just use come on import the react Js

2364:34

from the react JS and we would also need

2364:37

to grab the react node so now let me

2364:39

just save my file it's going to also

2364:41

take a few props so now let me just

2364:42

write like children and we're going to

2364:44

be annotating the as uh button promps or

2364:47

something like that so now let me create

2364:49

that interface with the name of button

2364:51

promps and now inside there we are going

2364:53

to be creating our children and now let

2364:55

me just space like react node which we

2364:56

are now importing from the reactjs or

2364:59

react node once again now let me just sa

2365:01

my file and that's going to be it also

2365:03

we would need to change this div to the

2365:06

button so that we should get our button

2365:08

right here so now let me just save my

2365:09

file I'm going to close this file right

2365:11

now now I'm going to go into this

2365:13

buttons folder and inside there we have

2365:16

this index.ts file so I'm going to click

2365:18

on there and here we are going to be

2365:20

exporting let's just try it like P

2365:22

default from where from where button

2365:24

folder or from our button file so now

2365:27

let me just save my file close there now

2365:30

we are going to be clicking on this

2365:31

index.ts file which is now available

2365:34

inside this components folder not inside

2365:37

the buttons folder so I'm going to just

2365:39

activate there and here we are going to

2365:41

be exporting our default as button from

2365:44

where from our buttons component so I'll

2365:47

just use like uh let's just go to the

2365:48

Advan folder and now let me just save

2365:50

there and that's toly done now finally

2365:53

we have to go into this root index.ts

2365:55

file which is now available inside this

2365:57

SRC folder and we only have to export

2366:00

every single thing from there so let's

2366:02

just use like export every single thing

2366:04

from that components folder like so now

2366:07

let me just s my file and that's already

2366:09

done so now we are going to be adding

2366:10

typescript to our component Library so

2366:12

what I'm going to do is that I'm going

2366:14

to write like npx and then TSC and then

2366:17

d d in it to initialize my typescript

2366:19

inside this project so now let me just

2366:21

close there and here you can see now

2366:23

it's going to giv us this TSC config.js

2366:25

file I'm going to just double click on

2366:27

there and I'm going to remove every

2366:28

single thing from there and now we are

2366:30

going to be replacing them with our own

2366:32

one so first of all we are going to be

2366:34

providing our compiler options and now

2366:36

inside this compiler option we're going

2366:38

to be first of all providing the target

2366:40

okay so our Target will be es next in

2366:43

this case I'm going to also provide a

2366:45

comma and we are going to be also

2366:46

providing like es module ENT repo and

2366:49

now let me set to True also we are going

2366:51

to be providing the force consistent

2366:53

casing in file names and let's just set

2366:56

the true and we are going to be also

2366:58

providing a strict mode and that's going

2367:00

to be also set to true and let's just

2367:02

also provide the skip Library checks

2367:05

that's going to be also true and for the

2367:07

root directory and the path will be only

2367:10

dot so now underneath there let me just

2367:12

even provide a comma there we going to

2367:14

be also providing a jsx so for the jsx

2367:17

we want to use reactjs in this case and

2367:19

also for the modu we are going to be

2367:21

setting that to es next I'm going to

2367:23

also provide the Declaration so let's

2367:25

just use like declaration that's going

2367:27

to be set to true we're going to be also

2367:29

providing a declaration uh directory and

2367:32

which will be our types directory in

2367:35

which we going to be writing our types

2367:37

okay so now let me provide a comma there

2367:38

we are going to be also setting the

2367:40

source map to true the out directory

2367:43

will be set to a disc because we are

2367:44

going to be building our project and now

2367:46

we are going to be using like module

2367:48

resolution and module resolution will be

2367:50

set to node okay we going to be also

2367:52

providing allow synthetic default

2367:55

Imports let's set that through and

2367:57

finally emit declaration only come on uh

2368:00

emit declaration only and also set that

2368:03

to true and now let me just save my file

2368:06

and that's everything that you have to

2368:07

provide for your TS config file and now

2368:09

we are totally done with the typescript

2368:11

stuff so now we are going to be

2368:12

installing rollup and that's going to be

2368:14

a lot of fun but you have to install a

2368:16

lot of dependencies for there so if you

2368:18

want to type there by yourself you

2368:20

totally can but you can also find all of

2368:22

them in my gab repository so I'm going

2368:24

to just use like npmi let's just zoom in

2368:27

a bit and then DD to install the as a

2368:29

dependency this just install the rollup

2368:31

and go to the plugin and then common JS

2368:35

we also have to install the rollup let's

2368:37

just go to the plugin once again install

2368:40

the note resolve then roll up once again

2368:43

go to the plugin and then terer then

2368:47

roll up plugin typescript because we're

2368:50

going to be using typescript and now we

2368:52

are not going to be providing this add

2368:54

symbol but we are going to be only

2368:55

providing just a rollup okay and then

2368:57

roll up uh plugin DTS and roll up plugin

2369:02

here dependencies external p is live

2369:05

roll up plugin then post CSS because we

2369:08

are going to be also installing a t in

2369:10

CSS so we have to install all of there

2369:13

right here it's going to take a while to

2369:15

install all of these dependencies but

2369:17

I'm going to just but I'm going to just

2369:18

face forward this R right now that's

2369:20

totally done I'm going to close go there

2369:22

and now I'm going to go ahead and just

2369:24

go to the root and here we're going to

2369:26

be creating a roll upjs file so for the

2369:28

configurations I'll use like rollup and

2369:31

then config then. JS so let's just add

2369:35

that close that one and here inside they

2369:38

we're going to be placing a lot of code

2369:40

but you don't have to worry about this

2369:41

code because these are just a code for

2369:44

building this project here you can see

2369:45

we now just grabbing all of their

2369:47

dependencies which we just install like

2369:49

resolve commonjs typescript d and so on

2369:52

and so forth and then we are providing

2369:54

an input like where is our file located

2369:56

then we want to get like the output in

2369:58

this file and format and so on and so

2370:01

forth okay so we are also providing a

2370:03

few plugins which we are going to be

2370:04

using inside this project so that's

2370:06

everything that you have to provide and

2370:08

if you want to also get that from my

2370:09

GitHub repository you totally can but

2370:12

you don't even have to worry about this

2370:14

code if you care about that well can

2370:17

just check out some video about the

2370:18

rollup but in my case I'm not going to

2370:20

be worrying about this so now let's just

2370:21

close was there and that was the setup

2370:23

of a rollup but now I'm going to go into

2370:25

my package.json and here we're going to

2370:27

be replacing a few things so I'm going

2370:29

to have to delete the main and also the

2370:31

test and also the keywords let's just

2370:33

delete them because we are going to be

2370:35

providing our own stuff okay so I'll

2370:37

just first of all provide my main and

2370:39

Main will be coming from this disc

2370:42

folder because once we build our project

2370:43

so it's going to go into this disc

2370:45

folder and then CJs and then

2370:48

index.js okay so that's going to be my

2370:50

main file entries now we are going to be

2370:52

also providing a files and for these

2370:54

files we are going to be going into the

2370:56

disc that's to done we going to be also

2370:58

providing a types okay so once I provide

2371:01

the for the typescript types declaration

2371:03

you want to go to the dis and then

2371:04

index.

2371:06

D.S like so and now underneath that

2371:08

we're going to be also providing our own

2371:10

script to build our project so I'll just

2371:12

go ahead and uh put the rollup and

2371:14

that's going to be set to uh roll up and

2371:18

then d c and then D- bundle s CG yes

2371:22

there we go I'm going to save this file

2371:23

right now and now underneath there we

2371:26

going to be also providing a keywords if

2371:28

you don't want to provide this keywords

2371:30

you don't even have to provide there but

2371:32

if you provide the like once you push

2371:34

this project to the npm so you're going

2371:36

to see these keywords inside your

2371:38

landing page so I'll just write like uh

2371:40

random and then I'm going to proide like

2371:42

test and then test two or something like

2371:45

that now underne these keywords we're

2371:47

going to be also providing a type and

2371:49

type will be set to modu okay so let's

2371:51

just Cho like module like so and now

2371:53

underneath that we're going to be also

2371:54

providing a PE dependencies okay so

2371:57

underneath this dependencies we're going

2371:59

to be providing a PE dependencies like

2372:01

dependencies and now let me just set the

2372:04

react come on not sing but set the react

2372:07

to re J not 18 19 but 18 so basically

2372:12

peer dependencies just simply means like

2372:14

whenever somebody else using these

2372:16

packages they have to have at least

2372:19

reactjs 18 or greater version than there

2372:22

and now let me just save my file and

2372:23

there was about the rule of JS and now

2372:25

let me close there okay so now we going

2372:27

to be installing a TN CSS in our project

2372:30

so I'll just go to the talin come on if

2372:33

I can get there today tent css.com I'm

2372:36

going to go to the getting started

2372:38

button now let me click on the framework

2372:40

and guides choose weed I'm going to copy

2372:42

all of these commands and now let me

2372:44

open my terminal and place it right here

2372:46

so it's can to install the T CSS post

2372:49

CSS in Auto prefixer now totally done

2372:52

I'm going to hit enter one more time to

2372:54

initialize my telin CSS inside this

2372:56

project right here so now we are getting

2372:58

this telin config.js file I'm going to

2373:00

go there and copy every single thing

2373:02

from there and place it right here

2373:04

that's also done I'm going to also

2373:06

create this index.css file so I'm going

2373:08

to copy there go to my SRC folder and

2373:11

create a new file with the name of

2373:12

index. CSS and now let me just copy

2373:15

every single thing from there place it

2373:16

right here say my file and that's going

2373:19

to be it and now if I just use like npm

2373:21

run uh roll up J so it's going to build

2373:24

my project so I'm going to use like npm

2373:26

run and then roll up now let me just hit

2373:28

enter and here you can see it's going to

2373:30

build my project right here so we can

2373:32

now find all of that code inside this

2373:33

disc folder now inside that we have our

2373:36

index. DTS we also have our CJs and

2373:39

inside there we have all of our

2373:41

components which are now ready to

2373:43

publish to the npm packages okay so if

2373:45

you want to publish there by yourself so

2373:47

you can just use like uh npm publish I

2373:50

guess and you have to also log into the

2373:52

npm it's going to publish there to your

2373:54

npm so this is how we are going to be

2373:56

building there and now let me just

2373:58

delete this folder and we're not going

2373:59

to be pushing there to the npm so that's

2374:01

St done now we are going to be adding a

2374:03

story book for visually testing our

2374:05

components so how in the world we are

2374:07

going be doing there we just have to

2374:08

write like npx and then story book at

2374:12

latest come on at latest and then iner

2374:15

now if I just hit enter so it's going to

2374:17

initialize the story book inside this

2374:19

project so now it's going to ask us to

2374:20

choose either wheat or some sort of a

2374:22

bundler so I'm going to have to choose

2374:25

wheat and now it's going to install it

2374:27

inside my machine and this is how my

2374:29

story book will look like but it will

2374:32

gives us an

2374:33

error uh you will just see that in a few

2374:35

second God damn it just show us the

2374:37

error oh if I click on that but anyways

2374:40

it's going to gives us an error because

2374:41

we need to install the weat we also have

2374:43

to install the react D so I'm going to

2374:45

just hit n and set there to no let me

2374:48

just rerun there once again I'm going to

2374:50

use like n PM not npm but I'm going to

2374:53

use like npm story book or npm run story

2374:56

book and once I do that now it's going

2374:58

to give us that error okay so here you

2375:00

can see it's going to crash because we

2375:02

have to install the weed so now we have

2375:04

to install the weed and react and react

2375:06

Dom so I'm going to use like npmi then

2375:09

react and react D and also the weat so

2375:12

now it will successfully start to work

2375:14

that's St done I'm going to use npm run

2375:16

story book once again and now it's going

2375:19

to start working so here you can see

2375:20

we're now getting our configuration if I

2375:22

go to the button so we are now getting

2375:24

these buttons primary secondary we are

2375:27

also getting our header components and

2375:29

we are also getting our pages and

2375:30

everything is working the way we expect

2375:32

them to work so that's toally done and

2375:35

now I'm going to have to just stop there

2375:37

for a few seconds because we are going

2375:38

to be removing every single thing from

2375:40

the stories and we are going to be

2375:42

defining our custom story in a few

2375:44

seconds okay so now we're going to be

2375:46

building a simple component and we're

2375:48

going to be also testing the inside our

2375:50

story book so what I'm going to do is

2375:52

that I'm going to go into my buttons

2375:53

component or just a simple button

2375:55

component and here I'm going to just

2375:58

remove every single thing from there and

2375:59

I'm going to just replace it with this

2376:01

RFC once again so the first thing that

2376:03

we have to do is that we have to import

2376:05

the react uh from the react J we would

2376:08

also need to import the CVA oh we did

2376:10

not install the CVA like class variance

2376:13

authorities so we are going to have to

2376:14

install the I'm going to use like npmi

2376:16

and then class variance

2376:19

Authority a t h o r i t y I guess that's

2376:23

the spelling so it's going to install

2376:25

there right here and we would also need

2376:27

to install something called the tww

2376:29

merge or tent uh merge I hope the

2376:34

spelling is correct yep that's only done

2376:36

so now we have to import the CVA from

2376:39

class variance Authority and we also

2376:41

have to import the tww merge like the

2376:43

Tailwind merge from the tailin merch

2376:45

package so now let me just save my file

2376:47

now underneath we are going to be

2376:48

defining our CVA so for the base CL is

2376:51

I'll just write like pairing for the

2376:53

xaxis will be set set to four pairing

2376:55

for the y axis will be set to two to it

2376:57

rounded and focus uh will be set to

2377:00

outline and then none then toly done I'm

2377:03

going to also provide my object and

2377:05

inside that we're going to be providing

2377:07

a different variations so I'll just

2377:08

write like variants and here inside

2377:11

there let's just provide our variant

2377:12

like v a r i a n t a few flowers forward

2377:16

buttons so just put like primary and

2377:18

primary will be set to background ho

2377:20

blue of five 00 and text will be set to

2377:23

totally white underneath that we going

2377:25

to be also providing a secondary and the

2377:27

background will be set to totally gray

2377:28

of 500 uh like so text will be set to

2377:32

totally black and now let me just save

2377:33

my file and now need this variant we're

2377:35

going to be also providing a size so for

2377:38

this size like or button can accept a

2377:40

small size and the text will be set to

2377:42

totally small and our button can also

2377:45

accept I thought I'm just writing a Json

2377:48

so or button can also accept the medium

2377:51

and it should be set to text of totally

2377:53

Bas and we can also specify the large

2377:56

size forward button which will be set to

2377:57

text totally large and that's going to

2377:59

be it and we're going to be also

2378:01

providing a disabled state so b i s a b

2378:03

l e d and for the disabled State we're

2378:05

going to be setting there to true so if

2378:07

it is disabled in this situation we're

2378:09

going to be providing the background of

2378:11

toay of 300 and text of toay

2378:15

600 like so cursor will be not allowed

2378:20

uh like so and now underneath for the

2378:22

default styling uh we are going to be

2378:24

providing like default variant variants

2378:27

and for the variant we going to be

2378:28

setting there to like primary for the

2378:30

default one and for the size test can be

2378:32

set to medium and also for the disable

2378:36

which will be set to F initially so now

2378:38

let me just save my file and this is how

2378:40

our class variance Authority looks like

2378:42

but I'm going to have to store that

2378:44

inside the button styes like so and now

2378:47

let me just save my file and I'm going

2378:48

to also hide there now our button will

2378:50

accept a few prompts so it's going to

2378:52

accept the variant I'm going to

2378:54

destructure there right here so it's

2378:55

going to uh accept the variant it's

2378:58

going to also accept the size and

2378:59

disabled children and class names like

2379:03

so or just a singular class name and

2379:06

next we're going to be also

2379:07

destructuring the entire props or

2379:09

resting the entire props and we also

2379:12

have to Define interface for there so

2379:14

that we can inate our component so I'll

2379:16

just use the interface with the name of

2379:18

button props which will extends from the

2379:21

react. buttons uh button HTML attributes

2379:26

and here we're going to be also

2379:27

providing HTML button and here we're

2379:29

going to be also providing a HTML button

2379:31

element I'm going to also close that in

2379:33

here inside there let's just provide our

2379:34

variant so v a r i NTS and or just a

2379:39

singular variant this going to be

2379:40

totally optional and we can either get

2379:43

the primary variant or we can get the

2379:45

secondary s n d a r y secondary variant

2379:48

so for the size which will be also

2379:50

totally off

2379:51

we can set the to is small size or

2379:55

medium size or large size okay uh and

2380:01

why am I providing a commas there God

2380:03

damn it I always do that and let's just

2380:05

provide a

2380:06

disable and disable will be set to a

2380:09

Boolean now let me just sa my file I'm

2380:11

going to copy this button props from

2380:13

there and I'm going to annotate my

2380:15

component with that like so and now let

2380:17

me just sa my file let's just go back so

2380:19

you guys can see everything a bit better

2380:21

and this is how my component looks like

2380:23

so now I'm going to be using a tail

2380:24

merge to merge our classes uh so I'll

2380:27

just use like tww merge and let me just

2380:30

import there because yeah I guess we

2380:32

already imported yeah we already did and

2380:35

so now inside there uh we are going to

2380:37

be passing our button style component or

2380:39

not a component but a function which we

2380:41

are now creating by using this CVA

2380:43

package like class variance Authority

2380:45

package so we are going to be calling

2380:47

there right here and inside this button

2380:49

style we're going to be providing what

2380:51

variant which we're now taking as a

2380:52

perimeter so I'm going to have to copy

2380:54

there from there place it right here

2380:56

we're going to be also providing a size

2380:58

today like so and finally we also have

2381:01

to provide the disabled prop so I'm

2381:02

going to copy there and place it right

2381:04

here I'm going to store the result of

2381:06

there inside my variable with the name

2381:08

of merged class names and that's going

2381:12

to be set to the St and config and by

2381:14

the way outside from this object and

2381:15

also these parentheses we going to be

2381:17

providing our class names and now that's

2381:20

toally done okay so now let me just send

2381:22

my file here inside this button uh I'm

2381:25

going to just first of all change there

2381:26

to the button because we are going to be

2381:28

using there and for this button label

2381:31

let me just change that to button right

2381:32

here like so and for this button label

2381:35

it's going to accept the children so now

2381:37

for the props we are going to be

2381:39

restructuring all of them and now let me

2381:40

just provide like props and for the

2381:42

class names we are going to be providing

2381:44

our merged class names and for the

2381:47

disabled State we are going to be

2381:48

providing that disabled State and now

2381:50

let me just sa my file and this is how

2381:52

we are going to be defining our button

2381:54

component by using class variance

2381:56

Authority uh tellin CSS tellin merge

2381:59

reactjs and typescript so now let me

2382:01

just close there and now we are going to

2382:03

be testing our component by using the

2382:05

story book so now let me just zoom in a

2382:07

bit and now inside this SRC folder uh

2382:09

I'm going to create a new folder with

2382:11

the name of stories and let's just

2382:13

Define our button story right here so

2382:14

I'm going to just uh create a new file

2382:16

with the name of button. stories. DSX

2382:19

and now inside there let's just Define

2382:21

our first story so the first thing that

2382:23

I want to do is that I want to import

2382:25

the type of meta and also the story

2382:29

object okay which we're going to be

2382:31

using right now from where from the

2382:32

story book not addons but from the react

2382:35

JS okay so now let me just sa my file

2382:38

and it should be upper case m not a

2382:40

lower case and now we are going to be

2382:42

also importing our button so that we can

2382:44

test there that's toally done and now we

2382:47

have to Define our meta so I'll just use

2382:49

like meta and I'm going to also in

2382:51

like So So Meta and the type of button

2382:55

because we now creating our button and

2382:56

this can be equals to this object so we

2382:58

have to provide the title so which will

2383:00

be our components and then button and

2383:04

now we also have to provide the

2383:05

component so the component is that

2383:08

component which we already grabb let me

2383:10

just even copy the name of there God

2383:11

damn it there we go and now let me

2383:13

provide a comma there for the parameters

2383:16

we going to be setting the to toally

2383:18

lout let's just put our lout and store

2383:21

centered like so and I'm going to also

2383:23

provide the tags so for these tags uh we

2383:27

are going to be also using the auto dos

2383:29

now let me just save my file and I'm

2383:31

going to hover over there I'm going to

2383:33

hover over there quick fix there and add

2383:35

there to the workspace settings so it

2383:37

will not gives us that error again and

2383:38

again now underneath that we're going to

2383:40

be exporting our default meta that's

2383:42

only done about the meta but now we have

2383:44

to Define our type and that's going to

2383:46

be set to a story and now let's just set

2383:48

there to like story object and here we

2383:51

are going to be providing a type of meta

2383:53

and close there now let me just save my

2383:55

file and now we are going to be

2383:57

providing our actual stories forward

2383:59

button so I'll just use like export cons

2384:02

primary and primary button will look

2384:04

something like this so I'm going to

2384:05

annotate there with this story first of

2384:08

all and it's going to be set to this

2384:09

object we have to provide the arcs and

2384:11

inside these arcs we have to provide the

2384:13

variant and the variant will be set to

2384:15

primary which is also a default value if

2384:19

you want to provide you totally can but

2384:20

if you don't want to proide there you

2384:22

don't have to so for the size I'm going

2384:24

to set there to medium and for the

2384:26

children I'll just put like primary

2384:28

button or something like that now let me

2384:30

save my file and I'm going to be using

2384:32

mpm run story book so that we can test

2384:35

this out story book and this is how my

2384:37

button looks like but I'm wondering why

2384:40

the classes are not provided if I click

2384:42

on there why is the classes not working

2384:46

you know what let me just go to index.

2384:49

CSS

2384:51

oh that's because we have to go in there

2384:54

to the story and then we have to go to

2384:55

the preview and now we are going to be

2384:57

importing over let's just go to the SRC

2385:00

folder and inside there we have our

2385:02

index. CS uh CSS and now let me just

2385:05

save my file refresh this out and here

2385:07

you can see where styling is now working

2385:09

the way we expect him to work if I click

2385:11

on the secondary so it's going to gives

2385:12

us this styling I can also get like the

2385:14

smaller button the medium button or the

2385:16

larger button I can totally change the

2385:19

content of the Buton I can do whatever I

2385:22

want to do with that so if I want to

2385:23

make that like disable if I click on the

2385:26

set Boolean and change that to true and

2385:29

here you can see the cursor is not

2385:31

allowed that's going to be my primary

2385:33

Button as you can see that right here so

2385:35

now let me just refresh there that's

2385:37

going to be my primary button let's just

2385:40

set there to

2385:41

false and I guess that's going to be

2385:43

fine now let me go ahead and go to my

2385:45

story book once again and I'm going to

2385:46

just create a few more stories now

2385:48

underneath there I'll just use like a

2385:50

export con secondary and I'm going to

2385:53

also annotate with my story it's going

2385:56

to be equals to this object we have to

2385:58

provide our arguments inside there the

2386:00

variant will be set to secondary and we

2386:02

also have to provide the size and the

2386:04

size will be set to totally medium and

2386:07

also for the children I'll say like

2386:09

secondary button component or something

2386:11

like that now let me just save my file

2386:13

click on the secondary and now we are

2386:15

getting the secondary so this is going

2386:16

to be basically our primary button and

2386:19

this is going to be our secondary button

2386:21

right here which is also looking cool

2386:23

now we're going to be taking care of the

2386:25

small button so I'll just use like small

2386:27

and provide my story right here and I'll

2386:30

just provide like arguments and for

2386:32

these arguments let's just provide our

2386:33

variance and primary and the size will

2386:37

be set to totally small and the children

2386:40

will say like small button or something

2386:43

like that I'm going to save this file

2386:45

right now click on the small and now we

2386:47

are getting our small button which is a

2386:49

bit smaller than this secondary but

2386:51

right here now let me create two more

2386:53

stories for the large and also for the

2386:55

disabled one so I'll use like large and

2386:59

as a story and here we're going to be

2387:01

passing our arguments and variance will

2387:03

be set to toally primary uh like so

2387:07

let's just say our file for the size

2387:09

we're going to be providing a large size

2387:10

today and for the children this going to

2387:13

be set to large button like so s our

2387:16

file click on the large and now we are

2387:18

getting our large button and finally we

2387:21

have to create another story for the

2387:23

disable button so I'll just use like

2387:24

disable and annotate there with the

2387:26

story and inside they provide our

2387:28

arguments and here we're going to be

2387:30

passing our variant and variant will be

2387:32

set to primary like so and the size will

2387:36

be set to totally medium and I'm going

2387:38

to also put disable and set the to true

2387:41

and the children will be set to disable

2387:44

uh button like so now let me just save

2387:46

my file and now if I click on the

2387:47

disable and as you can see this is a

2387:49

disabled button so the cursor is not

2387:52

allowed so this is how we are going to

2387:53

be creating our actual component this is

2387:56

how we are going to be visually testing

2387:58

our component but now if you want to

2388:00

like actually write a test cases for

2388:02

this component so we have to make a

2388:04

setup for there so we are going to be

2388:05

installing like we test and also the

2388:07

react testing library to test okay so

2388:10

now we are going to be installing the

2388:11

react testing library and so on and so

2388:14

forth so now let's just close there and

2388:16

I'm going to also stop there for a few

2388:19

seconds because now we are about to

2388:20

install a lot of things so the first

2388:22

thing that we have to do is that we have

2388:23

to install the what do we call it the

2388:26

vest as a Dev dependency so it's going

2388:28

to take a while to install there but we

2388:30

are going to wait for it

2388:33

baby okay it's taking a lot of uh so now

2388:36

that's totally done now we are going to

2388:38

be installing another package as a Dev

2388:40

dependency which is a testing library

2388:43

and then reactjs and also uh come on

2388:46

testing library and then user event okay

2388:51

so let's just proide them that's toally

2388:53

done we also have to install as a

2388:56

dependency the JS Dom and we also have

2388:58

to install what we call it npmi then DD

2389:02

at testing library and then just Dom

2389:05

come on just D install there now we are

2389:09

going to be installing a types for this

2389:10

so I'll use like npmi and then DD and

2389:13

add types for what for the just and also

2389:16

for testing library and then just come

2389:19

on just Dom oh we already installed the

2389:22

just Dom so it's going to overr right

2389:24

there basically and now okay it's taking

2389:27

a bit of time but now we have to install

2389:29

something called the testing Library L

2389:32

IB r a r y and then just a Dom now the

2389:35

next thing that we have to do is that we

2389:36

have to go to the root and inside this

2389:38

route we have to create a new file with

2389:40

the name of vest. config

2389:43

dots okay once we do that here inside

2389:46

there we have to provide a bit of

2389:47

configuration forward vest so I'll just

2389:50

first of all will import something

2389:51

called the Define config from the rollup

2389:54

not from the from the vest come on from

2389:57

the vest and then config and now

2390:00

underneath we going to be also importing

2390:02

rejs from where from the vest and we

2390:05

have to install this package so we're

2390:07

going to be installing the from the wejs

2390:09

and then plugin react I'm going to copy

2390:12

the name of there like so I'm going to

2390:14

open my terminal and use npmi and then

2390:17

wejs plugin reactjs so while let inst

2390:20

calling now we have to export default

2390:23

that Define config and here inside that

2390:26

we're going to be providing our plugins

2390:28

so we want to just use the reactj okay

2390:30

so I'm going to just execute there sa my

2390:32

file provide a comma there and now we

2390:34

are going to be providing our test cases

2390:36

so we want to use the environment e n v

2390:38

i r o m e n t so we want to use the

2390:40

environment which will be our JS Dom and

2390:43

we also want to provide the globals and

2390:45

which will be set to True come on true

2390:48

there we go and we're going to be also

2390:49

providing a set of files and which will

2390:51

be set to SRC test and setup. yes I'm

2390:54

going to save this file right now now we

2390:56

have to go into this SRC folder and

2390:58

inside there we are going to be creating

2391:00

a new folder with the name of test and

2391:02

inside there we are going to be creating

2391:04

a new file with the name of setup okay

2391:06

so I'll use like setup. TS and here we

2391:09

have to import a few things so I'll just

2391:10

import first of all the testing library

2391:13

and we are going to be getting there

2391:14

from the Gom and also we have to import

2391:17

something called the testing library

2391:20

from the the react JS so now let me just

2391:22

save this file right now that's only

2391:23

done I'm going to also go into my

2391:25

package.json file right now and we have

2391:28

to create our script for our test so

2391:31

what I'm going to do is that I'm going

2391:32

to just write like uh test and then UI

2391:35

and now we have to just write like vest

2391:37

and then d d you want not three dashes

2391:40

but only two dashes so now let me just

2391:42

save my file close there and I'm going

2391:44

to also go into my ts config file uh I

2391:48

mean like TS config.js Json file file

2391:50

and here we have to specify our types so

2391:53

let's just write like types and types

2391:55

will be set to retest and then Global

2391:59

globals like so g l o b l s there we go

2392:02

and here we also have to provide our

2392:04

comma Ser our file and then was it about

2392:07

the entire setup but I'm going to open

2392:08

my terminal right now and I'm going to

2392:10

use like npm run test and then UI it's

2392:13

going to ask us to install the vsi I'm

2392:16

going to just write like y so it's going

2392:17

to install the vsi right here and now we

2392:20

have rerun this command one more time

2392:21

and here you can see we're not providing

2392:23

any test so we have zero test so we have

2392:26

zero pass test zero fail test and zero

2392:29

total test okay so going to be creating

2392:32

our test file for our button component

2392:34

so now our setup is successfully done

2392:36

and now we are going to be writing a

2392:37

unit test for our component so what I'm

2392:40

going to do is that first of all I want

2392:42

to go into my G ignore file and we're

2392:44

going to be ignoring the what do we call

2392:46

it the this folder we would also need to

2392:47

ignore the rollup k a c a c e there we

2392:53

go and also I guess that's going to be

2392:55

fine so now let me just save my file and

2392:56

that's really done I'm going to also go

2392:58

into my test folder and inside there

2393:01

we're going to be creating yet another

2393:02

folder for the components and let's just

2393:04

use our button. test. TSX and now we are

2393:08

going to be writing a test cases for our

2393:10

button component so the first thing that

2393:11

I want to do is that I want to import

2393:12

react from the reactjs you would also

2393:15

need to import the render and also the

2393:16

screen and fire you went from where from

2393:19

the test library reactjs now let me just

2393:22

save this file right now you would also

2393:24

have to import the button component so

2393:26

we can test it and also now let me just

2393:28

use the describe and for the label I'll

2393:30

just write like button component and

2393:32

here let's just remove that second from

2393:34

there and now let me just save my file

2393:36

right now and here I'm going to just say

2393:38

like it should come on I don't mean to

2393:40

import that but it should come on it

2393:43

should render a button with default

2393:46

Styles like so and here we have to

2393:48

provide our Arrow function so that we

2393:50

can test that so I'll just pass my arrow

2393:52

function right here pass my render

2393:54

component and here we have to render our

2393:56

Buton component to the virtual do now

2393:59

say like click me and that's going to be

2394:00

fine and now underneath there why we

2394:02

getting this error that's because we

2394:04

have to make the disabl totally optional

2394:08

so not here but here I'm going to also

2394:10

have to just Mark the as disabled

2394:12

optional and that's totally done now

2394:14

underneath we are going to be getting

2394:15

our actual button so I'll just use like

2394:17

screen. get by R and here let's just

2394:19

space our button inside there because we

2394:21

are now testing our button component and

2394:23

I'm going to also store that inside the

2394:25

button variable like so and that's

2394:27

already done now let's just provide our

2394:29

expectation first of all so expect the

2394:31

button to have the text content of Click

2394:35

me and now let me just save my file I'm

2394:37

going to also provide a few more

2394:39

expectation for the default class names

2394:41

so whether they have a default class

2394:43

names or not so I'll just put it like

2394:45

expect and I'm going to pass my button

2394:46

inside there and we want to check like

2394:48

to have the class names of background

2394:51

toly blue of 500 I'm going to also

2394:53

duplicate that like a few times so

2394:55

change that to like background totally

2394:57

white and also change this one to

2394:59

background B and I'm going to also

2395:02

remove that last one from there that's

2395:04

all done now here we also have to

2395:06

provide another expectation for our

2395:08

button and we want that to initially not

2395:11

be disabled by default so I'll just

2395:12

write like not to be disabled and I'm

2395:15

going to execute this so as soon as I do

2395:17

that and sa my file now I'm going to

2395:19

have to run there but why in the world

2395:21

we are not getting this error okay so it

2395:24

should render a prop I'm going to go

2395:26

into my B component and search for the

2395:29

Bas class and it should be text base and

2395:32

I'm providing a BG uh base it should be

2395:35

a text base now let me just save my file

2395:38

and hopefully it will work but now this

2395:41

one is failing but because this one

2395:43

should be text as well and now all of

2395:45

our test are successfully passing but

2395:47

I'm going to have to quit there and I'm

2395:49

going to use like npm run test UI

2395:51

because we want to test that inside the

2395:53

U and now let me just refresh there so

2395:55

here you can see we have one p test and

2395:57

we even have just a total of one test so

2396:00

now our test is successfully passing and

2396:02

that's something that we want now let me

2396:04

just close there and also I want to open

2396:06

my story book as well because later we

2396:08

are going to be also testing our

2396:10

components so I'm going to use like npm

2396:12

run story book so both uh story book and

2396:15

also a test are successfully running so

2396:17

I'm going to have to copy there from

2396:19

there

2396:20

now let me just place it right here hit

2396:22

enter and here you can see this is how

2396:24

we are going to be testing our

2396:25

components visually and this is how we

2396:27

are going to be testing or unit testing

2396:29

our components so that was our first

2396:31

test so now let me just collapse there

2396:33

now I'm going to write another unit so

2396:35

we have to use the it once again and it

2396:38

should render a button with secondary

2396:41

variant okay so here we are going to be

2396:43

also passing our variants today so what

2396:45

I'm going to do is that I'm going to

2396:46

just render my component once again

2396:49

close there and God damn it execute

2396:53

there and and past my B component which

2396:55

will say like click me and also we are

2396:57

going to be passing a variance of

2396:59

secondary to there now let me just sa my

2397:01

file and underneath there we're going to

2397:03

be still getting our button component

2397:05

which will be a screen. get by roll and

2397:08

pass our button inside there save this

2397:10

file right now and here let's just pass

2397:12

our expectation today so pass our button

2397:14

to have the class names of background

2397:17

totally gray of 500 I'm going to also

2397:20

duplicate there and the text are totally

2397:22

black to there because now we are

2397:24

testing a secondary variant so my file

2397:27

and now let me just run this so here you

2397:28

can see we have two test cases and both

2397:31

of them are now successfully passing so

2397:32

I'm going to also hide there and the

2397:34

next thing that we have to do is that we

2397:35

have for a test cases for the small

2397:37

button so I'll just use like it render

2397:40

come on render a small or a button with

2397:43

a small size okay so I'll just pass my

2397:46

arrow function and here inside there

2397:49

let's just render or component by using

2397:51

that button and it's going to say like

2397:53

click me I'm going to also paste the

2397:55

size of totally small today now we have

2397:58

to use like screen dot get by roll once

2398:00

again and we're going to be searching

2398:01

for button and now let's store the

2398:03

inside the button variable and now let

2398:05

me provide my expectation of button to

2398:08

have the class name of text only small

2398:11

and now let me just save this file test

2398:13

this out so here you can see the small

2398:15

size button is also working I'm going to

2398:16

collapse that right here and now let's

2398:19

another test case so you know I'm going

2398:20

to just duplicate there because it's

2398:23

wasting a lot of our time so I'm going

2398:25

to just duplicate there and change this

2398:28

to it should render a button with large

2398:33

button with large size so we now getting

2398:36

our button and now here for our

2398:38

expectation I'm going to just change

2398:40

there to like LG for the larger size and

2398:42

our test is failing because something is

2398:45

not right so here you can see you now

2398:49

already a size of small medium and

2398:52

large but

2398:55

here we are providing a text of totally

2398:58

large txt dlg this because we are

2399:02

providing a small it should be a large

2399:04

God damn it now let me just sell my file

2399:06

and run there and our test is now

2399:08

successfully passing so I'm going to

2399:10

duplicate there yet another time

2399:12

duplicate there and change this test to

2399:17

the disabled test so I'm going to change

2399:19

there it should render a

2399:22

disable button and here we're going to

2399:24

be placing a disabled prop right here so

2399:27

place a disable and set that to True

2399:30

like so and we are now getting our

2399:32

button but now we have to remove that

2399:34

and here we have to proide our

2399:35

expectation for the button and we want

2399:37

it to be disabled and execute it now

2399:40

underneath we going to be also providing

2399:41

yet another expectation for the button

2399:43

once again and we want that to have the

2399:46

class names of background to gray uh

2399:49

Gray of 300 and I'm going to also

2399:51

duplicate there once again and gray of

2399:53

600 but it should be for the text so now

2399:55

let me just save my file and our test is

2399:57

now successfully passing and which means

2399:59

like everything is working the way we

2400:01

expect them to work I'm going to

2400:02

collapse there now we are going to be

2400:04

testing like whether we can provide our

2400:06

own custom styling or not so can we

2400:09

merge them or not so like it should

2400:11

merge custom class name with default

2400:15

Styles okay so here we're going to be

2400:17

passing our Arrow function once again

2400:19

and and I'm going to first of all render

2400:21

uh my component like so execute it it's

2400:24

going to say like click me lower case me

2400:27

and I'm going to also provide my own

2400:29

class names like custom classes or

2400:31

something like that and now underneath

2400:33

there we're going to be getting our

2400:34

button so use like screen get by uh come

2400:38

on get by R and here we have to pass our

2400:41

button inside there and I'm going to be

2400:42

using like button and it's going to be

2400:44

equals to this get by roll button right

2400:45

here so I'm going to paste my

2400:48

expectation and we are checking for the

2400:50

button and we want there to have the

2400:52

class names of custom class like so and

2400:56

now underneath there we also want to

2400:57

provide yet another expectation for the

2400:59

button and to have the class names of

2401:02

background totally blue of 500 now let

2401:05

me just save there now let's just

2401:06

refresh there so here you can see all of

2401:08

our test are now successfully passing

2401:10

which means like we can also specify our

2401:12

own custom styling forward button okay

2401:15

so like if somebody wants to add like

2401:16

new styling to the button they totally

2401:18

can and now finally we're going to be

2401:20

also taking care of the children prop so

2401:23

I'll just uh provide like it should

2401:25

render a button or it should render

2401:28

button with correct children text and

2401:32

here I'm going to pass my arrow function

2401:35

render my component and it's going to

2401:37

say like click or not click me but

2401:39

submit would be fine because we are now

2401:41

testing like we can place anything to

2401:43

this button not just a click new or

2401:45

something like that okay so I'll just

2401:47

get my button by using a screen get by

2401:50

roll and pass my button inside there and

2401:53

here we have to pass our expectation

2401:55

like button and that should have the

2401:58

text content of submit which we now

2402:01

passing as a content right here for this

2402:03

children check this out so here you can

2402:05

see all of our test are now successfully

2402:07

passing so this is how we are going to

2402:09

be creating our component this is how we

2402:11

are going to be visually seeing that

2402:13

component the result of that component

2402:15

and this is how we are going to be

2402:16

writing a unit test forward component

2402:18

okay so that was a about the button

2402:20

component now we are going to be

2402:21

creating yet another component for the

2402:23

accordion so I'm going to just uh go to

2402:26

my components folder and inside there we

2402:28

going to be defining yet another folder

2402:29

with the name of c r d i o n accordian

2402:33

and inside there we are going to be

2402:34

creating three files the first one will

2402:36

be for the index. TSX and then the next

2402:39

file which we are going to be creating

2402:40

will be for the accordion. TSX and we're

2402:43

going to be also creating one more file

2402:45

for the accordian section so a c r e o n

2402:49

Accord in section. DX okay so now let's

2402:52

just start from the first one which is

2402:54

accordian okay so I'm going to start

2402:56

from the first one and then we are going

2402:58

to be taking care of the rest of them so

2403:00

what I'm going to do is that I'm going

2403:01

to import my react JS and also the react

2403:06

node from where from the react JS okay

2403:09

so now let's just do the SMI file you

2403:11

would also need to import the CVA from

2403:13

the class variance Authority and we

2403:15

would also need the tww merge from the

2403:18

tailin merge Okay so so next we have to

2403:20

Define our component by using the rafc

2403:23

and now this component will take a few

2403:25

props so it's going to take the children

2403:27

it's going to also take the variant v a

2403:29

r i n t and can also take the size so we

2403:32

are going to be annotating there by

2403:33

using the accordian props and I'm going

2403:36

to copy a name of that and Define my

2403:37

interface right here so I'm going to

2403:39

just write like interface with the name

2403:40

of accordian props it's going to take

2403:42

the children we have to annotate there

2403:44

with the react node which we are now

2403:46

importing and we should also provide the

2403:48

variant which will be totally optional

2403:51

and the default value we going to be

2403:52

providing like default and also the

2403:56

bordered bordered and also we going to

2403:59

be providing a size for that and that's

2404:00

going to be totally optional we going to

2404:02

be setting there to either small or

2404:04

large size of accordian now let me just

2404:06

save my file and that's to it about the

2404:08

component but now we have to specify our

2404:11

class variance authorities so I'll use

2404:13

that accordian style is going to be

2404:15

equals to the

2404:17

CVA and here we have to test like the

2404:19

base classes of space on the y axis will

2404:21

be set to two and we also have to

2404:23

specify our own class variance Authority

2404:25

object so inside that we going to be

2404:27

testing our variant V NTS and inside

2404:31

this variance we have to specify a

2404:33

specific variation for this component so

2404:36

I'll use like variant and here we have

2404:38

to specify the default and the default

2404:39

value will be set to background forly

2404:41

white and we're going to be also

2404:43

providing a border and the Border will

2404:45

be border and then border come on Border

2404:48

gray of 300 100 and also call rounded

2404:51

large this can be it for the variant we

2404:54

also have to specify the size and the

2404:56

size will be set to small and for the

2404:58

smaller size we want to set the text to

2405:00

totally small and also for the large

2405:02

size we want to set the text to be

2405:04

totally large and now underneath this

2405:06

size we are going to be also providing a

2405:08

default variance but it should be

2405:09

underneath this one okay so we have to

2405:12

provide our default variance and inside

2405:14

there let's just space the default value

2405:16

for the variant which will be set to a

2405:17

default and also we are going be passing

2405:20

a size and the size will be set to

2405:21

totally large then said about the

2405:23

accordian style I'm going to copy a name

2405:25

of the laps there now we have to go into

2405:28

our jsx and remove that from there and

2405:30

I'm going to only pass my children's

2405:32

right here which we're now taking as a

2405:34

props and here for the class names we're

2405:37

going to be providing our come on tww

2405:40

merge first of all and here we have to

2405:41

pass our accordian Styles and now we are

2405:43

going to be passing our variant and also

2405:46

the size which you're now taking is a

2405:48

props from this compound that's all done

2405:50

about the accordion next up we have to

2405:52

go into what do we call it or accordion

2405:55

section component now let's just start

2405:57

working on there I'm going to go ahead

2405:58

and import the CVI from the class

2406:00

variance Authority I'm going to also

2406:02

import the reactjs and the react node if

2406:06

I can get there today oh we can so I'm

2406:08

going to have to write like uh react

2406:10

node and also we are going to be using

2406:12

the use St from where from the reactjs

2406:14

I'm going to save this file right now

2406:16

push that to the top and now we also

2406:18

have to import the tww merge from the

2406:20

Tailwind merge now we are going to be

2406:22

defining our uh component right here and

2406:24

our component will take a few props so

2406:26

we are going to be providing the

2406:28

children

2406:29

obviously and also we are going to be

2406:31

placing the title and the variant like

2406:33

so now let me annotate this component by

2406:36

using the accordian

2406:39

section n section props I'm going to

2406:42

copy the name of there and create my

2406:44

interface right here with the name of

2406:45

accordian section uh props and inside

2406:48

there we have to pass our children and

2406:49

which will be coming from the react node

2406:52

I'm going to also provide the title and

2406:54

title will be set to toly string we're

2406:56

going to be also providing a variant v a

2406:58

r i n this can be set to either a

2407:01

default value or a bordered value so now

2407:04

let me just save my file and I'm going

2407:06

to also make the variant totally

2407:07

optional like if you want to provide

2407:09

there you can if you don't want to

2407:10

provide there you don't have to now we

2407:12

are going to be using the CVA or the

2407:15

class variance Authority so that we can

2407:17

get over style so I'm going to use like

2407:19

con and then

2407:20

accordian section come on Section Styles

2407:24

can be equals to the CVA and P for the

2407:27

base classes we're going to be passing

2407:28

like pairing all around of four and here

2407:31

inside we have to pass our variance v a

2407:33

r i NTS and inside these variants we are

2407:36

going to be passing a specific variant

2407:39

and we are going to be also providing a

2407:40

default one so for the default we are

2407:42

going to be changing the background to

2407:44

toally gray of 100 and also we are going

2407:47

to be providing the bordered one so for

2407:49

the Border we are going to be providing

2407:50

like border of Border only for the

2407:52

bottom and Border color will be set to

2407:55

gray of 300 like so okay so now

2407:58

underneath I mean like underneath this

2408:00

one we're going to be also providing a

2408:01

default variance today and here we have

2408:04

to place our variant and the default

2408:05

will be set to default now let me just

2408:08

save my file and I'm going to also copy

2408:10

this name and collapse it right here I'm

2408:12

going to go into my jsx and remove that

2408:14

from there and here inside this jsx

2408:17

we're going to be using the H2 and P my

2408:19

title inside there and also for the

2408:22

classes I'm going to specify a few

2408:24

classes like Flex and justify will be

2408:26

set to like between also the cursor will

2408:28

be set to pointer and here we are going

2408:31

to be also passing like whenever

2408:32

somebody clicks on this accordian in

2408:34

this situation we're going to be fting

2408:36

this function which is a set is open and

2408:39

not is open like so and which we're

2408:42

going to be creating in a few seconds

2408:44

you have to just bear with me and you

2408:46

know all this is create there right now

2408:47

I'm going to go there and here we have

2408:49

to first of all Define our state so I'll

2408:51

use like is open and then set is open

2408:55

it's going to be equals to the use State

2408:56

and the initial value will be set to

2408:58

false semi file that's to done now we

2409:01

also want to wrap that with another D

2409:03

I'm going to cut that from there and I'm

2409:05

going to put that right here and inside

2409:08

this div you can even change that to a

2409:09

section or something like that we're

2409:11

going to be using our TN merge so I'll

2409:13

use like tww merge and place my

2409:15

accordian section right here and here we

2409:18

are going to be only taking those

2409:19

variants which we are now providing for

2409:21

our accordian section and we are going

2409:23

to be sending that to our accordian

2409:26

section Styles now finally we are going

2409:28

to be also providing a spin here and

2409:30

which will just render a few uh like

2409:33

icons so if our state is op so in this

2409:36

situation you want to use this minus or

2409:38

Dash whatever you want to call that but

2409:40

if that's not the case we are going to

2409:41

be changing that to this plus icon of

2409:44

course you can use the react icon

2409:46

libraries but in my case I'm not going

2409:48

to so if this is open and then you want

2409:51

to use this uh UI word here so I'm going

2409:54

to just render this UI which will be

2409:57

just a simple div and here we have to

2409:59

just pass our children inside there okay

2410:01

so I'm going to also P the class names

2410:03

of pairing for the top of two and that's

2410:05

going to be it but if that's not the

2410:07

case we are not going to be showing

2410:08

nothing at all so this is how we are

2410:10

going to be building our components so

2410:12

that's our accordian section component

2410:15

and that's our accordian component so

2410:17

now let's just combine both of them

2410:19

inside this index. TSX file so what I'm

2410:22

going to do is that I'm going to export

2410:23

default as the accordian section first

2410:26

of all from where from the this is go to

2410:29

the top from the accordion section and

2410:31

we're going to be also exporting default

2410:33

as the accordion c r d i o n from where

2410:38

from let's just go into the accordian

2410:39

component and save my file so this is

2410:42

how we are going to be creating our

2410:43

accordian component the next thing that

2410:45

we have to do is that we have to

2410:46

visually test there so that we can see

2410:48

there by using the story book okay so

2410:51

now let's create our accordian stories

2410:53

file so I'll just use like accordian

2410:56

stories. TSX and now let's just visually

2411:00

test our component so I'll just import

2411:02

react Js from the react you would also

2411:04

need to import the type of meta and also

2411:07

story object obj from where from the

2411:11

story book and then we want to get that

2411:13

from the Rea J you would also need to

2411:16

import our accordian component uh so

2411:18

that we can test we would also need the

2411:20

accordian section component so we are

2411:22

going to be also testing there okay so

2411:24

now we have to create our meta and now

2411:26

let me just annotate there with the meta

2411:28

and the type of accordion like so and

2411:31

I'm going to also close there so inside

2411:34

there we are going to be first of all

2411:35

providing the title and the title will

2411:36

be still going into the components

2411:39

folder and you want to pass our

2411:40

accordian there okay so here we have to

2411:42

just pass for a component and you want

2411:44

to test the accordian component a comma

2411:47

there and we are going to be also

2411:48

providing perimeters so for the layout

2411:52

uh layout you want to set there to

2411:54

centered and I'm going to save this file

2411:56

right now but it shouldn't be array it

2411:59

should be object like so I'm going to

2412:02

put a comma there and for the text we're

2412:05

going to be only passing this Auto a o t

2412:08

a GS auto tags or not auto tags but

2412:13

autod dos there we go and this is how we

2412:15

are going to be defining our meta but we

2412:17

are going to be also exporting there by

2412:19

using the same meta I'm going to also

2412:21

provide a type of story and going be

2412:23

equals to the story object and here we

2412:25

have to pass our type of meta and close

2412:28

there now it's time to Define our first

2412:30

story so what I'm going to do is that

2412:32

I'm going to just write like cons

2412:34

default default like so and we're going

2412:36

to be annotating there by using the

2412:38

story provide our ARS inside there and

2412:40

use our children and for this children

2412:43

we are going to be providing our UI so

2412:45

first of all let me just provide my Rea

2412:47

fragments and I'll use like accordian

2412:49

section right here in this case and for

2412:52

this accordian section we are going to

2412:53

be providing some sort of a title today

2412:55

which will say like section one and here

2412:58

inside this accordian section we're

2412:59

going to be providing a paragraph which

2413:01

will say like content or come on four or

2413:05

just a four section one I'm going to

2413:09

also make as uppercase and now let me

2413:11

just duplicate and now let me just

2413:12

duplicate there a few times so I'm going

2413:15

to change that to two and I'm going to

2413:16

also change this one to two and change

2413:19

this one to three and also the paragraph

2413:22

to three now let me just save my file

2413:24

and we are already running there right

2413:27

here so I'm going to have to quit that

2413:29

and use my npm run story book once again

2413:32

uh and now we are getting our accordians

2413:34

right here so we have this accordian and

2413:37

we can also test this out right here so

2413:39

we have the Border one if you set that

2413:41

to default that's going to be the

2413:42

default look if you click on there so

2413:44

it's going to show us this content if

2413:46

you click on there once again so it's

2413:47

going to hide there and this is how our

2413:49

border component will look like this is

2413:51

how the smaller screen will look like

2413:53

and this is how the larger will look

2413:54

like let me just set that to default and

2413:57

that's our default story right here uh

2414:00

no I'm going to just click on there and

2414:02

that's looking cool anyways so now let's

2414:04

just create a stories for the other ones

2414:06

I'm going to collapse them and I'm going

2414:08

to define a story for the Border one so

2414:10

I'll use like cons bordered and here

2414:13

let's just annotate with story this

2414:16

going to be equals to this object and

2414:17

proide my arguments in side there Prov

2414:20

the variant and the variant will be set

2414:21

to border and here let me just put a

2414:24

comma and children and here we are going

2414:26

to be passing or fragments or react

2414:29

fragments now let me call my accordian

2414:31

section component and it's going to take

2414:33

the title so I'll just pass like I don't

2414:35

know maybe section one or something like

2414:37

that we're going to be also passing our

2414:38

variants so I'll just set that to like

2414:40

border and inside there we're going to

2414:42

be using a paragraph which will say like

2414:44

content content for section one come on

2414:49

section one I'm going to save this file

2414:51

right now duplicate there a few times so

2414:54

this one will be a section two still

2414:56

border and also content for the section

2414:59

two content for the section three and

2415:01

content for the section three now let me

2415:03

just check this out so here you can see

2415:05

we now getting this border uh accordian

2415:07

component right here and you can totally

2415:10

customize there if you wanted to okay so

2415:12

that's our second story for the Border

2415:15

one now we're going to be creating

2415:16

another story for the smaller one so on

2415:19

small story and this going be equals to

2415:22

this object provide my arguments inside

2415:24

there and the size will be set to

2415:26

totally small and here let's space our

2415:29

children inside there and inside these

2415:31

childrens we are going to be providing

2415:33

our fragments and I'm going to say like

2415:35

a cordian section and here I'm going to

2415:37

also paste the title of like section one

2415:40

or something or what is HTML would be F

2415:43

like oh you know what section section

2415:45

one was fine I don't want to waste your

2415:48

time and here a space or paragraph which

2415:50

will say like content for the section

2415:52

for the section one and I'm going to

2415:55

duplicate that a few times I guess one

2415:57

time would be fine and here let me just

2415:59

change that to two and two right here

2416:02

semi file and now if I check this out so

2416:04

these are going to be basically my small

2416:07

content but I'm going to also duplicate

2416:09

there once again change there to three

2416:12

and change this one to three as well so

2416:15

this is how the smaller will look like

2416:16

this is how the Border will look like

2416:18

and that's default one now we are going

2416:20

to be also taking care of the another

2416:22

story which will be the last story and

2416:25

large story so we're going to be using

2416:27

like export con large and provide or

2416:31

annotate with the story not sory and

2416:34

here let's just SP our ARS inside there

2416:36

and for my size and the size will be set

2416:38

to large we're going to be also passing

2416:41

a children and for these children let's

2416:43

just space our react fragments and I'm

2416:45

going to say like a cordian section

2416:47

close the P my title inside then and I'm

2416:50

going to select section one inside this

2416:52

accordian section I'm going to place my

2416:54

paragraph which will select content for

2416:56

section one and I'm going to also

2416:59

duplicate there like a few times so this

2417:01

one will be content for the section two

2417:04

and this one will be content for the

2417:06

section three like so I'm going to save

2417:08

this file right now if I click on this

2417:10

large one so it's going to gives us this

2417:12

large one and these are the smaller ones

2417:15

right here but yeah that's totally

2417:18

correct so this is how we're going to be

2417:19

visually testing our accordian component

2417:22

next we have to write a unit test for

2417:24

our accordian component okay so now

2417:26

let's write a unit test for our

2417:28

component so I'm going to go into the

2417:30

test components folder once again and

2417:32

here we're going to be creating our

2417:34

accordion. test. TSX component or file

2417:38

rather and now we are going to be

2417:39

importing react from the reactjs we also

2417:41

have to import the render and also the

2417:44

screen fire event from where from the

2417:47

testing Library uh reactjs now let me

2417:50

just save this file we also have to

2417:52

import the

2417:53

accordian not the accordian plugin but a

2417:56

r di n accordion and the accordion

2417:59

section so that we can test both of them

2418:01

now we are going to be describing so

2418:04

let's just use there okay so we have to

2418:06

write there manually so accordian

2418:08

component that's going to be the message

2418:10

we also have to P our callback function

2418:12

today and here we are going to be using

2418:15

uh like it should or it renders

2418:17

accordian correctly or it should render

2418:21

a cordion it should uh render cians

2418:26

correctly now we're going to be passing

2418:28

our call back function today and here

2418:30

inside there we are going to be first of

2418:32

all using our render method so let's

2418:35

just use the render and inside this

2418:37

render method we are going to be

2418:38

rendering our accordian component what

2418:40

am I doing today God damn it what the

2418:42

hell is wrong with me accordian there we

2418:44

go and now let me just close there so

2418:46

inside there we are going to be also

2418:48

proving accordion section and I'm going

2418:50

to also close that here we're going to

2418:52

be pasing the title in section one okay

2418:55

so for this section one let me just pass

2418:57

a paragraph which will say like content

2418:59

for section one and now let me just save

2419:02

there or you know let me just make the

2419:04

lower case section one there we go now

2419:07

this is looking better now underneath

2419:08

that uh what do we have to do we have to

2419:10

provide our expectation so let me just

2419:12

use like screen. get by text and not

2419:16

test ID but get by text and we're going

2419:19

to be passing a section one we are going

2419:21

to be getting our item by using this

2419:23

section one and we want it to be in the

2419:26

document and I'm going to execute now

2419:28

underneath we're going to be using their

2419:30

expectation once again so let's just use

2419:32

the screen get by text and password

2419:34

content which is the same content I'm

2419:37

going to copy this entire thing from

2419:39

there now let me just place it right

2419:41

here and we want it to not to be in the

2419:46

document now let me just execute this

2419:48

and my file and I'm going to use like

2419:50

npm run uh test UI so it's going to run

2419:54

there and our test is failing I don't

2419:56

know why but we have to figure this out

2419:58

it shouldn't be get by it should be

2420:00

query by text so let's just use a text

2420:04

right here save my file and now our test

2420:07

are now successfully passing check this

2420:09

out let me just refresh there and uh

2420:13

where is that accordian component there

2420:14

we go I'm going to also collapse there

2420:17

so yeah this is totally working the way

2420:18

we expect him to work I'm going to hide

2420:20

there now we have to put yet another one

2420:22

and that's going to be the final one so

2420:24

it should uh come on it should toggle

2420:29

section content visibility v i s i b i l

2420:33

i Ty y there we go and I'm going to also

2420:36

provide my callback function today use

2420:39

my render and here pass my accordian

2420:42

component close there past accordian

2420:44

section also close there like so

2420:49

and we're going to be passing the title

2420:51

so title and we are going to be

2420:54

providing like section one inside there

2420:56

let's space our paragraph content for

2420:58

section one I'm going to save this file

2421:01

right now and now underneath we are

2421:03

going to be using our testing Library

2421:05

fire event and here let's just check

2421:07

like whenever somebody clicks on there

2421:09

in that situation we are going to be

2421:11

first of all getting uh item by using

2421:13

get by text and past like section one

2421:16

we're going to be getting there then

2421:18

next that we have to do is that we have

2421:19

to provide our expectation for that

2421:21

which will be screen get by text and um

2421:24

we have to pass that content like

2421:25

content for section one which is the

2421:29

same content so I'm going to have to

2421:30

copy that from there both of them are

2421:32

totally fine that's why it is now

2421:34

highlighting and we want there to be in

2421:37

the document and now let me just execute

2421:39

there and now underneath there we are

2421:41

going to be providing yet another

2421:43

expectation so basically I'm going to

2421:44

just duplicate there and whenever we

2421:46

click on there once again so then we

2421:48

don't want that so then we want to hide

2421:51

there so like whenever we click on that

2421:53

for the first time we want to show that

2421:55

content but whenever we click on there

2421:57

for the second time then we want to hide

2421:59

there let me just test this out okay so

2422:02

this is uh query by text and now let me

2422:05

just save that and here you can see all

2422:08

of our test are now successfully passing

2422:10

I'm going to expand that right here and

2422:12

yeah this test is also passing which is

2422:14

looking cool okay so that was there

2422:16

about the accordian component like this

2422:18

is how we are going to be building there

2422:20

this is how we are going to be visually

2422:22

testing there and this is how we are

2422:24

going to be writing a unit test for

2422:26

there now let me just close there and

2422:28

now we are going to be creating yet

2422:29

another component which will be for the

2422:31

card so I'm going to first of all create

2422:33

a new folder with name of card and

2422:35

inside there we are going to be creating

2422:36

three I mean like two files in this case

2422:38

so the first file will be for the card.

2422:41

TSX and the second file will be for the

2422:44

index. TSX okay so I'm going to go ahead

2422:47

and go to my card first of all and I'm

2422:49

going to use my rafc save this file and

2422:52

I'm going to go to the top and import

2422:54

the react from the react JS then we also

2422:56

have to import the CVA from the class

2422:58

variance Authority and also the tww

2423:01

merge for from the telin merge now this

2423:03

component should accept a few props so

2423:05

we are going to be destructuring this it

2423:07

should accept the size the Shadow the

2423:10

Border children and also the class name

2423:14

or just a singular class name now we are

2423:16

going to be also annotating there by

2423:18

using our interface so that we don't get

2423:21

those error or those typescript errors

2423:23

so I'll just write like card promps I'm

2423:25

going to copy that from there and let's

2423:27

just Define our interface with the name

2423:28

of card props and inside there let's

2423:30

just provide a size which will be

2423:32

totally optional like if you want to

2423:33

provide there you can but you don't have

2423:36

to so we going to be providing a small

2423:38

size or a medium size uh or the large

2423:43

size okay and now we are going to be

2423:45

also providing a shadow which will be

2423:47

also totally optional so either the

2423:49

shadow will be none or smaller or medium

2423:54

or come on or large so now let me just

2423:57

save that so that's going to be it for

2423:58

the shadow we are going to be also

2424:00

providing a border which will be totally

2424:01

optional so either border none or border

2424:05

solid or border rounded like so and now

2424:08

underneath that we also have to provide

2424:10

the children which will be coming from

2424:12

the react node okay so now let me just

2424:14

hit enter so it's going to also import

2424:16

this react node from the react J now

2424:19

underneath that we also have to provide

2424:20

the optional class names so class name

2424:23

which will be totally optional and this

2424:24

can be set to a string now let me just

2424:26

save my file and that's going to be it

2424:28

for these props and now let's just use

2424:30

our class variance Authority I'm going

2424:31

to Define that right here by using a

2424:33

card Styles and can be equals to the CVA

2424:36

for the class variance Authority so

2424:38

pairing for the all around will be set

2424:40

to four only rounded large and

2424:43

background totally white and Shadow will

2424:45

be set to totally medium now we going to

2424:47

be also providing our object and here we

2424:49

have to place our variants and inside

2424:52

these variants we are going to be first

2424:53

of all providing a size so sizes can be

2424:56

different sizes like small size let's

2424:58

just write like small the size is small

2425:00

so we're going to be providing like

2425:01

width of 64 and also the height will be

2425:04

set to 48 let's just use our our 48

2425:08

right here I'm going to also provide the

2425:09

medium and the medium will be set to

2425:11

width on 8 80 let me just use 80 and the

2425:16

height will be set to 60 but if that's

2425:18

not the case we are going to be also

2425:20

providing a large and the width will be

2425:21

set to 96 and the height will be set to

2425:24

72 like so now let me just save this

2425:27

file and now underneath the size we are

2425:28

going to be also providing a shadow and

2425:31

let's just use like if the shadow is

2425:32

none so we going to be using like Shadow

2425:34

none or if the shadow is small so we're

2425:37

going to be using like Shadow SM for the

2425:40

smaller Shadow or if the shadow is

2425:42

medium so in this situation we are going

2425:43

to be using like Shadow MD for the

2425:45

medium if the shadow is large so we are

2425:47

going to be using Shadow large and now

2425:50

let me just provide my comma there now

2425:52

underneath there we're going to be also

2425:53

providing a border uh yeah just a border

2425:56

like so and here let a space like if the

2425:58

border is none so we're going to be

2426:00

using like border none if the border is

2426:02

sonid so in that situation we are going

2426:03

to be using like it should be solid and

2426:06

border border gray of 300 and I'm going

2426:10

to also provide like rounded and rounded

2426:13

will be set to borderer two and borderer

2426:15

gray of 300 and totally round rounded

2426:18

large now let me just save this file

2426:19

right now and now underneath there we

2426:21

have to use our default variance and

2426:24

inside there I'm going to be providing a

2426:25

default size of medium and I'm going to

2426:28

also provide the shadow of totally

2426:30

medium and I'm going to also provide the

2426:32

border and the Border will be set to

2426:35

solid like so for the default variants

2426:38

that's to done now that we successfully

2426:40

write a code for our class variance

2426:42

Authority now we have to use that inside

2426:44

our jsx so I'm going to just remove that

2426:47

from here and I'm going to render my

2426:49

children inside there and now I'm going

2426:51

to also use the tww merge for the T

2426:53

merge and here we're going to be passing

2426:55

our card Styles so it's going to take

2426:57

those props like size and also the

2426:59

Shadow and also the border and we are

2427:01

going to be also providing our class

2427:03

names to there okay so I'll just use

2427:06

like con merged class names this going

2427:09

to be equals to this tww and it should

2427:11

be just a class name singular and now

2427:14

I'm going to copy the name of the go to

2427:16

my class names and here we're going to

2427:18

to be providing our class names remove

2427:19

there and paste my merge class names and

2427:22

that's going to be here now let me just

2427:23

save my file and this is how we are

2427:25

going to be creating or uh card

2427:27

component and this is not going to be

2427:29

the most beautiful looking card

2427:30

component but yeah if you want to change

2427:32

the styling of there you to you can but

2427:34

you don't have to now let me go ahead

2427:36

and go to my index.ts TSX file and I'm

2427:40

going to be exporting there by using

2427:41

default from the card component now

2427:44

let's just use a card and I also forgot

2427:46

to export the

2427:48

right here inside you know let me just

2427:50

uncollapse all of them I'm going to go

2427:52

into my components folder and inside

2427:55

that we have our index.ts file so now we

2427:58

are going to be exporting default as

2428:00

card from where from let's just go to

2428:03

the card H it should be from there we go

2428:07

and now if I hold control and click on

2428:09

this it's going to brings us to this

2428:10

card component right here which is

2428:11

looking cool and this is how we are

2428:13

going to be building our card component

2428:15

so now let's just create a story for

2428:17

this card comp component so now I'm

2428:18

going to go into the stories folder and

2428:20

inside there we are going to be creating

2428:22

a new file with the name of card.

2428:24

stories. TSX and now let's just start

2428:27

working on our stories baby so we have

2428:30

to import react from the react just we

2428:32

also have to import those types because

2428:33

we are going to be using that so we have

2428:35

to import The Meta and also the story

2428:37

object from where from the story book

2428:40

from the react just story book and we

2428:42

also have to import that card so that we

2428:44

can test that so let's just use that

2428:46

card I'm going to save this file right

2428:48

now now we are going to be creating our

2428:50

meta so I'll just use like meta and I'm

2428:52

going to also annotate that meta with

2428:54

this type of card close there and here

2428:57

inside we going to be placing our title

2428:59

which will be a components and then card

2429:02

component which we are now creating

2429:04

right here now we going to be passing

2429:06

our component and here let's just space

2429:08

our card right here and now we are going

2429:10

to be also providing a perimeters so

2429:12

that we can test that I'm going to use

2429:14

like layout and we want it to be totally

2429:17

Cent third and now we have to use the

2429:20

tags and for these tags we are going to

2429:22

be providing the auto docs so

2429:25

automatically generate a documentation

2429:27

for our component now we are going to be

2429:29

exporting default that meta so that we

2429:31

can use that in other file and now it's

2429:33

time to Define our story so I'll use

2429:36

like story and going to be equals to the

2429:37

story object and now we going to be

2429:39

placing a type of meta and close there

2429:42

now we going to be also using like

2429:44

export cons small and story going to be

2429:47

equals to this object provide my arcs or

2429:50

arguments inside there and I'm going to

2429:51

provide the size and the size will be

2429:53

set to small I'm going to also provide

2429:55

the Shadow and Shad will be set to

2429:57

medium and also for the

2430:00

Border what the hell am I doing the

2430:03

Border will be set to totally solid and

2430:06

we are going to be also passing a

2430:07

children which will be set to this div

2430:09

and which will say like small come on

2430:11

small card content or something like

2430:14

that now let me just save this file I'm

2430:16

going to open yet and another terminal

2430:18

and now I'm going to be using npm run

2430:20

story book to see their interaction and

2430:23

this is our card component now let me

2430:25

just click on there so now we are

2430:27

getting a card with a lot of variations

2430:29

so if I click on the medium so it's

2430:30

going to give us the medium one if I

2430:32

click on the large so it's going to

2430:33

gives us a large so if I click on the

2430:35

nun so it's going to remove those

2430:36

shadows I'm going to make there as a

2430:38

small and provide a bit of Shadow today

2430:41

you can see there right now and here you

2430:43

can see this is how it's going to look

2430:44

like for the medium Shadow and this is

2430:46

how the large shadow will look like and

2430:49

that was a rounded card we can also set

2430:51

that To None we can also set that to

2430:53

like totally rounded one or solid one

2430:56

and we can provide like our own children

2430:58

for this content as well and we can also

2431:01

provide our own custom classes if you

2431:03

wanted to so that was the first story

2431:05

now we are going to be defining a few

2431:06

more stories so now to need let's just

2431:09

use like export cons medium and Define

2431:12

my story inside there for the arguments

2431:14

uh we are going to be providing a size

2431:17

size

2431:18

and provide my medium size in there I'm

2431:20

going to also provide the Shadow and the

2431:22

shadow will be set to large for the

2431:24

Border we're going to be setting their

2431:25

to toally rounded and I'm going to also

2431:28

provide the children and children will

2431:30

be just a d which will select medium uh

2431:33

card content or something like that

2431:35

let's just sa our file click on the

2431:37

medium so this is how it's going to look

2431:38

like I'm going to close this so that's

2431:40

the smaller one and that's the medium

2431:42

one now let me Define a few more stories

2431:44

so I'll just use like uh export cons lar

2431:47

story

2431:48

it's going to be set to story and inside

2431:50

there we going to be providing the

2431:52

arguments so it's going to take the size

2431:54

of totally large because we are now

2431:56

building a large story The Shadow will

2431:58

be set to totally medium the Border will

2432:00

be also set to totally none and I'm

2432:03

going to also provide the children and

2432:05

the children come on children will be

2432:07

set to D it's going to say like large

2432:10

hard content right here semi file if I

2432:13

click on the large so this is how my

2432:15

large card will look like now we going

2432:17

to be creating yet another story for no

2432:19

border so I'll use like export cons no

2432:23

border and it's going to take a story

2432:26

and here inside they provide the

2432:27

arguments and I'll just use like size

2432:29

and the size will be set to medium and

2432:32

I'm going to also provide the Shadow and

2432:33

the shadow will be set to medium I'm

2432:35

going to provide the border and set that

2432:37

to none and the children will be set to

2432:41

D no border come on Border card found or

2432:45

something like that so now let me just

2432:47

click on the border and here you can see

2432:49

it will not include any borders if I

2432:51

click on the medium so it has this

2432:53

border if I click on the no border so

2432:55

it's not going to include any border

2432:57

okay that was a lot of things that I

2432:59

just explained but now I'm going to also

2433:01

show you like we can also specify more

2433:03

custom content to our uh card component

2433:06

so now let me just show you there so

2433:08

I'll use like export Cons with custom

2433:12

content and it's going to take a story

2433:14

inside there we're going to be placing

2433:15

the arguments and let's just use the

2433:17

size and for this size we going to be

2433:19

setting there to medium and I'm going to

2433:21

also provide the Shadow and the shadow

2433:23

will be set to totally large and for the

2433:25

Border we're going to be setting that to

2433:27

totally solid I'm going to also provide

2433:29

these childrens and let's just test this

2433:32

out so we can just provide a d and

2433:34

inside this D I'm going to also specify

2433:35

like H2 and I'm going to say like card

2433:38

title or something like that I'm going

2433:40

to use the class name like f will be set

2433:42

to semi bold semi Bold and the text will

2433:45

be set to totally large and we are going

2433:48

to be using a paragraph which will say

2433:50

like some content come on content inside

2433:53

the card period I'm going to also

2433:56

provide the class names of text only

2433:58

small sem my file now let me just

2434:00

refresh there click on the custom card

2434:03

and yep we can totally provide that we

2434:05

can even also specify some more content

2434:07

like lauram of something and here you

2434:09

can see this is how my card will look

2434:11

like so yeah there was it about the card

2434:14

component and this is how we going to be

2434:16

writing a story for there but next we're

2434:19

going to be writing a unit test for work

2434:20

card component I want you to bear with

2434:22

me for a second because we are now about

2434:24

to write a lot of unit test case so I'm

2434:28

going to go into this components folder

2434:29

which is now available inside the test

2434:31

and we're going to be creating yet

2434:33

another file for the card. test. TSX and

2434:37

now inside there let's get into it baby

2434:40

we're going to be importing Rees from

2434:41

the react we would also need to import

2434:43

the render and also the screen from

2434:45

where from the testing line Library uh

2434:48

reactjs underneath we're going to be

2434:50

also importing the card component save

2434:52

this file and we are going to be using a

2434:54

describe for there and let's just

2434:56

describe the right here so like card

2434:59

component and remove that second from

2435:01

there save this file go in there now we

2435:03

are going to be using like it okay so

2435:05

it's not importing so it uh should come

2435:09

on it should render with default renders

2435:12

would be fine so it renders with default

2435:16

props and here we are going to be

2435:19

passing our Arrow function and use our

2435:21

render method right here P our card and

2435:24

default card right here underneath we

2435:27

are going to be getting there right now

2435:28

so I'll just use like screen get by text

2435:31

we are now going to be getting our item

2435:33

by using this Rex right here if you guys

2435:36

don't know what a Rex is you don't even

2435:38

have to worry about that but basically

2435:39

we're now searching for this default

2435:41

card content right here okay so we we

2435:44

don't care if that's upper case or lower

2435:47

case but if you found this content gives

2435:49

us there and now we're going to be

2435:51

storing the inside the const card

2435:54

element and it's going to be equals to

2435:56

the screen now we are going to be

2435:58

providing our expectation like card

2435:59

element and we want it to be in the

2436:03

document and also let's another

2436:06

expectation for the card element once

2436:07

again and we want to have the class

2436:11

names and let's just proide the width

2436:13

and the width will be set to 80 and the

2436:15

height will be set to 60

2436:18

uh and also I'm going to provide

2436:19

expectation once again for the card

2436:21

element and I'm going to select to have

2436:23

the class names of shadow of medium I'm

2436:27

going to also provide here another

2436:28

expectation for the card element card

2436:31

element and we will select to have the

2436:33

class names and Border gray of 300 like

2436:37

so now let me just save my file paste

2436:40

this out so let's just go there here you

2436:42

can see we have our card test and which

2436:44

is now successfully passing and

2436:46

everything is working the way we expect

2436:48

him to work so I'm going to hide there

2436:50

now let me just write another unit test

2436:52

so I'll use like it applies large size

2436:55

class now we are going to be also

2436:57

testing the large uh size class so we

2437:00

would have to render our card component

2437:02

first of all so I'll use like card

2437:04

component and I'm going to say like

2437:05

large card and here we're going to be

2437:07

also providing a size of large today and

2437:10

now underneath we're going to be getting

2437:11

this so I'll use like screen. get by

2437:13

text and I'll just provide like large

2437:17

card and provide my I right there okay

2437:20

so we going to be using like card

2437:21

element it's going to be equals to this

2437:23

screen object so now let's just provide

2437:25

our expectation like card element and

2437:27

here we want that to have the class

2437:29

names of with will be now set to like 96

2437:33

and height will be also set to 72 7 to2

2437:36

there we go now let's just save our file

2437:39

and check this out so here you can see

2437:40

this test is also passing let's just

2437:43

duplicate the right here and now we're

2437:45

going to be changing like applies

2437:48

uh I'm going to change this to like

2437:50

applies no Shadow when Shadow is none

2437:54

okay so we're not going to be providing

2437:56

any Shadow today and in this situation

2437:58

we're going to be removing there and

2437:59

proide My Shadow and Shadow will be set

2438:01

to none and I'm going to also change

2438:03

that like no Shadow copy there from

2438:05

there place it right here and we want

2438:08

that to have the class names of Shadow

2438:11

oh my God Shadow none cuz we don't want

2438:14

to provide any Shadows when the shadow

2438:16

is set to none check this out test is

2438:18

passing cool I'm going to hide this one

2438:23

hide that one and now you need this it

2438:25

we're going to be also duplicating there

2438:27

once again so I'm going to just

2438:29

duplicate them and change the message of

2438:32

there to like applies large shadow in

2438:35

this case so I'm going to change it to

2438:37

like apply large Shadow when Shadow is

2438:41

LG or the large one and it should be

2438:45

Shadow there we go inside there we are

2438:48

going to be changing that to like LG and

2438:51

this should apply the large Shadow Card

2438:53

I'm going to copy the content of there

2438:55

and place it right here and this one

2438:58

should have the shadow of totally large

2439:00

I'm going to save this file right now

2439:02

and here you can see our test is now

2439:04

successfully passing so I'm going to

2439:05

have to collapse the other one and these

2439:07

test are now successfully passing and

2439:09

what about if we don't specify any

2439:11

borders today so I'm going to duplicate

2439:14

there and now let's just take care of

2439:16

there so here we we going to be saying

2439:17

like applies no border when border is

2439:21

set to none okay so in this case we are

2439:24

going to be just removing there and

2439:26

proide my border and Border will be set

2439:28

to none and I going to just say like no

2439:31

border card or something like there I'm

2439:33

going to copy the content up there and

2439:35

place it right here and here let's just

2439:37

change that to like border none I'm

2439:39

going to save this file right now okay

2439:41

so it is failing I don't know why but it

2439:45

is oh that's because it's not a shadow

2439:48

it's a border and now let me just test

2439:50

this out once again and here you can see

2439:52

it is now successfully passing I'm going

2439:54

to hide there and duplicate there one

2439:57

more time and now we are going to be

2439:59

checking for the rounded border so like

2440:02

applies rounded border when border is uh

2440:06

rounded okay and here let's just past it

2440:09

right here uh I'm going to just change

2440:11

there to like border rounded and change

2440:14

this one to rounded border

2440:17

card there we go and here we're going to

2440:20

be also changing that to like rounded

2440:21

border card so I'm going to write like

2440:23

rounded border and let's just also

2440:25

change these class names uh to like

2440:27

border 2 border gray of 300 and round it

2440:32

toward LG for the large border and test

2440:35

this out so here you can see all of our

2440:36

tests are now successfully passing and

2440:38

that's only done I'm going to once again

2440:41

duplicate there and now we are going to

2440:43

be checking for the custom class names

2440:46

like can we even provide a custom class

2440:47

names or not so I'll just write like

2440:49

applies additional a t d i t i o n a l

2440:54

additional custom class name okay so

2440:58

I'll have to change that to uh the class

2441:01

names like can we want provide a custom

2441:03

class names or not so I'll just write

2441:04

like custom class and change that to

2441:07

like I don't know maybe uh custom class

2441:10

card or something like that I'm going to

2441:12

copy that from there and now let me just

2441:14

replace it with this new content here we

2441:16

are going to be so changing this video

2441:18

to custom uh class right here now let me

2441:22

just save my file and here you can see

2441:24

our test is passing which means like we

2441:26

can also apply our custom styling for

2441:28

our card I'm going to duplicate that one

2441:30

more time and now we are going to be

2441:32

checking like can we want also provide

2441:34

our own children or not so I'll just

2441:37

write like it should render uh children

2441:41

corly or bruis Le whatever you want to

2441:45

call so I'm to just remove the and

2441:48

change there to like card and here we

2441:50

are going to be passing like a d and

2441:51

child content or something like that and

2441:55

I'm going to save this file right now

2441:56

and here we're going to be searching for

2441:58

the child content so

2442:00

child oh my God child so we are going to

2442:04

be searching for a child content God

2442:07

damn it we are not going to be searching

2442:09

for a child content but we are going to

2442:11

be searching for the child element

2442:14

content so let's space for child

2442:17

content uh and it should also be a child

2442:21

content right here I'm going to copy

2442:22

there and place there and we want that

2442:24

to be in the document and execute it and

2442:27

here you can see it should also renders

2442:29

the children's correctly like so which

2442:31

is looking cool and now we are going to

2442:33

be writing the final test so that's

2442:36

going to be a lot of fun use the it once

2442:39

again and it applies correct

2442:43

combination of size shadow uh and Border

2442:48

props okay so here we're going to be

2442:51

providing a correct one so that's going

2442:53

to be basically the last uh what we call

2442:55

it the last unit test so now let's just

2442:58

use our render test our card inside

2443:00

there and I'm going to say like combine

2443:03

combined props card and here we are

2443:06

going to be using like size and size

2443:08

will be set to large you would also

2443:10

provide the Shadow and the shadow will

2443:11

be set to SM for the smaller one this is

2443:14

PR where border and Border will be set

2443:16

to totally Sol

2443:17

so now we are testing like can we even

2443:19

provide all of them at once or not so

2443:21

let me just get the I'll use like screen

2443:23

get by text and P my

2443:26

combined uh it should be combined and

2443:29

close the provide I combined props card

2443:34

right here okay I'm going to also store

2443:36

the inside the card element it's going

2443:38

to be equals to this uh get by screen

2443:40

content my expectation right here the

2443:42

card element and we want it to have the

2443:45

class name not value but to have the

2443:49

class names of with will be set to 96

2443:52

and the height will be set to 72 and now

2443:55

underneath I'm going to just duplicate

2443:56

it like three times and here we're going

2443:58

to be providing like Shadow will be set

2444:01

to totally small and we are going to be

2444:03

also providing a border of totally gray

2444:06

come on Gray 300 like so I'm going to

2444:08

save this file right now and that was it

2444:11

about forward component oh I forgot to

2444:13

show you this one so now let me just

2444:15

refresh there and here you can see all

2444:17

of our test are now successfully passing

2444:19

and everything is working the way we

2444:21

expect them to work and this is how we

2444:22

are going to be creating our card

2444:24

component this is how we are going to be

2444:26

exporting there this is how we are going

2444:27

to be visually writing a stories for our

2444:30

components and this is how we are going

2444:32

to be testing our component all right so

2444:34

now it's time to build another component

2444:36

which will be a DAT picker component so

2444:39

I'll just go ahead and uh write a date

2444:42

picker there we go and now inside there

2444:44

we're going to be creating two files the

2444:46

first one will be for the index. TSX and

2444:49

the second one will

2444:52

be that picker. TSX so now let's get

2444:56

into the first one so what I'm going to

2444:57

do I'm going to import reactjs from the

2445:00

react and also we would need to import

2445:02

the CVA from the component or class

2445:04

variance Authority you would also need

2445:06

to import the tww merge from the

2445:08

Tailwind merge and now let's just use

2445:10

our component like so this component

2445:12

will take a few props so we are going to

2445:14

be providing a size color and select

2445:16

ected see e l e c selected dat and also

2445:21

the on change event handler now we are

2445:23

going to be also creating an interface

2445:25

for there which will be a de picker

2445:26

promps I'm going to copy a name of there

2445:28

and here let's just Define our interface

2445:30

which will be our de picker promps and

2445:32

I'm going to P the size which will be

2445:34

totally optional and the sizes can be

2445:36

like small size or medium size or uh

2445:41

large size or extra large size like so

2445:45

okay we are going to be also providing a

2445:47

color which will be also totally

2445:48

optional and the color can be either

2445:50

primary color or a secondary color or a

2445:54

danger color okay we we are going to be

2445:57

also providing the selected dat and

2445:59

that's going to be set to a string and

2446:01

also when somebody change the so on

2446:04

change event handler we are going to be

2446:06

fing this function which will take a DAT

2446:07

as a perimeter and that's going to be a

2446:09

string and we are going to be returning

2446:11

a white from there so I'll just use like

2446:13

white like so now let me just save my

2446:15

file now let me just go to the top and

2446:17

here let's just Define our class

2446:18

variance Authority so I'll use like that

2446:20

picker Styles uh going to be equals to

2446:23

CVA and let's just provide our Base

2446:26

Class like the class will be set to

2446:27

relative block with will be set to

2446:29

totally full text totally gray of

2446:32

700 uh 700 like so border and rounded

2446:37

totally large Focus state will be set to

2446:40

outline and none on the focus State the

2446:44

ring will be set to two and on the focus

2446:46

St once again F cus on the Focus ST once

2446:50

again we are going to be providing a

2446:51

ring of blue 400 that's to done we are

2446:54

going to be also providing our optional

2446:56

object and here inside there let's space

2446:58

our variant so v r i ns and for each

2447:03

variance we are going to be providing a

2447:04

size and for this size let's just

2447:06

provide like a few sizes like small

2447:08

medium large and so on and so forth so

2447:10

for the smaller size the padding on the

2447:12

y- axis will be set to one pading on the

2447:14

xaxis will be set to two text will be

2447:16

set to ho is small uh and on the medium

2447:19

screen size we are going to be providing

2447:21

pairing for the y axis of two pairing

2447:23

for the xaxis of three and text will be

2447:25

set to totally B and I'm going to also

2447:27

provide the large one so for the large

2447:30

screen size pairing on the y axis will

2447:31

be set to three pairing for the x-axis

2447:33

will be set to four text will be set to

2447:35

totally large for the extra large screen

2447:37

pairing on the y axis will be set to

2447:39

four pairing for the x-axis will be set

2447:41

to five text will be set to extra large

2447:43

now let me just save my file and now

2447:45

want to need these sizes we going to be

2447:47

providing a color and the color will be

2447:49

set to primary for the primary color

2447:51

order will be set to Blue 500 I'm going

2447:54

to also provide a secondary and the

2447:56

secondary color will be um we have to

2447:59

provide a comma there and the secondary

2448:01

color will be border green 500 and I'm

2448:04

going to also provide the danger one so

2448:06

for the danger border will be set to

2448:08

totally red of 500 now let me just save

2448:10

this file right now so that's going to

2448:12

be it for our variants now let me also

2448:14

provide a default variance like the

2448:15

default value for each variant so I'll

2448:17

just provide a size and size will be set

2448:19

to medium I'm going to also provide the

2448:21

color and color will be set to primary

2448:22

save this file and now our de picker

2448:25

styling are totally done I'm going to

2448:27

collapse it right here now let me go

2448:29

ahead and go to my component I'm going

2448:31

to just remove that from there and here

2448:33

inside the you know let me just WR like

2448:35

the class name of relative and inside

2448:37

this D we're going to be providing our

2448:38

input field which will take the type of

2448:41

uh date because we are now building a

2448:43

date picker and now we are going to be

2448:45

providing a value and value will be

2448:47

coming from the date which we are going

2448:48

to be defining in a few seconds and when

2448:50

somebody try to change that then we want

2448:52

to fire this function which is a handle

2448:53

change and we are going to be also

2448:55

building there in a few second now for

2448:57

the class names we are going to be using

2448:58

our tail merge so let's just use like

2449:01

tww merge and we are going to be ping

2449:03

our uh dead picker Styles which we just

2449:05

defined a few seconds ago and here we

2449:08

are going to be destructuring the size

2449:10

like we are going to be providing the

2449:11

size and the color now let me just save

2449:13

there and this size and color is now

2449:15

coming from this prop right here and now

2449:17

let me just take care of this date and

2449:19

also this handle change I'm going to go

2449:20

to the top right here and here we're

2449:22

going to be defining our dat so con dat

2449:25

and then set dat it's going to be equals

2449:27

to the used St and the initial value

2449:29

will be set to selected dat which we are

2449:31

now taking as a perimeter right here and

2449:33

now let me copy the name of uh this

2449:34

handle change and Define this function

2449:36

right here so I'm going to go ahead and

2449:38

just Define like uh handle change

2449:40

function it's going to take the event

2449:42

and now we are going to be annotating

2449:44

the as a react change event and let's

2449:47

just annotate with the HTML input

2449:49

element because we are going to be using

2449:50

the on the HTML input element okay so

2449:53

now inside the we are going to be

2449:55

getting like event. target. value and

2449:58

now let's just store that inside the new

2450:00

D it's going to be equals to this event.

2450:02

target. value and here let me just use

2450:04

like set date and new date and also when

2450:07

somebody try to change this we are going

2450:09

to be passing like a new date right here

2450:11

in this case now let me just save my

2450:13

file and that was it about how we are

2450:15

going to be building our date picker

2450:16

component but now let's test it by using

2450:19

the story book and also the v test oh

2450:22

and I also forgot to go into this index.

2450:25

TSX and I'm going to be using like

2450:27

export and then default from where from

2450:30

the dead picker which is a dead p i k r

2450:34

and now let me just save my file if I

2450:35

hold control and click on there it's

2450:37

going to brings us to this component

2450:39

which means like everything is working

2450:41

the way we expect them to work now let

2450:42

me just go into the stories and create a

2450:45

new story right here so I'll just give

2450:46

it the name of like that picker.

2450:49

stories. TSX and here we are going to be

2450:52

first of all importing the react from

2450:53

the react JS we also have to import the

2450:56

type and we are going to be getting the

2450:58

meta and and story object from where

2451:00

from the testing Library not testing

2451:03

library but from the story book and then

2451:05

reactjs there we go and we would also

2451:07

need to import the dead picker component

2451:09

so that we can see there I'm going to

2451:11

Define my meta right here so let's just

2451:13

use the meta and I'm going to annotate

2451:16

there with this meta and the type of

2451:17

will be set to De picker and close there

2451:20

like so and it's going to be equals to

2451:21

this object provide my title inside

2451:24

there and provide like components uh

2451:27

components and then dead picker like so

2451:30

I'm going to also provide the component

2451:31

right here it should be equals to A de

2451:34

picker p i c k e r for the perimeters we

2451:37

are going to be providing like the

2451:38

layout and once again we are going to be

2451:40

making the as a tottally centered and

2451:42

I'm going to also provide the text and

2451:44

the text will be set to uh Auto dos now

2451:47

let me just sa my file go to NE there

2451:49

and I'm going to export there right here

2451:51

so export default of meta and that's

2451:53

going to be fine now let me also Define

2451:55

my story so I'll use like s o r y and

2451:58

then story object and provide my type of

2452:00

meta and close there like so now let me

2452:03

use export cons default and here we have

2452:06

to pass our story inside there and I'm

2452:08

going to provide like arguments and for

2452:10

each arguments we're going to be

2452:12

providing a selected date and I'll just

2452:14

provide like some random date like

2452:17

2025 third month and the first date or

2452:20

something like that and whenever

2452:22

somebody change this in this situation

2452:24

we are going to be using like date and

2452:26

uh we are going to be passing this

2452:27

function which will be taking a date as

2452:29

a perimeter and uh we are going to be

2452:31

just logging to the console that

2452:33

specific dat right here so now let's

2452:34

just say our file we are already running

2452:36

our story book but we have to stop there

2452:39

and rerun there now let me go ahead and

2452:41

just refresh there and here you can see

2452:43

we are now getting our de picker and yep

2452:45

it is is looking cool so we can change

2452:48

there to like a medium one we can change

2452:50

that to large we can change that to

2452:51

extra large or small okay we can change

2452:54

the color of there to like primary which

2452:55

is the default color we can also change

2452:57

that to the secondary and also to the

2453:00

danger color cool so everything is

2453:02

working the way we exp him to work now

2453:04

we have to write a few more stories for

2453:06

there I guess I'm going to be just

2453:07

writing like two stories so I'll just go

2453:09

ahead and Define like export Cons with

2453:12

custom come on with custom size so like

2453:16

can we even provide our own custom size

2453:18

or not yes of course we can okay so now

2453:21

let's just provide like arguments and

2453:23

use the selected dat and here uh I'm

2453:26

going to set that to like

2453:27

2025 and the third month of

2453:31

2025 uh I'm going to use like 03 and the

2453:34

first date of 20 um 25 on change event

2453:39

handler and we're going to be writing

2453:40

like uh de come on inate as a string and

2453:44

once again we are going to be logging to

2453:45

the console dat

2453:46

I'm going to also provide the size right

2453:48

here so for the size uh we are going to

2453:51

be providing a small size and now if I

2453:54

click on there here you can see we are

2453:55

now getting our small size de picker

2453:58

which is also looking cool okay that's

2454:00

to done now let me provide the final

2454:03

story so which will be for the withd

2454:06

custom color and we are going to be

2454:08

using a story this going to be equals to

2454:10

this object so for the arguments uh

2454:13

let's just use the selected dent and

2454:15

provide like 20 25 and 03 for the month

2454:19

and 01 for the date on change Handler is

2454:22

going to take the date and return a

2454:25

string to us now we are going to be only

2454:27

logging to the console dat date and I'm

2454:29

going to also provide the color and the

2454:31

color will be set to secondary but I'm

2454:33

going to have to provide my comma there

2454:35

this is how we are going to be providing

2454:36

a color and yep our de picker is working

2454:39

the way we expect him to work so this is

2454:40

how we going to be writing a custom

2454:42

stories forward de picker but we are

2454:45

going to be also testing there by using

2454:47

the react testing library and v test

2454:49

time to write a unit test for our

2454:51

component so I'm going to go there and

2454:53

create a new file with the name of De

2454:55

picker. test. TSX and inside there the

2454:58

first thing that we have to do is that

2454:59

we have to grab the react from the

2455:01

reactjs then we have to import uh render

2455:04

screen fire event from where from the a

2455:08

testing Library react GS now we would

2455:11

also need our component like a DAT

2455:13

picker component and that's all now

2455:15

let's just describe or test speed so

2455:17

describe and I'm going to select dat

2455:20

picker component or something like that

2455:23

now I'm going to go there let's just put

2455:25

our first test speet like it should

2455:27

render correctly with initial de i n

2455:32

Initial D there we go and I'm going to

2455:34

be passing my arrow functions to there

2455:37

just pass a arrow function and inside

2455:39

this Arrow function we are going to be

2455:41

getting a handle change function so I'll

2455:43

use like handle change and going be

2455:45

equals to this VI and then if I hit

2455:47

enter so it's going to import it right

2455:49

here it is not so I'm going to have to

2455:50

do that manually so I'll just import the

2455:53

vi from where from the v test okay so

2455:56

now let me just sa my file vi. FN for

2455:58

the function and now underneath we are

2456:00

going to be rendering our function or

2456:02

component like dat picker component and

2456:05

I'm going to close there like this and

2456:07

we are going to be also providing a

2456:08

selected date today so I'll just SP like

2456:10

2025 and third month and the first date

2456:14

like 01 like so and we are going to be

2456:16

also passing the own change event

2456:18

handler today so let's just pass it

2456:20

right here so thenly done now we are

2456:22

going to be getting our input field by

2456:24

using screen get by display video and

2456:27

we're going to be ping like 2025 01 and

2456:31

then 0 not one but 0 3 and one I'm going

2456:34

to store the inside the inputs variable

2456:36

like so and I'm going to provide my

2456:38

expectation like input and we want it to

2456:40

be in the document and I'm going to

2456:42

execute it right here uh it should be

2456:45

just a input so now let me save my file

2456:48

and our test are successfully passing

2456:51

and this is how it looks like so I'm

2456:52

going to collapse there now let me go to

2456:54

the de picker and all of the tests are

2456:56

now successfully passing and which means

2456:57

like everything is working the way we

2456:59

expect them to work and now NE let's

2457:01

just write a last site for this so like

2457:03

it should call the on change when the de

2457:06

is selected selected like so and we are

2457:10

going to be passing our aror function

2457:12

today first of all we have to mock our

2457:14

function so I'll just use like handle

2457:16

change it's going to be equals to like

2457:18

VI and then FN and now we have to render

2457:20

our component which will be a dead

2457:22

picker component and I'm going to close

2457:24

it like so I'm going to be passing like

2457:26

the selected date and here let me just P

2457:28

the selected date like

2457:30

2025 and the third month and the first

2457:33

date and when somebody change this we

2457:35

are going to be fighting like handle

2457:37

change function right here now

2457:38

underneath there first of all we have to

2457:40

get our input field so I'm going to be

2457:41

using like screen H by display value and

2457:44

I'm going to past like 202 25 and 03 and

2457:48

then 01 for the day now I'll just store

2457:51

the inside the input once again semi

2457:53

file and now we are going to be using

2457:55

that fire event okay so whenever

2457:57

somebody try to type something inside

2458:00

this input field so in this situation we

2458:02

are going to be getting the Target and

2458:04

now we're going to be providing a value

2458:05

to that and that value will be like 2025

2458:08

and then 03 and then zero I'm going to

2458:11

change there to like two or you note I'm

2458:13

going to change this one to like maybe

2458:15

four month in this case and let's space

2458:18

for expectation like handle change and

2458:20

we want it to have been called with uh

2458:24

this one like

2458:25

2025 04 and then D2 okay now let me just

2458:29

save my file and this is not the correct

2458:32

one to have um been called with function

2458:38

are we one getting there yeah uh not

2458:40

this one called oh that's fine so now

2458:43

let me just save my file now let me

2458:45

refresh there so here you can see all of

2458:47

our test are now successfully passing

2458:48

and our component is working the way it

2458:51

should be working and there was our dat

2458:54

picker component we're going to be

2458:55

building uh what do we call it the input

2458:57

component right now so I'm going to

2458:59

create a new folder with the name of

2459:00

input and inside that we're going to be

2459:02

creating our index. TSX and also our

2459:05

input. TSX okay so now inside this

2459:08

input. TSX file uh we have to create our

2459:11

component so I'm going to import react

2459:12

from the react JS you would also need to

2459:15

import the CV from the class variance

2459:16

Authority you would also need to import

2459:18

the tww merge from the T merge and now

2459:21

I'm going to be using my RFC to create

2459:23

my input component so here we're going

2459:25

to be also providing the variant as a

2459:27

prop size as a prop disabled as a prop

2459:30

and class name as a prop and now let's

2459:32

just spread out the rest of them okay so

2459:34

we are going to be also providing the

2459:35

input props so now let me copy the name

2459:38

of the and create that specific

2459:39

interface right here with the name of

2459:41

input props and we are going to be

2459:43

placing a variance but before we do that

2459:45

first all we are going to be extending

2459:47

there I forgot to do this so we will use

2459:48

like extend and it will be extending

2459:51

from the omit then from the re. input

2459:54

HTML attribute so not this one from the

2459:58

react JS and then input HTML attributes

2460:01

and now let me just specifically provide

2460:03

my HTML input element right here because

2460:05

we are going to be using the on the HTML

2460:07

element attribute now let me provide my

2460:09

comma and provide my size there and

2460:11

close there like so okay so now if I

2460:13

save there this is how it's going to

2460:14

look like right now so now we are going

2460:16

to be providing our variant uh v a r i a

2460:19

n t this going to be totally optional

2460:21

and we going to be providing the primary

2460:23

variant the secondary variant and also

2460:26

the error variant right here next up we

2460:29

also have to provide the size so size

2460:31

will be also totally optional so we can

2460:32

either provide like small size or we can

2460:34

provide the medium size or we can

2460:37

provide the large size like so you can

2460:40

also put the disable d a LED and for the

2460:43

disable which will be also totally um

2460:46

optional so we have to provide like

2460:48

Boolean value to there so now this is

2460:50

how we are going to be annotating our

2460:51

component but now let's use our class

2460:53

variance Authority I'm going to go to

2460:55

the top and here we're going to be

2460:56

providing a Bas classes for our class

2460:58

variance Authority I'm going to give it

2461:00

the name of like input style or Styles

2461:03

rather and CVA for class variance

2461:05

Authority and pairing for the xaxis will

2461:07

be set to four pairing for the y axis

2461:09

will be set to two order and totally

2461:11

rounded and for the Focus ST the outline

2461:14

will be set to totally none I'm going to

2461:16

also provide this object right here for

2461:17

the variants um it's going to be set to

2461:20

this variant v a r i n t and let's just

2461:23

provide a few different variants to our

2461:25

component so we can put the variant of

2461:27

primary which will look something like

2461:29

this like border will be set to totally

2461:31

blue of 500 T will be set to totally

2461:34

blue of 500 and Focus ST will be set to

2461:37

a ring blue of 500 so it should be Focus

2461:41

f is like so and this going to be it for

2461:43

the primary this is quite the same

2461:45

secondary variant so it will look

2461:47

something like this so border uh will be

2461:50

set to gray 500 and text will be set to

2461:53

gray of 500 once again and for the focus

2461:56

State ring will be set to gray of 500

2461:59

like so I'm going to provide this comma

2462:01

there I'm going to also provide a comma

2462:03

right here and we are going to be also

2462:04

providing an error state so for the

2462:06

error state border will be set to to

2462:08

rate of 500 and text will be set to Red

2462:11

of 500 as well on the Focus ST the ring

2462:14

value will be set to red 500 and there

2462:16

we go that was our variance but now we

2462:19

are going to be specifying the sizes so

2462:21

for each size uh let's just start from

2462:24

the small one we're going to be

2462:25

providing like text of to small uh we

2462:28

going to be also providing a medium size

2462:30

so medium size will be Tex of to Bass

2462:32

and I'm going to also provide the large

2462:34

size and which will be Tex of to LG for

2462:37

the large one okay now we are going to

2462:39

be also providing a disabled state so d

2462:41

i s a b l e d and I'm going to set that

2462:43

to true so when this is true in this

2462:45

situation we are going to be using

2462:47

background gray of 200 x will be set to

2462:49

gray of 500 and cursor CR s o will be

2462:53

set to not allowed like so now let me

2462:56

just save this file right now and now

2462:58

underneath it we going to be providing a

2463:00

default value for our variants so I'll

2463:02

just write like default value for this

2463:04

specific variant it's going to be set to

2463:06

primary we're going to be also providing

2463:08

a default value for the size which will

2463:10

be set to medium and we are going to be

2463:12

also providing a default value for the

2463:14

disabled which will be set to false now

2463:16

let me just save my file and I'm going

2463:18

to copy there collapse it right here I'm

2463:20

going to also collapse there and now let

2463:22

me go ahead and use it right here but

2463:24

before we do that we're going to have to

2463:26

use our tww merge like tailin merge and

2463:29

we're going to be passing like input

2463:31

styles and now here we're going to be

2463:33

placing our props like the variant and

2463:35

so on and so forth so I'm going to copy

2463:37

the variant place there we're going to

2463:39

be also providing the size so I'm going

2463:40

to copy there and place it right here

2463:43

write a comma there and finally we are

2463:45

going to be also providing the this

2463:47

disabled one and provide there right

2463:48

here now outside from there we're going

2463:51

to be also providing a class names and

2463:53

we are going to be storing there inside

2463:55

some sort of variable like uh merge

2463:58

class names or something like that now

2464:00

let me just s my file and that's already

2464:02

done I'm going to copy these class names

2464:04

variable and now we have to use the

2464:06

inside our GSX so I'm going to just

2464:08

remove there and provide my input feed

2464:10

and close there and now we are going to

2464:12

be spreading out the props you will also

2464:14

need to provide the class name names and

2464:16

provide my U merge class names and for

2464:18

the disable we are going to be also

2464:20

providing that disable prop now let me

2464:22

just save my file and this is how we are

2464:24

going to be creating our component by

2464:26

using the class variance Authority by

2464:28

using typescript and also they will

2464:31

merge and reactjs now let me go ahead

2464:33

and go to my index do not this one but

2464:37

my index. TSX file which is inside this

2464:39

input dot which is inside this input

2464:41

folder not DOT so I'm going to just

2464:43

export default uh default from where

2464:47

from let's just go into the input folder

2464:50

now let me just save my file and that's

2464:51

done I'm going to also go into this

2464:54

index.ts file not this one you know let

2464:56

me just collapse there go to the SRC

2464:59

folder then I'm going to go to the

2465:00

components folder then I'm going to go

2465:02

to this index.ts file and here we also

2465:04

have to export there so we are going to

2465:06

be exporting default as uh is De picker

2465:09

which we also forgot so let's just go

2465:11

ahead and go to the dead picker

2465:13

component and we are going to be so

2465:15

importing not importing but exporting

2465:18

default um come on d e f a l t default

2465:21

is a input component from where from our

2465:25

input component folder so now let me

2465:26

just save my file and that's done so now

2465:29

let me close there and now we are going

2465:30

to be going into the stories folder and

2465:32

create a story for our input component

2465:35

so I'll use like input. stories. TSX and

2465:38

let's get into it baby let's get into it

2465:41

so the first thing that we have to do is

2465:42

that we have to import react from the

2465:44

react J would also need to import the

2465:46

type of meta come on meta and story

2465:50

object from where from the test not why

2465:52

am I saying testing all the time we

2465:55

should be getting there from the story

2465:56

book Rea J and we will also need our

2465:59

input component so that we can work with

2466:01

there but we are not going to be

2466:03

importing there from there we are going

2466:04

to be importing there from our

2466:06

components folder and then we have our

2466:09

input component like so now let me go

2466:11

ahead and provide my meta and I'm going

2466:13

to also use my meta type and the type of

2466:17

will be set to input so now inside there

2466:19

we're going to be passing our title and

2466:21

title will be set to components and then

2466:24

input component I'm going to also

2466:25

provide my component right here and that

2466:28

will be equals to this input field or

2466:30

that input component which we just

2466:32

defined and also the perimeters we're

2466:34

going to be setting that to the layout

2466:36

and layout will be set to centered like

2466:38

so I'm going to also provide the tags

2466:40

and for each tags we want there to gives

2466:43

us like automatically generated Docs all

2466:45

just use like autod dos save this file

2466:48

and now underneath there we have to just

2466:50

export there like so now we are going to

2466:52

be creating our type so type will be set

2466:55

to story and it's going to be set to

2466:57

story object and I'm going to provide

2467:00

like type of meta and close it like this

2467:03

now we are going to be creating our

2467:04

first story which will be a primary and

2467:06

now let's just annotate with the story

2467:08

and inside there we're going to be

2467:10

passing our arguments and provide my

2467:12

variant and variant will be set to

2467:14

primary I'm going to also provide the

2467:16

size so the size will be set to medium

2467:19

and I'm going to also provide the

2467:20

placeholder for my component like

2467:22

primary input I guess that can be fine

2467:24

so now let me just save my file go into

2467:27

my story book and everything is working

2467:29

and now let me go there and refresh

2467:31

there here you can see we are now

2467:32

getting our input components now if I

2467:35

click on there so we are now getting

2467:37

different colors like this can be set

2467:39

for a primary color secondary color and

2467:41

error color we can also get the smaller

2467:43

screen size the medium one and and also

2467:45

the large one we can also change the

2467:48

content to be something else or

2467:52

something like that and we can also make

2467:54

there disable so like whenever we have

2467:56

over there we would not be able to type

2467:58

something inside this input field so now

2468:00

let me just change that back to the

2468:02

smaller one and primary component like

2468:04

so and that was our first story and now

2468:07

let me Define a few more stories so I'm

2468:09

going to go ahead and just export my con

2468:11

secondary s e c o n d a r y and and

2468:15

provide my story there and inside there

2468:17

we're going to be passing our arguments

2468:19

and let's just use like variant and

2468:21

variant will be set to secondary and for

2468:24

the size that's going to be set to

2468:25

medium and I'm going to also provide the

2468:27

placeholder and placeholder will be set

2468:29

to secondary input like so I'm going to

2468:32

save this file right now go into the

2468:34

secondary component and here you can see

2468:36

the color is now totally changed I'm

2468:39

going to also Define a few more stories

2468:41

so I'll just go ahead and Export cons

2468:43

small story and this going to be set to

2468:46

the story and inside there let's just

2468:48

pass our arguments and I'm going to be

2468:49

passing the variant and variant will be

2468:51

set to primary I'm going to also put the

2468:53

size and the size will be set to small

2468:55

in this case and also the placeholder

2468:58

will say like small input field or

2469:00

something like that and now let me just

2469:03

go ahead and click on the small one and

2469:05

now it's going to gives us a small input

2469:06

field right here which is looking cool

2469:09

now I'm going to be generating the large

2469:10

input field so I'm going to go ahead and

2469:12

write my export cons and large infut

2469:15

large and provide the story right here

2469:18

and that's going to be set to the arcs

2469:20

and inside this arcs we are going to be

2469:21

placing a variant which will be set to a

2469:23

primary I'm going to be also placing a

2469:25

size and size will be set to large and

2469:27

the placeholder will be set to large

2469:30

input right here so now let's just sa

2469:32

our file and if I click on this now it's

2469:34

going to gives us a bit large input

2469:36

field right here which is also looking

2469:38

cool now the final story that we have to

2469:40

write will be for the disabled one so

2469:42

I'll just use like export cons disable

2469:45

and P my story right here I'm going to

2469:48

be passing my arcs and inside these arcs

2469:51

this's is sp the variant and variant

2469:53

will be set to primary the size will

2469:55

also be set to medium and I'm going to

2469:58

also provide the disable and set that to

2470:00

true I'm going to be faing a placeholder

2470:03

in which will select disabled uh input

2470:06

field like so now let me just save my

2470:07

file click on there and that was it

2470:10

about our stories about our input field

2470:14

so next we're going to be writing a unit

2470:17

test for our component time to write a

2470:19

unit test for our component so I'm going

2470:20

to go into my test folder then

2470:22

components folder then I'm going to

2470:24

create a new file with the name of

2470:25

input. test. TSX and now here first of

2470:30

all let's just remove this one and also

2470:33

that one now we're going to be importing

2470:35

reactjs from the react you would also

2470:37

need to import the render function and

2470:40

also the screen from where from the

2470:42

testing library and then react G we

2470:45

would also need to import or input

2470:47

component so that we can test that but

2470:49

not from the lib what the hell is there

2470:52

we have to go into the components folder

2470:56

God damn it and then we have to go into

2470:59

now we have to go to the components

2471:00

folder and now we are going to be

2471:02

getting there from the input there we go

2471:04

now let's just Define our describe and

2471:07

for this describe we are going to be

2471:08

passing like input component and let's

2471:11

just pass input component and password

2471:15

AR function inside there so first of all

2471:17

let's just write a first Suite like it

2471:19

should render correctly and then uh we

2471:24

are going to be pring our Arrow function

2471:26

so now let me just render my input

2471:28

component and now let me just close it

2471:30

like this I'm going to be also passing a

2471:32

placeholder which will select test uh

2471:35

input like so now let me just save my

2471:37

file right now then we are going to be

2471:39

selecting that component by using get by

2471:41

placeholder text and then we're going to

2471:44

be passing like text input right here

2471:46

and we are going to be selecting that

2471:47

component by using that placeholder text

2471:50

and now we going to be also providing an

2471:51

input element it's going to be set to

2471:53

this value and now underneath it let's

2471:55

just provide our expectation like for

2471:57

the input element we want it to be in

2472:00

the document let's just sa our file and

2472:03

let's just see all of our test are not

2472:05

successfully passing and I'm going to go

2472:07

into the v test refresh there and

2472:10

collapse this component uncollapse that

2472:12

yep our test is now successfully passing

2472:14

and which is is looking cool now we're

2472:16

going to be providing another test Suite

2472:18

like it should apply the primary come on

2472:21

primary variant by default uh like so

2472:25

and here we have to pass our uh Arrow

2472:28

function right here and I'm going to

2472:30

just render my component by passing my

2472:32

input field then we are going to be

2472:34

passing some sort of a placeholder like

2472:36

primary variant uh in lower case variant

2472:40

and now underneath there I'm going to

2472:41

get there by using screen. get by

2472:44

placeholder value let's holder not value

2472:48

but text and let's space our primary

2472:50

variant inside there now we're going to

2472:53

be storing the inside the input element

2472:54

and it's going to be equals to this

2472:56

value let me past my expectation and I'm

2472:58

going to past my input element and we

2473:00

want there to have the class name of

2473:03

Border totally blue of 500 I'm going to

2473:06

duplicate that three times and then I'm

2473:08

going to change that to like uh blue

2473:10

then the text to be blue of 500 and on

2473:14

the focus let's just remove them what

2473:16

the hell am I doing let's just remove

2473:19

them and for the focus T we're going to

2473:21

be passing ring of 500 blue and now let

2473:23

me just remove there check this out so

2473:25

yeah all four test are now successfully

2473:27

passing and by default it will provide

2473:30

that primary um variant to there so I'm

2473:32

going to collapse it right here and now

2473:34

we are going to be providing another

2473:35

test suite for the secondary so it

2473:38

should apply the secondary variant b a r

2473:41

i a n t when specified and and here

2473:45

let's just pass our Arrow function pass

2473:47

our render prop and it will F right here

2473:50

close there and for the placeholder we

2473:52

will select secondary variant I'm going

2473:54

to be also placing my variant of

2473:56

secondary right here s s n d a r y

2473:59

secondary variant and now need there we

2474:01

going to be getting that specific

2474:03

element by using uh get placeholder text

2474:06

and let's space our secondary variant

2474:08

right here like this and now we are

2474:11

going to be storing the inside the input

2474:13

element and it's going to look something

2474:14

like this

2474:15

now underneath we have to provide our

2474:17

expectation for our input element and we

2474:19

want that to have the class names or P

2474:22

toally gray of 500 I'm going to

2474:24

duplicate there a few times and I'm

2474:26

going to change this one to text of 500

2474:30

text of gray 500 and this one will be

2474:33

for the focus one so for the focus we

2474:35

want to put the ring of gray 500 and

2474:37

let's just remove them check this out

2474:40

all of our test are now successfully

2474:41

passing and yep here as well we are now

2474:45

at the 23 test cases cool that was a lot

2474:49

and now underneath there we have to

2474:51

provide yet another test suet like it

2474:54

should apply the error variant V an when

2474:59

specified like so and here we are going

2475:02

to be passing our callback function

2475:04

render our component by using this input

2475:06

close there and pass or placeholder

2475:08

which will say like uh error variant

2475:11

here we're going to be also placing a

2475:13

variant of error like so let me just sa

2475:15

my file and underneath there we are

2475:17

going to be using a screen get by

2475:19

placeholder text and I'm going to say

2475:21

like error uh variant and now we have to

2475:24

store the inside the input element

2475:27

variable like this underneath that we

2475:29

are going to be placing our expectation

2475:30

like input element and then we wanted to

2475:33

have the class names have the class

2475:36

names of border to R because this is a

2475:39

error variant and now this going to be

2475:41

set to 500 I'm going to duplicate there

2475:43

two more time in this one will be set to

2475:45

text off rate 500 and this one will be

2475:48

for the focus state so Focus ring rate

2475:51

500 check this out refresh there and our

2475:55

test is now successfully passing and

2475:57

that's because our code is working the

2475:59

way it should be working now underneath

2476:02

there we are going to be providing

2476:03

another test case for the smaller input

2476:05

field so I'll just write like uh it

2476:08

should apply the small size when

2476:12

specified when we specify a smaller SC

2476:15

size so it should just render that

2476:16

smaller input field okay so I'm going to

2476:18

be providing a placeholder which will

2476:20

say like small size or something like

2476:23

that I'm going to be also providing a

2476:24

size right here and the size will be set

2476:26

to small and now underneath them we are

2476:28

going to be getting by using screen get

2476:30

by placeholder and place our small size

2476:34

like so and then we're going to be

2476:36

getting our input element by using that

2476:39

placeholder text so now underneath them

2476:41

provide our expectation and we want the

2476:43

input element to have at least this

2476:46

class so to have class text of tot is

2476:50

small let's just say our file test this

2476:52

out yep our test is now successfully

2476:55

working now let me just uh duplicate

2476:57

there for the medium size so I'm going

2476:58

to duplicate there and change there to

2477:00

like it should apply the medium size m e

2477:03

d i u m and I'm going to also change

2477:05

there to like medium and change this one

2477:07

to medium I'm going to also change there

2477:10

to like medium and here we're going to

2477:12

be also changing the text to be B T our

2477:15

file and yeah our test is now

2477:17

successfully passing now let me do the

2477:19

same thing for the large screen size so

2477:22

now let me just duplicate there oh my

2477:24

God if I can get there today so now let

2477:26

me just duplicate there one time and

2477:28

should apply this medium so instead of a

2477:31

medium we going to be changing there to

2477:32

large size okay so large size and this

2477:35

one should be large size as well and

2477:38

this one will be large size as well

2477:42

change that to large and here for the

2477:45

text we're going to be changing there to

2477:46

LG and now here you can see it is also

2477:49

passing now let me duplicate that for

2477:51

the disabled state so I'm going to

2477:53

duplicate there and it should apply or

2477:55

not apply I'm going to just remove there

2477:58

it should be disabled when the disabled

2478:02

prop is passed like so and here we're

2478:05

going to be passing a disabled input

2478:07

disabled input and I'm going to also

2478:10

change this you know we are not going to

2478:11

be providing any size today but instead

2478:13

I'm going to pass a disable right right

2478:14

here okay so here I'm going to just

2478:17

write like uh disabled input and let's

2478:21

just remove them what do I provide a new

2478:23

expectation and provide our input

2478:25

element inside there and we want it to

2478:27

be disabled and I'm going to execute

2478:29

there right here and here you can see it

2478:31

should also take the disabled State as

2478:34

well that's to done and we should also

2478:36

check like it should not be disabled by

2478:38

default so you know let me just write

2478:40

another test case for there I'm going to

2478:42

go ahead and just write like it should

2478:44

not be disabled by default and here

2478:48

let's just space our Arrow function my

2478:50

render function and input field like so

2478:53

and then we're going to be placing a

2478:54

placeholder of enabled input and I'm

2478:57

going to use like screen. head by

2479:00

placeholder uh then password enable text

2479:03

right here and I'm going to be using

2479:04

cons input element and it's going to be

2479:06

equals to the screen of that input

2479:08

element now let me just P my expectation

2479:10

of input element and we want it to not

2479:13

be disable disable there we go and now

2479:16

let me just save my file okay so we are

2479:19

now getting that one as a error and why

2479:21

is that because it should be

2479:24

enabled now let's just passord Ed and

2479:27

now let me just refresh still it is not

2479:29

working oh that's because it should

2479:32

be input not text and now it is working

2479:35

successfully now let me write the final

2479:38

test case and that's going to be it for

2479:39

this input test or input component so

2479:42

I'll just write like it should merge

2479:45

custom class name um

2479:49

correctly because we also made this so

2479:51

that the user can also specify their own

2479:53

classes if they want to so I'll just use

2479:56

like input close then now let me just P

2479:59

my placeholder which will say like

2480:00

custom class in lowercase class there we

2480:03

go and I'm going to be also providing a

2480:05

custom classes like custom class or

2480:07

something like there and I'm going to

2480:09

also use like let me just get the from

2480:11

the screen get by placeholder and let's

2480:14

space or custom uh class right here I'm

2480:17

going to store that inside the um input

2480:21

element and it's going to be equals to

2480:22

the screen of placeholder now let me

2480:24

just place my expectation of input

2480:26

element and we want there to have the

2480:28

class of custom class like so I'm going

2480:31

to save this file right now and here you

2480:33

can see you should also take a custom

2480:35

classes okay that was a lot of typing in

2480:39

a lot of speaking so now that we

2480:42

successfully created the input component

2480:44

uh where is the we successfully created

2480:46

the input component then we write a

2480:49

story for our input component then we

2480:52

provided a test cases for our input

2480:54

component okay so now we are going to be

2480:56

building a bit tricky component so which

2480:58

will be a pagination component so I'm

2481:01

going to go ahead and go to the

2481:02

components folder I'm going to create a

2481:04

new folder with the name of p a i n a o

2481:07

n pagination inside the imagination. TSX

2481:11

and also input uh not input but index.

2481:14

TSX right here I'm going to close the

2481:16

index one and now let's get into the

2481:18

pagination component so I'm going to go

2481:20

ahead and just import the react from the

2481:22

re we would also need the CVA component

2481:26

and also the tww merge from the tailin

2481:28

merge now let me use my RFC inside there

2481:31

and it's going to take a few props so

2481:33

now let me just destructure this so it's

2481:34

going to take the current page it's

2481:36

going to also take the total page or

2481:39

pages and yeah it's going to also take

2481:41

the on page change like whenever the

2481:44

page change changes it's going to also

2481:45

take the size the variant and also the

2481:49

disabled as well now we going to be also

2481:52

inating there by using the pation props

2481:55

I'm going to copy the name of there and

2481:57

Define this interface right here I'm

2481:59

going to just go ahead and Define this

2482:01

interface and inside there let's just

2482:03

space the current Uh current page and

2482:06

the current page will be set to a number

2482:08

we are going to be also placing a total

2482:10

Pages this going be also set to a number

2482:12

we're going to be also placing like on

2482:14

page change like whenever the page

2482:15

changes so we're going to be placing a

2482:17

function which will take a page as a

2482:19

perimeter this going to be also a number

2482:21

and we should return the wide like

2482:23

nothing from there so size will be

2482:25

totally optional but we are going to be

2482:27

providing like small screen size or

2482:30

medium screen size or large screen size

2482:34

okay we can also specify the variants so

2482:37

variant will be set to default and then

2482:41

uh it's going to be set to primary and

2482:44

secondary s and d r y like so now

2482:47

underneath we going to be also passing

2482:48

the disable d s a b l e d and disable

2482:51

will be set to a Boolean and also

2482:53

totally optional now let me just save my

2482:55

file and that was about for this

2482:57

interface and now we are going to be

2482:59

using our class variance Authority so

2483:01

I'll just go ahead and Define my page in

2483:03

p a i n a o n page Nation Styles it's

2483:07

going to be equals to the CVA and here

2483:09

for the base classes we are going to be

2483:10

passing like Flex and items will be set

2483:12

to to center spaces on the ex will be

2483:14

set to two I'm going to also paste this

2483:17

object and here we're going to be pasing

2483:18

the variants and for these variants

2483:20

let's just pass the size and the size

2483:23

will be a few sizes like small and when

2483:25

it is small size then we're going to be

2483:28

providing like text of totally small and

2483:30

when it is a medium size m e d i u m the

2483:33

text will be set to totally Bas and when

2483:36

it is a large screen size then we're

2483:37

going to be passing a text of totally

2483:39

large today but I'm going to also have

2483:41

to specify my comma there and now to

2483:43

need this size variant we're going to be

2483:45

also passing our own variants to there

2483:48

so for the default variant the

2483:50

background will be set to to gray of 100

2483:53

text will be set to toally gray of 800

2483:56

and also when somebody H over there so

2483:58

background color will be set to gray of

2484:01

200 I'm going to also provide another uh

2484:03

variant which will be set for a primary

2484:05

so background will be set to totally

2484:07

blue of 500 T will be set to totally

2484:10

white and when somebody H over there so

2484:12

background totally blue of 600 100 like

2484:14

so I'm going to be also passing a

2484:16

secondary and for the secondary

2484:18

background will be toally gr of 300 and

2484:21

text toally Gray of 700 and I'm going to

2484:25

be also passing like when somebody how

2484:26

over there so background gray of 400 in

2484:29

this situation so that was our own

2484:31

variance but we are going to be also

2484:33

providing a disabled state so d s a b e

2484:36

d and I'm going to set that to true so

2484:38

when the disabled state is true in this

2484:40

situation we are going to be changing

2484:41

the background to gray of 200 and text

2484:44

will be set to gray of 400 and cursor

2484:48

will be not allowed a l o w e d there we

2484:51

go and then for the default values uh

2484:54

let's just pass these default values

2484:56

we're going to be passing the default

2484:58

value for the size of medium we're going

2485:00

to be also providing a default variant

2485:02

to be default and also for the disable

2485:04

it it should be false now let me just sa

2485:07

my file I'm going to collapse that right

2485:09

here I'm going to copy the name of them

2485:11

I'm going to also collapse this

2485:12

interface and let's just use the inside

2485:14

our component I'm going to go into this

2485:16

component and I'm going to be using the

2485:18

tail merge and here let's space our

2485:20

pagination Styles today and now we are

2485:22

going to be placing the size as a prop

2485:25

variant as a prop and disable as a prop

2485:28

okay so now let me store the inside the

2485:30

variable with the name of merged um

2485:33

class names this going to be equals to

2485:35

this tww merge and now let me go into

2485:38

this UI and take care of this so for

2485:40

this D we're going to be passing the

2485:42

class names of that merge

2485:44

class names there we go and now inside

2485:47

there we're going to be removing that

2485:48

pagination and we are going to be

2485:50

creating a button and this button will

2485:52

be a special button okay so I'll just

2485:55

write like first of all my entity this

2485:57

HTML entity which will be if I can get

2485:59

the today end symbol and then alt T and

2486:03

then pre so that's going to be set for a

2486:05

previous button and we're going to be

2486:07

also creating a next button so let's

2486:08

just write like you know let me just

2486:10

delete that from here and I'm going to

2486:12

change that to next and then end GT and

2486:14

close there okay so first of all let me

2486:17

just take care of the what do we call it

2486:18

the previous button then we're going to

2486:20

be taking care of the next button right

2486:21

here so when somebody try to click on

2486:23

this in this situation we're going to be

2486:25

using this function which is handled

2486:27

previous which we are going to be

2486:28

creating in a few seconds and I'm going

2486:30

to be also passing a disable State and

2486:32

for this disable state if the current

2486:35

page is equal to one then this should be

2486:38

disabled but if that's not the case so

2486:40

it should not be disabled so I'll just

2486:42

write like class names pairing for the

2486:43

ex will be set to four pairing for the Y

2486:45

AIS will be set to two and totally

2486:47

rounded now let me just s my file and

2486:49

I'm going to be taking care of this uh

2486:51

handle previous and also this current

2486:53

page so I'll just copy there go to the

2486:56

top or maybe here now let me just uh

2486:59

create this function which will be

2487:01

handled previous it's going to be

2487:02

basically an aror function which will

2487:04

only just return like if the current

2487:06

page is greater than one which we are

2487:08

now taking as a prop in this situation

2487:10

on page change prop we'll take the the

2487:14

current page minus one uh whatever page

2487:17

we are on so just minus one from there

2487:19

go to the previous page okay so it's

2487:21

going to gives us there and that's going

2487:23

to be it for this uh what do we call it

2487:24

previous button and now let me go into

2487:26

this uh next button and when somebody

2487:28

try to click on this button then we're

2487:30

going to be passing like handle next and

2487:33

I'm going to be also passing a disable

2487:34

state today so the if the current page

2487:37

is equal to the total Pages or disable

2487:40

so I'm going to paste like the class

2487:41

names of pairing for the xais of four

2487:43

pairing for the y AIS of two totally

2487:45

rounded so now let me just save my file

2487:47

right now I'm going to copy there and

2487:49

now let me go to the top here and now

2487:51

let me create that function so I'll just

2487:53

go ahead and uh create this handle next

2487:55

it's going to be also an AR Arrow

2487:57

function we are going to be checking if

2487:59

the current page is less than the total

2488:01

Pages which we are now taking as a props

2488:03

in this situation the on page change

2488:06

will take the current page and then we

2488:08

are going to be adding one to this so in

2488:10

this situation it's going to gives us

2488:12

the next page okay so the that's also

2488:15

totally simple and easy but now the real

2488:18

magic will happen the middle of these

2488:20

two buttons and which will be a lot of

2488:22

cool stuff so here basically we're going

2488:24

to be creating a function and then we

2488:26

are going to be rendering that function

2488:28

which will be a render page numbers and

2488:31

now let me just execute there I'm going

2488:33

to copy the name of there go to the top

2488:35

and create this function right here and

2488:37

I want you to bear with me for a few

2488:39

second because it's going to require a

2488:41

lot of explanation first of all let me

2488:43

just cre create the body of this

2488:45

function and inside there we are going

2488:47

to be first of all creating a container

2488:49

where we are going to be storing our

2488:51

Pages I'll just write like cons uh page

2488:54

numbers and it's going to be set to this

2488:56

empty array now the next thing that we

2488:58

have to do is that we have to iterate

2488:59

over through their total Pages which we

2489:01

are now taking as a prop okay so we have

2489:03

to iterate over through these total

2489:06

Pages like how many pages we have so we

2489:08

want to just iterate over through there

2489:10

so to do that we can use like the four

2489:12

off Loop or just a for Loop to be

2489:14

precise I'll just use like let I is

2489:16

equal to one so we're going to be

2489:18

starting from one the zero will not be

2489:20

count so we want to start from one and

2489:22

if I is less than or equal to the total

2489:25

Pages then we want to increment there by

2489:28

one then I ++ okay so if that is the

2489:31

case so for each iteration we're going

2489:33

to be taking our page numbers and then

2489:35

we're going to be pushing this button to

2489:37

there so now inside this push let's just

2489:39

create this button right here and I'm

2489:41

going to close them and here we're going

2489:43

to be only render

2489:44

that I which we are now taking as a

2489:46

index for from this for Loop okay so

2489:49

that's to done now let me provide a key

2489:51

to that because we now iterating over

2489:53

through this so it will require the key

2489:54

and now we have to specify that I as a

2489:56

index today and now we are going to be

2489:58

providing a PA of classes to there so

2490:00

the class name will be totally Dynamic

2490:02

so that's why we are going to be using

2490:03

these back Texs so pairing for the xaxis

2490:06

will be set to four pairing for the Y

2490:07

AIS will be set to totally to totally

2490:09

rounded and here let's space or classes

2490:12

Dynamic so if the I like the index is

2490:14

equal to the current page in that

2490:16

situation let me just go back in that

2490:18

situation we are going to be providing

2490:20

this uh blue color which will be

2490:22

background totally blue of 500 and also

2490:25

the text will be set to totally white

2490:27

but if that's not the case in this

2490:29

situation we're going to be changing the

2490:31

background background to totally gray of

2490:34

100 and also the text will be gray of

2490:36

800 so now let me just past SM file okay

2490:39

so now let me just explain there once

2490:41

again if you guys do not get it so if

2490:44

index which we are now iterating over

2490:46

through is equal to the current page

2490:48

which we are now taking as a perimeter

2490:50

or prop so if that is the case so you

2490:52

want to change the background to be to

2490:54

totally blue and also the text to be

2490:56

totally white and if that's not the case

2490:58

then we are going to be setting there to

2491:00

like background totally gray of 100 and

2491:03

text off totally gray of 800 so that's

2491:05

it now underneath that uh when somebody

2491:07

try to click on there then you want to

2491:09

fire this function which will be uh this

2491:11

handle page change come on p a g and

2491:15

then change handle page change if I can

2491:19

get there today and here we are going to

2491:21

be passing our index inside the also for

2491:24

the disabled State we're going to be

2491:25

providing our disabled state right here

2491:27

and finally I'm going to be creating

2491:28

this function in a few seconds but

2491:30

finally we have to return something from

2491:33

this function or from this iteration so

2491:34

I'll just use like return page numbers

2491:37

okay so which is these page numbers and

2491:40

we are now pushing this button for each

2491:43

iteration to this page number so

2491:44

basically it's going to gives us like

2491:46

the page numbers I'm going to copy the

2491:48

name of this function and now let me go

2491:50

to the top and here we going to be

2491:51

defining that function which will be

2491:53

super simple so I'll just use like

2491:55

handle page change and the page will be

2491:57

set to a number and here inside there

2492:00

let's just remove that P and on page

2492:03

change and let's just pass our page

2492:05

inside there and that's totally done

2492:08

okay so this is how we are going to be

2492:09

creating our page nation and I hope it

2492:12

helps but if it didn't I don't know what

2492:15

to do so I explained that enough so now

2492:17

that we successfully created our page

2492:19

Nation component by using reactjs class

2492:21

variance Authority tman merge tman CSS

2492:25

and also typescript now the next thing

2492:27

that we have to do is that we have to go

2492:29

into this index. TSX file and we have to

2492:32

export there so I'll use like export

2492:34

then default from where from our

2492:36

pagination component now let me also go

2492:39

ahead and go to this index.ts and I'm

2492:42

going to also Port T right here so

2492:44

export default uh default as pag p a g i

2492:50

n a d i o n pagination from where from

2492:52

the pagination component now let me save

2492:55

my file and that's done next thing that

2492:57

we have to do is that we have to create

2492:59

a stories for there and then test cases

2493:01

okay so time to create a story for the

2493:03

pagination component so I'll just create

2493:05

a new file with the name of

2493:07

pagination do stories. DSX and inside

2493:11

there um we first of all need to import

2493:13

re from the rejs then we would also need

2493:15

to import the type um meta and also the

2493:20

story object from where from the story

2493:23

book and then we have to get there from

2493:25

the reactjs and now we also have to get

2493:28

the pagination component so that we can

2493:30

use it inside this file now we have to

2493:32

create a meta and that's going to be set

2493:34

to meta type of will be set to

2493:37

pagination p a g i n a t i o n and I'm

2493:40

going to close that that's going to be

2493:41

set to this object inside there we have

2493:44

to render our components and then the

2493:47

pagination inside there and it should be

2493:50

C NT and now we have to render our main

2493:54

component which will be the page Nation

2493:57

component p a g i n a t i o n I'm going

2494:00

to be also providing a perimeters and

2494:02

that's going to be set to totally a l of

2494:05

centered I'm going to be also providing

2494:07

a tags so the tags will be set to the

2494:09

auto dos so that it will automatically

2494:12

generate a documentation for us or for

2494:14

our component so let's just export

2494:16

default The Meta and create a type

2494:19

forward story so I'll use like type

2494:21

story can be equals to the story object

2494:24

we're going to be providing a type of

2494:25

meta and close there now underneath

2494:28

there we're going to be exporting so

2494:30

let's just use like export cons default

2494:32

and there going to be a story and it's

2494:34

going to be equals to this ARs and here

2494:36

inside there we're going to be passing a

2494:38

current page and current come on current

2494:41

page IND this can be set to one and the

2494:44

total Pages uh will be set to five and

2494:47

we're going to be also providing the on

2494:49

page change like whenever somebody triy

2494:51

to change this page so we're going to be

2494:53

passing a function today which will take

2494:55

a page as a perimeter and that's going

2494:56

to be a number and we will just loog to

2494:58

the console like uh page change to that

2495:02

specific page which we are now taking as

2495:03

a perimeter okay so

2495:06

sat it should be a story there we go and

2495:10

underneath we also have to specify the

2495:13

SI and the size will be set to medium

2495:15

and we also have to provide a variant

2495:17

and the variant will be set to default

2495:19

now let me just save my file and check

2495:21

this out whether everything is working

2495:23

or not okay so everything is effed up so

2495:27

we have to start over I'm going to just

2495:29

use like npm run story book and test

2495:32

this out right now let me just refresh

2495:34

there and here you can see we're now

2495:36

getting our pagination component you can

2495:38

also increase or decrease the sizes of

2495:40

this like the current page will be set

2495:42

to three it's going to jump into three

2495:44

if you set there to five it's going to

2495:45

jump to five to two and so on and let's

2495:48

suppose if you want to get like 20 pages

2495:50

so it's going to give us 20 Pages let's

2495:52

suppose if you want to get like 100

2495:53

Pages it's going to gives us 100 Pages

2495:56

if you want to get like 10 pages so it's

2495:57

going to gives us 10 pages um we can

2496:00

also set that to small medium or large

2496:03

component and this is how the default

2496:04

look will look like and this is how the

2496:06

what do we call it the secondary look

2496:08

will look like secondary look will look

2496:11

like what the hell am I talking about

2496:12

and also so if you click on the set uh

2496:15

disable you can also disable there if

2496:17

you wanted to so now let me just close

2496:19

there and now there was a default story

2496:22

next uh we are going to be creating

2496:24

another story for there which will be a

2496:27

primary story so I'm going to go to the

2496:28

bottom and use export cons primary and

2496:32

that's going to be set to a story and

2496:33

it's going to be uh taking the arguments

2496:36

and inside there let's just space our

2496:37

current Pages inside there which will be

2496:39

set to one the total pages will be set

2496:41

to five and on page change uh so that's

2496:45

going to take a page and that's going to

2496:46

be set to a number and we will just loog

2496:48

to the console that same thing like page

2496:51

change to that specific page I'm going

2496:54

to go to the top and I knew I imported

2496:57

something but we don't have to use that

2497:00

so now let me just write like the size

2497:02

and the size will be set to medium I'm

2497:04

going to be also providing a variant and

2497:06

the variant will be set to primary save

2497:08

this file and refresh there I'm going to

2497:10

go into the primary and this is how my

2497:11

primary component will look like

2497:14

and you can definitely go ahead and

2497:15

change the styling if you don't like the

2497:17

styling so in my case that's looking

2497:19

totally cool so I'm not going to change

2497:21

there the next thing that we have to do

2497:23

is that we have to use export cost small

2497:25

and then I'm going to be using the story

2497:27

inside there this space or arguments and

2497:30

pass our current page which will be set

2497:31

to one for the total Pages which will be

2497:33

set to five pages and on page change

2497:36

we're going to be using the page and

2497:38

that's going to be a number use the

2497:40

console.log page change to change to

2497:44

this specific page which we now taking

2497:47

as a perimeter and also for the size

2497:49

we're going to be setting there to small

2497:51

and also for the

2497:53

variant I'm going to change it to

2497:55

default save my file I'm going to go to

2497:57

the small and this is how my small uh

2498:00

component will look like or the small

2498:02

variation of this component now let me

2498:04

Define another story for the large one

2498:06

I'm going to basically duplicate there

2498:09

and change the name of there to large so

2498:12

I'll just go ahead and change that to

2498:13

large and here just change the size to

2498:16

large I'm going to save this file right

2498:18

now and click on the large and this is

2498:20

how it looks like so this is a small one

2498:22

and this is a large one now let me

2498:24

create the final story which will be for

2498:26

the disabled state so I'll just

2498:27

duplicate there once again and change

2498:29

that to the disabl b s a b l e and here

2498:34

uh I'm going to only provide like the

2498:35

disabled and set there to true and now

2498:38

let me just save my file click on there

2498:40

and here you can see this is now

2498:41

successfully disabled so yeah that was

2498:44

there about the what do we call the

2498:46

stories of this pagination component and

2498:48

next we're going to be writing a unit

2498:50

test for our component so now let me go

2498:52

ahead and go to my test file or folder

2498:54

and inside there we're going to be

2498:56

creating another file with the name of p

2498:58

a a n pagination test. TSX and inside

2499:03

there let's just import react from the

2499:05

react J we also need to import the

2499:08

render uh also need to import the screen

2499:10

and the fire event from where from the

2499:13

testing Library wejs we also need to

2499:16

import our pation components so we can

2499:18

use them inside this file I'm going to

2499:20

also just Define my describe function

2499:22

and here inside there let me just use

2499:24

like page Nation component uh c m p o n

2499:28

n t and I'm going to use my arrow

2499:31

function inside there and let's space

2499:33

our first test case like it should

2499:36

render correctly with G1 total Pages GI

2499:42

I V and given total pages and here let

2499:46

me just P my arrow function inside there

2499:48

and render my component like page Nation

2499:51

component close there and I'm going to

2499:53

be passing the current page which will

2499:54

be set to one the total Pages which will

2499:57

be set to five and the on page change

2500:01

which will be set to the mock function

2500:03

which is like VI and then FN for the

2500:05

function and we also have to import that

2500:08

vi from the testing Library v test so vi

2500:11

from where from the vest

2500:13

v test v t s there we go and now let's

2500:16

just save our file I don't know why it's

2500:18

giving me an error now let me have over

2500:20

there and variant is missing okay go to

2500:23

the

2500:24

pation variant is missing that's because

2500:27

we have to make that totally optional

2500:29

I'm going to close that and now that

2500:30

error is successfully gone so now

2500:32

underne this render uh we going to be

2500:34

providing our expectation like screen

2500:36

and then get by text and pass or less

2500:39

than in previous sampol okay so we want

2500:42

it to B in the document what is that

2500:45

even mean so we are now checking if the

2500:47

previous button are present or not I'm

2500:50

going to also duplicate there and I'm

2500:51

going to also change there to the next

2500:53

button and also change this symbol to

2500:56

this greater symbol right here like now

2500:58

in this case we are checking if the

2501:00

previous and next buttons are present or

2501:03

not okay so then if that is the case in

2501:06

this situation we're going to be

2501:08

iterating over through there so I'll use

2501:10

like let I equals to one and then I is

2501:13

less than five or less than or equal to

2501:15

five then I ++ in this case and now

2501:18

let's space our expectation like screen.

2501:20

get by text and here not test but text

2501:24

get by text there we go and I'm going to

2501:27

be ping like I and then two string and

2501:29

execute it and we want it to be in the

2501:32

document and execute it like so and now

2501:36

I'm going to go there and here we have

2501:38

to run like npm run test UI and now let

2501:41

me go to this vest refresh this

2501:43

and go into my component which is this

2501:47

pagination component let me just click

2501:49

on there and yep everything is passing

2501:50

and everything is working the way we

2501:52

expect them to work I'm going to

2501:54

collapse them I'm going to also hide

2501:56

this it function or this cases and now

2501:59

underneath there we have to Define yet

2502:00

another one so it calls the on page

2502:04

change function change when a page

2502:08

number is clicked okay so it should call

2502:11

that function which we just Define a few

2502:13

seconds ago and inside there first of

2502:15

all we are going to be mocking a

2502:16

function so I'll just use like and then

2502:19

FN execute there and I'm going to store

2502:21

the value of that inside the on page uh

2502:23

changes going be equals to this value

2502:26

now underneath that we have to use our

2502:27

render method and inside there let's

2502:29

just pass our page nation and I'm going

2502:31

to close it like this and now here we

2502:33

have to pass our current page which will

2502:34

be set to one and the total Pages which

2502:37

will be set to five and on the page

2502:39

change in this situation we are going to

2502:41

be passing our mock function which is a

2502:43

on page change okay so now let me just

2502:45

sp there and now underneath there we are

2502:48

going to be using the fire event and

2502:50

when somebody clicks on this in this

2502:52

situation we are going to be using like

2502:53

screen. get by text and we want to get

2502:56

like come on get by text there we go you

2502:59

want to get the third text right here in

2503:00

this situation and now we have to check

2503:02

whether the on page change function was

2503:04

called with a correct page number or not

2503:07

so now let me just P like expect an on

2503:09

page change and then to have been card

2503:13

with card with there we go I'm going to

2503:15

just paste three right here now let me

2503:17

just save my file and yep sure it does

2503:20

and here you can see where test are now

2503:22

successfully passing now let me just

2503:24

collapse this one as well and we should

2503:26

also disable the previous button if the

2503:29

page is less than one so I'll just

2503:31

choose like it disables disables the pre

2503:36

come on I guess I'm going to have to

2503:38

write a double quote so disables the

2503:41

what do we call it the pre button when

2503:43

on the first page uh pre Buton not when

2503:48

but yeah that's totally fine and here

2503:50

we're going to be also passing our Arrow

2503:52

function and render my component like

2503:54

page Nation component and close there

2503:56

and I'm going to be placing the current

2503:58

page which will be set to one the total

2503:59

Pages which will be set to five and on

2504:02

page change uh in this situation we are

2504:04

going to be providing our M function

2504:06

like VI and then FN and close this now

2504:08

let me just save there and underneath

2504:10

this render uh we're going to be getting

2504:12

our pre previous button so I'll just use

2504:14

like screen. get by text and past my

2504:16

list and symbol in previous button like

2504:19

so and now we are going to be getting

2504:20

our previous button and it should be

2504:22

equals to this value I'm going to also

2504:25

provide my expectation for the previous

2504:27

button and we want it to be disabled and

2504:30

I'm going to execute it like so and here

2504:32

you can see our test are now

2504:34

successfully passing and which is

2504:35

looking cool I'm going to also hide

2504:38

there and I'm going to just duplicate

2504:40

there because we are going to be using

2504:41

there for the next button so it should

2504:44

disables the next button come on the

2504:47

next button when it is the last page so

2504:49

let's just use the last let me check out

2504:52

the codes now we are providing every

2504:53

single thing that we should be providing

2504:56

I'm going to also change that to like

2504:58

next button and here uh we should just

2505:01

change there to like oh my God next and

2505:04

then greater than symbol and now let me

2505:06

just save my file and I guess that's

2505:07

totally done okay so we are now getting

2505:09

our next button when the last page is

2505:12

defined oh we we have to change there to

2505:13

five the current page should be five now

2505:16

let me just refresh there and yep

2505:17

everything is now working the way we

2505:19

expect them to work and now we have

2505:20

provide a test case for both the

2505:22

previous button and also for the next

2505:24

button to be disabled when the disabled

2505:26

prop is true okay so in this situation

2505:28

we are going to be using like

2505:31

disables uh the come on the I can't even

2505:35

speak today so I'll just use like the

2505:39

previous and also the x button when

2505:44

disabled uh prop is true that's totally

2505:48

true and here we have to pass our Arrow

2505:50

function render or component by using

2505:53

the page nation and I'm going to close

2505:55

there like this inside there we're going

2505:57

to be passing the current page which

2505:58

will be set to three we're going to be

2506:00

also passing the total Pages which will

2506:02

be set to five and on page changes in

2506:04

this situation we are going to be

2506:06

marking our function by using VI in FN

2506:08

and disabled will be set to totally true

2506:12

now let me just sa my file and now let's

2506:14

test this out underneath there first of

2506:16

all we are going to be getting the

2506:17

previous button and also the next button

2506:19

so I'll use like pre button it's going

2506:21

to be equals to the screen. get by text

2506:25

and past my list in preview button and

2506:27

I'm going to also duplicate and change

2506:29

that to the next button like so and also

2506:33

change this lbel to the next button and

2506:35

now we have to provide our expectation

2506:37

based on this so expect and we want the

2506:39

previous button to be disabled and we

2506:43

also want the next button to be also

2506:45

disabled and let's just save our file

2506:47

test this out so here you can see this

2506:49

test is also passing which means like

2506:52

everything is working the way we expect

2506:54

them to work and both the previous

2506:56

button and also the next button will be

2506:57

disabled if the prop is set to true if

2507:00

the disabled prop is set to true there

2507:01

we go and now we are going to be

2507:03

providing the final test which should

2507:05

highlight the current page with the

2507:07

correct styling okay so let's just use

2507:09

like

2507:11

highlights uh the current page with the

2507:14

correct Styles there we go and here we

2507:18

are going to be passing our Arrow

2507:19

function like this render our component

2507:22

which will be our page ination component

2507:25

and I'm going to close it like this pass

2507:27

our current page which will be set to

2507:28

three and total Pages which will be set

2507:31

to like five in this case and on page

2507:33

change in this situation we are going to

2507:35

be providing our mock function like V

2507:37

and FN save this file and underneath

2507:39

there we have to check if the correct

2507:41

page number is highlighted or not so

2507:43

I'll use like current page button it's

2507:45

going to be equals to the screen doget

2507:48

by text not all text but get by text

2507:52

like so and provide three inside the

2507:54

here we are going to be ping our

2507:56

expectation like current page button and

2507:58

we want that to have the class of uh

2508:01

background totally blue of 500 and I'm

2508:04

going to also duplicate that and changes

2508:06

the class of there to like T of totally

2508:09

white now let me just save my file and

2508:10

now also we are going to be ensuring

2508:12

that other Pages do not have the current

2508:15

page style okay so to ensure that we are

2508:17

going to be providing our expectation

2508:19

once again in screen. get by X once

2508:21

again and here we're going to be passing

2508:23

one inside there and not to have the

2508:27

class and here we're going to be passing

2508:28

like background totally blue of 500 let

2508:31

me just duplicate it like five times and

2508:34

here we're going to be changing these

2508:35

values so I'll just go ahead and change

2508:38

that to two this one to three this one

2508:39

to four and this one to five okay so now

2508:42

let's a s file and our test is

2508:45

failing okay so our test is failing I

2508:47

don't know why but it is let me just go

2508:50

into fix blue for the third one why is

2508:54

it failing for the third one oh that's

2508:55

because we are providing this third one

2508:57

right there it should be four and then

2509:01

uh five and we should just remove the

2509:02

last one so 1 2 four and five and we are

2509:06

already providing this three right here

2509:07

because we are not selecting that one

2509:10

and now let me just check this out so

2509:11

here you can see all of test are now

2509:13

successfully passing and we wrote 36

2509:16

test baby that's a lot of

2509:18

test that's a lot of test time to create

2509:22

another component which will be a select

2509:24

component so I'm going to go there and

2509:26

create my select inside there let's just

2509:29

create our index.

2509:31

TSX TSX there we go and also the select.

2509:35

TSX so I'm going to close all of them

2509:38

I'm going to go into the select right

2509:40

here and I'm going to first of all

2509:41

import react from reactjs also the CVA

2509:45

from the class variance Authority also

2509:48

the tww merge from the tailin merge and

2509:51

now we are going to be using our RFC it

2509:53

should take a few props so I'm going to

2509:55

restructure there which will be a

2509:57

variant prop the size prop the disabled

2510:00

prop and the options prop because we're

2510:03

going to be providing different options

2510:04

today op t o NS and also the class name

2510:08

and dot dot dot props we're going to be

2510:10

also annotating this component with the

2510:12

select props and now let me just copy

2510:15

the and create interface for them I'm

2510:16

going to go ahead and just write my

2510:18

interface and select props which will be

2510:20

extending from uh the omit and here

2510:23

let's space our react and then dot

2510:26

select HTML attribute and we are going

2510:28

to be specifically using there on HTML

2510:31

select element I'm going to close it

2510:33

right here also we have to provide the

2510:35

comma and size now let me just close

2510:37

there like this and inside there we are

2510:39

going to be using the variant uh so

2510:42

let's space or variant v a r i a n t

2510:45

this can be totally optional provide a

2510:47

primary variant or a secondary variant

2510:51

right here I'm going to be also

2510:52

providing a size and the size will be

2510:54

either a small size or use a medium size

2510:58

m e d i m or use a large size let's just

2511:02

save this file right now and we're going

2511:04

to be also providing a disabled one uh d

2511:06

i s a l which will be totally optional

2511:09

so now let me just anate the as Boolean

2511:11

and also for the options we are going to

2511:13

be providing a label for the option

2511:15

which will be totally a string and we're

2511:17

going to be also providing a value which

2511:18

will be also a string of array now let

2511:20

me just save this file right now now I'm

2511:22

going to go to the top and use my class

2511:24

variance Authority so I'll just use like

2511:26

con select and styles can be equals to

2511:29

CVA for the class variance Authority for

2511:32

the base classes we going to be

2511:33

providing a block and with will be set

2511:34

to totally full pairing for the xais

2511:36

will be set to four pairing for the y

2511:38

axis will be set to two and totally

2511:40

rounded Focus state will be to totally

2511:43

outline and none it should be Focus focu

2511:47

there we go and I'm going to be also

2511:49

providing a border and now we have to

2511:51

specify our different variation so I'll

2511:53

just use like variants v r i n TS and

2511:57

inside these variants let's space our

2511:59

specific variant today so for the

2512:01

primary we going to be providing like

2512:03

background totally white text of totally

2512:05

black and Border will be set to gray of

2512:08

300 and also for the focus we're going

2512:11

to be using ring blue 500 and on the

2512:14

focus the Border will be set to totally

2512:16

blue of 500 so now let's just save this

2512:19

file and now we going to be providing

2512:20

yet another prop for the secondary so

2512:22

let's just use like secondary I'm going

2512:24

to go back and this going to be set to

2512:26

like background to gray of 200 text will

2512:28

be set to totally black and Border uh

2512:31

will be set to gray of 400 I'm going to

2512:33

be also providing a focus for the ring

2512:36

and ring will be set to gray of 500 and

2512:39

for the focus once again the Border will

2512:41

be set to gray of of 500 so now let me

2512:43

just save this file right now underneath

2512:45

this variance we're going to be also

2512:47

specifying the size for there so the

2512:49

size is small uh so in this situation we

2512:51

are going to be using text of totally

2512:53

small and pairing for the Y AIS will be

2512:55

set to one for the medium screen we are

2512:57

going to be providing like text of

2512:58

totally base and pairing for the y axis

2513:01

will be set to two and now we are going

2513:03

to be also providing a large screen size

2513:05

which will be set to like text totally

2513:06

large pairing for the y axis will be set

2513:08

to three I'm going to save this file

2513:10

right now now we're going to be also

2513:12

providing a disabled state so d i s a b

2513:15

l e d for the disabled State this is

2513:18

provideed true to there so background

2513:19

will be set to gray of 300 and text will

2513:22

be set to gray of 600 and cursor not

2513:26

allowed because this going to be totally

2513:28

disable or will be gr of 300 now let me

2513:31

just save my file and now let's just

2513:33

provide a default variance for values or

2513:36

default values for the variants so I'll

2513:38

just use like variant and the default

2513:40

value for there will be set to primary

2513:42

the size will be set to medium and also

2513:44

the disabled state will be set to

2513:46

totally false okay so let's just change

2513:48

there now let me just save my file I'm

2513:50

going to copy there from there I'm going

2513:52

to collapse there and now let's use the

2513:54

inside our component so what I'm going

2513:56

to do is that I'm going to just use like

2513:57

tww merge for the tail merge and place

2514:00

my select styling inside there and we're

2514:03

going to be placing a variant size and

2514:04

disable from the props and here we're

2514:07

going to be also ping a class name and

2514:10

now let's store the inside the variable

2514:11

with the name of merged last name or

2514:14

names rather now let me just save there

2514:16

I'm going to copy the name of them here

2514:18

let me just remove this jsx and I'm

2514:20

going to change there to select and here

2514:22

inside there oh my god let's just change

2514:25

there to select and here inside there uh

2514:27

first of all we have to spread out all

2514:29

of the prompts and now let me past the

2514:31

class name and for these class names we

2514:33

are going to be passing our merge class

2514:35

names and also for the disabl state

2514:37

we're going to be passing that disabled

2514:39

state which is now coming from the props

2514:41

inside this select uh now we are going

2514:43

to be trting over through all of that

2514:45

options which we are now taking as a

2514:46

perimeter and now let me pass my option

2514:49

and here inside this option let's space

2514:51

our option right here okay so here let's

2514:54

just render our option come on option.

2514:57

Lael and now we are going to be also

2514:59

providing a key because it's going to

2515:00

take some sort of a key so option. value

2515:03

in this case and for the for each of the

2515:05

value we're going to be ping like

2515:07

option. specific value so now let me

2515:09

just save there and that's everything

2515:11

that we have to do for or select

2515:13

component so that was are about the

2515:15

story component I'm going to go into

2515:16

this index. TSX file and here we're

2515:18

going to be using export default from

2515:21

where from the select component come on

2515:25

I have to type this select and now let

2515:27

me say my file that's already done now

2515:30

let's go into this index.ts file which

2515:33

is now inside this components and now we

2515:35

are going to be also exporting um

2515:38

default as a select component from where

2515:42

from the select this just go into that

2515:44

select folder and now that's already

2515:46

done the next thing that we have to do

2515:48

is that we have to create a story for

2515:49

that component so I'm going to right

2515:51

click on there and create a select.

2515:53

stories. TSX and here inside there I'm

2515:56

going to import first of all react from

2515:58

the reactjs you would also need to

2516:00

import the type and which will be the

2516:02

meta type and also the story object is

2516:06

we're going to be grabbing there from

2516:07

the story book reactjs so let's just

2516:09

import there you also need to import our

2516:12

select components so we can test there

2516:14

now I'm going to just Define my meta and

2516:16

I'm going to annotate that with this

2516:17

meta and the type off will be set to

2516:19

this select and close then going to be

2516:21

equals to this object and we have to

2516:23

specify the title and the title will be

2516:25

this components and select component

2516:27

okay so we are going to be also passing

2516:29

the actual component and which will be

2516:31

that select component I'm going to also

2516:33

provide the perimeters and which will be

2516:35

that layout and here we have to set

2516:37

there to centered and I'm going to also

2516:40

provide the text and which will be set

2516:41

to

2516:42

the autod Dos like so now let me save my

2516:45

file but I'm going to also have to

2516:46

export it like so now here I'm going to

2516:49

be passing my type of story and this

2516:52

going to be equals to the story object

2516:54

and here let's space for type of meta

2516:56

and close it like this I'm going to be

2516:58

creating my story which will be a

2517:00

primary story so it's going to be equals

2517:02

to let's just write like story and it's

2517:04

going to be equals to this object and

2517:06

here we're going to be passing our

2517:08

arguments and the variant will be set to

2517:10

primary the size will be set to medium

2517:13

in this case and I'm going to also

2517:14

provide a few options like um it's going

2517:16

to have a few options so I'm going to

2517:18

past like label and label will have like

2517:20

option one and I'm going to also specify

2517:23

the value and the value will have the

2517:25

value of only one now let me say there

2517:28

put a comma there and I'm going to

2517:30

duplicate the three or two times so this

2517:32

one will be two and this one will be

2517:34

three I'm going to also change this one

2517:36

to two and this one to three now let me

2517:38

save my file and now let me just go

2517:40

ahead and go to my components refresh

2517:43

there and then I'm going to be going

2517:44

into this select component and here you

2517:46

can see we have our select statement

2517:48

where we can select our different

2517:49

options so that's going to be my primary

2517:51

component now if I click on this so

2517:53

that's going to be the secondary we can

2517:54

also change that to small or medium or

2517:57

large and here we can also set that to

2518:00

totally disable so if I have my mouse

2518:02

over today so it is now disabled and we

2518:05

can also check out our primary component

2518:07

but I'm going to have to refresh there

2518:09

this just refresh there and now let me

2518:10

click on this primary and this is our

2518:12

primary component now let me create

2518:15

another story so basically we're going

2518:17

to be exporting like con secondary it's

2518:20

going to be set to that story once again

2518:22

and inside there let's just pass our ARs

2518:24

and I'm going to be passing the variant

2518:26

and variant will be set to secondary and

2518:28

let's just past the size uh size and

2518:31

size will be set to medium and also past

2518:34

those options so you know what I'm going

2518:35

to have to copy there from there let's

2518:38

just copy there place it right here sa

2518:40

my file check this out so if I click on

2518:43

the secondary so this is how my

2518:44

secondary uh select statement will look

2518:46

like I'm going to just copy and place

2518:48

this entire story like one more time and

2518:51

now in this case we're going to be

2518:52

creating a story for the small one so

2518:55

there going to be small and here we can

2518:57

also specify like I don't know maybe

2518:59

primary would be fine but I'm going to

2519:01

change the size to totally small and

2519:03

that's totally done let's sa there and

2519:05

if I click on the small one so this is

2519:07

how we are going to be getting a small

2519:08

uh what do we call it select statement

2519:10

or our component now let me duplicate

2519:12

there one more time this time we are

2519:15

going to be creating a story for the

2519:16

large one so now let me just write like

2519:18

large that's going to be set to primary

2519:21

and now we have to change the size to

2519:22

like large and the rest of the stuff

2519:24

will be the same so let's say our file

2519:26

test this out if I click on the large so

2519:28

it's going to gives us this large select

2519:30

statement right here or uh select

2519:32

component to be precise so that's SL

2519:35

done now we are going to be creating the

2519:36

final uh story for the disable so I'll

2519:39

just export default or export con

2519:42

disabled and it's going to be a story so

2519:44

let's just annotate there I'm going to

2519:46

be also providing an arguments and

2519:48

provide my variant and variant will be

2519:49

set to primary I'm going to be also

2519:51

providing a size and the size will be

2519:53

set to medium and for the disabled one

2519:56

we are going to be setting that to true

2519:57

in this case and I'm going to also

2519:59

specify a few options today so let's

2520:01

just space those options I'm going to

2520:03

past like label just one option would be

2520:05

fine and this will be a disabled option

2520:07

because we would not be able to select

2520:09

it so that's why I'm only writing one

2520:11

and it's going to be just a disabled I

2520:13

guess save my file if I click on there

2520:16

here you can see this is now totally

2520:17

disabled okay so that was the entire

2520:20

story of our select component so then

2520:22

install done now let me go ahead and go

2520:24

to my test folder and then I'm going to

2520:26

go into the components folder and now

2520:28

here we have to create a new file for

2520:30

the select. test. DSX and here inside

2520:34

that we have to import react from the

2520:35

reactj we also have to import the render

2520:38

and also the screen from where from the

2520:40

testing Library and then from the

2520:42

reactjs we would also need to import our

2520:45

select components so we can use it and

2520:47

now here we are going to be just

2520:48

creating our describe and select

2520:51

component like so and I'm going to just

2520:54

hit Tab and then inside there we're

2520:56

going to be writing our first test case

2520:58

like it should renders with the correct

2521:02

options first of all we have to even

2521:03

check like whether it will render or not

2521:06

with the correct options so I'll just go

2521:08

ahead and WR a few options right here so

2521:10

inside they I'll just Define like label

2521:12

one you know what I'm going to just copy

2521:14

that thing from here I'm going to just

2521:16

copy there and place it right here so

2521:19

I'm going to have to remove this

2521:20

existing one and that's going to be add

2521:22

for the options now the next thing that

2521:23

we have to do is that we have to render

2521:25

our component to the virtual Dom so I'll

2521:27

just use like select and I'm going to

2521:29

close it like this now here we have to

2521:31

specify those options and I'm going to

2521:33

be placing those options which we are

2521:35

now providing right here okay so that's

2521:37

only done now we are going to be also

2521:39

using the on change event handler

2521:42

and we want to make a clown or mock of

2521:44

there so I'll use like uh VI and then FN

2521:47

we also have to import that vi from the

2521:49

vest so I'll just import that vi from

2521:52

where from the v test like so now let me

2521:55

just save this file right now and now

2521:56

here we are going to be checking if all

2521:58

the options are rendered or not so we're

2522:00

going to be using like option dot for

2522:02

each option and we're going to be just

2522:04

passing like that specific option and

2522:06

I'm going to be providing my expectation

2522:08

like uh for the screen. get by text

2522:11

we're going to be set cting our element

2522:12

by get by text and let's space our

2522:15

option. label inside there which we are

2522:17

now providing right here there we go so

2522:21

if that is the case we want that to be

2522:23

in the document and now let me just

2522:25

execute this s my file and now let me go

2522:27

into this s test and let's just refresh

2522:30

there so here you can see all of our

2522:31

tests are now successfully passing but

2522:33

I'm going to collapse this one and let's

2522:35

just check this testing I mean like this

2522:37

select testing and yep it is working the

2522:40

way we exp him to work I'm going to hide

2522:42

there from here and now underneath there

2522:45

we have to check like it renders with uh

2522:49

the correct variant and size class or

2522:53

classes would be fine rather so now let

2522:55

me just P my arrow function inside there

2522:57

and I'm going to just create a few

2522:59

options so that options would be like

2523:01

label and that's going to be set to like

2523:02

option one I'm going to be also

2523:04

providing a value to the and value will

2523:06

be set to only one I'm going to just

2523:08

duplicate there one more time and change

2523:10

there to two and change this value to to

2523:11

two as well so that's to done now we are

2523:14

going to be destructuring the container

2523:16

from the render function so now here we

2523:18

are going to be passing first of all our

2523:19

select statement and I'm going to

2523:21

execute the like this so we are going to

2523:23

be passing not this one but the options

2523:26

and here we have to past those options

2523:28

inside there or it should be options

2523:32

let's just put s and also s here and we

2523:36

are going to be also providing a variant

2523:38

and variant will be set to primary

2523:40

primary like so and I'm going to be also

2523:43

specifying a size and the size will be

2523:45

set to medium it is not helping me with

2523:48

the auto correct so I'm struggling here

2523:50

so I'm going to just use like on change

2523:52

and let's just provide our mock function

2523:54

and execute them and now that's toally

2523:57

done but here we are going to be

2523:59

destructuring the container from this

2524:01

Rand method so I'll just destructure the

2524:03

container c n t i n e r there we go and

2524:06

now we are going to be just renaming

2524:08

there to like primary container like so

2524:11

and now underneath it we have to provide

2524:13

our expectations so now I'm going to be

2524:14

using like expect and then primary

2524:16

container that first child okay and we

2524:20

want that to have these classes which we

2524:22

are now going to be providing right here

2524:24

so we want that to have the class of

2524:25

background to White Tex of to Black and

2524:28

border of gray of 300 and on the Focus

2524:32

ST we're going to be providing like ring

2524:34

blue of 500 and also on the Focus ST the

2524:38

Border will be set to totally blue of

2524:40

500 so now let me just say there and

2524:42

underneath there we are going to be

2524:43

providing yet another expectation for

2524:45

the primary container and we are going

2524:47

to be getting the first child from there

2524:49

and we want that to have the class of uh

2524:52

text will be set to totally base and the

2524:54

pairing for the y axis will be set to

2524:56

two I'm going to save this file right

2524:57

now and test this out now let me just

2524:59

refresh there and here you can see our

2525:01

second test is also passing or or our

2525:04

third test yeah this is a second one not

2525:06

a third test let me just zoom in a bit

2525:09

and yep our test is now successfully

2525:11

passing I'm going to hide there because

2525:13

that's a lot of code and now we are

2525:14

going to be also testing the secondary

2525:16

variant as well inside that same test so

2525:20

I'm going to go ahead and just uh render

2525:21

my component once again and I'm going to

2525:23

be using like select statement and I'm

2525:25

going to have to close it like this and

2525:28

provide my options inside there and that

2525:30

same options and provide my variant and

2525:32

in this case we're going to be passing a

2525:34

secondary variant like so and for the

2525:36

size we're going to be providing like

2525:38

the large size and I'm going to be also

2525:40

providing the on change and let's just

2525:42

use like V and then FN and execute there

2525:45

but now in this case we are going to be

2525:47

restructuring the container and I'm

2525:49

going to rename that to the secondary

2525:53

secondary um container like so and now

2525:56

let me just save this file right now and

2525:58

now we are going to be using this

2525:59

secondary container to provide our

2526:01

expectations so now underneath there uh

2526:04

what do we have to do we have to provide

2526:06

our expectation and you want to get like

2526:08

the secondary container and first child

2526:10

from there we want that to have at least

2526:13

these classes okay so I'll just write

2526:15

like background tot gray of 200 and also

2526:18

text will be set to totally black border

2526:20

will be set to gray of 400 and the Focus

2526:24

ST f c us on the Focus ST ring will be

2526:27

set to gray of 500 on the Focus ST once

2526:29

again we're going to be providing a

2526:30

border of totally gray and 500 I'm going

2526:33

to be providing yet another expectation

2526:35

for this same it okay so let's just use

2526:38

like secondary container once again you

2526:40

want to get the first child out of there

2526:43

and we want that to have the classes of

2526:45

textor large and also pairing on the y

2526:48

axis will be set to three now let me

2526:49

just save my file and now let me just

2526:51

refresh there and here you can see we

2526:53

are now getting all of our test are now

2526:55

successfully passing so now we have to

2526:58

hide there because that's a lot of code

2527:00

and now we are going to be providing yet

2527:02

another test case so let's just use like

2527:05

it disables come on disables the select

2527:09

s e c select when the disable prop come

2527:13

on Prop is true okay so we are going to

2527:15

be disabling our select statement when

2527:17

the disabled prop is provided and that

2527:20

set to True okay so now inside there

2527:22

let's just uh create a few options and

2527:24

let's just provide like I don't know

2527:26

label one uh which will be option one

2527:29

and now we are going to be also

2527:31

providing a value and value will be set

2527:32

to one change that to two and change

2527:36

this value to two as well underneath

2527:38

there we are going to be using the

2527:39

render method and provide my select

2527:41

statement and close it like this and for

2527:43

the options we going to be providing

2527:45

those options and for the disable now we

2527:48

are going to be setting that to true in

2527:50

this case and on change we're going to

2527:52

be using like vfn and execute there and

2527:55

now underneath there we are going to be

2527:56

getting that specific element by using

2527:58

get by row and here let's just proide

2528:01

like uh combo box because in this case

2528:04

we're going to be selecting our options

2528:06

or select statement to be precise that's

2528:08

why we are now ping like combo box and

2528:11

now let's just use like select element

2528:13

this going to be equals to that same

2528:15

value underneath that we have to provide

2528:17

our expectation and which will be set to

2528:19

a select element and we want it to be

2528:22

disabled and execute it so let's say our

2528:25

file test this out so here you can see

2528:27

it will be disabled uh when we specify

2528:30

the disabled prop to true that's to done

2528:33

I'm going to also hide that underneath

2528:35

we going to be creating yet another it

2528:37

statement so it should renders uh with

2528:40

the default value if provided okay so if

2528:44

somebody provided a default value today

2528:46

so it should also render there let me

2528:48

just P these options right here and now

2528:51

underneath there we're going to be using

2528:52

like Fender and let's space our select

2528:55

statement and close there I'm going to

2528:56

be also providing these options and

2528:58

place these options right here and value

2529:01

will be set to two in this case so now

2529:03

we are going to be selecting that second

2529:05

value out of the and on change will be

2529:07

set to V and then FN and execute there

2529:10

underneath let's just proide our

2529:12

expectation that's going to be the main

2529:13

thing okay so let's just get our element

2529:16

by rule first of all and we are going to

2529:18

be getting there by using this combo box

2529:22

and now we want it to have the value of

2529:25

two so now let me just save this file

2529:27

right now so here you can see it should

2529:29

also render with the default value if

2529:31

somebody provided that's only done I'm

2529:34

going to also hide that and now let me

2529:36

provide the last case for this component

2529:39

so like it applies the correct Styles uh

2529:43

when disabled okay so we should also

2529:46

apply correct style when we disabled

2529:48

there okay so first of all let's assume

2529:50

and create a few options it's going to

2529:52

be set to like um that same option level

2529:55

one or option one and we're going to be

2529:59

also providing a value and value will be

2530:01

set to one duplicate that change that to

2530:03

two and change this value to two as well

2530:06

okay so here now we are going to be

2530:08

providing our render method and provide

2530:10

our select statement inside there but we

2530:12

not going to be closing it like this now

2530:14

we are going to be providing our options

2530:15

and that options which we just defined

2530:17

up above provide this disable and set it

2530:20

to true and when somebody try to change

2530:23

this we are going to be using V in FN

2530:25

and execute there but now from this

2530:27

render method we're going to be

2530:29

destructuring this container this going

2530:31

to be set to this container I mean like

2530:32

this render method to be precise okay so

2530:35

now first of all we want to get the

2530:37

first chart so we going to be using that

2530:39

container and then first childart and

2530:41

I'm going to sort the value of that

2530:43

inside this selected selected element

2530:46

and it's going to be set to this

2530:47

container first child to be precise now

2530:50

let me just proide my expectation and we

2530:52

want to provide those expectation for

2530:54

this selected element and we want that

2530:56

to have the classes of background to gr

2530:59

of 300 I'm going to duplicate there a

2531:01

few times and here let's just change

2531:03

these class names to like cursor not

2531:06

allowed and also change that to order

2531:10

will be set to gray uh gray of 300 and

2531:14

now let me just save my file and all of

2531:16

our test are now successfully ping which

2531:18

means like where components is working

2531:21

the way we expect them to work and

2531:23

that's

2531:24

amazing that's phenomenal that's

2531:28

incredible okay I guess that was the

2531:30

last component I'm not quite sure

2531:32

welcome to the new section so in this

2531:34

one I'm going to be showing you the real

2531:36

power of yan workspaces mono

2531:39

repos I said it like a Yaga anyway so

2531:42

what I'm going to do is that I'm going

2531:44

to right click on there and open my

2531:45

terminal zoom in a bit so you guys can

2531:48

see everything a bit better like so and

2531:50

now we are going to be creating a new

2531:52

folder with the name of uh mono repost

2531:55

demos and I'm going to go into that mono

2531:57

repost demos now let me open that in my

2531:59

vs code and this is how it looks like so

2532:02

here you can see we are now inside this

2532:03

mono repost demos folder and now I'm

2532:06

going to be just creating a new file

2532:07

with the name of package.json and inside

2532:11

there I'm going to just specify a few

2532:13

things so the first thing that I have to

2532:15

specify will be a private because we are

2532:17

going to be creating our private uh what

2532:19

do we call it monor repo and I'm going

2532:21

to set that to true and also we are

2532:23

going to be specifying the workspaces

2532:25

because in this case we want to use the

2532:27

workspaces if you're working with

2532:28

multiple projects inside your monor repo

2532:31

like for instance you're going to be

2532:32

working with the UI component library or

2532:35

something like you don't have to create

2532:37

this folder which I'm about to create

2532:38

you're going to be also working on the

2532:40

web version

2532:41

and also you're going to be working with

2532:43

the uh come on the native or the mobile

2532:47

version or something like that of your

2532:49

project so in that case you can specify

2532:52

those folders right here inside this

2532:54

rout of package.json inside this

2532:57

workspaces like you can specify mobile

2533:00

version and so on and so forth but we

2533:01

are not going to be doing that I'm going

2533:03

to just remove these three folders and

2533:06

instead we're going to be creating

2533:07

another folder with the name of packages

2533:10

like so and we're going to be storing

2533:12

all of our packages inside this folder

2533:15

okay so now here we just have to specify

2533:17

that packages folder so I'll use like p

2533:20

a c k a g s and every single thing

2533:22

inside their packages folder okay so now

2533:25

let me just save my file and that's to

2533:27

it about the package.json and now let me

2533:29

just close there now the next thing that

2533:30

I want to do is that I want to create a

2533:32

few packages so what I'm going to do is

2533:34

that I'm going to just zoom in a bit

2533:36

first of all we are going to be creating

2533:37

a folder which will be my math and now

2533:40

inside this folder I'm going to be

2533:42

writing some code which will be useful

2533:43

for those other packages so this one

2533:45

will be like basically my utility

2533:47

functions uh package or something like

2533:49

that now let me create yet another

2533:51

folder inside the packages and which

2533:53

will be like my project so basically uh

2533:57

we are going to be writing our utility

2533:59

functions or math utility functions

2534:01

inside my math and then we are going to

2534:03

be using them inside this my project

2534:05

folder okay so then inst all you're done

2534:08

now the next thing that we have to do is

2534:09

that we have to initialize both both of

2534:11

these packages okay so I'm going to open

2534:13

my terminal and now let me go ahead and

2534:15

go to that packages folder uh so let's

2534:18

just write like packages folder and now

2534:20

inside there first of all we are going

2534:21

to be going into this my math folder so

2534:24

I'll just go ahead and go to my math and

2534:26

now we are going to be using a Yan in- y

2534:29

to initialize there so here you can see

2534:31

it's going to giv us this package.json

2534:33

so now let me just click on there so it

2534:35

only has the name version main license

2534:38

and they said okay so now we

2534:40

successfully initialize or my math

2534:42

package but now here we are going to be

2534:44

also creating a new file with the name

2534:46

of

2534:47

index.js and we are going to be filling

2534:49

there in a few second but now let me

2534:50

just close there so that's totally it

2534:52

about the my math package now let me go

2534:55

ahead and go to this my project and we

2534:57

are going to be also initializing that

2534:59

okay so I'll just uh go out from my math

2535:01

which we are now inside so I'm going to

2535:04

go out from there and now we are inside

2535:06

the packages folder so now you want to

2535:08

go into this my math project so I'll

2535:10

just just go ahead and CD to my math uh

2535:13

not my math but my project there we go

2535:15

and now we are going to be also

2535:16

initializing that so I'll just use like

2535:18

here in y and now if I hit enter so as

2535:21

you can see we now getting this

2535:23

package.json we now getting the name

2535:25

version man and license and that's all

2535:27

yet now I'm going to also right click on

2535:29

there and create a new file inside there

2535:30

which will be index.js and once again we

2535:33

are going to be filling there in a few

2535:34

seconds but not right now so now let me

2535:37

just close there now here I'm going to

2535:39

open this package.json and I'm going to

2535:41

specify the type of module okay so in

2535:44

this case we're going to be using a

2535:45

modules if you guys don't know what this

2535:48

line means you don't have to worry about

2535:50

that because this is just related to uh

2535:52

the nodejs and you don't have to worry

2535:54

about this type module okay so basically

2535:56

it's going to allows us to use the es6

2535:58

um or Beyond like Import and Export

2536:00

statement so we don't have to just write

2536:02

like uh what do we call it the export do

2536:04

something and something like that so we

2536:07

just have tried like export default and

2536:08

something and we just have tried import

2536:11

something from some package there we go

2536:14

that was a rough explanation but here

2536:16

you have to keep that in mind I'm going

2536:17

to copy this line of code now let me go

2536:19

ahead and go to my math package then I'm

2536:21

going to go into my package.json and

2536:23

place there right here and now let me

2536:25

just save this file right now so next

2536:28

I'm going to go into this my math

2536:29

package and here we are going to be

2536:31

writing a few math utilities so I'll

2536:33

just basically write like add function

2536:35

and it's going to take like X and Y and

2536:37

we are going to be just combining or

2536:39

yeah adding there and now we're going to

2536:41

be also creating like subtract function

2536:43

and this going also take the X and Y and

2536:46

now we are going to be subtracting X

2536:48

from y we would also need to multiply m

2536:52

l TP l y is going to also take the X and

2536:55

Y and we are going to be using like X

2536:56

time Y and also you would need the divde

2537:00

it's going to take the X comma Y and

2537:03

here is going to be equals to like X

2537:05

time y or not times but divide y God

2537:09

damn it and now here we're be just

2537:11

exporting there so we can use the in

2537:12

other files so I'll just use like add

2537:15

then subtract come on subtract also

2537:18

multiply and divide so now let me just

2537:20

save my file and that's going to be it

2537:22

for our utility function now that we

2537:24

successfully created this utility

2537:26

function and we also exported there so

2537:28

that we can use that in other packages

2537:30

or files now let me just close them I'm

2537:33

going to go into my my project and now

2537:35

let me just open this index.js right

2537:38

here now we are going to be consuming

2537:40

there okay so what I'm going to do is

2537:43

that I'm going to just write like import

2537:44

and now we are going to be getting the

2537:46

ad from where from my math and here you

2537:49

can see you might be thinking like husan

2537:51

you have to write some sort of a path

2537:53

then you would be able to use there like

2537:55

you have to write this path and then go

2537:56

to my math and then you are going to be

2537:58

getting that content from this index.js

2538:00

but now we are not working with the

2538:02

static files we are now working with the

2538:04

mono repo so which means like we have to

2538:06

install this my math package first of

2538:08

all and then we would be able to use

2538:10

there so if I just save my file right

2538:12

now and console.log this add function so

2538:14

I'm going to just write like two and

2538:16

then three so it's going to add there

2538:18

and that's toally done so now that we

2538:20

successfully import the code from my

2538:22

math and we are now using there but it

2538:24

will not work and why is there that's

2538:27

because we have to install this package

2538:29

inside this dependence inside this

2538:32

project then we would be able to use

2538:34

there you can think about that is like

2538:36

uh for instance you are working with

2538:38

reactjs and you have to install the T in

2538:40

CSS then you would be able to use that

2538:42

okay so what I'm going to do is that I'm

2538:44

going to go into my package.json file

2538:47

and here we're going to be providing our

2538:49

dependencies so I'll use like

2538:50

dependencies and for these dependencies

2538:53

I'm going to be adding like my math and

2538:55

here I'm going to be writing like uh the

2538:57

version of

2538:58

1.0.0 and now let me just save my file

2539:01

now that we successfully add the as a

2539:03

dependency but now we have to install

2539:05

there okay so now let me just close

2539:06

there and I'm going to open my terminal

2539:08

now let me go ahead and we are already

2539:10

in inside this my project so now we just

2539:12

have to use like Yar install and once I

2539:15

do that Watch What Happens so here you

2539:17

would be able to see that package.json

2539:19

and now if I just hit enter so here you

2539:21

can see it's going to gives us this node

2539:23

modules and also yarn. log okay so now

2539:26

let me just close there if I go into

2539:28

this node modules so now inside there we

2539:31

have our my math if I open there now

2539:33

inside my meth we are now getting all of

2539:35

that functions right here now let me

2539:37

just close them and finally we just have

2539:39

to run our code which is now available

2539:42

inside my project so what I'm going to

2539:44

do is that we are already inside this my

2539:46

project so I'm going to use like node

2539:47

and then index.js hit enter so now it's

2539:50

going to gives us the value of fiveo

2539:52

here so if I want to import something

2539:54

else like I don't know maybe um multiply

2539:56

or something like that and I'm going to

2539:58

just duplicate this line of code and

2539:59

change there to like multiply come on

2540:02

multiply like so and now let me just say

2540:04

my file run there and now it's going to

2540:06

also multiply there which means like our

2540:09

package is working the way we exp him

2540:11

work so that was about the basics of

2540:12

yarn workspaces mon repos but in some

2540:15

situation you would also see like people

2540:17

add where you call it their name or

2540:19

their aliases so what do I mean by there

2540:21

I'm going to go ahead and go to my

2540:23

project and then I'm going to go into

2540:24

the package.json inside there and here

2540:27

we are going to be changing the name to

2540:29

our Alias so I'll just add like this add

2540:32

symbol and I'm going to give it my name

2540:33

which is husan and if you are using your

2540:35

own package so you should also

2540:37

definitely provide your own name and I'm

2540:39

going to copy this save this file and

2540:41

now I'm going to go into my math project

2540:44

and then I'm going to go into the spec.

2540:45

Json and place there right here save

2540:48

this file and now here let's just remove

2540:50

the I'm going to delete this node

2540:52

modules folder I'm going to also remove

2540:54

the san. log folder and now I'm going to

2540:57

open my terminal and now we just have to

2541:00

reinstall this I'm going to go into the

2541:01

root first of all and now here let's

2541:04

just use like uh yarn install but before

2541:07

we do that I forgot to mention first of

2541:09

all we have to go into this package.json

2541:12

inside my my project and we also have to

2541:15

change that to hosan because now we are

2541:18

going to be installing this package

2541:20

because we already changed the name of

2541:21

there okay so now let me just close

2541:23

there and watch what happens so if I

2541:25

just use like ion install and if I hit

2541:28

enter so it's going to install there

2541:30

right here inside my project so now if I

2541:32

just go there here you can see we have

2541:34

only one folder and inside there we have

2541:36

our packages right here so which means

2541:38

like we can totally use that and now let

2541:40

me just close there I'm going to go into

2541:42

my project and now it will not work and

2541:45

can you guess why it will not work it

2541:48

will not work because we have to change

2541:50

this name to uh husan webd or just husan

2541:54

and then my project or my math now let

2541:56

me just use them and here I'm going to

2541:59

just uh use that same command but first

2542:01

of all we have to go ahead and go to my

2542:03

project so I'll use like my project then

2542:06

I'm going to use like node index.js and

2542:08

hit enter so now it will success y work

2542:11

but now if I just remove that from here

2542:13

and rerun there it will gives us an

2542:15

error because we have to specify that

2542:17

actual path right here okay so that's to

2542:20

done and this is how we can set up our

2542:22

mono repost so first of all we have to

2542:24

initialize our package.json and then we

2542:27

have to specify our works spaces or our

2542:30

packages like this so if you have like

2542:32

more than one packages you can totally

2542:34

Define there right here like uh you can

2542:36

say my math uh you can also say like you

2542:40

can also say like my project or

2542:42

something like that but I want to group

2542:44

all of their packages into one folder

2542:46

which will be a packages folder because

2542:48

this is a public convention like

2542:50

everybody use this convention so that's

2542:52

the only reason I'm going to be using

2542:54

packages and every single thing inside

2542:56

these packages will be included as a

2542:59

package okay so this is a separate

2543:01

package and this is also a separate

2543:03

package so if I change that to like

2543:05

something else if I store that inside

2543:07

some other folder it will totally work

2543:10

because we have to just install that

2543:12

right here and it will not care about

2543:14

this code and by the way let me just

2543:15

also show you one more thing so if you

2543:17

weren't using yarn workspaces like monor

2543:20

repo so like let's suppose if I go ahead

2543:22

and go to my math and if I just change

2543:25

something like if I made a bug here you

2543:27

can see this is now adding but let's

2543:29

suppose if I just write like minus say

2543:32

my file and now let me just close this

2543:34

file and here you can see we are now

2543:36

using this add and it's supposed to add

2543:38

these two numbers right here right so

2543:40

now let me just delete this line of code

2543:42

and now I'm going to be using that uh

2543:44

node index.js and if I hit enter right

2543:47

here so now it will gives us minus three

2543:49

and why is that that's because we Chang

2543:52

this code right here there is some bug

2543:54

inside our library we have to fix there

2543:57

so if you weren't using the yarn

2543:59

workspaces first of all you would need

2544:01

to fix this buug that's the first thing

2544:03

that you would have to do second of all

2544:05

you need to push the to the npm by using

2544:08

npm um what was there npm push us I'm

2544:13

not quite sure about that but it was a

2544:14

command which will allow you to push

2544:16

your packages to the npm but the next

2544:18

thing that you have to do first of all

2544:20

you have to fix the bug then you have to

2544:22

push that to the npm then you also have

2544:24

to push that to the GitHub and also then

2544:28

you would have to reinstall your

2544:30

packages from there and then finally you

2544:32

would have to use this code and then you

2544:34

would have to check like whether the

2544:35

code will work or not but now you're

2544:38

using a monor repos so anything you

2544:40

change inside this file will be directly

2544:43

reflect inside this file okay so if I

2544:46

just fix this pug and now let me just

2544:48

try there once again and here you can

2544:50

see we are now getting the exact same

2544:51

result but now if I change something

2544:54

like I don't know maybe if I just use

2544:56

like minus or something like that once

2544:58

again and if I just rerun that here you

2545:00

can see we are also getting that same

2545:03

result so you don't have to do like all

2545:04

of that work you don't have to like

2545:07

first of all you have to fix a uh bug

2545:09

then you would have to publish there to

2545:10

the npm also you would need to publish

2545:12

there to the GitHub then you would have

2545:14

to uninstall that from your existing

2545:16

project and then you have to reinstall

2545:19

there and then you have to use the code

2545:21

and check whether the code will work or

2545:23

not okay so that was a lot of

2545:26

explanation about the mono repos and I

2545:28

hope you enjoyed it all right guys so

2545:31

now we are at the point where we are

2545:32

going to be building our own design

2545:34

system in reactjs and that's going to be

2545:36

a lot of fun so what I'm going to do is

2545:39

that I'm going to open my ter

2545:40

and now let me just zoom in a bit so you

2545:42

guys can see everything a bit better

2545:45

like so I'm going to create a new folder

2545:48

with name of uh my own design system now

2545:51

let me go ahead and go to that my own

2545:53

design system folder like so and I'm

2545:56

going to open there in my vs code and

2545:58

this is how it looks like so I'm going

2546:00

to open my terminal and first of all we

2546:02

have to initialize our GitHub repository

2546:04

if you want to do that you can but if

2546:06

you don't want to do that you don't even

2546:08

have to do that now we're going to be

2546:09

using another command which will be the

2546:11

Yan set version Berry basically it's

2546:15

going to use us the latest version of

2546:16

the Yar okay so now let me open my

2546:19

sidebar right here so it's going to

2546:20

install the latest version of yan and

2546:22

chances are if you are watching this

2546:24

course in the future the version of yan

2546:26

will be totally change and that's

2546:28

totally my guarantee it will be Chang

2546:31

and now we are using uh Yan

2546:34

4.6.0 but as long as you're using like

2546:36

Yar set Berry version that's going to be

2546:39

completely fine so that's done now the

2546:41

next thing that we have to do is that we

2546:42

have to create our mono repo so first of

2546:44

all we are going to be creating our

2546:46

packages folder and inside this packages

2546:48

folder we are going to be defining our

2546:50

own packages so I'm going to go ahead

2546:52

and first of all start from the first

2546:54

one which will be the foundation package

2546:56

f o u n d a t i o n like so we are going

2546:59

to be also creating another package for

2547:01

the rejs and also we are going to be

2547:03

creating a package for the story book

2547:05

like so and in which we're going to be

2547:07

writing our stories and you will see

2547:10

there in a few second but now we are

2547:12

going to be going into this Foundation

2547:14

folder and we have to initialize there

2547:16

as a package so I'm going to open my

2547:18

terminal and now I'm currently inside my

2547:20

own DS package which is now the root so

2547:23

now you want to go into the packages and

2547:25

then the foundation folder so I'm going

2547:26

to use like CD and then the packages

2547:28

folder then we want to go to the

2547:30

foundation folder and now we are going

2547:32

to be using like Yan in it and now if I

2547:35

hit enter so it's going to initialize my

2547:36

yarn right here so if I open there here

2547:39

you can see we are now getting this

2547:40

package.json and also readme.md and we

2547:43

are now getting like uh the name of

2547:45

foundation and also the package manager

2547:47

so now let me just close there that's

2547:49

totally done now the next thing that we

2547:50

have to do is that we also have to go

2547:52

into this react package and also

2547:54

initialize that okay so I'm going to

2547:56

open my terminal once again we are now

2547:58

inside the foundation package so I'm

2547:59

going to go back from the CD dot dot and

2548:02

now we are going to be going into CD to

2548:05

the react folder and now we are going to

2548:07

be using Yan in it right here so if I do

2548:10

there now let me just close there now if

2548:12

I expand this react folder so we still

2548:15

have this package.json and also this

2548:17

readme.md inside both of these folders

2548:20

okay so now let me just close there now

2548:22

we are going to be going into the story

2548:24

book folder and we are going to be

2548:25

initializing there as a private package

2548:28

so how we are going to be doing there

2548:30

first of all we have to get out from

2548:31

this reactjs now we are inside this

2548:33

packages folder and now we are going to

2548:35

be going into the story book package so

2548:38

I'll just write like story book and now

2548:40

let me just hit enter and now we are

2548:41

going to be using like Yan in it and

2548:44

then D- private because we want to

2548:46

initialize that as a private package

2548:48

which we are not going to be pushing

2548:49

there to like anywhere now let me just

2548:51

open this package.json file so here you

2548:54

can see we're now providing this uh

2548:56

private label right here which means

2548:57

like this package is totally private

2549:00

which means like we are going to be only

2549:01

able to use the inside this packages

2549:03

folder but nowhere else so now that's to

2549:07

done now the next thing that we have to

2549:08

do is that we have to make the is ual

2549:10

monor repo so I'm going to just double

2549:12

click on there and here we are going to

2549:14

be passing our workspaces so now let me

2549:17

go to the yeah we're now at the same

2549:19

place and now I'm going to just use like

2549:21

workspaces and we have to tell a

2549:23

specific workspace which will be that

2549:25

packages folder and every single thing

2549:28

inside that packages folder p c k a g s

2549:31

and which is that packages folder right

2549:33

here that's totally done the next thing

2549:35

that we have to do is that we have to

2549:36

provide our aliases so I'm going to go

2549:38

to the foundation package

2549:40

and now I'm going to just write like the

2549:42

Alias of Huzan come on hen DS and that's

2549:45

going to be here if you using some other

2549:48

package like if you want to provide your

2549:49

own name you totally can but my

2549:51

recommendation will be to at least

2549:53

provide my name because I'm going to be

2549:55

using some commands and you will just

2549:57

get confused so at least if you watching

2549:59

this course please provide my name and

2550:02

then later if you want to change there

2550:04

you totally can so I'm going to copy

2550:06

there from here say my now let me just H

2550:08

my mouse over to there and you won't be

2550:10

getting this uh error so now let me just

2550:12

add this sa my file now I'm going to be

2550:14

going into this react package open my

2550:17

package.json from there and place it

2550:19

right here this hosen DS and reactjs now

2550:22

let me go ahead and go to this uh story

2550:24

book then package.json and also place it

2550:27

right here save my file and close there

2550:30

now I want to explain one more thing

2550:32

about uh what do we call it mon repos so

2550:34

let me just zoom in a bit here you can

2550:36

see this story book package is now

2550:38

dependent upon the rejs and also this

2550:41

Foundation package so now inside this

2550:44

Foundation package we are going to be

2550:45

using or we are going to be building or

2550:48

design tokens and we are going to be

2550:50

also using those design tokens inside

2550:52

this Rea components and then we are

2550:55

going to be visualizing there by using

2550:56

this story book so both of these

2550:59

packages are super important for this

2551:01

story book and this story book is

2551:04

dependent upon these two packages so now

2551:06

let me just highlight there right now

2551:08

and let's just right click on there then

2551:10

I'm going to go into the set color and

2551:13

I'm going to change some color off there

2551:14

you don't even have to do that because I

2551:17

want to do that I'm showing you there

2551:19

I'm going to just choose this fuchsia

2551:20

color and now let me just click on there

2551:22

so I want to say like these two packages

2551:25

are super important for this story book

2551:27

and now we are going to be adding both

2551:29

of these packages to this story book so

2551:31

for that we're going to be using this

2551:33

command so now let me just go back and

2551:35

first of all you want to go into the

2551:36

yarn workspace and we want to access

2551:39

Jose n DS and then the story book okay

2551:42

which will be story book package like so

2551:45

so now what do we want to add so I'll

2551:47

just use this add we want to add reactj

2551:49

and also the foundation package so I'm

2551:51

going to just use like hosan DS and we

2551:54

want to just add the reactjs and we also

2551:56

want to add hen DS and then the

2551:59

foundation package so now if I hit enter

2552:01

so it's going to just install all of

2552:03

that packages inside this story book

2552:06

right here so if I click on there now we

2552:08

are getting the dependencies of who DS

2552:10

foundation and also H DS reactjs so

2552:13

that's totally done and now we also know

2552:15

that reactjs is also dependent upon this

2552:18

Foundation package like we are going to

2552:20

be building or design tokens inside this

2552:23

Foundation package which we are going to

2552:25

be using inside this react package so

2552:27

now we have to install this Foundation

2552:29

package inside this react JS so how the

2552:32

what we are going to be doing there well

2552:34

we have to open our terminal let me just

2552:36

go back from there and now we are going

2552:39

to be just using using or Y pin

2552:41

workspace and now we are going to be

2552:43

accessing first of all hen DS and

2552:45

reactjs and we want to add something

2552:47

called the husan DS and then the

2552:50

foundation package so now let me just

2552:52

hit enter so it's going to install the

2552:54

inside this react package so you know

2552:56

let me just delete there or maybe change

2552:59

the color of this so I'll just change

2553:01

okay so how the we going to be even

2553:03

changing the color let me just remove

2553:05

that from there and that's done so now

2553:08

here you can see if I go ahead and go to

2553:10

this uh reactjs and go to the

2553:12

package.json so what are we getting we

2553:14

are now getting this dependencies and

2553:15

inside there we now getting like huzen

2553:18

DS for design system foundation and we

2553:20

are now attaching this workspace to

2553:22

there that's all done and next we're

2553:24

going to be adding a typescript forward

2553:26

project so that was about the basic

2553:28

setup and now we are going to be

2553:29

installing a typescript inside this

2553:31

entire monor repo so what I'm going to

2553:34

do is that I'm going to open my terminal

2553:36

and I'm now inside the route as you can

2553:38

see there right here and I'm going to

2553:40

just use like yarn add and then DD as a

2553:42

d dependency typescript so now if I just

2553:45

hit enter so it's going to install the

2553:47

inside the route now let me just show

2553:48

you there okay so if I go ahead and go

2553:50

to the packages so here you can see uh

2553:52

we are now getting this typescript

2553:53

version and by the time you are watching

2553:55

this video obviously this version will

2553:58

be changed okay so that's done now we

2554:00

are going to be installing the inside

2554:02

this Foundation package then we're going

2554:04

to be installing the inside the Rea and

2554:05

finally inside the story box so now let

2554:08

me go ahead and inst they inside this

2554:10

Foundation package so I'm going to open

2554:12

my terminal once again and I'm going to

2554:14

write like Yar then workspace and then

2554:16

in which workpace you want to install

2554:18

there so I'm going to use like hosen DS

2554:20

for hosen design system I'm going to go

2554:23

into first of all the re or you know

2554:25

first of all let me go to the foundation

2554:27

package and we are going to be adding

2554:28

there as a d dependency and I'm going to

2554:31

just write like typescript so it's going

2554:32

to add there now let me go back and this

2554:34

is how it looks like so now let me just

2554:36

hit enter so just can install inside the

2554:38

found Foundation package let me go ahead

2554:41

and show you there if I go to the

2554:43

foundation package and here you can see

2554:44

we now getting this typescript right

2554:46

here now let me also go ahead and go to

2554:48

the react package and we're going to be

2554:50

installing there inside the react so

2554:51

once again I'm going to be using like

2554:53

here workspace and then I'm going to go

2554:54

into husan DS and then reactj and we're

2554:57

going to be adding there as a Dev

2554:59

dependency typescripts now let me just

2555:01

hit enter so it's going to install that

2555:03

inside the react uh package as well now

2555:06

let me use like Yan workspace I'm going

2555:08

to go ahead and go to hen DS and then

2555:10

the story book now we are going to be

2555:12

adding the as dependency typescript so

2555:15

now let me just hit enter so it's going

2555:17

to install inside uh both of these

2555:20

packages so if I go ahead and go to the

2555:21

reactjs here you can see we are now

2555:23

getting the typescript if I go into the

2555:25

story book here you can see we are also

2555:27

getting there right here now we also

2555:29

have to create our TS config file inside

2555:31

the root so I'm going to just double

2555:33

click on the root and I'm going to give

2555:35

it the name of like TS config.js let me

2555:37

just zoom in a bit and this is how it

2555:39

looks like now let me just hit enter and

2555:41

now inside there we are going to be

2555:43

providing a few compiler options so

2555:45

first of all let's start from the

2555:47

compiler option so compiler option there

2555:50

we go so the first thing is we want to

2555:52

allow JavaScript and we want to set

2555:54

there to true and then allow synthetic

2555:57

default import which is this one right

2556:00

here and I'm going to set that to true

2556:02

I'm going to also provide the strict

2556:04

mode and true let's justlo the no

2556:06

implicit any okay so we going to be also

2556:10

setting that to true and then for the

2556:12

strict null checking uh we are going to

2556:14

be also setting that to true I'm going

2556:16

to be also forcing the consistent casing

2556:18

in files so I'll just use like uh Force

2556:21

come on f o r c consistent casing in

2556:24

files and true no fall through cases in

2556:27

switch so I'll use like no fall through

2556:29

cases in switch and set the true no

2556:32

unused local variables I'll write like

2556:34

no unused uh locals and I'm going to set

2556:37

there to true I'm going to also provide

2556:40

the module resolution which will be also

2556:41

set to true so module resolution and

2556:44

this going to no that's going to be set

2556:46

to node not true isolated module will be

2556:49

also set to true so isolated module and

2556:52

set that to true I'm going to be also

2556:54

providing a down level iteration so

2556:57

which is level iteration and I'm going

2556:59

to set that to True uh declaration will

2557:01

also be set to true and the remove

2557:03

comments remove comments when we want to

2557:05

build it this going be set to false and

2557:08

the SCE map will be set to True going to

2557:12

be also providing a lib we want to use

2557:13

the lib like es next and we also want to

2557:16

use the Dom okay so now underneath them

2557:19

uh we're going to be providing a base

2557:21

URL and that's going to be only set to

2557:23

dot which means like the root and I'm

2557:25

going to also specify the paths so these

2557:28

paths will be set to this in this path

2557:30

like hen DS and now we want to go inside

2557:34

there and here we want to set there to

2557:36

the packages so I'll just use like uh

2557:39

pack packages and every single thing

2557:41

inside the packages and then inside the

2557:43

lib okay so first of all let me just put

2557:45

a comma there and then to done I'm going

2557:47

to also put a comma there and then es

2557:50

Module come on module enter repo and

2557:53

that's going to be set to true I'm going

2557:55

to be also providing a skip lip checking

2557:57

as well and that's going to be set to

2557:59

true and then resolve and then resolve

2558:02

Jon modu so let's just remove there and

2558:06

resolve Json modu and set through

2558:09

experimental declaration will also be

2558:11

set to through we're going to be also

2558:13

providing the no emit error not this one

2558:17

no no emit this going to be set to true

2558:20

then the strict function types will also

2558:23

be set to True let's just set the to

2558:25

true and now underneath there we going

2558:27

to be excluding a few files so I'll just

2558:29

write like exclude and we're going to be

2558:31

excluding the node modules folder m o d

2558:34

u s and also we are going to be

2558:37

excluding every single thing let's just

2558:39

write two two stars and then test dot

2558:43

every single thing like all of the file

2558:44

which will have this test file okay so

2558:46

you just want to exclude there so there

2558:48

was about the main root configuration

2558:51

for the typescript now let me just go

2558:52

back and this is how it looks like if

2558:54

you want to copy there from my GitHub

2558:56

repository you totally can or if you

2558:58

want to pause the video and type there

2559:00

by yourself you can also type there now

2559:02

let me just close that from here I'm

2559:04

going to go ahead and go to my packages

2559:06

then I'm going to go into my react

2559:07

package and here we are going to be be

2559:09

creating a new file with the name of TS

2559:11

config so TS config.js and here we are

2559:14

going to be first of all extending our

2559:17

own configuration which we just created

2559:19

so we are going to be using like extends

2559:21

and we are going to be grabbing there

2559:22

from let's just go ahead and go to the

2559:24

root and then we are going to be

2559:26

grabbing there from the TS config.js

2559:28

file so now let me just save my file if

2559:30

I hold control and click on this so it's

2559:33

going to brings us to this root TS

2559:35

config.js file right here okay so we are

2559:37

now taking like every sing thing which

2559:39

is available inside this route we are

2559:42

now taking the and now we are going to

2559:43

be adding a few more okay so I'll just

2559:45

provide a comma and let's just add a few

2559:47

more compiler options for the reactjs so

2559:51

we are going to be providing a base URL

2559:53

and the base URL will be going into the

2559:55

SRC folder which we are going to be

2559:56

creating in a few seconds and the outer

2559:58

directory like when we build this we are

2560:01

going to be using like outer directory

2560:03

and we want to go to the lip folder okay

2560:05

so we're going to be also providing a

2560:06

down level iteration so let's just write

2560:08

like down

2560:09

iteration and now let me just set that

2560:11

to true we are going to be also

2560:12

providing a Target and Target will be

2560:14

set to yes next this is also provide the

2560:17

jsx and here we're going to be providing

2560:19

the react jsx because we are now going

2560:22

to be using jsx inside this package

2560:24

this's us also provide the module and

2560:26

module will be set to es next okay so

2560:30

now we are going to be also providing a

2560:31

es module uh into repo set that to true

2560:35

and also allow JavaScript obviously true

2560:39

and then the strict mode will also be

2560:41

set to true and now on need we are going

2560:43

to be including a few files and then we

2560:45

are going to be excluding a few files so

2560:47

now let me just include there like we

2560:49

want to only include the SRC folder and

2560:52

now we are going to be excluding a few

2560:54

folders so like e xcl and we want to

2560:56

exclude first of all the node modules

2560:58

folder and we also want to exclude every

2561:00

single thing which is inside the test

2561:03

file okay so we not going to be writing

2561:04

any test for this repo but uh if you

2561:07

want to write there you totally can and

2561:09

that will not be included here that will

2561:11

be totally excluded we also want to

2561:13

exclude the LI folder and now let me

2561:15

just save there and then toally it about

2561:17

the react uh TS config right here so if

2561:20

you want to write that by yourself you

2561:22

totally can but if you want to copy that

2561:23

from my GitHub repository you can also

2561:26

copy there so now let me just close

2561:27

there now let me go ahead and just

2561:29

create a simple component so that we can

2561:31

check whether the typescript is working

2561:33

or not so I'm going to just go ahead and

2561:34

go to my react folder and we are going

2561:36

to be creating another folder with the

2561:38

name of Sr C and inside there let's just

2561:40

create our index.ts file inside there

2561:43

and I'm going to just use like uh some

2561:45

simple component like greed let going to

2561:47

take a name of a person and that's going

2561:49

to be totally a string and now let's

2561:51

just write like um render first of all

2561:54

the person name and then person name or

2561:58

we are going to be showing the word

2561:59

right here is not n we have to also

2562:02

provide this colon right here which

2562:04

means like our typescript is now

2562:06

successfully working if I don't specify

2562:08

then it expect this colon so now let me

2562:11

just provide there and here you can see

2562:12

where typescript is now working the way

2562:14

we expect him to work so now let me just

2562:16

use like export default and then cre

2562:18

component and now let me just save my

2562:20

file and yeah our typescript is now

2562:22

successfully working and now let me just

2562:24

build there so that we can see there I'm

2562:26

going to go ahead and go to this react

2562:28

package and inside this react package we

2562:31

are going to be going into this

2562:32

package.json file okay so here we're

2562:34

going to be also creating a script for

2562:36

ourself so I'll just write like scripts

2562:38

and here inside there I'll just write a

2562:40

build script for ourself and now

2562:42

currently we are going to be only

2562:43

building our TSC like only our

2562:45

typescript configuration so now let me

2562:47

just save my file close them and now

2562:50

watch what happens right here I'm going

2562:52

to open my terminal right now and now

2562:55

let's just go back I'm going to go ahead

2562:56

and go to the packages then the reactj

2562:59

and here I'm going to be using Yan build

2563:01

and now if I hit enter so it's going to

2563:03

build there right here inside the slip

2563:06

folder so now let me just zoom in a bit

2563:07

and here you can see we we have this lip

2563:09

folder and inside there we have our

2563:11

index.js file and yep it is working the

2563:14

way we expect it to work and these are

2563:17

or typescript Declaration file so that's

2563:19

totally working I'm going to delete this

2563:21

folder right now and there was about the

2563:23

typescript so there was about the

2563:25

typescript now we are going to be adding

2563:27

our design token inside this Foundation

2563:30

package so what I'm going to do is that

2563:32

I'm going to open my terminer right here

2563:33

and I'm going to be using Yan workspace

2563:36

and then we are going to be going into

2563:37

the hen DS and then the Foundation

2563:39

package right here okay so we are going

2563:41

to be adding as a Dev dependency style

2563:44

dictionary because it really allows us

2563:46

to transform our design tokens into

2563:48

meaningful code so we're going to be

2563:50

using like style dictionary and now let

2563:52

me just add there so it's going to

2563:54

install there inside the foundation

2563:56

package so it's going to take a bit of

2563:57

time and I'm going to fast forward the

2563:59

video oh it just installed it so I don't

2564:02

have to fast forward the video and next

2564:04

we're going to be adding our design

2564:06

tokens inside this Foundation package

2564:08

now let me just even check there yep we

2564:10

are now getting our style dictionary

2564:12

version 4 or something and by the time

2564:14

you are watching this video you're going

2564:16

to be getting some new version now let

2564:18

me go ahead and just create a new folder

2564:20

with the name of SRC inside the

2564:22

foundation package and then we are going

2564:24

to be creating a new file inside there

2564:26

which will be a tokens file so I'll just

2564:28

write like tokens and inside this tokens

2564:30

folder we are going to be adding a few

2564:32

more files so first of all we're going

2564:33

to be adding our uh colors. Json and

2564:37

here we're going to be placing all of

2564:38

our colors which we already designed in

2564:41

the figma section of this course so now

2564:42

let me just place the file and as you

2564:44

can see right here first of all we have

2564:46

our Json object then inside there we

2564:48

have our color so first of all we have

2564:50

our primary color then we have a

2564:52

different variations of uh those color

2564:55

like we have 9 950 then we have 900

2564:58

through 50 so now let me just show you

2565:00

there okay so now I'm going to go back

2565:03

so that is my primary color if I can

2565:06

hide there then we have our neutral

2565:08

color then we have we have our warning

2565:10

then danger color success color and gray

2565:12

scales right here I'm going to also H

2565:14

over there and I'm going to add there to

2565:17

my workspace like so so now let me just

2565:20

save my file and that's totally done I'm

2565:21

going to also close there now we are

2565:23

going to be adding our radius tokens I'm

2565:25

going to right click on there and just

2565:27

write like radius. Json and here we're

2565:29

going to be placing our radius tokens

2565:32

I'll just place there right here sa my

2565:33

file so here you can see first of all we

2565:35

have our radius and inside there we have

2565:37

our tiny radius then uh extra small

2565:40

small medium small medium large extra

2565:45

large super large huge gigantic and full

2565:49

radiuses right here okay so now we are

2565:51

going to be also placing this in my file

2565:54

I'm going to be also creating yet

2565:55

another file with the name of opacities

2565:58

so op a c i t i s. Json and in this file

2566:02

we're going to be placing all of these

2566:04

opacities so first of all we have our

2566:05

OPAC then we have the semi OPAC then

2566:08

transp arent light transparent very

2566:11

transparent now let me close this file

2566:13

now we are going to be adding yet

2566:14

another file which will be for the shads

2566:17

so I'll just write like Shadows or just

2566:19

yeah shadows. Json would be fine now let

2566:22

me also place it right here so my file

2566:24

so it's going to gives us a few warnings

2566:27

and now let me just add there here you

2566:28

can see we have our shadows object and

2566:30

inside there we have our uh extra small

2566:33

sharow then we have a small sharow then

2566:35

medium sharow then large sharow and

2566:38

extra large Arrow let's just close this

2566:40

file and finally we are going to be

2566:42

adding our spacing so I'll just uh

2566:44

create a new file with the name of

2566:45

spacing or spacing. Json okay and inside

2566:50

there let me just uh save this file so

2566:52

first of all we have a four uh spacing

2566:54

then we have a 8 12 16 20 uh 24 28 32 36

2567:03

40 44 48 52 56 60 64 68 72 76 80 84 88

2567:15

92 96 and finally we have 100 okay so

2567:20

yeah that's also my entire spacing and

2567:22

next we're going to be using a style

2567:24

dictionary to make actual code out of

2567:26

there like the SS code also the CSS code

2567:29

and also the JavaScript code so to do

2567:32

that first of all we are going to be

2567:33

going into the foundation route which is

2567:36

this folder I'm going to right click on

2567:38

there and create new file with the name

2567:39

of style Dictionary d i c t i o n a r y

2567:43

style dictionary.c config.js file and

2567:46

inside there we are going to be

2567:47

providing a few configuration for our

2567:49

style dictionary so I'll use like

2567:51

module. export so module oh my God moio

2567:55

if I can get there today and then export

2567:58

exports and here we're going to be

2567:59

passing our source first of all so let's

2568:01

just add the source and then Source will

2568:04

be set to uh we want to go ahead and go

2568:06

to this SRC folder and then you want to

2568:09

go to this tokens folder which is this

2568:11

SRC and then the tokens folder you want

2568:13

to go there and every single thing

2568:16

inside there which ends with the Json

2568:19

extension so we want to go there this

2568:21

going to be our source now we are going

2568:23

to be building there for different

2568:25

platforms we are going to be using like

2568:27

uh platforms and here inside these

2568:30

platforms first of all we are going to

2568:31

be building there for the scss so I'll

2568:34

just write like scss but why in the word

2568:37

I'm providing this codes right here let

2568:39

me just close there and we don't have to

2568:41

provide these codes so first of all

2568:42

we're going to be building there for the

2568:44

scss and I'm going to just write like

2568:46

transform group so

2568:49

transform and we're going to be

2568:50

transforming there first of all for the

2568:52

scss and now we me provide my build path

2568:55

and we are going to be building there

2568:56

inside the lip folder so we want to

2568:58

create a tokens folder for there and we

2569:01

specifically want to Output there on the

2569:03

scss folder okay so that's totally done

2569:06

we're going to be also providing our

2569:07

files type and also the extensions so

2569:09

first of all let me just go ahead and

2569:11

remove there and change there to array

2569:13

and inside there we're going to be

2569:14

adding our object let me just add my

2569:16

destination d s t i n a t i o n and the

2569:20

destination will be this tokens. CSS

2569:22

file or SC CSS rather SCS there we go

2569:26

we're going to be also providing our

2569:27

format so it will format the as a scss

2569:31

and then the variables like so so now

2569:33

let me just save this file right now now

2569:35

we are going to be adding our CSS

2569:37

configuration so I'll just write like

2569:39

CSS and then we are going to be

2569:40

providing our transform group and now

2569:43

this can be set to this CSS because in

2569:45

this case we are going to be

2569:46

transforming that to the CSS now let's

2569:48

just Prov our build path and we're going

2569:50

to be going into the LI folder then the

2569:52

tokens folder then the CSS now let me

2569:55

just add my files so for these files uh

2569:57

we are going to be providing our

2569:58

destination first of all D STI d s t i n

2570:04

a t o n destination this going to be set

2570:06

to our tokens. CSS in this case and the

2570:08

format will look like this first of all

2570:11

the CSS folder then the variables like

2570:14

so I'm going to save this file right now

2570:16

underneath there we are going to be also

2570:18

providing the JavaScript Source

2570:19

configuration so I'll just write like JS

2570:22

and then SRC and here inside there we

2570:24

are going to be providing our transform

2570:26

group this going be set to our

2570:28

JavaScript we are going to be also

2570:29

providing our build path and build path

2570:32

will be set to SRC then the tokens

2570:34

folder then the JavaScript folder like

2570:36

so okay so we are going to be also

2570:37

providing our files and the files will

2570:39

look something like this so let's just

2570:41

provide our name and the name in this

2570:43

case we're going to be going into this

2570:45

tokens folder and then we are going to

2570:47

be providing our JS SRC like for the

2570:50

JavaScript we're going to be adding the

2570:51

inside this tokens folder okay so I'll

2570:54

just provide like tokens we're going to

2570:56

be also providing our destination uh

2570:58

which looks something like this like

2571:00

we're going to be writing our uh tokens.

2571:02

JS in this case and the format will look

2571:04

something like this we're going to be

2571:05

writing our John folder and then the

2571:07

modu or just a module a singular and now

2571:11

underneath there let's just add a pure

2571:13

JavaScript so in that case we're going

2571:15

to be writing our transform Group which

2571:17

will be set to just a pure JavaScript

2571:19

and we're going to be also providing our

2571:20

build path and build path will go into

2571:23

the LI folder and then we are going to

2571:25

be going to the tokens folder then the

2571:27

JavaScript folder and that's going to be

2571:29

it okay so now we're going to be also

2571:31

providing our files and files will first

2571:33

of all put the name and then the name

2571:36

will be set to tokens the Destin ation

2571:38

will be set to tokens. JS and also the

2571:42

format will be set to JavaScript and

2571:45

that's totally done that was about the

2571:47

entire configuration for the style

2571:49

dictionary so if you want to write there

2571:52

by yourself you totally can but if you

2571:54

want to go to my gab repository and copy

2571:57

all of that from there you can also do

2571:59

that so now that's to done I'm going to

2572:00

also go into inside this Foundation

2572:04

package we're going to be going into

2572:05

this package.json and here I'll just

2572:08

write a script for myself so I'll just

2572:10

use like uh script first of all we are

2572:12

going to be building a tokens so I'll

2572:14

just write like build tokens and that's

2572:16

going to be set to the style dictionary

2572:18

p i c t i o n a r y style dictionary we

2572:21

are going to be building them and then

2572:23

provide our config and then style

2572:25

Dictionary d i c t i o n n a r y and

2572:28

then config.js file so we are going to

2572:31

be first of all building there and then

2572:32

we're going to be building the entire

2572:34

project by using yarn build tokens like

2572:37

we also want to use this Command right

2572:40

here and now we're going to be also

2572:42

providing the TSC like also build the

2572:44

typescript okay so I'll just write like

2572:46

TSC and that's going to be it now let me

2572:48

just save my file right now close there

2572:50

close this file and for now we are going

2572:52

to be only building these tokens so I'm

2572:54

going to open my terminal and I'm going

2572:56

to use like yon build tokens and now if

2572:58

I hit enter right now oh we are now

2573:00

inside this Rea so we have to go into

2573:03

first of all the foundation package and

2573:06

I'm going to use y build tokens and if I

2573:09

hit enter right now it's going to take a

2573:11

bit of time and now it's going to build

2573:12

there and all of that are now

2573:14

successfully build so it's going to

2573:15

gives us the scss folder it's going to

2573:18

also gives us the CSS folder the JS SRC

2573:20

folder and also the JavaScript folder so

2573:23

now let me go ahead and go to this lip

2573:25

first of all and here inside there we

2573:27

are now getting these different tokens

2573:29

so if I go to the CSS here you can see

2573:31

we have our tokens. CSS and it's going

2573:33

to generate all of that um design tokens

2573:36

for us so here you can see we have

2573:38

primary token then the neutral and we

2573:41

have the warning danger success and we

2573:44

have the gray scale we also have the

2573:46

different opacities radiuses and the

2573:50

different shadows spacing and you name

2573:52

it so that's going to be it for the

2573:54

tokens. CSS file we can also go ahead

2573:56

and go to the JS file and this is how

2573:59

our Javascript file will look like so

2574:00

first of all we have a primary and then

2574:03

we have a 100 and now we can go to the

2574:06

bottom it's going to give uses different

2574:08

colors as you can see right here and you

2574:11

name it now we are going to be also

2574:12

going into this scss file and here you

2574:15

can see it's going to also generate the

2574:16

SS variables for us so it's going to

2574:19

also generate a SS variables and I'm

2574:21

going to close there and that's totally

2574:22

done next we're going to be adding our

2574:24

tailin CSS setup okay so now we are

2574:27

going to be adding our tailin preset so

2574:28

I'm going to collapse every single thing

2574:30

I'm going to go into the packages folder

2574:32

then the foundation folder then the SRC

2574:34

folder and now here we are going to be

2574:37

adding our t preset so I'll just uh

2574:39

right click on there create a new file

2574:41

with the name of TDP like the tnd design

2574:45

preset then do config.js and inside

2574:49

there we're going to be first of all

2574:50

importing our design tokens from the

2574:52

JavaScript folder so I'll just write

2574:54

like Tok sense can be equals to require

2574:57

and if you guys don't know what a requir

2574:59

is you don't have to worry about that

2575:01

because require is a nodejs thing and

2575:03

you don't have to worry about that so

2575:05

basically this is just a older way of

2575:07

using the import statement like nowadays

2575:10

we use this import something from

2575:12

somewhere uh but we used to use this

2575:16

required statement so it will require a

2575:18

lot more configuration to use this

2575:20

statement like I use import something

2575:22

something so that's the only reason I'm

2575:24

using this older way okay so we are

2575:26

going to be first of all going into the

2575:27

tokens folder which is this tokens

2575:30

folder Right Here and Now inside there

2575:33

we have ajs token right here and inside

2575:36

this JS token we have our token .js file

2575:39

and it is mess Let me just show you

2575:42

there okay so first of all we are going

2575:43

to be going into the tokens folder then

2575:45

the JavaScript folder and then the

2575:47

tokens. JS we don't have to provide the

2575:49

JS right here I'm going to save this

2575:51

file right now and now I'm going to

2575:53

write a bit more JavaScript code which

2575:55

looks something like this now let me

2575:57

just save my file this is basically a

2575:59

function which will flat in our object

2576:02

you can learn more about that if you

2576:03

wanted to but I don't want to waste your

2576:05

time now let me just show you what this

2576:06

function does here you can see inside

2576:09

this tokens. JS file we have a huge

2576:12

object first of all we have the colors

2576:14

then we have each variation for

2576:16

different color and then we have a

2576:18

different value and which is a nested

2576:21

object like this is object one this is

2576:23

object two this is object three this is

2576:25

object four and this is object five and

2576:27

so much more so now to flatten there we

2576:30

are going to be using this utility which

2576:32

will allows us to Flat in our object

2576:34

okay so if you want to write that by

2576:36

yourself you totally can if you want to

2576:37

copy the from my GitHub repository you

2576:39

can also do that so I'm going to just

2576:41

hide there right now and here we're

2576:43

going to be using module. export so

2576:45

let's just use modu and here we're going

2576:48

to be providing do exports and it's

2576:50

going to be equals to this object so

2576:52

first of all we are going to be adding

2576:53

some prefix if you want to provide this

2576:55

prefix you totally can but if you don't

2576:57

want to provide there you don't even

2576:59

have to provide this so I'll just use

2577:00

like prefix and I'm going to prefix with

2577:02

my own name which is hosan so basically

2577:05

let me just show you like why we're

2577:06

adding there basically whenever we are

2577:08

just creating some component I'm going

2577:10

to go into the react component right

2577:12

here and then we're going to be using

2577:13

some sort of uh let me just use like R

2577:15

fce you don't have to write this code by

2577:17

the way and we're going to be providing

2577:19

some class names and for each class

2577:21

names like uh if you want to use the T

2577:24

CSS so you will just write like

2577:25

background blue of 500 like so or 400

2577:30

but if you want to use your own design

2577:32

system class so first of all you would

2577:34

have to write hosan then you would write

2577:36

a background then blue and then 500 or

2577:38

400 right here so that's the only reason

2577:41

we are now adding this prefix right here

2577:44

okay so if you want to provide there you

2577:46

can but you don't have to so now let me

2577:48

just save that and close that right here

2577:49

and now we are going to be adding our

2577:51

theme and first of all we have to add

2577:53

our color so that we can use our own

2577:54

colors and we are going to be wrapping

2577:57

there first of all inside the flatten

2577:59

values which is this uh function so now

2578:01

I'm going to copy the name of that and

2578:03

place it right here and we want to first

2578:04

of all flat in the values of tokens and

2578:07

then a spe specific colors from their

2578:09

tokens so what am I doing right here

2578:11

first of all let me just go into this

2578:12

folder so we are now providing those

2578:14

tokens as you can see right here which

2578:16

will be a huge object and now from that

2578:19

tokens we want to specifically provide

2578:21

that colors which are these colors right

2578:24

here now let me just collapse there then

2578:25

we are going to be adding the opacities

2578:27

then we are going to be adding the

2578:29

radiuses and then finally we are going

2578:30

to be adding the shadows and spacing

2578:33

okay so this is how we going to be

2578:34

adding there so now that was there about

2578:36

for the tokens. color

2578:38

and now we are going to be also

2578:39

providing a border radius so let's just

2578:41

use like border radius and here we are

2578:44

going to be using that flaten Val P our

2578:47

tokens do uh what do we call it radius

2578:49

right here we're going to be also

2578:51

providing our spacing not tokens.

2578:53

spacing but just a spacing and spacing

2578:56

will be set to Flat in value and let's

2578:59

space for tokens do uh spacing right

2579:02

here okay I'm going to be also providing

2579:04

a box Shadow and box Shadow we use this

2579:07

Splat in value

2579:08

and here we are going to be using like

2579:09

tokens. sharow and now that's going to

2579:12

be it we're going to be also providing

2579:13

our font family which will just use like

2579:16

enter font but if you want to provide

2579:18

your own font you totally can Okay so

2579:20

let's just use like sense and this going

2579:22

to be set to this enter font enter like

2579:26

this and now for the plugins we're not

2579:27

going to be writing any plugins but now

2579:29

let me just even provide the plugins

2579:32

that's going to be set to just empty

2579:33

array now let me save this file right

2579:35

now and that's everything that you have

2579:37

to do for adding the T preset okay so

2579:40

now we have to build this Foundation

2579:41

package so we can consume there in other

2579:44

packages so I'm going to close there I'm

2579:46

going to collapse every single thing I'm

2579:47

going to go into the packages folder

2579:48

then the foundation and now here we are

2579:50

going to be adding first of all our TS

2579:52

config for our typescript so I'll just

2579:54

create a new file with the name of TS

2579:56

config.js and inside there we're going

2579:59

to be adding a few uh configuration so

2580:02

first of all we have to even extend the

2580:04

existing configuration which will be

2580:05

available inside the root so I'll just

2580:07

write like TS config.js I'm going to

2580:10

hold control and click on this so it's

2580:11

going to brings us to this root

2580:13

configuration I'm going to close it

2580:14

right now let me provide my comma there

2580:17

and we are going to be adding our own

2580:18

configuration which will be compiler

2580:20

options and let's just add our basic

2580:23

base URL and which will be set to let's

2580:25

just go ahead and go to this source and

2580:28

for the output directory so I'll just

2580:30

write like output directory we're going

2580:32

to be adding that to the lib okay so

2580:34

let's just add that to the liveb and

2580:36

also we're going to be including one

2580:38

more file so let's just use like a

2580:40

include and we are going to be including

2580:42

the SRC folder now let me just save my

2580:45

file in this can be for. here config

2580:47

about this uh Foundation package and now

2580:51

you want to go ahead and go to this

2580:52

package.json file which is available

2580:54

inside this Foundation package and

2580:56

inside there let me just go back first

2580:58

of all so you guys can see everything a

2580:59

bit better we have to add one more

2581:01

script and that's going to be here so

2581:03

you'll just write like build style

2581:05

dictionary and if you want to do that

2581:07

you totally can but you don't have to

2581:09

this I'll just use like style dictionary

2581:11

and now we are going to be building the

2581:12

config and then style Come on Style

2581:15

dictionary and then config.js right here

2581:19

now let me just save this file right now

2581:21

now I'm going to be also adding two more

2581:23

things so first of all we have to add

2581:24

the main and Main will be this uh first

2581:28

of all we have to go into the lip folder

2581:30

inside the lip folder we have our

2581:32

index.js file and now we are going to be

2581:35

also adding a types so types will be

2581:37

available inside the LI folder which it

2581:40

will gives us when we build this package

2581:41

so now it's going to be available inside

2581:43

the lib and then index. D.S okay so now

2581:46

let me just save my file and there all

2581:48

yet close there now here inside this SRC

2581:51

we are going to be creating yet another

2581:52

file which will be

2581:54

index.ts and inside there we're going to

2581:57

be importing all of our tokens uh from

2581:59

the JS tokens and now we have to export

2582:01

there so we can use there now let me

2582:03

just save this file right now and

2582:05

finally let me just zoom in a bit and

2582:07

we're going to be building this entire

2582:09

Foundation package okay so let's just

2582:12

remove these

2582:13

tokens sure I REM yeah I'm going to just

2582:16

remove that from there I'm going to also

2582:17

go to this SRC then go to the tokens I'm

2582:20

going to also delete this JS folder okay

2582:22

so just delete that and now we're going

2582:24

to be building this Foundation package

2582:26

so I'm going to open my terminal and I'm

2582:28

going to use like Y and then build okay

2582:31

let me just go back yarn build and hit

2582:33

enter so now it's going to build that in

2582:35

a few seconds so yep we are now getting

2582:39

them and now if we go ahead and go to

2582:40

this Li folder we have our tokens we

2582:43

have our index.js index. D.S uh and

2582:47

configuration and so on and so forth so

2582:49

this is how we are going to be building

2582:51

our package and now we are totally ready

2582:53

to consume this package inside the react

2582:56

package right here okay so that was

2582:58

about the foundation package and now

2583:00

we're going to be taking care of the

2583:02

react package so first of all we have to

2583:04

install reactjs and also the what do we

2583:07

call it react Rea Dom and also their

2583:08

types and then we will be able to use

2583:10

that so I'm going to go back and now we

2583:12

are going to be going into the react

2583:15

package or we don't even have to do that

2583:17

because we are going to be using a Yan

2583:18

workspaces so we just have to write like

2583:21

Yan and then workspace and then we want

2583:23

to go into this hen DS and react J and

2583:27

we want to add as a Dev dependency react

2583:29

JS and react D okay so now let me just

2583:32

hit enter so it's going to install the

2583:34

inside our react package now we going to

2583:37

be also adding let's just go ahead and

2583:39

go to or hen DS and also react JS so

2583:42

we're going to be also adding as a d

2583:44

dependency the types for react JS and

2583:48

also the types for the react Dom so I'll

2583:50

just use like react Dom and now let me

2583:52

just hit enter so it's going to also

2583:54

install that let's just close there now

2583:56

let me go ahead and go to my react

2583:58

package and here you can see we're now

2584:00

going to be getting this uh types and

2584:03

also reactjs and reactjs Dom or just

2584:06

react Dom right here okay now we are

2584:08

going to be also adding a peer

2584:10

dependencies and peer dependencies are

2584:12

those dependencies which will be used by

2584:15

your consumer like the people who are

2584:16

using our package or our design system

2584:19

so I'll just write like peer dependency

2584:21

God damn it peer dependencies it is

2584:23

challenging like speaking and typing at

2584:25

the same time so we are going to be

2584:27

adding react JS and we want that to have

2584:30

at least greater greater version of

2584:34

16.80 of reactjs and also the react Dum

2584:38

it should have the greater version of uh

2584:42

greater than or equal to

2584:45

16.80 version now let me just save this

2584:48

file right now and this is how we are

2584:50

going to be adding our per dependencies

2584:52

close there we also don't need this PNP

2584:55

do CJs file let's just delete there we

2584:58

also don't need this PNP loader. MJS

2585:01

file let's just also delete there and

2585:03

now we are going to be going into this

2585:04

EML file and we are going to be only our

2585:08

node Linker and node Linker will be

2585:10

equals to this node modules okay so now

2585:13

let me just save this file right now and

2585:15

that's to it about the react package so

2585:17

then St done now let me go ahead and go

2585:18

to my react package then I'm going to go

2585:20

into the SRC folder and here I'm going

2585:22

to just remove this index.ts file and

2585:25

I'm going to be creating a component

2585:26

with the name of button. TSX and I'll

2585:29

just use my RFC inside the same my file

2585:32

and jsx element implicitly has type of

2585:35

any this because we all already added

2585:38

react JS but we now have to install all

2585:40

of that packages so to install that I'm

2585:42

going to go ahead and go outside from

2585:44

this react so I'll just use like CD do

2585:46

dot I'm going to also go ahead and go

2585:48

outside from this packages folder so

2585:50

I'll just use like CD do Dot and here

2585:53

I'm going to go back and I'm going to

2585:55

just use like Yan install and now if I

2585:57

hit enter so now it's going to gives us

2585:58

that node modules folder right here and

2586:01

that's going to be it so now let's just

2586:03

close that now let me go ahead and go to

2586:06

my p. TSX and that's working the way we

2586:09

expect them to work and now here I'll

2586:11

just write like props and here I'm going

2586:14

to also remove that from here and I'm

2586:16

going to just write like button close it

2586:18

like this and now we are going to be

2586:20

spreading out those props I'm going to

2586:22

save this file right now I'm going to

2586:23

also type the as any so it should just

2586:26

remove that typescript error now let me

2586:28

close that and that's totally done okay

2586:30

so that was about the foundation package

2586:32

and also the reactjs package now we are

2586:34

going to be taking care of this

2586:36

storybook package so what I'm going to

2586:38

do is that I'm going to install the

2586:39

story book but first of all we have to

2586:41

go to the packages then the story book

2586:43

and now inside there we're going to be

2586:44

using npx and then story book and then

2586:47

inert if I hit inert so it's going to

2586:49

ask us to install we I guess I'm not

2586:52

quite sure but it's going to install

2586:54

that story book inside that specific

2586:56

directory yes I'm going to just type why

2586:59

and here I'm going to choose Rea and we

2587:03

okay so it's going to take a bit of time

2587:05

to install there okay our GitHub

2587:08

repository is getting Huger and Huger I

2587:11

forgot to include that get ignore file

2587:13

and obviously it's going to gives us an

2587:14

error right now we don't want to report

2587:16

anything so I'm going to just set that

2587:17

to in like now and now we going to be

2587:20

installing like y add and weed is a Dev

2587:24

dependency okay so let's just hit enter

2587:27

and just going to install the inside as

2587:29

a Dev dependency to a story book and now

2587:31

we can use like Yan story book and here

2587:34

you can see it's going to gives us that

2587:35

story book right here which means like

2587:37

everything is working the way we expect

2587:40

it to work so this is how we are going

2587:41

to be adding a story book and we are now

2587:43

getting a lot of errors but you don't

2587:45

have to worry about that I'm going to

2587:47

stop there for now and now I'm going to

2587:48

go ahead and go to my story book right

2587:51

here and here we're going to be adding

2587:53

our TS config file so I'll just use like

2587:55

TS config.js and here inside there uh

2587:59

what I'm going to do is I'm going to

2588:00

just write a few configurations so first

2588:02

of all we have to extend all of their

2588:04

types no more root types so I'm going to

2588:06

go there this is right like TS config.js

2588:09

I'm going to make sure so I'm going to

2588:11

hold control and click on there yep we

2588:13

are now successfully importing them

2588:15

right here and now let me just close

2588:16

there provide my comma there and now I'm

2588:19

going to provide my compiler options

2588:21

inside there let's space or Bas URL and

2588:23

that's going to go into the stories and

2588:26

now we are going to be also providing

2588:27

the down level iteration set that to

2588:29

true I'm going to be also providing a

2588:31

Target and Target will be set to ES3 I'm

2588:34

going to also provide the GSX so let's

2588:36

just add this we're going to be adding a

2588:38

react jsx in this situation and I guess

2588:41

that's going to be it but we also have

2588:43

to include that folder so I'll use like

2588:44

include and here let's just add our

2588:46

stories dot yeah I guess stories would

2588:48

be fine now I'm going to save this file

2588:50

right now and that's everything that you

2588:52

have to add for this TS config for this

2588:55

story book right here okay so what the

2588:57

hell is going on oh that's because I I

2589:00

was clicking on the wrong folder okay so

2589:02

that's everything that you have to do

2589:04

for this story book and now we are going

2589:05

to be adding the most simple play story

2589:08

so that we can test there so I'm going

2589:09

to remove every single thing inside the

2589:11

stories now I'm going to create a new

2589:13

folder which will be that same stories

2589:15

folder and inside there we're going to

2589:17

be creating our file with the name of

2589:19

button so I'll use like button. TSX and

2589:22

now inside there the first thing that we

2589:24

have to do is that we have to import the

2589:25

button from the buttons so import

2589:28

buttons from let's just go into hoseen

2589:30

Diaz and then I'm going to go into the

2589:32

react G then I'm going to go into the

2589:34

SRC folder and now we are going to be

2589:36

getting our button

2589:37

okay so now let's just use like export

2589:39

default and inside there provide my

2589:41

title and here God damn it t tle e and

2589:45

here that's going to be set to like um

2589:47

components in then button I'm going to

2589:49

be also providing my component right

2589:51

here and this going to be set to the

2589:54

button now let's just sa our file and

2589:56

I'm going to just write the most basic

2589:58

what do we call it story so I'll just

2589:59

write like export and then cons primary

2590:02

it's going to be taking uh primary and

2590:05

it's going to be taking there as a

2590:06

function so we just have to printer this

2590:08

component and I'm going to be providing

2590:10

a variant today uh v r n and variant

2590:13

will be set to primary variant because

2590:16

we're not going to be doing anything

2590:17

with this so that's the only reason I'm

2590:18

writing it at this way and I'm going to

2590:20

also close there and change there to

2590:22

like primary duplicate there a few times

2590:25

I'm going to also change that to like

2590:26

secondary and also change this one to

2590:29

secondary I'm going to also change this

2590:31

one to danger and close that just put a

2590:35

danger remove that from here also change

2590:37

the variance of this so I'll just write

2590:39

like secondary and also change this one

2590:42

to the danger I'm going to save this

2590:44

file right now and now let me just use

2590:46

my Yar story book so it's going to run

2590:48

there and it shouldn't be just a button

2590:51

it should be God damn it let me just

2590:52

close there it should be a button.

2590:55

stories. TSX so I'll just write like

2590:58

stories. TSX I'm going to close there

2591:00

right now and I'll use my Yan come on

2591:03

Yan and then story book like so and here

2591:07

you can see we're now getting our button

2591:08

component and which is a primary then

2591:10

the secondary and then the danger button

2591:12

which means like our story book is

2591:14

working the way we expect him to work

2591:16

but now we have to add a TN CSS to this

2591:18

project and that's going to be here oh

2591:21

my God

2591:23

10K that's awesome so you know what I'm

2591:26

going to collapse there create a file

2591:28

which will be the get ignore file and

2591:30

ignore all of that stuff now let me just

2591:32

save there and close there and hopefully

2591:36

it should get disappear oh it's not

2591:39

working I don't know why but it's not

2591:41

anyways we're going to be taking care of

2591:43

that in a few seconds but first of all

2591:45

you want to go into the tailin come on

2591:47

tailin css.com I'm going to click on the

2591:49

getting started then I'm going to go to

2591:51

the framework and guides go there copy

2591:54

there now I'm going to open my terminal

2591:56

and let's just go back open the terminal

2591:59

once again now we are going to be going

2592:01

into the package.json now we are going

2592:02

to be going to the react package and now

2592:05

let's just install t CSS or you know

2592:07

what we can also do that totally simply

2592:10

so I'm going to just write like ion

2592:13

workspace and now we are going to be

2592:15

going into the hosen DS and then we want

2592:18

to go to the reactjs and we want to add

2592:20

there as a Dev dependency a talin CSS so

2592:24

let's just hit enter so it's going to

2592:25

install a t in CSS as a d dependency

2592:28

inside your reactjs package so let's

2592:30

just close that and that's to done now

2592:32

we are going to be going into the

2592:34

packages then the reactj then we want to

2592:36

go to the SRC uh yeah not even the SRC

2592:40

but inside the reactjs I'm going to

2592:42

right click on there and create a new

2592:43

file with the name of uh T.C config.js

2592:48

config.js there we go I'm going to hit

2592:50

enter right now and inside there we are

2592:52

going to be going in there I'm going to

2592:54

copy every single thing from there

2592:56

player right here we don't need this

2592:58

theme so I'm going to delete this save

2593:00

this file now we going to be adding our

2593:02

Plug-In or our preset which we just

2593:04

created so I'll just write like preset

2593:07

and here for the presets we are going to

2593:09

be adding our own preset right here

2593:10

provide a comma there so we are going to

2593:12

be requiring there require or importing

2593:15

there so we are going to be importing

2593:17

there from where from the hoseen DS and

2593:19

from the foundation then from the lip

2593:21

folder and then inside the LI folder we

2593:23

have a

2593:24

TDP and then config that's going to be

2593:27

it and now let me just save my file okay

2593:29

so now let me just close there next we

2593:31

have to go into this SRC folder and I'm

2593:33

going to create my index. CSS file and

2593:36

now now we are going to be copying this

2593:38

index. CSS directives and now let me

2593:40

just place that right here save this

2593:42

file and finally I guess that's going to

2593:44

be the final step of this entire thing

2593:47

I'm going to go into this package.json

2593:49

and here we are going to be adding our

2593:52

script right here so that was there

2593:53

about for the build I'm going to change

2593:55

that I'm going to write like y build and

2593:57

then CSS and DSC like for the typescript

2594:02

we going to be also providing the watch

2594:03

mode for the CSS so we are going to be

2594:06

using like any PX and then tellin CSS

2594:09

and we want you to go ahead and go to

2594:10

the SRC folder and watch for the index.

2594:13

CSS and gives us the output of there

2594:16

inside the LI folder and then the

2594:18

output. CSS and watch there and so

2594:21

that's going to be it for the watch CSS

2594:23

we're going to be also providing a build

2594:25

CSS so I'll just use like npx and then

2594:28

tvin CSS and we want to go into the SRC

2594:32

folder and then we want to go into the

2594:34

input. CSS file we want to output there

2594:37

you want to go into the LI folder then

2594:39

the output. CSS file and that's going to

2594:42

be here now let me just save my file and

2594:44

now we are going to be testing our

2594:46

component but first of all I'll just go

2594:48

ahead and uh build there so I'll just

2594:50

use like uh first of all let me just see

2594:52

one go into the foundation package I

2594:55

guess we already built that I'm not

2594:56

quite sure about that yes we already did

2594:59

so we don't have to go to the foundation

2595:00

let me just go outside from there I'm

2595:02

going to just use like um watch CSS okay

2595:07

so we have to go into the reactjs and

2595:09

then we going to be watching that CSS

2595:11

God damn it Yan watch CSS and now it's

2595:15

going to watch there right now okay

2595:18

input. file is not

2595:21

specified I guess I named that as index

2595:23

but it should be input yep I'm going to

2595:26

have to rename that to input and then

2595:29

CSS and now let me just use like y watch

2595:31

CSS and now it's going to totally work

2595:35

okay so that's totally done it's going

2595:36

to first all build there as you can see

2595:38

right here it's going to build there and

2595:40

we're now getting all of that values and

2595:42

now we can totally use that inside our

2595:44

component and that's it so what do I

2595:46

mean by that I'm going to go ahead and

2595:48

remove that from here and I'm going to

2595:50

just write like Buton component which

2595:51

will say like click me let's just zoom

2595:54

in a bit and here we can just write our

2595:56

class names and now if I just write

2595:59

hosen first of all we have to enable our

2596:01

intelligence then it will work so I open

2596:03

this extension which is a TN CSS

2596:05

intelligence and I'm going to click on

2596:07

this switch to pre-release version it's

2596:09

going to take a while to install there

2596:11

and now I'm going to just restart my

2596:13

extension okay so now let me just go

2596:15

ahead and go to my component once once

2596:16

again and I'm going to remove this class

2596:18

name from there and I'm going to just

2596:20

write like class name if I just use like

2596:22

you know let me just use like BG and

2596:24

here you can see we are now getting all

2596:25

of our background colors right here so

2596:27

we are now getting background color of

2596:29

hen you know what I can't even show you

2596:31

there right now what the hell is going

2596:32

on with my IDE today I'll just write

2596:35

like husan and if I if I just use like

2596:37

um PG so here you can see it's going of

2596:39

gives us all of that colors which we can

2596:41

use right here so we are now getting

2596:43

like all of our colors which is a

2596:45

primary color oh my God why can't you

2596:48

see that God damn it and we can also

2596:51

provide our pings and so on and so forth

2596:54

so you know what let me just show you

2596:55

there I'm going to use like background

2596:57

of warning and 500 which is my own color

2597:00

right here okay so which is the hosan

2597:03

background color and now we are going to

2597:05

be also providing some sort of a pairing

2597:06

so I'll just use like husan Ping on the

2597:08

x-axis will be set to add it will

2597:10

totally work I can also provide like

2597:12

husan pairing on the y- axis of four it

2597:15

will totally work I'm going to also

2597:17

provide like hen rounded totally small

2597:20

it will work and yeah as you can see we

2597:22

are now getting all of that values and

2597:24

we can also specify like hen the width

2597:27

will be set to 16 and it will totally

2597:30

work now let me just save my file right

2597:32

now I'm going to open my terminal so

2597:33

it's going to rebuild there and now we

2597:36

are going to be opening yet another

2597:37

poers Shell poers Shell God damn it not

2597:40

Powers shell so I'm going to click on

2597:42

that and now we are going to be opening

2597:43

another terminal now I'll use like npm

2597:45

or Yan story book so it's going to open

2597:48

there right here but first of all we

2597:50

have to go into the storybook package

2597:53

and then we're going to be using like

2597:54

Yan story book story book with a Yan and

2597:59

now let me hit enter no it's going to

2598:01

work let me just refresh there okay it's

2598:04

not working I don't know why I guess I'm

2598:05

going to have to restart so I'm going to

2598:07

close there I'm going to also close

2598:09

there and let me just restart this watch

2598:11

once again and we are going to be

2598:14

restarting the story book once again

2598:17

it's still not working I don't know why

2598:19

we have to check it out so you know if I

2598:21

right click on there go to inspect

2598:22

element we should be getting all of

2598:24

these classes but it's not working so

2598:26

I'm going to have to figure this out

2598:27

right now okay so that was not one error

2598:31

but there was a lot of errors and it

2598:33

took me a lot of time to figure this out

2598:36

the first error was uh you know what let

2598:38

me just remove every single thing and

2598:40

rebuild there I'm going to go ahead and

2598:42

go to the foundation and delete there

2598:45

just a lift folder also go to the tokens

2598:47

folder and remove this uh JS folder from

2598:50

there I'm going to delete them now let

2598:52

me go to the react package we're going

2598:53

to be removing this lip folder which we

2598:56

just built and also I'm going to go

2598:58

ahead and go to this telin config.js

2599:00

file and instead of providing this uh

2599:03

export default we are not going to be

2599:04

doing there but instead we are going to

2599:06

be using this syntax which is a module.

2599:09

export that's the first thing that you

2599:10

have to do now we are going to be

2599:12

rebuilding our project so now let me

2599:14

just stop there stop this one even kill

2599:16

this entire terminal and now let me just

2599:18

reopen there right here so we are now

2599:20

inside the route I'm going to go ahead

2599:22

and go to first of all the packages

2599:24

folder then I'm going to go to the

2599:25

foundation folder and I'm going to just

2599:27

build there so I'll use like here on

2599:29

build and now it's going to build there

2599:31

so that's totally done now I'm going to

2599:33

go outside from this Foundation package

2599:35

and I'm going to go into the react

2599:36

package so I'll just use like CD and

2599:39

then reactjs and I'm going to also build

2599:41

this so I'll use like here on build and

2599:44

I'm going to just build there also we

2599:45

are going to be building a y CSS uh yeah

2599:48

just a build CSS as well so it's going

2599:51

to also build there now we are going to

2599:53

be watching for the CSS I'll use like

2599:55

here watch and then CSS so that's

2599:57

totally done the next thing that we have

2599:59

to do is that we have to go ahead and go

2600:01

to our stories then we are going to be

2600:04

going into this do story book folder now

2600:06

we are going to be going into this

2600:07

preview. file and here we have to import

2600:10

that CSS output file so I'll just go

2600:12

ahead and import there I'll use like dot

2600:14

dot and then I'm going to go into the

2600:16

root directory now we are going to be

2600:18

going into the reactj now we have to go

2600:21

into this Li folder which we just built

2600:23

and now we are going to be getting like

2600:25

output. CSS which is this folder now let

2600:28

me just show you this we are going to be

2600:29

going into this SL folder and we have

2600:31

this output. CSS file so now we are

2600:34

going to be importing there the next

2600:35

thing there we have to do that we have

2600:36

to also our story book so we can see

2600:39

there so I'll use like your story book

2600:41

and now if I just hit enter okay so we

2600:43

have to first of all go into the story

2600:46

book folder now we are going to be using

2600:48

a u what do we call it yeah story book I

2600:51

can't even uh I even forgot the names of

2600:53

them so now if you test this out here

2600:56

you can see it will now successfully

2600:57

work okay and why is there it's because

2601:00

everything is now totally correct and

2601:02

now we can just use our own design

2601:04

system styling inside this design Des

2601:06

system and that will totally work so

2601:08

here you can see I was using my primary

2601:10

color but let's suppose if I want to

2601:12

change that to like my secondary color

2601:13

so I'll use like hosan and then

2601:15

background of to one in color it's not

2601:18

even giving me that intelligence but

2601:20

that's totally okay so now let me just

2601:21

save my file and here you can see the

2601:23

color is now changed to this yellow

2601:24

color and I'm using my warning color

2601:27

right here which is coming from our

2601:28

design system I'm going to also provide

2601:30

a few pairing like pairing for the xaxis

2601:32

of eight and then pairing for the Y AIS

2601:35

of four so let's just add the four I'm

2601:37

going to be also providing a few

2601:38

roundness so I'll just write like

2601:40

rounded toly small which is my own thing

2601:43

okay so I build it by myself by using my

2601:46

design system and here you can see it's

2601:48

going to make this amazing button and

2601:50

let's suppose if you want to change the

2601:51

styling of this I'll use like husan and

2601:53

width will be set to 16 or something

2601:55

like that and I'm going to also provide

2601:57

like husan and the font will be set to

2601:58

semi bold I'm going to save this file

2602:00

right now and here you can see it will

2602:02

also work so I'm going to go ahead and

2602:05

just remove this width of SC from there

2602:07

save my file and that's totally working

2602:09

and the next thing that you have to keep

2602:10

in mind is that we also build our own

2602:13

component Library so you can also push

2602:16

that to the npm and use that right here

2602:18

or you can create a new file for there

2602:21

and I mean like new folder for there

2602:23

which will be a component Library so you

2602:25

can put there right here inside your

2602:26

packages folder and then you would be

2602:28

able to successfully use there inside

2602:31

your design system and that was it about

2602:33

the design

2602:35

system that was a lot of talking and a

2602:37

lot of explanation and I hope you

2602:39

enjoyed it hey guys and YouTube channel

2602:42

so in this video we are going to be

2602:44

building this mer St monster from

2602:48

scratch okay so now let me just show you

2602:50

how this entire project is going to look

2602:52

like and then we're going to be jumping

2602:54

into the prerequisites and the setup so

2602:57

what you can expect by the end of this 7

2602:58

hour of content is this entire

2603:01

application so now let me just show you

2603:02

that so first of all we have this

2603:04

amazing slider right here and we can

2603:06

change our movies by just clicking on

2603:08

these dots or we can just click on these

2603:10

arrows so it's going to just also change

2603:12

our movies right here okay so then it's

2603:14

going to just gives us that choose for

2603:16

you like all of the top rated movies

2603:19

okay so we can also change our movies by

2603:20

just clicking on there and then it's

2603:22

going to also gives us our top movies as

2603:24

well so it's going to just grab our top

2603:26

movies from our database and it's going

2603:28

to just show it right here something

2603:30

which we going to be also learning in

2603:31

this course okay so now let me just

2603:33

click on there so here you can see we

2603:35

can totally change our movie

2603:36

like that and then we have a Choose

2603:38

movie right here we can also choose

2603:40

different kind of movies by just

2603:42

clicking on this genre so now let me

2603:43

just click on this action so it's going

2603:44

to just only gives us that action movies

2603:47

so if I just click on this adventure so

2603:48

it's going to also giv us that adventure

2603:50

movies and so on and so forth so that

2603:53

was just a homepage now let me just go

2603:55

ahead and go to this browse movies and

2603:57

now once I click on that and it's going

2603:59

to brings us to this entire movies

2604:01

database and we can just search for

2604:03

different kind of movies like for

2604:04

instance if I want to search for like

2604:06

the Antman is going to give us that

2604:07

Antman or the black arum or John Wick or

2604:12

I don't know Avengers or something like

2604:14

that so we can totally search for a

2604:16

specific movie or we can also select a

2604:18

movie by a specific genre so I'm going

2604:20

to just click on there and let's suppose

2604:21

if I only want to get the action movies

2604:23

so I'm going to just click on that so

2604:24

it's going to just only gives us the

2604:26

action movies right here or if I want to

2604:28

go to a specific like I don't know maybe

2604:30

Adventure so it's going to just give us

2604:31

that adventure movies right here or if I

2604:33

want to go to like I don't know maybe

2604:35

comedy or yeah romance just click on

2604:38

this so it's going to just give us that

2604:39

song and I accidentally put that right

2604:42

here and we can totally remove that from

2604:44

more genres so that's there now we can

2604:46

also select a different movies by a

2604:48

specific year so I'm going to just click

2604:50

on that and we can just choose like 2009

2604:52

so it's going to gives us all of the

2604:54

movies which was released in 2009 I did

2604:57

not provide a lot of movies because I

2604:59

don't have but I'm going to show you how

2605:01

you're going to be adding a lot of

2605:02

movies to your database but this is just

2605:04

a test to show you we are going to be

2605:06

building and now let me just click on

2605:07

this sort by and I can sort the movies

2605:10

by the new category so now let me just

2605:12

click on that and it's going to gives us

2605:14

the latest movies right here or I can

2605:16

also click on the top so it's going to

2605:18

gives us the top movies like the top

2605:20

rated movies and I can also choose the

2605:22

random movies so here you can see it's

2605:24

going to gives us that uh what do you

2605:26

call it Avatar right here and now let me

2605:28

just refresh that and now let me just

2605:29

click on that random movie once again so

2605:32

anytime I click on that random movie

2605:34

it's going to gives us that specific

2605:35

random movie right here okay so that's

2605:37

that now let me just go ahead and go to

2605:39

a specific movie like I don't know if I

2605:41

want to go to maybe this Avengers and

2605:43

game now let me just click on there so

2605:44

first of all it's going to gives us the

2605:46

movie image then it's going to gives us

2605:47

the movie name description and also the

2605:51

cast and also the releasing that as well

2605:53

something which we're going to be

2605:54

discussing as well and here you can also

2605:56

see that we can totally provide a review

2605:58

for that so how that what we're going to

2605:59

be doing them so now let me just click

2606:01

on this icon right here so we can

2606:03

totally log in if you already have our

2606:05

account but if you don't have our

2606:06

account so we can just click on this

2606:08

register or we can just click on this

2606:10

plus button right here this plus user

2606:12

icon right here so it's going to also

2606:13

brings us to this page where we can

2606:15

create different users so now let me

2606:16

just create a specific user like I don't

2606:18

know maybe the Black Adam we would have

2606:20

the Black Adam gmail.com and we will

2606:24

also provide the password of Black Adam

2606:26

and one 12 black adam12 once again and

2606:30

now let me just click on there and here

2606:31

you can see we are now successfully

2606:33

registering a specific user and now let

2606:35

me just go ahead and just uh provide a

2606:37

review for a specific movie so I'm going

2606:39

to go ahead and write a review for this

2606:42

John Wick okay so now let me just write

2606:45

like I don't know uh this is amazing

2606:49

movie blah blah blah or something like

2606:52

that and now if I click on this submit

2606:54

button so here you can see it's going to

2606:56

also gives us that who did that review

2606:58

and what kind of review that person did

2607:00

and we can also see when that review was

2607:03

made okay so that's the now let me just

2607:06

click on this drop down menu we can log

2607:08

out if you wanted to or we can go ahead

2607:10

and go to our profile so we can totally

2607:12

update our profile like the user name

2607:14

the email and also the password we can

2607:16

totally do that but now let me just log

2607:18

out and now one of my favorite part

2607:20

about this course which is the admin

2607:23

functionality okay so now let me just

2607:25

log in as an admin and you can create

2607:27

different admins if you wanted to

2607:29

something which we going to be also

2607:30

diving into in a really great detail but

2607:32

now let me just log in as an admin and

2607:34

now let me just click on this sign in

2607:36

and here you can see we also have the

2607:37

dashboard right here so now let me just

2607:39

click on this dashboard and it's going

2607:40

to gives us that amazing dashboard right

2607:43

here where we can see all of the users

2607:45

all of the comments and all of the

2607:47

movies right here okay so it's going to

2607:49

also gives us that how many people

2607:51

subscribe like how many people log in

2607:53

and yeah and then it's going to also

2607:55

gives us the top content right here like

2607:57

how many comments are provided for each

2607:59

of these specific movie so we can

2608:01

totally see there we can also see the

2608:02

comments if you wanted to we can also go

2608:04

ahead and go to the create movie mov and

2608:06

here we are going to be just creating a

2608:08

different movie so now in this case I

2608:09

can just click on this upload image and

2608:12

I'm going to just provide like I don't

2608:13

know maybe this one 1899 TV series so

2608:16

I'm going to just provide like 18 uh

2608:19

99 and TV series or something like that

2608:24

and I don't know when this series was

2608:26

released so I'm going to just provide

2608:27

like

2608:28

2023 or something like that and now let

2608:30

me just SP like um

2608:33

[Music]

2608:34

horror DV

2608:36

series which will just make you yeah I'm

2608:39

going to just leave the detail right now

2608:41

because this is just a test and now let

2608:43

me just provide the cast and the cast

2608:44

was hosan and also the John and also

2608:48

come on John and also um web dev or

2608:52

something like that we can also select a

2608:54

specific genre so now let me just click

2608:56

on there and we can put that in a

2608:58

specific genre so now let me just put

2609:00

the in the comedy or something like that

2609:02

and now let me just click on this create

2609:03

movie so it's going to just create a

2609:05

specific movie and it's going to brings

2609:06

us to all of that movies right here now

2609:09

let me just go back to my dashboard once

2609:10

again and now what I want to do is that

2609:13

I'm going to just click on this create

2609:14

genre so we can just create a specific

2609:16

genres right here so I can just create

2609:18

like uh I don't know

2609:20

documentary or something like that now

2609:22

let me just click on this let me right

2609:24

click on there and select as a

2609:25

documentary now let me just click on

2609:27

this submit button so we can just select

2609:28

this documentary right here we can

2609:30

select a specific genre we can update

2609:32

that if you wanted to or we can delete

2609:34

this so like in this case I want to

2609:35

update that to something else or

2609:37

something like that now let me just

2609:39

click on this update button so it's

2609:40

going to just update that right here and

2609:42

now if I want to delete that so I can

2609:43

just click on this button and I can just

2609:45

click on this delete so it's going to

2609:46

just delete there right in here okay so

2609:48

yeah that's that now let me just refresh

2609:50

that and now let me just go back and we

2609:52

can also go to the update movie so I'm

2609:54

going to just click on there and we can

2609:56

just choose a specific movie to either

2609:58

update or delete so in this case I'm

2610:00

going to just update like andman so in

2610:03

providing an end man now let me just

2610:05

remove that and real man okay so we can

2610:08

update the year we can update the detail

2610:10

we can update the cast we can update the

2610:12

image we can update every single thing

2610:15

that we want so I'm going to just click

2610:16

on this update movie and it's going to

2610:18

brings us to this movies detail and here

2610:20

you can see we have our Antman now let

2610:22

me just show you there and here you can

2610:24

see we now successfully changed that

2610:26

from the Antman to the real man and now

2610:28

let me just click on there once again

2610:30

let me just go to my dashboard once

2610:31

again and what I want to do is that I

2610:34

can delete a specific movie let me just

2610:36

go ahead and go to this update movie and

2610:38

let's suppose if I want to delete this I

2610:40

don't know maybe this s or you know let

2610:42

me just delete this because this one was

2610:43

just arbitrary so now let me just click

2610:45

on this update movie I can just click on

2610:47

this delete movie and there you have it

2610:49

so it's going to now successfully delete

2610:51

the from my database so now let me just

2610:53

close there and here you can see we no

2610:55

longer have that 1899 mie and now let me

2610:58

just click on there once again go to my

2610:59

dashboard we can also check all of the

2611:02

comments like entire comment section so

2611:05

now let me just click on these comments

2611:06

so we can read all of the comments like

2611:08

who did a specific comment what they are

2611:10

saying and when this comment was made

2611:13

okay so now let me just click on this

2611:15

delete button so we can also delete a

2611:17

specific comment if you don't like that

2611:19

so yeah that's the entire thing that we

2611:21

are going to be building in this amazing

2611:23

7 hour of content so now let's talk

2611:26

about the prerequisites for this course

2611:28

like what are the thing that you will

2611:29

need to work with this project so now

2611:31

let me just go ahead and go to my

2611:32

YouTube channel right here you can just

2611:34

type husan webd on the YouTube and and

2611:35

it's going to just bring you to my

2611:37

amazing channel right here where you can

2611:39

learn different kind of things but and

2611:41

you can also Even build this e-commerce

2611:43

project and this is the biggest project

2611:45

I have ever made okay and you can also

2611:48

build 100 projects and so on and so

2611:50

forth but what I want you to do is that

2611:52

I want you to just go to this specific

2611:54

playlist right here which is the full

2611:56

stack web development complete Course

2611:58

once you click on this playlist so it's

2611:59

going to just bring you to this playlist

2612:01

right here so what you have to know for

2612:03

this project is HTML but not CSS so if

2612:06

you already learned CSS from somewhere

2612:08

else so we are not going to be using CSS

2612:10

in this project we are going to be using

2612:12

something called the tment CSS so you

2612:15

can totally skip the SS because in this

2612:17

project we're not going to be using the

2612:18

SS so you have to know the HTML you also

2612:21

have to know the 10 CSS you also have to

2612:23

know a lot of JavaScript you don't have

2612:25

to be a master in JavaScript but you do

2612:27

have to know the es6 and how to work

2612:29

with the new features of es6 and all of

2612:31

that and you don't have to know the

2612:33

typescript because in this course we're

2612:35

not going to be using a typescript and

2612:36

then you also must have to know the

2612:38

reactjs and also the Redux toolkit and

2612:41

rtk query you also have to know that and

2612:44

you don't have to know these two courses

2612:46

and you also have to know a lot of not J

2612:49

and a lot of expresses and a lot of

2612:51

okay and you can also skip the VJs

2612:54

and if you want to be fast like me so

2612:56

you can also take this course but you

2612:58

don't have to okay so let me just count

2613:00

there this is going to be the 1 2 3 4 5

2613:06

six 7even and eight courses that you

2613:08

have to take then you would be able to

2613:10

follow along with this amazing project

2613:12

so yeah that's everything you need to

2613:14

know for this amazing project and now

2613:16

let's get into it all right guys so now

2613:18

let me make a set of for recording

2613:19

Journey so I'm going to open my terminal

2613:21

right here inside my desktop and now let

2613:24

me just make that a bit bigger and what

2613:26

I want to do is that first of all I'm

2613:28

going to be creating a separate folder

2613:29

inside my desktop so I'm going to just

2613:31

WR not CD but mkd R and my M you can get

2613:35

any name you like and then I'm going to

2613:37

go into my movies so I'm going to just

2613:39

write like CD my movies and now what I

2613:41

want to do is that I want to create my

2613:43

react project so I'm going to be just

2613:44

using this Command right here it's going

2613:46

to allows us to create a new react

2613:48

project by using the weed and now here

2613:50

I'm going to just rename that to like

2613:52

front end let's just rename that to

2613:55

front end okay so now let me just hit

2613:57

enter Right Here and Now what we want to

2613:59

do is that we want to go into this front

2614:01

end folder right here so we are

2614:03

currently inside a desktop and inside

2614:04

the desktop we have my movies project

2614:07

and then inside my movies we have this

2614:09

front and folder right here you know

2614:10

what let me just show you there so I'm

2614:12

going to be using the ls right here and

2614:13

here you can see we only have this front

2614:15

end folder and now I'm going to go into

2614:17

this frontend folder right here and then

2614:19

I'm going to be using the npmi to

2614:21

install all of the packages which we

2614:23

need for the reactjs so it's going to

2614:24

install all of the packages right in

2614:26

here so here you can see all of the

2614:28

packages are now successfully install

2614:30

and now let me just go back from this

2614:32

frontend folder so we are now inside

2614:34

this my muis project and now I'm going

2614:36

to be using the code Dot and it's going

2614:37

to open my vs code right here and you

2614:39

know what let me just use this code dot

2614:41

once again so it's going to open my vs

2614:43

code on the other screen right here okay

2614:45

so here you can see we only have this

2614:47

front end folder and inside this folder

2614:49

we only have our react boiler plate okay

2614:52

so now the next thing which you want to

2614:53

do is that you want to create a separate

2614:54

folder for the back end so I'm going to

2614:56

just create a back end right here and

2614:58

now the next thing which you want to do

2615:00

is that inside my movies not inside the

2615:03

front end and also not in inside the

2615:06

backend but here inside my movies let me

2615:09

just highlight that for you inside my

2615:11

movies folder I'm going to be

2615:13

initializing my back end stuff okay so

2615:15

now let me just write npm in net come on

2615:18

I nit

2615:20

t-y so it's going to just initialize our

2615:22

note package right here and here you can

2615:24

see inside the file we have the name the

2615:26

version the description Main and all of

2615:28

that kind of stuff so what I want to do

2615:30

is that I want to just write the type of

2615:33

module okay so you just just have to

2615:35

write this save your file and now we

2615:37

have to install a lot of packages for

2615:39

the back end not for the front end but

2615:42

for the back end the first thing you

2615:44

have to do is that we have to install

2615:45

the BCP so I'm going to be just writing

2615:47

the npmi and then let me just place this

2615:50

BCP right here now the next thing which

2615:51

you want to do is that we also need the

2615:52

body passord so now let me just place

2615:54

there right here and we're going to be

2615:56

also using the concurrently to combine

2615:59

the back end and the front end so now

2616:00

let me just install that the next thing

2616:02

which you need is the cookie parser so

2616:04

now let me just install there as well

2616:06

and we would also need the EnV because

2616:09

we want to secure our file and here you

2616:11

can see we are now just passing orb

2616:13

right here and now let me just head

2616:14

space one more time we're going to also

2616:16

like obviously need Express ja so we're

2616:19

going to be also installing the express

2616:21

ja and now we are going to be also

2616:23

needing the Json web tokens now let me

2616:25

just head space one more time we would

2616:27

also need the mongus so now let me just

2616:29

install my goose and also the

2616:31

multer as well and finally the noron

2616:34

Okay so now let me just hit enter right

2616:36

here but before I do I want to show you

2616:38

every single thing so we are now

2616:40

installing the B the body parser

2616:42

the concurrently cookie parser EnV

2616:45

Express Json web token mongus molter and

2616:48

normon so we are now installing all of

2616:50

their packages inside my movies not on

2616:53

the back end and also not on the front

2616:56

end okay so now let me just hit enter so

2616:57

it's going to just install all of that

2616:59

packages for me and now the next thing

2617:00

which you want to do is that we want to

2617:02

take care of the front end but now let

2617:04

me just leave this one to do thing and

2617:06

I'm going to just see you in a few

2617:07

seconds all of the packages are now

2617:08

successfully installed so now the next

2617:10

thing which you want to do is that you

2617:12

want to make sure that everything is

2617:14

successfully installed or not so here

2617:17

you can see we have a big CP we have the

2617:18

body part C currently and all of them

2617:21

right here so yeah that's cool but now

2617:22

the next thing which you want to do is

2617:23

that we want to go into this frint

2617:25

folder and you want to install a lot of

2617:27

packages inside there so I'm going to

2617:29

just using the CD and front end so it's

2617:31

going to just brings us to that front

2617:32

end folder and now let me just use the

2617:34

npmi to first of all install the react

2617:36

icons we would also need the Redux

2617:38

toolkit so we're going to have to just

2617:40

write first of all the react Redux and

2617:43

then we would also need to install the

2617:44

Redux toolkit so now let me just place

2617:46

the Redux toolkit right here let me just

2617:48

make oh you know I'm not going to make

2617:50

that a bit bigger and now we would also

2617:52

need the react router and now here you

2617:54

can see we are now placing the react

2617:56

router now we would also need the react

2617:58

router Dom so now let me just place that

2618:00

right here we would also need the react

2618:02

silk and now here we would also place

2618:05

the react silk right here and also the

2618:07

react toastify so here let me just place

2618:09

the react toastify and finally for the

2618:12

react I mean like finally not finally

2618:15

yeah I guess finally this is going to be

2618:17

the final package which we are going to

2618:18

be installing so now let me just install

2618:20

sell car okay so now let me just make

2618:22

that a bit bigger so the first thing

2618:24

which we are installing is the react

2618:25

icons then the react Redux then the

2618:27

Redux toolkit then the then the react

2618:29

router react router Dom react silk react

2618:32

toastify and silk Carousel so now let me

2618:35

just hit enter right here so it's going

2618:36

to install all of their packages inside

2618:39

this folder right here now let me just

2618:41

make that a big bigger or you know let

2618:43

me just go into this folder and it's

2618:44

going to install all of their packages

2618:46

which we are currently installing inside

2618:48

this front folder right here okay so now

2618:51

let me just wait for that and it is

2618:53

looking awful but it will install there

2618:55

right here let me just make there a bit

2618:56

bigger and yeah and see all of the

2618:58

packages are now successfully installed

2619:00

and now I'm going to close that and now

2619:02

what I want to do is that I want to

2619:04

delete this public folder fer and I also

2619:06

want to delete this SS folder I also

2619:08

want to delete this uh yeah I also want

2619:11

to delete this app let me just go ahead

2619:13

and go to my app and now let's just

2619:15

remove every single thing from there and

2619:17

I'm going to be using this uh RFC

2619:19

shortcut and now let me just remove

2619:21

every single thing from the index. CSS

2619:24

and now I'm going to also remove this

2619:26

react strict mode from here let's just

2619:28

remove there and here you can see

2619:30

everything is looking a okay but now the

2619:32

next thing which you want to do is that

2619:33

you want to ignore this node modules

2619:35

folder and now let me just write a DOT

2619:37

get ignore and here we are going to be

2619:40

just ignoring the node modules folder

2619:43

and here you can see that St or no

2619:45

moduls with s now let's just save there

2619:49

and now the next thing which you want to

2619:50

do is that we also want to use the EnV

2619:52

and now inside this EnV first of all

2619:54

we're going to be defining our Port

2619:56

which will be 3,000 and then we're going

2619:58

to be also defining our URI so I'm

2620:00

going to be using the URI URI it's

2620:03

going to be equals to the string of off

2620:05

let me just search for URI right

2620:07

here and I'm going to just search for

2620:08

come on Mongoose and here let's

2620:12

just click on myose and here let's just

2620:15

click on myose and I'm going to just

2620:17

copy there okay so let's just copy that

2620:19

from here and now let me just place that

2620:21

right here and we are going to be using

2620:24

a single code here as well instead of

2620:26

writing a test I'm going to change that

2620:27

to um M app or something and we would

2620:31

also need something that JWT secret

2620:33

which I already discussed so now now let

2620:35

me just Place some random text right

2620:36

here you can place whichever kind of

2620:38

thing you like you can pass one two 3

2620:41

whatever so yeah that's looking cool but

2620:43

now you know let me just first of all go

2620:44

to this front end folder and I'm going

2620:47

to just use first of all front end and

2620:49

npm not I but npm run dep to to run our

2620:53

project by using this port so now let me

2620:55

just go into my port and let's just see

2620:57

here you can see we don't have any

2620:58

errors nothing inside there which is

2621:01

looking totally cool and a okay but now

2621:03

we also want to bind the back and also

2621:05

the front end functionality to one thing

2621:08

so for that we're going to be using a

2621:09

script so I'm going to go ahead and go

2621:11

to my package.json and now let's just

2621:13

remove this script from here so now the

2621:15

first thing which I want to do is that I

2621:16

want to create a script from my front

2621:18

end so we are going to be running our

2621:20

front end by using the npm Run front end

2621:23

so we are going to be first of all going

2621:25

into the front end folder and then and

2621:29

npm run Dev so that was the first script

2621:32

and now the next thing you have to do is

2621:33

that we have to duplicate that let's

2621:35

just remove that and we will also have

2621:36

to create for the back end as well so

2621:38

I'm going to just write a back end and

2621:40

now here we are going to be running our

2621:41

backend by using the node modon and then

2621:44

first of all we have to go into the

2621:45

backend folder and then inside this back

2621:47

end folder we are going to be just

2621:48

listening to this index.js right here so

2621:51

now finally let me just create for the

2621:53

full come on full stack you can give it

2621:55

any name you like but in my case I'm

2621:56

going to just give it the name of like

2621:58

full stack and here what I want to do is

2622:00

that I'm going to be using the

2622:01

concurrently and first of all we going

2622:03

to be just writing a back slash and

2622:05

inside that we're going to be using the

2622:07

npm run back end first of all and let's

2622:10

just close that and I'm going to be also

2622:11

using the back slash one more time and

2622:13

now let me just reuse my npm run front

2622:17

end like we are going to be first of all

2622:19

running the back end and then we are

2622:20

going to be running the front end so for

2622:22

that what you want to do we just have to

2622:24

write one more back slash and then end

2622:26

off the codes and now let me just put

2622:28

that down and here let me just provide a

2622:30

comma let's just remove that from here

2622:32

sell my file and now let me just go

2622:34

ahead and go to my back end folder and

2622:36

inside this back end folder we're going

2622:38

to be doing a lot of things we are not

2622:40

going to be doing that right now but now

2622:43

let me just create a few folders so the

2622:44

first folder I'm going to be creating

2622:45

for the config so let's just create

2622:47

folder for config the next one will be

2622:49

for uh the controllers so controllers

2622:53

the next folder which we are going to be

2622:54

creating for the routes so let's just

2622:56

name it as a routes and we are going to

2622:58

also creating a folder for the middle

2623:00

wees so middle Wares and we are going to

2623:03

be also creating one for the models so

2623:05

now let me just write a models and here

2623:07

finally we're going to be creating a

2623:09

folder for the utils so utility

2623:12

functions we are going to be writing it

2623:13

inside there now finally we just have to

2623:15

create a separate file inside there and

2623:18

I'm going to just name that to the

2623:19

index.js and inside this file we're

2623:22

going to be defining a few things for

2623:24

now so you know let me just write let me

2623:26

just go back and I'm going to be just

2623:27

writing like uh yeah running baby or

2623:31

something like that now let me just save

2623:33

my file and here you can see we already

2623:35

stop our server and now let me just go

2623:37

back from this front folder and here I'm

2623:39

going to be just first of all using the

2623:41

npm run back in So if I just write npm

2623:44

run back in so here you can see it's

2623:46

going to run our file by using the nor

2623:48

modon so which is totally a okay so now

2623:50

let me just change something inside

2623:51

there s my file and here you can see

2623:53

it's going to gives us there yeah okay

2623:56

so yeah that's only working but now the

2623:58

next thing which you want to do is that

2623:59

we also want to run our front end so I'm

2624:01

going to be using the npm Run front end

2624:04

right here so now if I hit enter and

2624:06

here you can see it's going to also run

2624:07

the front end for me and that's looking

2624:09

totally cool but now the next thing

2624:10

which I want to do is that I want to run

2624:12

both so for that we are going to be

2624:14

using The npm Run full stack stack there

2624:17

we go and now if I hit enter right here

2624:19

so it's going to first of all run my

2624:21

back end and then it's going to run my

2624:23

front end right here which is totally

2624:25

amazing so yeah that's cool but now let

2624:27

me just remove that from here now the

2624:29

next thing you have to do is that we

2624:30

also have to add over uh database right

2624:33

here so I'm going to just go to my fig

2624:35

folder and inside this folder we are

2624:36

going to be just creating a db. JS and

2624:39

now inside this file the first thing

2624:40

which you want to do is that we want to

2624:41

grab the from the and also

2624:44

we just want to create a function so I'm

2624:46

going to just name that to connect DB

2624:49

and here we're going to be using the as

2624:50

synchronous function and now what I want

2624:53

to do is that I'm going to be using the

2624:55

try and catch block and for the catch

2624:57

statement we are going to be just

2624:58

writing like cons. error and here let's

2625:01

just put our come on successfully

2625:05

connected to mongod DB okay and I'm

2625:08

going to also Place correct okay yeah

2625:13

this one right here now let me just also

2625:15

use the process. exit if you have some

2625:18

sort of error so we're going to be just

2625:19

exiting out every single thing and

2625:21

finally let's just go back we're going

2625:23

to be exporting the default connect DB

2625:26

and now let me just provide my logic

2625:28

inside there so if you want to connect

2625:29

to our database so for that we are going

2625:31

to be using the not but

2625:34

use. connect method and we're

2625:36

going to be using the process come on p

2625:39

r o CS process. ENB

2625:44

mangu I come on you know let me just

2625:46

copy that from here and now let me just

2625:49

copy that from here and now let me just

2625:51

place it right here so we are now

2625:52

successfully connected to our database

2625:55

so we would also need some sort of a

2625:56

message inside the console what the hell

2625:58

am I doing CLG and

2626:02

successfully uh s c a s f l y

2626:06

successfully connect here to mongod DB

2626:12

okay oh that's not what I want that's

2626:15

not what I want I'm going to have to cut

2626:17

that from here and then we're going to

2626:19

be just writing console. error and here

2626:21

we're going to be just passing our error

2626:23

if we got one and now let me just render

2626:25

my error right here so error. message as

2626:28

not M Goose but message as m e s a e so

2626:32

error message as well now let me just

2626:35

save that and that's every single thing

2626:36

that we need right here now the next

2626:38

thing which you want to do is that you

2626:39

want to use that inside our index.js

2626:41

file and now what I want to do is that

2626:44

I'm going to be importing a lot of

2626:45

packages right here so we would need the

2626:47

express the cookie pass the EnV and also

2626:50

the path and that's every single thing

2626:52

that we need for now and now let me just

2626:54

grab something from the files so let's

2626:57

just name that as a files and we're

2626:59

going to be just importing our connect

2627:01

DB from where let's just go ahead and go

2627:03

to the config file and then dot JS right

2627:07

here okay so now we just have to provide

2627:09

our configuration so I'm going to just

2627:11

write a

2627:13

configuration I guess this is how you

2627:15

spell it so now let me just use the EnV

2627:17

and then do config okay and now let me

2627:20

just execute there and finally we're

2627:21

going to be also connecting to our

2627:23

database and underneath that what do you

2627:25

want to do we just want to create

2627:26

instance of our Express so we just want

2627:28

to store the server app and not like

2627:31

that exps and now let me just execute

2627:34

that and here we're going to be also

2627:35

passing our middleware okay Wares as

2627:38

well what the hell m i e l e w r s and

2627:44

now let me just use the app. use and we

2627:46

are going to be using the express. Json

2627:49

express. URL encoded right here inside

2627:52

that we're going to be just providing

2627:53

the extended extended to true and we're

2627:56

going to be also providing the app. use

2627:59

of cookie pars which we already grabbed

2628:01

and now underneath that we just want to

2628:03

get our Port so we we going to be just

2628:05

writing a port it's going to be equals

2628:06

to process. env. port or just use the

2628:11

3000 by default and now underneath that

2628:14

we're going to be just creating our

2628:16

routes and here let's just Define our

2628:18

route or you know we're going to be

2628:19

defining our route a bit later and now

2628:21

what I want to do is that I just want to

2628:23

listen to that Port so I'm going to be

2628:25

using the app. listen and I'm going to

2628:28

just listening to this port right here

2628:30

and now let me just place my console.

2628:32

log of server is running on Port and

2628:37

let's just place this port right here

2628:39

okay so everything is now successfully

2628:41

done now let me just go back to show you

2628:43

every single thing right here so first

2628:45

of all we are just importing our

2628:46

packages then we are just grabbing our

2628:48

connect DB then we are providing our

2628:50

configuration we are creating an

2628:51

instance of Express JS we are providing

2628:54

the needed middle wees and we are also

2628:56

grabbing the port and also we are just

2628:58

listening to that Port right here okay

2629:00

so now let me just rerun every single

2629:02

thing right here let me just zoom in a

2629:04

bit and I'm going to be using the npm

2629:06

run and back in this case and now let me

2629:08

just hit enter server is running on Port

2629:10

3000 and also successfully connected to

2629:12

mongod DV so everything is now working

2629:14

totally as expected and now the next

2629:16

thing which you want to do is that you

2629:18

want to create a routes right here but

2629:21

you know I'm going to just take care of

2629:22

that in a few seconds but we would also

2629:24

have to install the T CSS right here so

2629:27

what I want to do is that I'm going to

2629:29

just go back from there and then I'm

2629:31

going to just go into the front end

2629:32

folder now let me just hit enter right

2629:34

here so we are now inside this front

2629:36

folder and now let me just install the

2629:38

twin CSS so I'm going to just write like

2629:40

tell TN CSS right here let's just go to

2629:45

them and I'm going to be just hitting

2629:47

control K and then or you know let me

2629:50

just click on this getting started

2629:51

onward here let me just zoom in a bit

2629:54

and then we have to click on this

2629:55

framework guides and here we just have

2629:57

to select our White Project right here

2630:00

what they are suggesting is that first

2630:01

of all we have to create our project

2630:03

then we have to navigate to their

2630:04

project and then we have to just use

2630:06

these two commands right here so I'm

2630:07

going to just copy there but now let me

2630:09

just go back to show every single thing

2630:12

and here now let me just place this

2630:13

Command right here okay so it's going to

2630:15

just first of all install the T CSS and

2630:17

post CSS and also the auto prefixer and

2630:20

then it's going to just initialize our

2630:22

project or tman css project by using

2630:24

this command and now let me just

2630:25

initialize my T CSS by using the npx T

2630:28

CSS in it

2630:30

DP that was a bit mouthful but now let

2630:32

me just hit enter right here okay it's

2630:34

going to just initialize our post CSS

2630:36

and also the tman config file okay so

2630:39

yeah that's cool but we have to test it

2630:40

out so now let me just use the npm Run

2630:43

uh not full stack but the front end

2630:46

there we go so it's going to do it oh we

2630:48

are already inside this front end folder

2630:50

so we have to go back from there and

2630:51

then we have to use the npm Run front

2630:54

end and it's going to do its thing but I

2630:56

just want to copy there let's just copy

2630:59

that from here we have to go ahead and

2631:01

go to or telling config file that there

2631:04

we go let me just replace that by using

2631:06

this one this new one which we just

2631:08

copied right here now the next thing you

2631:10

have to do is that we have to copy the

2631:12

CSS styling and now let's just save this

2631:13

file let me just go ahead and go to my

2631:17

SRC and then I'm going to just place it

2631:20

right here inside this index. CSS file

2631:22

which is already located inside the SRC

2631:24

folder and now let me just copy this H1

2631:27

from here and now here let me just go

2631:29

ahead and go to my app and now let me

2631:31

just replace this div with this H1 so

2631:33

now let me just SA there and here you

2631:35

can see it is already running let's just

2631:37

stop there and now let me just use my

2631:39

npm run uh front end one more time and

2631:42

now let me just hit enter so it's going

2631:44

to just start my server once again and

2631:46

here you can see TN CSS is working

2631:48

totally as expected so we can change

2631:51

whatever you want to change like Toft

2631:53

till I don't know 200 or something like

2631:55

that and here you can see that's working

2631:57

totally a okay

2631:59

and yeah that was all about the setup of

2632:03

this project so we would have to take

2632:05

care of a lot more than that but yeah

2632:07

that was just the entire setup of this

2632:09

amazing project so that was the setup

2632:10

now let's take care of the user

2632:12

management so I'm going to go ahead and

2632:14

go to my back end first of all and let's

2632:17

just go into my index.js file and now

2632:20

underneath inside the routes so now

2632:22

let's just Define a route by using the

2632:24

app.use and we are going to be going

2632:26

into the API the version one and then

2632:28

the users because we are currently

2632:31

taking care of the users so we're going

2632:32

to be justifying the user routes and a

2632:34

few seconds but first of all we have to

2632:38

define the schema so I'm going to just

2632:40

take care of the user routes in a few

2632:42

seconds but now let's just take care of

2632:43

the schema or the model whatever you

2632:45

want to call this so user.js would be

2632:48

fine and now let's create our model

2632:50

right here the first thing we have to

2632:51

import is the from and then

2632:54

we also have to create our schema so

2632:56

cons user schema will be now equals to

2632:59

Mongoose come on Mongoose there we go

2633:02

Mongoose schema and here we just have to

2633:05

Define our schema right here so the

2633:06

first thing which you want to do is that

2633:07

you want to put the username and inside

2633:10

this username we're going to have to

2633:11

define the type oh my God what the hell

2633:14

let's just remove that and also remove

2633:16

that one as well and now inside there

2633:18

for the type it's going to be set to

2633:20

string and it's going to be required

2633:22

like the user should have to provide the

2633:24

types are required like that let's just

2633:27

sell our file so this is how we're going

2633:29

to be providing a username now let me

2633:31

just take care of the email as well so

2633:33

we're going to have to WR a type of

2633:34

string and also

2633:37

required uh will be set to true and it

2633:40

should be unique so unique u n IQ will

2633:44

be also set to True let's just create

2633:47

for the password as well so we are going

2633:49

to just providing a type of string to it

2633:51

and also it should be required set to

2633:54

True let's just provide our comma there

2633:57

and finally we just have to take care of

2633:59

the is admin okay so if the user is

2634:02

admin so it's going to be a to only

2634:04

Boolean and whether the user is admin or

2634:07

not and then let's just provide a

2634:08

required we'll be now set to three and

2634:11

we have to just provide a default

2634:12

instead of that to false okay so by

2634:14

default the user will be not admin and

2634:18

then we can make it as admin if you want

2634:20

it to and now let me just Pro my time

2634:21

stamp right here so times come on times

2634:25

STS will be set to true as well okay so

2634:28

let's just save there let me just go

2634:30

back and this is how we are going to be

2634:32

creating our schema so first of all we

2634:33

are providing the username then the

2634:35

email then the password then the admin

2634:38

and finally the time stamps so now

2634:39

underneath all of that we have to just

2634:42

export that right here so we're going to

2634:44

be just creating a user it's going to be

2634:45

equals to the mongus do model and here

2634:49

we just have to pass our user right here

2634:51

and let's just pass our user schema and

2634:53

now let's just export that so we're

2634:54

going to be using export default of user

2634:57

so now let's just save that but now we

2634:59

have to create our routes right here so

2635:01

we're going to be just creating a route

2635:02

of the user routes.js so now inside

2635:06

these routes the first thing which you

2635:07

have to do is that we have to grab or

2635:09

Express from expressjs and now the next

2635:12

thing which you have to do is that we

2635:13

have to also grab a lot of controllers

2635:15

so we are going to be grabbing

2635:17

controllers right here and we will also

2635:19

grab the middle wees as well but we're

2635:22

going to take care of that in a few

2635:24

second but now let me just create my

2635:25

router right here so conso router we be

2635:27

now set to express. router okay so now

2635:31

underneath that what do you want to do

2635:33

and here we just have have to Define our

2635:35

router. route as simple route when

2635:38

somebody go to the user so what do you

2635:39

want to do in that case so if somebody

2635:41

post something so now let me just WR a

2635:43

post request then we're going to be

2635:46

passing our create user right here so

2635:47

now let me just create that right here

2635:49

I'm going to sve this file and we're

2635:51

going to be also exporting a router so

2635:53

cons export default router right here

2635:57

default DF a l t there we go and now let

2636:00

me just create this controller word here

2636:02

now let me just save there and what I

2636:04

want to do is that I want to go to my

2636:05

controllers inside these controllers

2636:08

we're going to be creating our user

2636:12

controller.js and inside there the first

2636:14

thing which you want to do is that you

2636:15

want to grab our user from where from

2636:18

our model so where is our model let's

2636:20

just go ahead and go to our models then

2636:22

we have to just write a user.js and now

2636:25

underneath that we're going to also need

2636:26

the BCP so I'm going to just write a

2636:28

bcjs from where from the bcjs okay so

2636:32

now underneath there we're going to also

2636:33

have to just

2636:34

uh create a token and also the

2636:36

asynchronous Handler so now let me just

2636:38

take care of that in a few seconds so

2636:40

I'm going to go into my middle wees

2636:41

right here and we're going to be

2636:42

creating two middlewares the first one

2636:44

which I'm going to be creating for the

2636:46

async Handler handler. JS and then we're

2636:50

going to be also creating for the off

2636:52

middleware doj whether the user is

2636:55

authenticated or in admin so we're going

2636:57

to be creating our custom Asing Handler

2636:59

right here so I'm going to be just using

2637:00

like Asing Handler you can give it any

2637:03

name you like and it's going to take a

2637:04

function as a perimeter it's going to

2637:06

also take the request the response and

2637:08

also the next because this is a

2637:09

middleware so we have to pass the next

2637:11

right here and inside there what you

2637:13

want to do we just want to write a

2637:14

promise. resolve and when the promise is

2637:17

resoled so we're going to have to pass

2637:18

this function once again uh and which is

2637:21

which we are taking right here as a

2637:23

perimeter and inside that we're going to

2637:25

have to pass our next perimeter right

2637:27

here so we're going to have to just

2637:28

write request and response and also the

2637:30

next as well and now inside there or you

2637:33

know not like this we have to catch

2637:34

something if you have some sort of error

2637:36

so for that if we have some sort of

2637:38

error so we are going to be catching

2637:40

that error by using rest. status and

2637:42

then we have to just pass 500 and we

2637:44

just have to write a Json provide a

2637:47

message to that and we're going to be

2637:48

just passing our error. message okay so

2637:51

that's there now finally we just have to

2637:52

write export default and Asing hand

2637:55

Asing hand alert there we go now let me

2637:57

just s my file and that's it about the

2637:59

asynchronous Handler and now let's just

2638:01

take care of the Earth mware the first

2638:03

thing which I want to use that I want to

2638:04

take care of the JWT so we're going to

2638:06

be just grabbing the JWT from the Json

2638:08

web tokens and I already discussed all

2638:11

of that things in my merge St course and

2638:14

also in the other projects so I'm going

2638:15

a bit fast that's because I already

2638:17

discussed all of that things so now let

2638:19

me just go to my models and we're going

2638:21

to have to grab our user.js and then we

2638:24

also have to grab our sing Handler from

2638:29

where from let's just go ahead and go to

2638:32

our asynchronous come on from

2638:34

sing handler. JS right here okay so then

2638:37

the next thing you have to do is that we

2638:39

have to check if the user is

2638:41

authenticated or not so for that we're

2638:44

going to be creating a function which

2638:46

will be

2638:47

authenticate and it's going to be now

2638:49

equals to the S synchronous or a sync

2638:51

Handler function which we already

2638:52

created right here and we're going to be

2638:54

providing yet another call back function

2638:56

so request response and also the next

2638:59

and now inside that we're going to be

2639:00

just creating a separate variable right

2639:02

here for the token and now we are going

2639:04

to be initializing a token to there so

2639:07

it's going to be coming from the

2639:08

request. cookies and then the JWT the

2639:11

Json web tokens and I'm going to show

2639:13

you where this coming from so read JWT

2639:16

from the um JWT cookie which I'm going

2639:20

to show you so now let's just check if

2639:22

the token is valid or not but first of

2639:24

all we have to check if you even have

2639:26

our token or not okay so if you have the

2639:28

tokens so for that we're going to be

2639:30

using the try and catch block and if you

2639:32

have some sort of Errors so we're going

2639:33

to be just like res. status and then

2639:35

here we just have to passord 401 and

2639:38

then

2639:39

th new error uh not like that but error

2639:44

not authorized no token failed there we

2639:49

go and now if we have the token and

2639:50

token is valid so what we want to do we

2639:52

just want to decode that so we're going

2639:54

to be just using decoded and it's going

2639:56

to be equals to A JWT and verify

2639:58

function and here we just have to passw

2640:00

token and also the process. EnV and we

2640:03

all already defined our JWT Secret in

2640:06

other file which you can see right here

2640:09

inside this EnV we are now defining our

2640:11

JWT secret and we're now passing that

2640:13

secret right here okay so now the next

2640:15

thing which you have to do is that we

2640:16

have to get the user so request. user

2640:20

will be now equals to a user. find

2640:24

a a w a t a find uh not just find but

2640:29

find by ID we are going to be first of

2640:31

all getting the user and then we're

2640:32

going to be just writing a code. user ID

2640:35

we are going to be just getting the user

2640:37

ID and we are going to be just selecting

2640:39

the password like we need every single

2640:41

thing but the password we don't need the

2640:43

password okay so now let me just use the

2640:46

next and now let's just go back and

2640:48

that's everything we need to do for now

2640:50

but if you don't have the token so that

2640:53

was like if we have the token so we're

2640:55

going to be just decoding the token we

2640:57

would need every single thing about the

2640:58

user but we don't want to get the

2641:00

password and then finally we just want

2641:02

to get to the next middle where and what

2641:04

if we don't have the token right here so

2641:06

what do you want to do in that case so

2641:07

for that we're going to be just using

2641:09

like rest. status and then 401 and here

2641:11

we just have to write a throw new error

2641:15

of not authorized and no token we don't

2641:18

found any token so yeah that's it about

2641:21

how we going to be checking if the user

2641:23

is authenticated or not now let me just

2641:25

collapse it right here now the next

2641:27

thing which you have to do is that we

2641:28

have to check if the user is admin or

2641:30

not so check uh if the user is admin or

2641:34

not okay so I'm going to be just

2641:36

creating a function I'm going to just

2641:37

give it name of like authorize authorize

2641:40

admin it's going to be equals to the

2641:42

request response and also the next and

2641:44

inside that we're going to be checking

2641:45

if request. user and request. user do is

2641:51

admin okay so we're going to be getting

2641:53

these two values from our request then

2641:55

just go to next middle where like

2641:56

everything is totally a okay but if the

2641:58

user is not in admin so we just have to

2642:00

write like r. status of 401 and then

2642:04

um let's just send this message right

2642:06

here which will be not authorized uh as

2642:10

in admin okay so now let me just save

2642:13

there and finally we just have to export

2642:14

both for middleware so I'm going to be

2642:16

just exporting the authenticated and

2642:18

also the authorize is in admin so now

2642:19

let me just save there and we're now

2642:21

totally done with both of these middle

2642:23

wees right here but now we have to use

2642:25

them somewhere I'm going to just close

2642:27

it right here and now let me just grab

2642:28

that right here so the first thing which

2642:29

you have to do is we have to grab our

2642:31

async Handler async Handler from where

2642:35

from or sing Handler so let's just go to

2642:38

my uh Metar right here let's just go to

2642:41

my sing Handler we will also need to

2642:43

create a token I forgot to show you that

2642:46

first of all we have to just do that and

2642:48

I'm going to just go to my utility

2642:49

function right here and we're going to

2642:51

be just creating a token so I'm going to

2642:52

just give it the name of like create

2642:54

token. JS and to create a token the

2642:57

first thing we would need is the JWT

2642:59

from the Json web tokens and also let's

2643:02

just create our tokens so I'm going to

2643:03

just Define a function

2643:06

generate uh generate token is going to

2643:08

be equals to the response and also the

2643:10

user ID and inside there what you want

2643:13

to do we just want to get the token

2643:14

first of all so cons token will be

2643:16

coming from the JWT sign and we are now

2643:19

going to be just destructuring the user

2643:21

ID and then we have to just write a

2643:23

process.env and we already Define our

2643:27

JWT secret and then we have to just pass

2643:30

our expiration uh dat right here so it's

2643:33

going to have expired in 30 days so now

2643:35

let me just pass my 30 days and now

2643:37

let's just save that so this is how we

2643:38

are going to be creating a token and now

2643:40

the next thing which you have to do is

2643:41

that we have to set the token as an JWT

2643:44

HTTP only cookie so now let me just WR a

2643:47

set JWT ASN HTTP only uh cookie there we

2643:53

go so now let me just save that and

2643:55

let's just close that right here and now

2643:57

we are going to be using rest cookies uh

2644:00

not cookies but just a singular cookie

2644:02

and we have to just write a JWT for Json

2644:05

web token and then we have to just write

2644:06

a token which we already generated right

2644:09

here let me just show you that which we

2644:11

already generate right here now the next

2644:13

thing which you have to do is that we

2644:14

have to place these properties and

2644:15

values so HTTP only will be set to True

2644:18

secure will be just getting from the oh

2644:20

I forgot to do now let me just copy that

2644:23

just realize that I forgot to do that

2644:25

let's just place that right here and I'm

2644:27

going to just place it right here it's

2644:28

going to be equals to the development DV

2644:31

PM n there we go and now let me just

2644:32

save there and the secure will be set to

2644:35

the node envirment not equal to

2644:37

development so in this case this is set

2644:39

to development but when we launch or

2644:41

deploy this project so it's not going to

2644:43

be in the development mode so then it

2644:45

should be secure so then the same site

2644:47

will be set to straight and here we are

2644:49

just providing the max edge of 30 days

2644:51

right here okay so now let me just save

2644:53

that and now let's just return there

2644:55

right here so we have to just write

2644:56

return token and there you have it

2644:59

underneath that we are going to be just

2645:00

using export default of generate token

2645:03

right here which we already create right

2645:06

in here okay so now we successfully

2645:08

create our token but now we have to use

2645:10

that okay so now we are going to be

2645:11

using it right here and to use that the

2645:13

first thing we would need is the create

2645:15

token from where let's just go to my UT

2645:19

tails and then we have to go to the

2645:20

create token word here and now finally

2645:23

we have to create our user so we are

2645:24

going to be just writing like con uh

2645:26

create user and it's going to be equals

2645:28

to the asynchronous Handler async

2645:31

Handler function which we already

2645:32

defined and now let me just provide my

2645:34

sing Handler of request response and

2645:37

inside there we're going to be just

2645:38

restructuring the username the email and

2645:40

also the password from where from the

2645:43

request. body and now let me just write

2645:45

a cons. log of create not create but

2645:48

usern name and also the email and also

2645:52

the password as well so now let me just

2645:53

save that and finally we just have to

2645:55

export the create user from there and

2645:58

now let me just save there and we have

2646:00

to grab the controller from there so

2646:02

we're going to be just using like import

2646:04

create user and let me just hit enter

2646:07

right here and finally at the end we

2646:08

have to just specify this. JS and now

2646:11

let me just we are already using the

2646:12

word here but I forgot to show you one

2646:14

thing we have to go to the index.js file

2646:17

and we have to import the word here so

2646:19

let's just try it's not going to just

2646:21

Auto Import we have to manually import

2646:23

that so we're going to be just importing

2646:25

this user routes from where let's just

2646:27

go to our routes and inside this routes

2646:30

we have the user routes.js now let me

2646:32

just save there and close every single

2646:34

thing and for that we're going to just

2646:36

using npm run back end and now let me

2646:38

just hit enter and here you can see we

2646:40

don't have no errors inside there now we

2646:43

can use either the Thunder Cline or the

2646:45

postman so throughout the course I'm

2646:47

going to be using the postman because I

2646:49

know a lot of people don't already know

2646:51

about the thunder cin so I'm not going

2646:53

to be using that although it is called

2646:55

tool and I always like every single day

2646:58

use this thunder CLI but in this course

2647:00

we're going to be using this Postman

2647:02

word here so now let me just create a

2647:03

blank collection right here and I'm

2647:06

going to just name it like M project or

2647:09

something like that and now inside that

2647:11

we're going to be just creating a few

2647:12

folders or not folders but files and

2647:15

let's just create a add request and we

2647:17

are now first of all creating or create

2647:21

user right here and what I want to do is

2647:24

that we are listening to this port right

2647:26

here and you know first of all let me

2647:29

just Define my Local Host let me just

2647:31

Define

2647:32

http then Local Host 3,000 and we are

2647:37

now listening to this port right here

2647:39

which is API come on API version one and

2647:43

then users okay so now if I hit or you

2647:46

know it should be a post request right

2647:48

here because currently we are just

2647:50

listening to the post method right here

2647:52

okay and we also have to send some sort

2647:54

of a data inside there so for that we're

2647:56

going to be just sending some sort of a

2647:57

data inside the raw and then we have to

2648:00

click on the Json and now let me just

2648:02

provide some sort of a data right here

2648:04

and I'm going to just pass let me just

2648:05

zoom in a bit Ah God damn it let's just

2648:09

click on that and here we're going to be

2648:10

just passing the username first of all

2648:12

so username and the username will be set

2648:15

to Alex and then we have to just uh

2648:17

specify the email for that so we would

2648:19

have like Alex gmail.com and we also

2648:22

have to provide some sort of a password

2648:24

for that and password will be like

2648:26

alex12 or something like that and now

2648:28

let me just click on the send button and

2648:30

here let's just check out okay it's not

2648:33

working I don't know why but we are just

2648:35

getting some sort of error okay so 404

2648:38

not found what's up what are we

2648:41

doing uh 3,000 is okay but ah I forgot

2648:45

to include the one right here we have to

2648:47

just write this version one and then we

2648:49

have to click on the send button and

2648:51

then it's going to give us the username

2648:53

the email and also the password right

2648:55

here at the end okay so this is how

2648:57

we're going to be sending the data by

2648:58

using the postman and now let's just

2649:00

create our user actually so now let me

2649:02

just get get into that and we're going

2649:04

to be just removing this code from here

2649:06

and now let's just create a real user

2649:08

but before we create a user first of all

2649:10

we have to validate so we want to check

2649:12

if we don't have the username or if we

2649:15

don't have the email like if the user

2649:18

did not specify the username or the

2649:19

email or the user did not specify the

2649:22

password so what you want to do in that

2649:23

case we just want to throw new error

2649:25

like throw error and we just want to say

2649:27

like please fill all the fields right

2649:31

here okay so if the user does Pro all of

2649:33

the input field so what you want to do

2649:34

in that case we just want to check for

2649:36

already existed users so we're going to

2649:38

be just writing like const user exist

2649:43

and it's going to be equals to aent and

2649:45

user. find one which is Mongoose method

2649:48

and inside that we're going to be just

2649:50

passing the email okay and we're going

2649:52

to be also checking if you already have

2649:54

user already existed uh so what do you

2649:57

want to do in that case you know what

2649:58

let me just make that as a oneliner and

2650:00

we're going to be just runting like r.

2650:02

status of 400 100 and we just have to

2650:04

write a send user already exist s there

2650:09

we go now let me just sell that so at

2650:12

this point we are not creating the user

2650:14

but now let's just generate our user so

2650:16

first of all we are going to be just

2650:18

hashing the user password so hash the

2650:20

user pass user password right here and

2650:24

now if you want to Hash the user

2650:25

password we're going to have to provide

2650:27

some sort of a salt inside there so for

2650:29

that we're going to be using a and then

2650:31

bpjs not JS but just a BCP did I name it

2650:35

as a BCP JS it shouldn't be a JS just a

2650:38

BCP now let me just copy that and now

2650:40

let me just place it right here as a b

2650:42

crib and we have a method inside there

2650:44

which is a gen Sal so it's going to just

2650:46

generate a solt for us and then we have

2650:48

to pass the generated salt inside our

2650:51

hashed password so we have to just write

2650:52

a hashed password and it's going to be

2650:55

equals to A and then let's just use our

2650:57

BCP one more time and it should be a w

2651:01

we have to use our BCP one more time and

2651:03

we just have to Hash our password by

2651:05

using this hash method and here we have

2651:07

to specify this password right here

2651:10

which we are already getting from the

2651:11

user okay so we have to specify the hash

2651:14

password and we want to provide a Sol of

2651:17

this 10 randomly generated uh something

2651:20

some text right here like I don't know

2651:21

the numbers and yeah it's going to just

2651:23

generate a solt for us and we want to

2651:25

provide that salt into a real password

2651:28

and now the next thing which you have to

2651:29

do is that we have to create a new user

2651:31

so we're going to be just writing like

2651:33

con uh new user it's going to be equals

2651:35

to new then we have to just specify the

2651:38

user model word here and we have to just

2651:40

write a username which the user is

2651:42

already giving us and also the email and

2651:45

also the password we are not going to be

2651:47

just writing a password but instead we

2651:49

have to pass our hash password right

2651:51

here okay so now let me just pass this

2651:53

hash password and that's it this is how

2651:56

we going to be creating our user but now

2651:58

we have to store this user inside our

2652:00

database over there we are going to be

2652:02

using the try and catch block for the

2652:03

catch we're going to be just writing

2652:05

like r. status of 400 and underneath

2652:08

that we're going to be also just um

2652:10

providing some sort of error like uh

2652:12

invalid U user data or something like

2652:14

that and for the tri block first of all

2652:16

we are going to be storing our user

2652:18

inside our database so for that we're

2652:20

going to be just using the come on the

2652:22

schema name or the variable Name by

2652:24

which we are creating our user and then

2652:26

we have to just specify the save method

2652:28

so it's going to just save our user to

2652:30

our database and now we have to also

2652:32

create a token based on the user so

2652:34

we're going to be just writing like

2652:35

create token that function which we

2652:38

already created right here inside the UT

2652:40

Tails file here you can see we already

2652:42

defined this function it is taking the

2652:44

response and also the user ID and we are

2652:47

now grabbing there right here so now we

2652:50

have to just specify there and so what I

2652:51

want to do is that we have to just

2652:53

specify the response and also the new

2652:55

user so it's going to just gives us the

2652:57

ID right here already so that's some

2653:00

good things so we are now providing a

2653:02

specific user new ID right here so based

2653:05

on that ID it's going to just create a

2653:07

token for us okay so now underneath that

2653:09

we just want to show some sort of a

2653:10

message to user like yeah the username

2653:12

and everything is totally a okay so

2653:14

we're going to have to just write like

2653:15

r. status and we have to just write 2011

2653:18

like the user already created or the

2653:20

user just created like the new user

2653:22

created and we're going to have to just

2653:23

write IDE of new user and we have to

2653:26

just get the unique ID from there we

2653:28

have to define the username and the new

2653:31

user and then we have to just WR a

2653:33

username and also we have to define the

2653:36

email we have to just WR a new user and

2653:38

then the email and also finally is admin

2653:42

uh a DM i n and then we have to just WR

2653:45

a new user dot is admin okay so now let

2653:48

me just sell there and now let me just

2653:50

go back and let me just say that once

2653:52

again so the first thing which we are

2653:53

doing is that we are grabbing the

2653:54

credential from the user and then we are

2653:56

checking their credential and all of

2653:58

that field so if the user did not

2654:00

specify any of the field or if the user

2654:02

Miss any of these fields so we're going

2654:04

to have to just pass this error please

2654:06

fill all of the input fields and then we

2654:08

are checking if the user already exists

2654:10

inside our database so for that we're

2654:11

going to have to pass the user already

2654:13

existed if the user provide every single

2654:15

thing and the user is not already

2654:17

existed inside our database and then we

2654:19

have to just generate the salt and we

2654:21

have to pass that salt into a real

2654:23

password so it's going to just make it

2654:25

as a random characters and then finally

2654:27

based on that random characters and the

2654:29

user data first of all we're going to be

2654:31

just providing the user entered username

2654:33

then the email and we're going to be

2654:35

also providing the hash password so that

2654:37

nobody can see that and finally we are

2654:39

just saving the user to the database and

2654:40

we are creating a new token based on

2654:42

that specific user ID and finally we're

2654:45

just showing something to the user like

2654:46

yeah the user is created or not okay so

2654:49

now what I want to do is that let's just

2654:50

go back ah that was a lot that was a lot

2654:55

of going back okay so now let me just

2654:57

create my user right here and for that

2655:00

we are going to be going into my mongod

2655:03

you can use the mongodb compass if you

2655:04

wanted to but I'm going to be just using

2655:07

my mongodb so now let me just drop this

2655:09

already created datab bases so H movies

2655:12

and we also have the movies app let's

2655:14

just delete that so movies app come on

2655:19

movies app and now let me just hit enter

2655:21

right here and here you can see we don't

2655:22

have any other databases but now if I

2655:25

click on this button right here so it's

2655:27

going to just gives us uh this preview

2655:29

right here it is now set to Raw but if I

2655:31

click on the prev so it's going to just

2655:33

make it free I can also click on the

2655:34

visualize and then click on this

2655:36

visualize response and then click on the

2655:38

continue so it's going to just take a

2655:40

bit of time and here you can see it's

2655:41

going to just create a table for us so

2655:43

we have the user ID then we have the

2655:45

username then we have the user email and

2655:47

also the user is not admin okay so now

2655:50

let me just show you that inside my real

2655:52

database right here so now let me just

2655:53

refresh that and here you can see we

2655:55

have a movies app we have a users

2655:57

collection inside there now let me just

2655:58

click on that then we have to go to the

2656:00

document inside this document we only

2656:02

have have one document right here so we

2656:04

have a uniquely created ID right here

2656:07

then we have a username then we have a

2656:08

email and here you can see the password

2656:11

is totally hashed and the user is not

2656:13

currently set to admin so it is now set

2656:15

to false and the created de is this de

2656:18

right here okay so yeah this is how we

2656:20

are going to be creating a new user now

2656:22

I want to create a few more users so

2656:24

that we can work with them so I'm not

2656:26

going to be just clicking on the test

2656:27

I'm going to just click on the body and

2656:29

I'm not even going to be just

2656:31

visualizing this so I'm going to just

2656:32

click on this pry right here and now let

2656:34

me just uh change all of their data so

2656:36

I'm going to be just creating first of

2656:38

all myself but before I create myself

2656:41

I'm going to have to drag that at the

2656:44

bottom I guess and now let me just

2656:46

create myself so I'm going to be just

2656:47

creating myself which is husan baby and

2656:50

now let me just create husan gmail.com

2656:52

and we have a

2656:53

h12 okay now let me just click on that

2656:56

so it's going to just create that hen

2656:57

for us then we have Al we already

2656:59

created alexer Jordan and I'm going to

2657:02

just create Jordan and also Jordan one

2657:06

two let's just click on that and finally

2657:09

we're going to be just creating a few

2657:10

fruits so mango and we have mango and

2657:17

mango and now let's just click on that

2657:20

finally let's just create for one for

2657:22

the I don't know

2657:23

banana one of my oh you know not banana

2657:26

but

2657:27

Sprite uh Sprite like that copy there

2657:32

place there last there right here let's

2657:35

just save there so now let me just show

2657:36

you all of their users so I'm going to

2657:38

just refresh there and here you can see

2657:40

we have all of their users right here so

2657:41

this is how we are going to be creating

2657:43

a user but now let's talk about how we

2657:45

going to be logging in a specific user

2657:47

so I'm going to go into my user route

2657:50

here we have to just register a new

2657:52

route so we're going to be just writing

2657:53

like router. poost and then we have to

2657:55

just write off inside there and login

2657:58

user so we're going to be creating this

2657:59

controller right here we have to first

2658:01

of all grip grab it save this file and

2658:03

then we have to create it right here so

2658:05

now let me just create my login user and

2658:08

it's going to be also an asynchronous

2658:09

Handler we have to just passord a

2658:11

request and the responses as well and

2658:15

now inside that we're going to be just

2658:16

getting the email and then the password

2658:19

from the user then by using that same

2658:21

email and password we would be able to

2658:23

successfully log in and log out so you

2658:26

know let me just write cons. logo of

2658:27

email and also the password as well are

2658:31

we want getting the user email and

2658:33

password or not so now let me just copy

2658:35

that place it right here sve my file and

2658:38

now let me just create another request

2658:39

right here so add request and in this

2658:42

case this is going to be the get request

2658:44

or not a get request it should also be a

2658:47

post request right here so now let me

2658:48

just make that as a post request I'm

2658:50

going to just go back so you guys can

2658:52

see everything a bit better and now let

2658:54

me just copy this exactly same thing and

2658:56

now let me just place it right here now

2658:59

in this case what you want to do we just

2659:00

want to write the O okay so now let me

2659:03

just copy that and now let me just place

2659:04

the off and we also have to send some

2659:07

sort of a data right here so we are

2659:08

going to be just writing uh binary not

2659:13

yeah raw and then Json and here we just

2659:15

have to specify first of all the user

2659:18

not a username but the email so the

2659:20

email will be uh Alex

2659:24

gmail.com and then we have to just

2659:26

specify the password for that Alex we're

2659:28

going to have to just write a password

2659:30

uh not password but Alex one to okay so

2659:33

now let me just click on the send button

2659:35

so it's going to

2659:36

just uh what's okay so it's going to

2659:39

just gives us the email and we are also

2659:41

getting the password right here which is

2659:42

totally a okay and now we have to save

2659:45

this file everything is looking totally

2659:47

a okay based on this email and password

2659:49

we are going to be logging in the user

2659:51

but first of all we have to check

2659:52

whether if you already have the user in

2659:54

the database or not so we going to be

2659:56

just work like exist

2659:59

exis user there we go it's going to be

2660:01

equals to aware and then user model and

2660:04

we're going to be using the Mongoose

2660:05

method which will be the find one and we

2660:07

are going to be just providing the email

2660:09

so now let me just log that email right

2660:11

here or existing email or user why am I

2660:14

saying email okay so here if I click on

2660:17

the send bound right here and here you

2660:19

can see it's going to gives us all of

2660:20

that data based on that specific user

2660:23

which means like yeah this user is

2660:24

already inside our database so what do

2660:27

you want to do in that case we just want

2660:28

to provide our if statement if you

2660:30

already have the user inside our

2660:32

database so what do you want to do we

2660:33

just want to compare their password

2660:35

whether the user is providing the valid

2660:37

password or not okay so con is password

2660:41

valid so what do you want to do we just

2660:42

want to write a BCP and we have a

2660:44

compare method inside there and we're

2660:47

going to be comparing this password

2660:48

which the user is providing right here

2660:51

and also we have to just uh search for

2660:53

the existing user and then we have to

2660:55

just search for a specific password

2660:57

right here which is already defined

2660:59

inside our database so yeah that's cool

2661:02

but now the next thing which you want to

2661:03

do is that you want to also check for

2661:04

the valid password so if the password is

2661:07

come on not his password

2661:09

but uh is password valid so what do you

2661:12

want to do in that case we just want to

2661:14

create a new token so we're going to be

2661:15

just using Create token we have to

2661:17

provide a response and then we have to

2661:19

just put existing user and set that ID

2661:22

right here and finally we have to show

2661:24

some message to user so we are going to

2661:25

be just showing the user ID the user

2661:28

email and I mean like the usern name and

2661:29

the email and also whether the user is

2661:31

admin or not okay so if that's not the

2661:34

case what do you want to do in that case

2661:36

so like if the user is not authenticated

2661:39

so what do you want to do in that case

2661:41

we just want to write oh no here I'm

2661:43

going to cut that from here now let me

2661:45

just place it right here and now we have

2661:47

to just specify r. status and for the

2661:50

status we're going to be just passing

2661:51

like 401 and then Json okay and here we

2661:55

just have to pass the message and the

2661:57

message will be invalid password there

2662:00

we go now let me just save there and

2662:01

underneath this Li Braes we're going to

2662:03

be also defining our else block right

2662:05

here so rest. status of 401 right here

2662:08

as well and we're going to be just

2662:10

providing the Json message and the

2662:13

message will be user not found okay so

2662:15

if the user credentials are invalid so

2662:18

the user will not found okay so now what

2662:20

I want to do is that I want to do a

2662:22

review first of all we are getting the

2662:24

email and the password from the user and

2662:26

then we are checking if we already have

2662:28

our user based on this email and

2662:29

password I me like based on this email

2662:32

so if we already have the email already

2662:34

available inside our database then we

2662:36

are checking for the password validation

2662:38

so if the password is valid what you

2662:40

want to do we just want to create a new

2662:42

token based on that password and we're

2662:44

now specifying the existing user and ID

2662:46

to that and finally we are just showing

2662:48

something to the user so if that's not

2662:50

the case so we are just providing like

2662:52

invalid password or if that's not the

2662:55

case we are just providing like user not

2662:56

found so now let me just test this out

2662:58

by using the postman now let me just

2663:00

save that and here we are working with

2663:02

with login or user login would be fine

2663:06

okay so we are now logging this specific

2663:08

user inside well you know first of all

2663:10

let me just show you the cookies now if

2663:12

I click on that here we already have

2663:14

there but now let me just close that

2663:15

from here you know I'm going to just

2663:16

close this entire thing right here now

2663:18

let me just go into my login user once

2663:20

again and now let me just click on this

2663:22

cookies right here and here you can see

2663:24

we have a zero cookies right here but as

2663:26

soon as I pass the email and also the

2663:28

password and now if I click on the send

2663:30

button right here it's going to just

2663:31

show us like this user is now

2663:33

successfully logged in and now if I

2663:35

click on the cookies here you can see

2663:37

it's going to just giv us that JWT

2663:39

cookie which we are already creating

2663:40

right here let me just show you that

2663:42

which we are already creating right here

2663:44

so we have a JWT cookie right here which

2663:47

we are providing so we have a response.

2663:50

cookie so we have response. cookie and

2663:52

we're now providing a JWT cookie right

2663:55

here and this is going to be over value

2663:57

right here okay so yeah we are now

2664:00

creating our cookie but now I want to

2664:01

just click on this cookies right here

2664:03

and here you can also see we are now

2664:05

successfully logging in this specific

2664:07

user so yeah we are now setting the

2664:09

cookie which means like we are now

2664:11

successfully logging in this specific

2664:12

user so now what I want to do is that I

2664:15

want to close that now let me just

2664:16

reopen that once again and now let me

2664:19

just click on the cookies once again so

2664:20

here you can see we already deleted that

2664:22

cookie now I want to log in some other

2664:24

user like I don't know myself or

2664:25

something like that I'm going to just

2664:27

log in myself so we have a hosan we also

2664:29

have hosan one2 and now let me just

2664:31

click on the same button one more time

2664:33

it's going to just use us that same not

2664:36

same but totally different cookie right

2664:37

here and now let me just click on that

2664:39

here you can see it's going to also

2664:40

gives us so yeah this how we are going

2664:42

to be logging in a specific user okay so

2664:45

we are now totally done with this login

2664:47

as well now let me take care of the

2664:49

logging out okay so now let me just

2664:51

duplicate there and instead of writing

2664:53

off we are going to be just writing a

2664:55

log out and here it should be the log

2664:59

log current user I'm going to copy that

2665:03

and let's just place it right here and

2665:05

we're going to be creating this

2665:06

controller in a few second I'm going to

2665:08

copy this name now let me just go ahead

2665:11

and provide it right here and now let me

2665:13

just create that controller so we're

2665:14

going to be just creating like log out

2665:16

ah not log current user but log out the

2665:20

current user I'm going to copy that or

2665:22

you know I'm going to copy this entire

2665:24

name let's just place it right here s

2665:26

file and I'm going to also place it

2665:29

right here in both of these areas s file

2665:31

but now now we have to provide our async

2665:34

nness Handler so we have to just write

2665:35

async Handler we have to provide our

2665:37

async request response and inside there

2665:40

we're going to be just using a rest.

2665:42

cookie we're going to be just providing

2665:43

a JWT because we are working with the

2665:46

JWT and we are just providing the empty

2665:48

cookie okay and we are going to be also

2665:50

providing the HTTP only which will be

2665:53

also set to three and we're going to be

2665:54

just providing the expiration dat so

2665:57

expires at new dat recing this same

2666:00

second finally we just have to show some

2666:02

sort of a response to the user like yeah

2666:05

we are totally logged out so I'm going

2666:07

to just write like message and here we

2666:11

just have to write like logged out

2666:14

successfully there we go so now let me

2666:16

just save that and now let me just test

2666:17

this out so I'm going to just save there

2666:20

and here you can see we have this JWT

2666:22

right here but now let me just close

2666:24

there we are going to be creating yet

2666:26

another uh request right here I'm going

2666:28

to just give it the name of like uh log

2666:30

out it should be all so post request and

2666:33

now let me just copy that same thing and

2666:36

now let me just place it right here

2666:38

collapse that and instead of writing off

2666:40

we are going to be just writing like log

2666:41

out here you can see we already have

2666:44

this JWT right here but now if I click

2666:46

on that so it's going to just give us

2666:47

that result right here like logged out

2666:49

successfully and here you can also see

2666:52

inside the cookies we don't have any

2666:54

cookies right here okay so now let me

2666:55

just save there let's just close there

2666:58

let me just reopen there once again and

2667:00

then if I click on this cookies one more

2667:02

time and here you can see that cookies

2667:03

are totally gone okay so yeah this how

2667:06

we going to be logging out the users so

2667:08

now let me just show you this entire

2667:09

flow one more time okay so here you can

2667:11

see this how we're going to be logging

2667:13

in the user user login I'm providing my

2667:16

email and also the password credential

2667:18

now let me just click on there so it's

2667:20

going to just set this cookies and here

2667:22

you can see we have this cookie and now

2667:24

if I click on these cookies so we

2667:25

already have one cookie right here which

2667:27

is totally okay and now let me just

2667:29

close that and now let me just go ahead

2667:30

and go to my log out and click on this

2667:33

cookies right here so we have this JWT

2667:35

cookie and now if I click on this send

2667:38

button we would not see this cookie

2667:40

right here inside this cookie and if I

2667:42

click on this cookies right here and

2667:44

here you can see that cookie is totally

2667:45

gone okay so yeah this is how we're

2667:47

going to be logging out the user so let

2667:49

me just rename that to user log out or

2667:51

something like that and rename that to

2667:55

user log out there we go now let's talk

2667:58

about how we are going to be getting all

2667:59

of the users inside our database so for

2668:02

that what do you want to do and yeah for

2668:06

that we're going to have to first of all

2668:07

import our middlewares which is the

2668:09

authenticated and the authorized so

2668:11

we're going to have to first of all

2668:12

import the something from let's just go

2668:15

ahead and go to not a config but

2668:18

middlewares then we have to go to the

2668:19

off middleware right here and we're

2668:22

going to be importing our authenticate

2668:23

and also the authorize as an admin and

2668:26

now we are going to be just creating yet

2668:27

another uh dog right here because we are

2668:31

getting the users so in this case the

2668:33

user should be authenticated and also

2668:35

authorize as an admin so authorize as an

2668:38

admin then they would be able to see all

2668:40

of the user the regular user cannot be

2668:43

able to see all of the users the users

2668:45

should be authenticated and also

2668:47

authorizes an admin then they will be

2668:49

able to see all of the users so we're

2668:50

going to be just writing like all the

2668:52

users come on get all users like there

2668:55

I'm going to copy that and now let me

2668:57

just place it right in here save my file

2669:00

and now let me just copy this name

2669:02

let me just go ahead and create there

2669:04

right here but first of all we have to

2669:05

register there and now let me just

2669:08

create there right here so con get all

2669:10

the users we're going to be providing

2669:12

our async Handler and we have to just

2669:14

specify the asynchronous request and

2669:16

also the response and now inside there

2669:19

we're going to be just using a mongoose

2669:20

method so we're going to be just writing

2669:22

like users aware user. find and we're

2669:24

going to be getting all of the users so

2669:26

now let me just write like rest. Json

2669:28

and users save my file and now let me

2669:31

just test this out so I'm going to just

2669:33

creating uh get all the users so now let

2669:36

me just write like all users right here

2669:40

and now let me just close that and by

2669:43

the way I have to copy that I always

2669:46

forget that so now let me just copy then

2669:48

place it right here and here we are not

2669:51

going to be just writing a log out we're

2669:52

using the get method so it's going to

2669:54

give us all of our users right here and

2669:57

I just way zoomed in I don't know why

2669:59

but now let me just uh zoom in a bit

2670:01

like that

2670:02

and now let me just click on this send

2670:03

button one more time so it's going to

2670:05

okay not authorize no token because we

2670:07

are currently not authorized like we are

2670:09

not providing our credentials we have to

2670:11

first of all log in and we also have to

2670:14

be an admin so here you can see we now

2670:16

getting like not authorized not token

2670:18

but now we have to be log in okay so

2670:20

here you can see this how we're going to

2670:22

be logging in we now successfully

2670:24

logging in we are getting this uh JWT

2670:27

cookie right here which is totally a

2670:29

okay but now come on how the hell can I

2670:31

close this but now if I try to get all

2670:33

of the users it's going to gives us a

2670:35

different warning it's going to say like

2670:36

not authorized as an admin like you have

2670:39

to be an admin then you would be able to

2670:41

get all of the users so now let me just

2670:43

make this hosan as an admin I'm going to

2670:45

go ahead and go to my Mong B let me just

2670:48

found myself so this is a mango Jordan

2670:51

and this is Huzan right here okay so now

2670:53

let me just make myself as an admin

2670:55

let's just remove this false and I'm

2670:57

going to just set that to True sell my

2670:59

file and now I am totally in admin and

2671:02

now if I click on this send button right

2671:04

here it's going to gives us all of their

2671:06

users right here because currently I am

2671:08

logged in and I'm also in admin so

2671:11

that's why I can totally see all of the

2671:12

users and all of the users data right

2671:15

here so yeah so the admin can see every

2671:17

single thing so this is how we are going

2671:19

to be getting all of the users by using

2671:21

this user. find method okay so yeah now

2671:24

let me just close this one out now the

2671:26

next thing which I want to do is that I

2671:27

want to get a specific user profile so

2671:30

underneath that we going to just

2671:31

creating like router. route and it

2671:34

should be going into the profile and

2671:36

we're going to be also changing the

2671:38

profile later but right now the user

2671:40

should just be authenticated the user

2671:43

should not be authorized as an admin but

2671:45

the user should be authenticated then we

2671:47

would be able to get the current get

2671:50

current user profile so now let me just

2671:54

copy that and now let me just place it

2671:57

right here s my file and now let me just

2672:00

place it right here as well now and now

2672:02

let me just create them so what I want

2672:04

to do is that I want to create my

2672:05

controller as the asynchronous Handler

2672:08

and we are going to just also passing

2672:10

the asnc request and also the response

2672:13

as well and here inside there we're

2672:15

going to be first of all getting the

2672:16

user by using the AET and then user find

2672:20

by ID and here we have to just specify

2672:23

request user and their unique ID word

2672:26

here okay and then what else do you have

2672:28

to do we have to check if you already

2672:29

have the user or not okay so you know

2672:32

first of all let me just show you there

2672:34

I'm going to just log to the console

2672:35

this user sell my file and now I'm going

2672:38

to go into the specific user which is an

2672:41

Alex I'm going to copy his ID right here

2672:43

so now let me just test this out so I'm

2672:45

going to go ahead and go to my Postman

2672:47

and create a new request and here get

2672:51

specific user okay so let's just copy

2672:55

there place there and it should be a get

2672:58

request and we're not going to be using

2673:00

the O but instead we are going to be

2673:01

providing the user ID so I'm going to

2673:04

copy this user ID one more time which is

2673:06

an Alex copy there and now let me just

2673:08

place it right here click on the send

2673:10

button so it's going to just uh what's

2673:13

up and I forgot to include the profile

2673:16

so now let me just provide a profile and

2673:19

then hit enter right here still getting

2673:21

that error let's just check it out so

2673:23

here you can see let's just copy this

2673:25

profile and instead of writing users and

2673:28

let's just place this profile but why

2673:31

it's not working uh and the user should

2673:33

be the method is good the user should be

2673:36

authenticated and we're now getting get

2673:37

all of the user profile we don't have to

2673:39

provide that specific ID we just have to

2673:42

users and profile and now let me just

2673:44

click on the send button right here and

2673:46

now let me just open my terminal so here

2673:47

you can see it's going to gives us that

2673:49

specific user ID right here okay like

2673:51

the user which is already logged in okay

2673:54

my bad I was providing an unique ID

2673:56

right here I was just thinking about

2673:58

something else so now let me just close

2674:00

that now let me just save there so why

2674:01

are we getting this specific user data

2674:04

that's because we are logged in as this

2674:06

specific user that's why we are now

2674:08

getting this specific user credential or

2674:10

the specific user information right here

2674:12

okay so let's just close that and yeah

2674:16

that's to okay but you know what get a

2674:18

specific usero okay so yeah we are not

2674:21

toally able to get the user credentials

2674:23

and not a credential but the user

2674:24

information right here and now what I

2674:27

want to do is that let me just remove

2674:28

this console. log from here and here we

2674:30

have to first of all check if you

2674:32

already have the user so we just have to

2674:34

write like res. Json and we have to just

2674:36

specify the user ID and the user ID

2674:39

right here the username will be just set

2674:41

to the user username and also the email

2674:45

will be set to user. email okay so if

2674:47

that's not the case if you don't have

2674:50

the user so what do you want to show to

2674:51

your user you just want to say like four

2674:53

or four user not found so throw new

2674:56

error and I am going to just say like

2674:58

user not found and Dot okay so now let

2675:01

me just s there and let me just test

2675:03

this out so now first of all if I click

2675:05

on there here you can see it's going to

2675:06

give us the user information right here

2675:08

but if I click on this cookies and

2675:10

remove this Cookie From Here and Now if

2675:12

I click on this send button right here

2675:14

so it's going to give us like not

2675:15

authorized no token it did not found the

2675:17

token so that's why we now getting this

2675:19

uh no no token right here okay so yeah

2675:22

this how we're going to be getting a

2675:23

specific user or getting a specific user

2675:26

profile but now let's talk about how we

2675:28

are going to be updating the users so we

2675:30

are going to just writing the dot put

2675:33

method right here and the user should be

2675:34

authenticated not authorizes an admin

2675:37

but just authenticated and then update

2675:40

the current user profile now let me just

2675:43

copy this sa my file and now let me just

2675:46

place it right here inside a controller

2675:48

area let's just copy that and I'm going

2675:51

to be just placing it right here and now

2675:53

let me just create that controller let

2675:55

me just go back and I'm going to be just

2675:56

creating this controller by using the

2675:59

asynchronous Handler and we have we have

2676:01

to provide our asking request response

2676:04

and inside that we're going to be just

2676:05

getting the user by using the a user

2676:08

find by ID and let's just provide a

2676:11

request and then the user and then the

2676:14

specific user inside our database so if

2676:17

we already have the user so what do you

2676:19

want to do with that user uh we just

2676:21

want to get the user and then the

2676:22

username and it should be coming from

2676:25

the request. body. username we are going

2676:27

to be specifying that so if that's not

2676:30

the case so we just want to stick to the

2676:31

default username so we just have to

2676:33

write the user and then the username

2676:35

right here okay so if the user already

2676:38

specified some sort of a email so that

2676:40

email will be coming from the request.

2676:42

body. email so if that's not the case we

2676:45

just want to stick to the older one or

2676:47

the previous one which is just a regular

2676:48

user email so inside there we're going

2676:51

to be providing yet another check which

2676:53

will be if the user request. body if the

2676:56

user also specify the password so we

2676:58

just want to provide a salt and we just

2677:00

want to use aware and then BB and then

2677:03

we have a generate salt we have to we

2677:05

have to generate the salt and we have to

2677:07

also hash the password so we have a hash

2677:09

password will be now equals to a wa and

2677:12

then BB and we have a hash password we

2677:14

are going to be just proving the

2677:15

request. b. password which the user will

2677:18

gives us we're going to be also adding a

2677:20

salt to that and then user. password

2677:22

will be equals to this hash H HED

2677:26

password right here okay so now let me

2677:28

just save that so this is totally a okay

2677:30

so now underneath we going to be just

2677:32

updating the users so I guess underneath

2677:34

this one yeah we going to be just

2677:37

writing like updated User it's going to

2677:39

be equals to A and then user. save so we

2677:42

just have to save this updated user and

2677:44

we also have to show some sort of a

2677:45

message to the user so we're going to be

2677:47

just showing to the user the user ID the

2677:49

email I mean like the name the email and

2677:51

also the password not a password but if

2677:54

the user is admin or not okay so now let

2677:56

me just take care of the else class for

2677:58

the else block so what do you want to do

2678:00

we just want to provide a rest. status

2678:02

of St us of 404 and let's just

2678:06

throw new error which will say user not

2678:10

found okay so now let me just save there

2678:12

and now let's just test this out let's

2678:14

just copy there and I'm going to be

2678:16

creating yet another request right here

2678:19

and let's just place it right here and

2678:21

I'm going to say update user and it

2678:24

should be a put method and now let me

2678:26

just go to the body then go to the

2678:28

binary not a binary but the raw and we

2678:31

are going to be providing some sort of

2678:32

raw data right here okay so what do you

2678:35

want to do we logged in as oh we didn't

2678:38

even logged in we have to be logged in

2678:40

okay so let's just go ahead and log in

2678:42

as someone Alex maybe I'm going to just

2678:44

log in as Alex and we have the password

2678:47

of

2678:48

alex12 and now let me just click on this

2678:51

send bound so we are not logging in

2678:54

what's up hash is not defined where are

2678:57

we oh we are getting the hash let's just

2679:00

remove this

2679:01

there like so and where are we using one

2679:05

hash now let me just save there and here

2679:07

you can see everything is okay now let

2679:09

me just click on this button one more

2679:10

time and we are now logging in as an

2679:12

Alex right here which is totally cool

2679:15

but now let me just go ahead and provide

2679:17

some sort of a Json right here so the

2679:19

first thing which I want to do is that I

2679:21

want to change the Alex name to

2679:22

something else so uh let's just zoom in

2679:26

a bit and we are now log in as an Alex

2679:28

but now let me just change the username

2679:30

to something else so I'm going to be

2679:32

just providing like uh I don't know

2679:34

computer and I also want to change the

2679:37

email as well so instead of providing an

2679:39

Alex gmail.com I'm going to just change

2679:41

there to computer gmail.com and I'm

2679:44

going to also change the password of the

2679:46

Alex so I'm going to just change that to

2679:48

computer one two okay so now let me just

2679:51

first of all show you there and here you

2679:54

can see we have Alex name then we have

2679:56

Alex gmail.com and we have this password

2679:59

right here but now let me just close

2680:01

this one as well and we have that Alex

2680:03

on the top and now let me just click on

2680:05

the send button right here let's just go

2680:08

back and let me just show you that so

2680:10

here you can see the username is now

2680:12

changed to computer the email is changed

2680:14

to computer gmail.com and he is not an

2680:17

admin so it is now set to false and now

2680:19

let me just click on the first one once

2680:21

again and here you can see instead of

2680:22

getting the Alex we're now getting the

2680:24

computer and also computer at gmail.com

2680:27

and H password right

2680:29

here that was a a lot of talking so yeah

2680:32

that was it about uh for the back end of

2680:35

creating the user updating the user

2680:37

getting a user specific profile getting

2680:39

all of the users and all of that kind of

2680:41

stuff like how we going to be

2680:42

authenticating and authorizing as an

2680:44

admin how we going to be creating a

2680:46

token and all of that so yeah that was

2680:48

just a backend part of how we are going

2680:50

to be managing our users so we are

2680:52

totally done with the backend logic now

2680:54

the next thing which you want to do is

2680:55

that we want to use that same logic

2680:57

inside react component and the UI

2681:01

okay so now let me just go ahead and go

2681:03

to my we config and here we have to

2681:05

provide our proxy right here underneath

2681:08

that we're going to just creating a

2681:09

server and inside the server we are

2681:11

going to be providing the proxy and

2681:14

proxy like that and the proxy will be

2681:16

first of all for the API and now let me

2681:20

just provide my HTTP and colon colon

2681:23

local host of 3,000 we're going to be

2681:27

God what the hell did I just do let me

2681:30

just retype them once again so local

2681:32

host of

2681:34

3,000 and now let me just put a comma

2681:36

here I'm going to copy that same thing

2681:39

and we're going to be also taking care

2681:41

of the uploads a bit later but now let

2681:43

me just provide my uploads folder right

2681:45

here and now let me just provide a proxy

2681:47

for that okay so I just messed it up

2681:51

right here let me just place it right

2681:52

and this how we're going to be providing

2681:54

a proxies for our Weir project so now

2681:56

the next thing which you want to do is

2681:58

that we are going to be creating our

2681:59

folder structure right here so so I'm

2682:01

going to be just creating a comp let me

2682:02

just zoom in a bit and I'm going to be

2682:04

just starting from the components and

2682:06

inside they we're going to be just

2682:07

creating a loader components loader. jsx

2682:10

I'm going to take care of that in a few

2682:12

seconds but now let me just create

2682:13

another folder which will be for the

2682:15

pages inside this Pages we're going to

2682:17

have a few folders and I'm going to just

2682:20

create first for the off and the second

2682:22

one will be for the user and now let me

2682:26

just collapse that now let me just

2682:27

create another folder which will be for

2682:30

the Redux so in this case redex is a bit

2682:32

appropriate name but in some situation

2682:34

people give it the name of like app and

2682:36

yeah you totally get the idea and now

2682:39

let me just create another component

2682:40

inside this redex folder which will be

2682:42

for the API and now let's just create

2682:44

one for the feat or features and now

2682:49

inside there we're going to be creating

2682:50

one for the Earth as well so that's

2682:54

there but now let me just create my

2682:55

store inside this retex folder and I'm

2682:57

going to just give it the name of like

2682:58

store.js and now let's just start from

2683:00

the the store first of all and what I

2683:02

want to do is that to create a store

2683:04

first of all we have to just write a

2683:06

configure uh store function from where

2683:08

from the Redux toolkit okay so we are

2683:11

going to be grabbing there first of all

2683:13

let me just proide my curly braces right

2683:14

here and underneath that we're going to

2683:16

be also grabbing our setup listener

2683:19

setup l i s t n e r from where from our

2683:23

redex toolkit and then we have to go

2683:25

into the query come on query and then we

2683:28

have to just write react now let me just

2683:30

go back back and now underneath that

2683:32

we're going to be creating our store

2683:33

right here and we are going to be just

2683:35

calling our configure store function and

2683:38

inside that we're going to be providing

2683:39

a reducer and in this case we're not

2683:41

going to be providing any reducers to it

2683:43

and now let me just export default or

2683:46

store right here and also the setup

2683:48

listener will be listening to the store.

2683:51

dispatch something which I'm going to be

2683:53

doing in a few seconds and you know what

2683:56

I'm going to also provide my middleware

2683:57

right here for the K so middleware will

2684:00

be now equal to the get default

2684:02

middleware come on ah get default m i d

2684:06

l e w a r e like so and now what I want

2684:10

to do is there is going to be set to the

2684:12

get default middleware one more time and

2684:14

we are going to be calling there and we

2684:16

are going to be just concatenating or

2684:18

API slice which we did not create it not

2684:21

right now but we are going to be

2684:23

creating in a few second now let me just

2684:24

SP my comma and then we're going to be

2684:26

setting the dep tools to True okay so

2684:29

now let me just go back and then single

2684:31

thing that we need for the store okay so

2684:33

yeah that's that but now we have to use

2684:35

the store inside our main component so

2684:38

now let me just go to my main component

2684:39

and the first thing we would need is to

2684:41

import the store let's just import that

2684:43

right here let's just go ahead and go to

2684:46

our store uh you know one file then we

2684:49

have to go to the Redux then we have to

2684:51

go to the store right here not API but

2684:53

let's just WR a

2684:56

store.js and then we also have to import

2684:58

the provider so I'm going to to be just

2685:01

writing an import Provider from where

2685:03

from the react Redux and the next thing

2685:05

which I want to do is that I'm going to

2685:06

be also using the react router so I'm

2685:08

going to be just grabbing the router or

2685:11

route first of all let's just grab the

2685:12

route and we're going to also have to

2685:14

grab the router provider and also the

2685:17

create routes from elements okay so

2685:21

we're going to be getting there from the

2685:23

react router and underneath that we're

2685:26

going to be also getting something

2685:27

called the create browser come on let me

2685:30

just get the create b r o WS browser

2685:34

router from where from the react and

2685:37

router Dom so we're going to need all of

2685:40

that stuff and now let me just also

2685:41

provide a comment for the off user and

2685:44

also for the restricted user so

2685:47

restricted user now underneath all of

2685:50

them we're going to have to create a

2685:51

router so we're going to be just writing

2685:52

like cons router and let's just use our

2685:55

create browser uh router and it should

2685:58

be an uppercase B let's just make that

2686:02

as uppercase B I'm going to copy and

2686:04

place it right here and now we have to

2686:05

use that and now inside that we're going

2686:07

to have to pass or create routes from um

2686:11

element right here inside that we're

2686:13

going to have to just pass our route

2686:15

okay so now let me just close there and

2686:17

it's going to take the path of home and

2686:19

here we have to pass the element or the

2686:22

component as an app component which we

2686:25

are I guess already grabbing right here

2686:27

we are already grabbing that so we are

2686:29

now providing a route right right here

2686:31

so now the next thing you want to do is

2686:32

that you want to use this so I'm going

2686:33

to go ahead and copy that and now let me

2686:36

just remove this app from here inside

2686:39

this render method we're going to be

2686:40

using our provider and we are going to

2686:42

be binding our Redux store which we are

2686:44

already grabbing and inside that we're

2686:46

going to be just providing a router

2686:48

provider and we just have to provide our

2686:50

router which we are already creating

2686:52

above above okay so now let me just save

2686:54

them and yeah I guess that's every

2686:56

single thing that we need for now but

2686:59

now let me just create a few components

2687:00

or you know first of all let me just

2687:02

take care of the store and then also

2687:04

this API slices as well the first thing

2687:07

which you have to take care of the

2687:08

loging in and the logging out of the

2687:10

user so we're going to have to go inside

2687:12

this off and inside this off we are

2687:14

going to be creating a o sl. JS aut come

2687:19

on a slice. JS and if you want to create

2687:23

a slice so we're going to have to import

2687:25

the create slice from where from the

2687:28

Redux toolkit Okay so so we're going to

2687:31

have to just write redex toolkit so it's

2687:33

going to just import there for us and

2687:34

now let me just create my slice so off

2687:36

slice will be now equals to the create

2687:38

slice and here inside there we're going

2687:40

to have to provide our name first of all

2687:43

and the name in this case we're working

2687:45

with the authentication so we're going

2687:46

to be just providing the O and yeah then

2687:49

we have to provide our initial state in

2687:51

this case I'm not going to be creating

2687:52

my initial state right here but what I

2687:54

want to do is that I'm going to copy

2687:56

there and create my initial State

2687:57

outside from there because in this case

2687:59

we going to be work working with a lot

2688:01

of things so we're going to have to

2688:02

first of all get the user info by using

2688:04

the local storage and then we have to

2688:07

just write a get item and then we're

2688:10

going to be just searching for the user

2688:11

info if that's the case what do you want

2688:13

to do we just want to Json pars and then

2688:16

we just want to pass out our local

2688:18

storage and then get item of the user

2688:20

info come on inside a string of user

2688:23

info user info there we go and if that's

2688:26

not the case we just want to set that to

2688:28

no okay so now let me just save there

2688:30

and we are already using that right here

2688:32

and now the next thing which I want to

2688:33

do is that I want to create my reducers

2688:35

so now let me just put my reducers and

2688:38

inside these reducers the first action

2688:40

which we're going to be creating is the

2688:41

set credential c r e r d e n t i a l s

2688:47

and we have to provide a state and also

2688:50

the action in this case so now inside

2688:52

there we're going to be just writing a

2688:53

state to user info will be now equals to

2688:56

the action. payload and now underneath

2688:59

that we're going to be setting our data

2689:00

to our local storage so we're going to

2689:02

be just writing like a local storage.

2689:04

set item and inside that we're going to

2689:06

have to pass our user information and we

2689:08

are going to be just writing like user.

2689:10

stringify and we're going to be just

2689:12

passing our action and payload which we

2689:14

already have inside the action and we're

2689:16

going to be also providing the

2689:18

expiration dat so I don't want to type

2689:19

it out so now let me just place it right

2689:21

here and finally we just have to use our

2689:23

local storage. set item and we have to

2689:26

just for expiration time and the

2689:28

expiration time will be this expiration

2689:30

and come on let me just copy the name of

2689:32

that and now let me just place it right

2689:34

here and now that's it about how we're

2689:37

going to be setting the credentials but

2689:38

now how we are going to be logging out a

2689:40

specific user so now let's just create

2689:42

action for that so we're going to be

2689:43

just writing like a log out and it's

2689:45

going to only take the St and what I

2689:47

want to do is that inside a St we're

2689:49

going to be searching for the user info

2689:51

and I'm going to just set that to know

2689:53

and I'm going to be also setting the

2689:55

local storage to totally clear so it's

2689:57

going to just remove every single thing

2689:59

that we currently have inside or local

2690:01

storage so now let me just export the

2690:02

set credentials and also this log out

2690:05

actions I'm going to come to the bottom

2690:07

and I'm going to be using export const

2690:09

and let's just export our set

2690:11

credentials and also the log out

2690:13

function from where from the OD slice

2690:15

and then actions with the S and now I'm

2690:18

going to be also using export default

2690:20

off off slice and then reducer and now

2690:23

let's just register that inside our

2690:25

store so I'm going to go ahead and go to

2690:26

my store right here and the first thing

2690:28

which I want to do is that I'm going to

2690:30

be just importing my auth

2690:32

reducer from where from let's just go

2690:35

ahead and go to the feature come on not

2690:37

API but a features and inside this

2690:39

feature we have Au and inside the Au we

2690:41

have Au slice right here and we're going

2690:44

to be importing that and now let's just

2690:45

use it right here inside the reducers

2690:48

and I'm going to just say the O property

2690:50

and the value will be off reducer so now

2690:52

let me just save that and that's toally

2690:54

cool but now we also have to take care

2690:57

of the API for this authentication so

2691:00

now we we are totally done with that and

2691:02

what I want to do is that inside this

2691:03

redex folder let me just zoom in a bit

2691:05

I'm going to be creating yet another

2691:07

file I'm going to give it the name of

2691:08

like con constants you don't have to do

2691:12

that if you don't like this convention

2691:13

so you don't have to do that but I'm

2691:15

going to be just extracting my constants

2691:17

and I'm going to be putting that inside

2691:19

this constants file so I'm going to just

2691:20

hit enter right here and the first thing

2691:22

which I want to do is that I want to

2691:23

create a constant for the b b e and URL

2691:27

is going to be equals to totally empty

2691:28

string and why is that because because

2691:30

inside our we config we are already

2691:33

setting our API to Local Host of 3,000

2691:36

right here so that's why we can totally

2691:38

leave there as an empty string now let

2691:40

me just create a constant for the users

2691:43

URL and it's going to be equals to first

2691:45

of all let's just go ahead and go to the

2691:47

API then the version one and then the

2691:49

users now let me just save there and

2691:51

close this file and what I want to do is

2691:53

that I want to create a rtk query right

2691:56

here so I'm going to go into my API

2691:59

right here the first thing we show want

2692:00

to do is that I want to create my api.js

2692:03

and inside there we're going to be

2692:05

working with almost all of the rtk query

2692:08

and inside this file we're going to be

2692:09

making a set of four or rtk query so I'm

2692:12

going to just say like fetch base query

2692:14

we're going to have to first of all grab

2692:15

that then we have to just write a create

2692:18

API and then we have to grab that from

2692:21

the Redux toolkit and we're going to be

2692:22

getting that from the query and then the

2692:25

react I'm going to go back and

2692:26

underneath that we're going to also need

2692:28

to get our constant right here here from

2692:30

where from let's just go ahead and go to

2692:33

our constants and we would just need our

2692:36

BAS come on bass URL right here okay so

2692:40

now we have to use that underneath that

2692:42

we're going to have to provide our B

2692:44

query come on let's just make this a

2692:47

constants and then it's going to be

2692:49

equals to the fetch base query and

2692:51

inside that we're going to be providing

2692:53

our BAS not B query but Bas URL it's

2692:57

going to be equals to or base URL like

2692:59

that now let me just save there and

2693:01

that's tottally cool but now the next

2693:03

thing which you want to do is that we

2693:04

want to create our API slice so we're

2693:06

going to be just writing like export and

2693:08

then cost API slice will be equals to

2693:11

the create API and inside the we going

2693:14

to be just providing our base query

2693:16

which we are already creating right here

2693:18

now let me just copy then now let me

2693:20

just place it right here and underneath

2693:22

that we're going to be defining our end

2693:23

points so end points and that end points

2693:27

will be coming from a separate file you

2693:29

don't have to do that if you don't want

2693:31

to do that but in my case I'm going to

2693:32

be creating a separate file for my

2693:34

endpoints and we're going to be

2693:36

injecting that endpoints right here

2693:37

inside this file so yeah that was just a

2693:40

total setup for the rtk query now let's

2693:42

just remove that now let me just create

2693:44

another file for my users endpoint so

2693:46

I'm going to be just creating a file

2693:47

given name of like user.js and inside

2693:50

there the first thing which I want to do

2693:51

is that I want to get my API slice from

2693:53

where let's just go ahead and go to the

2693:55

API uh I mean like API slice and then we

2693:58

would also need to get the users URL

2694:00

from the constants right here now let's

2694:03

just use our export con of user API

2694:06

slice and it's going to be coming from

2694:08

the API slice and we are going to be

2694:10

injecting our end point inject come on

2694:12

inject the end points inside the okay so

2694:16

what are we doing first of all uh what

2694:19

the hell is let's just remove that from

2694:21

here so what are we doing let me just

2694:23

show you there here you can see we are

2694:25

providing our empty end points right

2694:26

here and now we are going to be

2694:28

injecting all of our end points to this

2694:32

API slice right here okay so now let's

2694:34

just do that so what I want to do is

2694:35

that I'm going to be passing my end

2694:37

points and inside there first of all let

2694:39

me just take care of the logging in the

2694:41

user so builder. mutation m u t a t i o

2694:45

n because in this case we are changing

2694:48

something we are posting some data to

2694:50

our database so for that we're going to

2694:52

have to just write a query it's going to

2694:54

take a data and now let me just uh use

2694:57

my function right here and inside that

2694:59

we're going be proving the URL and in

2695:01

this case our URL will be coming from

2695:03

the users URL right here and we

2695:06

specifically want to go to the off so

2695:08

that's why we are now providing the off

2695:09

and then we're going to be also

2695:11

providing the method of to the post

2695:13

method okay so now let me just provide a

2695:15

comma here as well and it should be a

2695:19

method so now let me just make there is

2695:20

a method and we're going to be also

2695:22

providing a body and the body will be

2695:24

set to toally data let's just save that

2695:26

now let me just create a hook based on

2695:28

this endpoint right here so so I'm going

2695:30

to just write like export con and we're

2695:33

going to be exporting something from the

2695:35

user API slice so what are we doing we

2695:38

are going to be just writing a use and

2695:39

here you can see we have a use user API

2695:42

slice no that's not something that we

2695:44

want we have to just already use log in

2695:49

what the hell is going on we now inside

2695:52

endpoints I don't know why but it is not

2695:54

helping me in this case but let me just

2695:57

do that manually so I'm going to just

2695:58

write like use login m u t a t i o n and

2696:03

yeah I guess they should do it use login

2696:06

mutation would be fine now let me just

2696:08

save there and yeah this how we're going

2696:11

to be creating our hook based on there

2696:13

and now let me just use this somewhere

2696:16

but before I do that first of all let me

2696:19

just go to my pages and inside these

2696:21

Pages now let me just zoom in a bit

2696:23

inside this Pages we're going to be

2696:24

creating one file for the home. jsx I'm

2696:27

going to just write RFC and I'm going to

2696:30

just leave there the way it is okay so

2696:32

I'm not going to touch there and now the

2696:34

next thing which I want to do is that

2696:35

I'm going to go ahead and go to my off

2696:37

and inside this off we're going to be

2696:39

creating our login. jsx right here okay

2696:41

so now let me just use my RFC sa my file

2696:44

and now let me just go ahead and go to

2696:46

my main and register there right here

2696:48

okay so we are doing every single thing

2696:50

that we supposed to do but now inside

2696:52

this routes the first thing which I want

2696:54

to do is that I want to create a route

2696:56

and I'm going to be just passing the

2696:58

index of true right here in this case gu

2697:00

and now let me just for a path of uh

2697:02

home right here and we're going to be

2697:04

also passing the element of home or the

2697:07

component of home and now let me just

2697:09

close that and we also have to grab the

2697:11

home so it's not going to do it for us

2697:14

but we're going to have to do it

2697:15

manually I guess so now let me just

2697:18

import the home from there let's just go

2697:22

to my com not component but pages and

2697:24

then we have a home. jsx right here s my

2697:27

file and here you can see it is giving

2697:29

us an a because we have to run uh npm

2697:32

run full stack so now if I just wrun npm

2697:34

run full stack so it's going to just run

2697:36

both the front end and also the backend

2697:38

and now let me just refresh that right

2697:40

here and it's going to gives us

2697:42

something let me just right click on

2697:44

there and click on a force dark and

2697:47

that's looking cool but why in the world

2697:48

we're not getting the home you know I'm

2697:50

going to just right click on that and go

2697:52

to the inspect element and we have

2697:55

nothing inside there then let me just go

2697:57

to the console and we are getting

2697:59

something inside a store now let me just

2698:01

go ahead and go to the store and yeah I

2698:03

guess I'm going to have to comment this

2698:05

line out for a few seconds I'm going to

2698:07

comment this line out s file and refresh

2698:10

that so the

2698:11

module uh query does not provide an

2698:14

export name setup

2698:16

listener let's just comment this line

2698:18

out and I'm going to also have to

2698:20

comment this line out as well s file

2698:24

what the hell is wrong let's just un

2698:27

uncom oh I made a setup but I did not

2698:31

configure inside my store that's the

2698:34

only thing I'm doing wrong so now let me

2698:35

just go to my users and here you can see

2698:38

we are creating the endpoint and we are

2698:40

set uping almost all of the rtk query

2698:43

and we are even creating a hook based on

2698:45

that but we are not registering that

2698:47

inside our store and now let's just do

2698:48

that okay so what I want to do is that

2698:51

to grab my API slice let me just hit

2698:54

enter right here and now let me just

2698:56

place it right here API slice and then

2698:58

reducer path R

2699:01

RR path it's going to be equals to not

2699:04

equals to but this is a property and we

2699:06

have to provide a value of API slice and

2699:08

reducer now let me just put a comma here

2699:11

sell my file and we also have to remove

2699:13

this colon from there sell file we also

2699:16

have to remove this ah that was a lot of

2699:20

errors and now let me just refresh this

2699:22

so we are now getting the internal

2699:23

server error which is saying they're

2699:26

missing

2699:28

query yeah so let's just search for I'm

2699:32

going to have to copy that and let's

2699:34

just search for this specific thing and

2699:37

we're going to have to grab there from

2699:38

the query there we go now let's just

2699:41

sell there and we should be getting

2699:43

something but we are not okay the

2699:46

requested

2699:48

module and does not provide an export

2699:51

name setup listener it should be

2699:53

listeners with s and now let me just

2699:56

copy that let me just place it right

2699:58

here s my file and refresh refesh there

2700:00

still does not provide theic sport store

2700:03

so I guess I'm going to have to go to my

2700:05

man and we are doing something wrong

2700:08

inside a store I'm going to just remove

2700:10

these curly braces from here let's just

2700:12

remove that s my

2700:14

file and here you can see we are getting

2700:17

over hello word right here which is

2700:19

totally cool

2700:20

but what I want to do is that we are now

2700:24

providing our home component right here

2700:27

inside this home component we are first

2700:28

of all providing our app we shouldn't be

2700:31

doing that let me just provide this hit

2700:34

enter right here but now let me just go

2700:36

to my app and now let's just take care

2700:37

of the app component the first thing

2700:39

which you want to do is that I'm going

2700:41

to go to the top and then we're going to

2700:44

be getting the outlet from the react

2700:47

router Dom so we going to have to grab

2700:49

the react router Dom yeah we're going to

2700:52

have to just get the outlet first of all

2700:54

then we have to get the toast container

2700:57

because we're going to be also using the

2700:58

toast in this project so we going to

2701:00

just write a toast container from the

2701:02

react toasttify and then we have to just

2701:06

grab our CSS so we're going to be just

2701:08

writing like react toasttify and then

2701:11

let's just go to the disc folder then we

2701:13

have to go to the react toasttify do CSS

2701:18

right here underneath that what I want

2701:20

to do is that I'm going to just remove

2701:22

this H1 from here and I'm going to just

2701:24

passing my toast container and also I'm

2701:28

going to just pass my main and I'm going

2701:30

to just provide the padding for the y

2701:32

axis of maybe three would be fine so I'm

2701:35

going to just past the padding for the

2701:36

y-axis of three and we are going to be

2701:39

just providing our Outlet right here so

2701:40

now let me just save that and we're

2701:42

going to also have to provide our

2701:44

fragments so that we don't get these

2701:46

nasty errors so now let's just provide

2701:48

there and here you can see we are now

2701:50

getting the home right here so that was

2701:52

the entire setup that we have to make

2701:54

but anyways we are not totally done with

2701:56

that but we are going to also have to

2701:57

create a navigation right here at the

2701:58

bottom then we will be able to work with

2702:00

that so what I want to do is that I'm

2702:02

going to go ahead and go to my o and

2702:05

inside this o we are going to be

2702:06

creating our navigation. jsx n a v i g a

2702:10

t o n and now let me just use my

2702:13

rafc and here uh we are going to be

2702:16

importing our navigation right here so

2702:17

I'm going to just say like uh you know

2702:20

underneath there we're going to be

2702:21

grabbing our navigation let me just copy

2702:24

that and underneath this uh toast

2702:26

container we're going to be just placing

2702:28

there right here semi file

2702:30

and here you can see we are getting our

2702:31

navigation right here which is totally a

2702:33

okay and what we have to do is that we

2702:36

have to just design this navigation and

2702:38

that's going to be a lot of fun so the

2702:40

first thing which you have to do is that

2702:42

we have to import the used stad uh not

2702:44

used T but used T from where from the

2702:48

reactjs and then what we have to do we

2702:50

have to grab a lot of uh font icons from

2702:53

the react icons library and we're going

2702:57

to be getting that from the AI I'm not

2702:59

going to waste your time by writing all

2703:00

of them so I'm going to just place them

2703:04

right in here okay so we're going to be

2703:05

just using all of them and now

2703:07

underneath we're going to be also using

2703:09

this one as well this is also a font

2703:11

which is coming from the MD folder and

2703:13

we will also need the link from the

2703:16

react rou D and we will also need to

2703:18

grab the use navigation as well uh I

2703:22

mean like the use navigate not

2703:23

navigation okay and we will also need

2703:26

the use selector to read the data from

2703:29

the store so we're going to be just

2703:30

writing the use selector and also the

2703:33

use dispatch

2703:35

DP P TCH to change the data from the

2703:39

react router not router but the Redux

2703:42

and we will also have to get the use

2703:44

login mutation which we already cre this

2703:47

is our own buil-in hook and then we also

2703:50

have to grab the log out okay so we're

2703:52

going to be getting there from the

2703:54

feature and then the all slice so we are

2703:56

now getting almost every single thing

2703:58

that we need right here but now let me

2704:00

just create instances of there so the

2704:02

first thing which I want to do is that

2704:03

we're going to be just graving the user

2704:04

info from where from the use selector

2704:08

and we're going to be just passing our

2704:09

state right here and we're going to be

2704:10

just writing a state. off and underneath

2704:13

that we're going to be just creating a

2704:14

state so I'm going to just say like a

2704:16

drop down open we are going to be

2704:18

creating a drop down menu right here and

2704:20

then set drop come on drop down open

2704:24

it's going to be equals to the come on

2704:26

the use T and currently it's going to be

2704:28

set to false and now underneath there

2704:31

we're going to be just creating a

2704:32

function for toggling that drop down so

2704:34

toggle dropdown in lowercase will be now

2704:38

uh Arrow function and we going to be

2704:40

just writing like I said drop down uh

2704:43

open and not drop down open there we go

2704:46

now let me just create instances of both

2704:48

the dispatch uh the use dispatch and we

2704:50

are going to be just using the dispatch

2704:53

and it's going to be equals to this use

2704:54

dispatch and we're going to be also

2704:56

creating an instance of navigat so we

2704:58

are going to just writing a use n get

2704:59

word here and then we have to use our

2705:01

own hook which is cost uh log out API

2705:06

call from where from the use logout

2705:09

mutation and we're going to be just

2705:11

using that and now underneath there let

2705:14

me just save this file we have to just

2705:15

write your jsx right here and that's

2705:18

going to be a lot of jsx so I guess I'm

2705:20

not going to waste a lot of your time by

2705:22

writing a lot of jsx or a lot of classes

2705:25

rather so I'm going to just remove this

2705:27

navigation from here and now let just

2705:29

provide a class name and I'm going to

2705:31

just remove that and place these classes

2705:34

right here so I'm going to just give you

2705:35

a few seconds to stop the video and

2705:38

write all of these classes by yourself

2705:39

or you can go to my gab repository and

2705:41

grab all of these styling right here and

2705:43

and grab all of their styling from there

2705:46

or you can just stop the video and just

2705:48

type it by yourself now inside there

2705:50

what do you want to do let me just you

2705:51

save this file and now inside there what

2705:53

you want to do we going to be just

2705:55

creating a section and for this section

2705:57

we going to be just writing a flex and

2705:58

justifying

2705:59

between and also the items will be set

2706:02

to totly Center and inside that we're

2706:04

going to be just creating two sections

2706:06

we have a section one and section two so

2706:08

inside this section one we're going to

2706:10

be creating a div so now let me just

2706:12

create a div and I'm going to be just

2706:14

spacing the class name to there and

2706:16

we're going to be just placing these

2706:17

class names right here okay so now

2706:20

inside there we going to be just

2706:21

creating a link and I'm going to just

2706:23

pass the two and it's going to just only

2706:25

go to the home and now let me just

2706:27

provide some classes to it and trust me

2706:30

I'm not going faster because I want to

2706:32

save your time now let me just go back

2706:34

and save our file and here you can see

2706:36

these are the only stting that you have

2706:38

to provide right here for this specific

2706:39

link and now what I want to do is that

2706:42

I'm going to be just using the AI

2706:44

outline home okay and we have to just

2706:47

specify the classes to it so we have to

2706:48

just write a margin for the right of two

2706:51

margin for the top of three R and we

2706:54

also have to provide some sort of a size

2706:55

for that so I'm going to just specify

2706:57

the size of 26 and now underneath that

2707:00

we're going to be also providing a span

2707:02

of to home and now let me just provide a

2707:05

class name of hidden and also the nav

2707:08

item name and also the margin for the

2707:11

top will be set to let me just provide

2707:14

three Rim right here okay so now let me

2707:16

just save that and the use is not a

2707:19

function or it's not a return it trible

2707:23

uh okay we not even using the US so why

2707:26

the what we going to be needing there oh

2707:29

I I forgot to destructure that now let

2707:31

me just save that and refresh that so

2707:33

here you can see we are getting our

2707:35

navigation right here and everything is

2707:37

a okay and if I click on this so it's

2707:39

going to just brings us to this home

2707:40

right here anyway so that was just a

2707:43

small little silly bug that I just fixed

2707:46

now underneath this link we're going to

2707:48

be creating yet another link and it's

2707:50

going to go to the movies uh page which

2707:54

we did not create not right now but we

2707:56

are going to be creating there in a few

2707:57

second now let me just provide a class

2707:59

names to there and here you just have

2708:01

provide these class names right here

2708:03

okay so now let me just save there and I

2708:05

want you to just pause the video and

2708:06

proide these classes to that and now

2708:08

inside this link we're going to be just

2708:10

writing like MD outline and then that

2708:13

movies right here we have to just write

2708:15

our classes of margin for the right of

2708:16

two margin for the top of three rim and

2708:20

we also have to provide some sort of a

2708:21

size for that so the size in this case

2708:23

will be also 26 size and now let's just

2708:26

close there we're going to be also

2708:27

providing a span of shop in this case

2708:30

and now let me just put a class name of

2708:33

uh come on the class name of hidden and

2708:36

also the na item name and margin for the

2708:39

top will be set to three Rim okay so now

2708:41

let me just close there let's just close

2708:43

that as well so now let me just save

2708:45

there and here you can see we are

2708:46

getting this movies icon right here if I

2708:49

click on that so it's going to just

2708:50

brings us to these movies right here

2708:52

which we did not create not right now so

2708:55

yeah that's cool but now let's just take

2708:57

care of the section two so I'm going to

2709:00

just hit enter right here let me create

2709:02

a div and I'm going to just give it the

2709:04

class of relative and inside this div uh

2709:08

r e l a t r e l a t i v e and inside

2709:12

this div we're going to be creating two

2709:14

buttons for one button right here so

2709:16

when somebody clicks on this button so

2709:19

we're going to be just passing this drop

2709:20

down function which we already created

2709:22

up above now let me just put a class

2709:24

names of text of totally gray of 800 and

2709:28

also the f

2709:29

c will be set to outline of none and now

2709:33

inside this B what do you want to do we

2709:35

just want to check if you already have

2709:36

the user info so what do you want to do

2709:38

in that case we let me just hit ENT

2709:40

right here we just want to create a span

2709:43

and let me just create their spin right

2709:45

here manually and we're going to have to

2709:47

provide a class names of text of totally

2709:49

white and now inside there we are going

2709:52

to be just providing the user info do

2709:54

name or username rather and if that's

2709:57

not the case like if the user did not

2709:59

specify I mean like if you don't have

2710:00

the users so then we don't have to

2710:03

provide nothing and just empty fragments

2710:06

so yeah that's it and underneath that

2710:09

I'm going to be placing a bit of code

2710:11

but I want you to bear with me and I am

2710:13

going to give you a lot of time to write

2710:15

that code so now let me just write a

2710:16

user info so if we already have the user

2710:19

info and uh then just do something if

2710:23

you don't have that then do another

2710:25

thing okay so now if we have the user

2710:27

info so we are going to just place ing

2710:29

this SVG right here and you can found

2710:31

this SVG in my gab repository so here

2710:33

you can see what we are doing is that we

2710:35

are just passing the entire SVG and we

2710:37

are now passing this class totally

2710:40

dynamically so if we already have the

2710:41

drop down open so for that we're going

2710:44

to be just writing the transform and the

2710:45

rotate of 180° if that's not the case we

2710:48

are going to be just setting there to

2710:50

empty string and we are just filling

2710:52

there with no colors we're not providing

2710:54

I me like we are providing a bit of view

2710:55

box to it you can totally specify icon

2710:58

right here in this case but in my case

2711:00

I'm not going to be doing that because

2711:01

this is just a simple drop down which I

2711:03

just created right here oh you know it

2711:05

should be just only one case it should

2711:07

not be more than that so now let me just

2711:09

remove that from here and just put your

2711:10

SVG right here and there you have it

2711:13

underneath this button what do you want

2711:14

to do we just want to create yet another

2711:17

drop down menu right here so drop down

2711:19

menu and the user info and then do

2711:23

something with that so inside there

2711:25

we're going to be just creating our ul

2711:27

and for this UL we are going to be

2711:29

finding a lot of uh classes right here

2711:30

but that classes will be dynamic so I'm

2711:33

going to just provide the absolute right

2711:35

here and the right will be set to

2711:36

totally zero margin for the top will be

2711:38

set to two the margin for the right will

2711:40

be set to 14 and width will be just

2711:43

totally 10 rims and I'm going to also

2711:45

specify the space of Y AIS will be set

2711:48

to two and I'm going to also say the

2711:50

background will be set to totally white

2711:51

and text will be gray of 600 and inside

2711:55

there we're going to be just rendering

2711:56

if you don't have the user info and is

2712:00

admin if the user come on is admin so if

2712:03

the user is not an admin in this case so

2712:05

what do you want to do we just want to

2712:07

write the Top Value to 20 and then if

2712:10

the user is admin so then we just have

2712:12

to write a top of 24 okay so now inside

2712:15

there what do you want to do let me just

2712:16

scroll down inside there we're going to

2712:19

be just writing like if the user is

2712:20

admin so is admin and inside that we're

2712:24

going to just writing our fragment and

2712:26

here we just have to specify our lii and

2712:29

let's just provide a link and for this

2712:31

link it's going to just go to first of

2712:32

all the admin and then it's going to go

2712:34

to the movies and then it's going to go

2712:37

to the dashboard which we did not create

2712:39

not right now but we will create there

2712:41

in a few SEC not in a few seconds but

2712:43

later okay so it's going to be totally

2712:46

block and also the pading for the xaxis

2712:48

will be set to four ping for the Y AIS

2712:50

will be set to two and when somebody how

2712:52

there so we're going to be just changing

2712:54

the background color of that to totally

2712:56

gray of 100 and here it should be just a

2712:59

dashboard this is going to be only

2713:01

happening for the admin user not for the

2713:03

regular users so yeah that's cool but

2713:06

now underneath that what you want to do

2713:08

we just want to create lii yet another

2713:11

lii right here and I'm going to just say

2713:13

the lii and inside this Li we would have

2713:15

yet another link and it's going to just

2713:17

go to the profile now let me just put a

2713:20

class name to there it should be block

2713:22

ping for the xaxis will be set to four

2713:25

ping for the y axis will be set to two

2713:26

when somebody hows over there background

2713:29

will be set to totally gray of 100 and

2713:31

inside this link we are going to be just

2713:33

writing a profile okay and then

2713:35

underneath this lii we're going to be

2713:38

creating yet another Ali and inside this

2713:40

lii we're going to be creating a button

2713:41

when somebody clicks on this button

2713:43

we're going to be just creating a log

2713:45

out Handler which we did not create not

2713:48

right now and we are going to be also

2713:49

providing a classes like block and with

2713:52

will be set to four pairing for the

2713:53

xaxis will be four pairing for the Y AIS

2713:56

will be two text will be set to totally

2713:57

left and somebody how over there we are

2714:00

going to be changing the background

2714:01

color to totally 100 for the label we

2714:04

are going to be just writing a log out

2714:06

let's just save that we have to also

2714:08

create that function of above we have to

2714:11

check if we don't have the user info and

2714:15

uh what do you want to do we just want

2714:16

to write Li I mean like UL but the user

2714:19

did not logged in so we're going to be

2714:21

just showing this UI to the user like uh

2714:23

Flex first of all and inside there we're

2714:25

going to be just writing a Li and we're

2714:27

going to also have to create a link and

2714:29

it should go to the login page and now

2714:33

let me just put a few classes word here

2714:35

and I'm going to just place this classes

2714:36

word here and you have to do the same

2714:39

now inside this link we just have to

2714:41

write our AI outline login not a home

2714:45

log in and we have to specify the

2714:47

classes of margin for the right will be

2714:49

set to two margin for the top we be just

2714:51

set to four pixel and now let me just

2714:54

provide a size of 26 let's just close

2714:57

there underneath that we're going to

2714:58

also proving a span and it should be a

2715:01

log in in uppercase and now here we're

2715:04

going to be just providing a hidden

2715:06

class and the nav item will be set to

2715:08

name and the final Ali which you have to

2715:11

take care of is going to be another Ali

2715:14

and we're going to have exactly the same

2715:16

link but it should go to the register so

2715:19

now let me just write register right

2715:20

here and we are going to be also

2715:22

providing these same Clauses so now let

2715:24

me just review that and now let me just

2715:26

place these Clauses right here and in

2715:28

this link uh we are going to be just

2715:30

writing like AI outline user ad okay and

2715:35

the size will be set to 26 let's just

2715:38

close there and what the hell did I just

2715:41

do I'm just getting tired a lot now let

2715:44

me just write a span and it should be

2715:47

register and here we just have to write

2715:49

a class name not in upper case but in

2715:51

lower case hidden and nav item will be

2715:55

set to toally the name okay so we also

2715:58

have to close there s my file and I

2716:01

guess that's every single thing uh that

2716:05

we need for now here you can see this is

2716:07

how currently what navigation looks like

2716:09

but I'm going to change the UI a bit

2716:10

later so if I click on this it's going

2716:13

to brings us to the movies but now if I

2716:16

click on um this button right here so

2716:18

it's going to brings us to a login page

2716:20

and now if I click on this register

2716:22

button so it's going to just brings us

2716:23

to this register page right here which

2716:25

we did not create not right now so we

2716:28

are now getting the home right here

2716:29

which is totally okay but now the next

2716:31

thing which you want to do is that we

2716:32

want to go ahead and go to our main and

2716:34

inside this main we are going to be

2716:35

registering or making a specific routes

2716:38

for the login component and we're going

2716:40

to be also creating yet another

2716:41

component which will be the register.

2716:43

jsx r g i. jsx and we are going to be

2716:48

just using the RFC for now let's just

2716:50

save there and we already have our login

2716:52

component right here and now let me just

2716:54

grab that right here so I'm going to be

2716:56

using the login let's just grab that and

2716:58

we're going to be also using the

2717:00

register component as well and now what

2717:02

I want to do is that I want to just

2717:04

place it right here just create a

2717:06

separate route for that so I'm going to

2717:07

just using the route let me provide a

2717:09

path for that and we're going to be

2717:10

going into the login and as element

2717:13

we're going to be just passing or let me

2717:15

just pass my element not element but our

2717:18

login right here let's just close that

2717:20

and let me just close this component as

2717:22

well now let me just save that and what

2717:24

I want to do is that I want to just

2717:25

click on this bound right here so it's

2717:26

going of just brings us to this login

2717:28

and here you can see we are now getting

2717:30

our login right here which is totally

2717:31

amazing but now we also have to register

2717:34

or register component as well so now let

2717:36

me just duplicate there and instead of

2717:38

writing a login we are going to be just

2717:39

writing a register not react down but

2717:42

register and we are going to be also

2717:44

changing that to register component so

2717:46

now let me just save there let's just

2717:48

refresh there and now let me just click

2717:50

on this person and it's going to just

2717:52

giv us that register component right

2717:54

here which is totally amazing so yeah

2717:56

that's it about how we're going to be

2717:57

grabbing stuff but now the next thing

2717:59

which you have to do is that we have to

2718:00

create our register component so we're

2718:03

going to need a few things to grab from

2718:04

our store and also the state and all of

2718:07

that so the first thing we would need is

2718:08

the use T and also the use effect

2718:11

because we are going to be using both of

2718:12

them so now let me just write a link and

2718:15

also the use location not this one l o c

2718:18

t o n and also the use navigate from

2718:21

where from the re router Dom okay so

2718:24

we're going to need that and we would

2718:25

also get the used dispatch and also the

2718:29

use selector to just interact with or

2718:32

storage now let me just wrap the inside

2718:34

curly braces and we are going to be just

2718:36

grabbing there from the react and Redux

2718:38

okay now underneath that we're going to

2718:40

also need our loader which we defined

2718:42

but we did not create that so we're

2718:44

going to be just grabbing our loader

2718:46

from our components folder so now let me

2718:48

just go ahead and go to my components

2718:49

folder and we're going to be grabbing

2718:51

our loader from there and we're going to

2718:53

be also grabbing our set credential CR d

2718:57

uh CR d n t i LS from where from let's

2719:01

just go ahead and go to our feature uh

2719:03

I'm going to go ahead and go to my uh

2719:05

Redux first of all and then we're going

2719:07

to be going into the features and inside

2719:09

this feature we have off and then we

2719:11

have our all slice right here now let me

2719:13

just provide a craes inside there and

2719:15

now let me just go ahead and go inside

2719:17

there I'm going to copy there let me

2719:20

just place it right here s file and

2719:22

finally we're going to also need the

2719:23

toasttify so I'm going to be using like

2719:25

ah what the hell did I just do we're

2719:28

going to just writing our toast and

2719:30

we're going to be getting there from the

2719:31

react come on from the react and

2719:33

toasttify there we go so now let me just

2719:35

save that so that's every single thing

2719:38

that we currently need right now but I

2719:39

want to go ahead and go to my Redux and

2719:41

inside this Redux we're going to have to

2719:43

go to the API and then I want to go to

2719:45

the users and now underneath this login

2719:48

we're going to be defining yet another

2719:49

query not a query but or endpoint and

2719:52

I'm going to just write a register and

2719:54

it's going to be a builder. mutation

2719:57

because we are sending something sort of

2719:58

a data to our database so that's why it

2720:01

should be mutation not a query and we're

2720:03

going to be just writing a query and

2720:04

we're going to be passing our data and

2720:06

inside this data uh we are going to be

2720:08

just passing first of all the URL and

2720:11

the URL will be just a users URL which

2720:14

we already Define and now let me provide

2720:15

my comma and we're going to be also

2720:17

providing the method of post because

2720:19

we're going to be posting some sort of a

2720:21

data right here in this case and finally

2720:23

we just have to provide our body let me

2720:26

just do that in a lower case Body and we

2720:28

have to just specify our data which we

2720:31

are already defining or grabbing as a

2720:33

perimeter right here so now we

2720:34

successfully create our endpoint and now

2720:36

let me just put a comma here and if I

2720:38

just use the use keyword so it's going

2720:40

to gives us that use register mutation

2720:42

so now let me just copy this save this

2720:45

file and then let me just go ahead and

2720:46

go to my register component and now let

2720:49

me just grab the so I'm going to be just

2720:51

using the import and we're going to be

2720:53

just grabbing this same Hook from where

2720:55

from let's just go ahead and go to our

2720:58

uh Redux so I'm going to just go to my

2721:00

Redux and inside that we're going to

2721:02

have to go to the API then we have to go

2721:04

to our users right here so now let me

2721:06

just save there and now the next thing

2721:08

which you have to do is that we have to

2721:09

create a lot of States so con uh first

2721:12

of all for the username because if you

2721:15

want to create the user we're going to

2721:16

have to get some sort of a name from the

2721:18

user so it should be SE username rather

2721:22

SE uh user like that or you know it

2721:24

should be in lower case so Set uh

2721:27

username or something like that it's

2721:29

going to be equals to the used T and

2721:30

we're going to be just defining the

2721:32

totally empty string we would also need

2721:34

to get the email from the users so we

2721:36

are going be just writing a set email

2721:37

and it's going to be also equals to the

2721:39

use St of to empty string and underneath

2721:42

that we're going to also need one for

2721:43

the password and set password and then

2721:46

it's going to be equals to the use tat

2721:48

and inside that we're going to be just

2721:49

defining our initial set of empty string

2721:52

and then cost for the confirmation

2721:55

password so cost confirm password uh and

2721:59

also said confirm pass come on PSD will

2722:03

be now equals to the US St and it's

2722:06

going to be equals to to the empty

2722:08

string we're going to need the dispatch

2722:10

and it's going to be equals to the use

2722:12

dispatch and we're going to just

2722:13

executing there and then finally we

2722:15

would just need the navigate and it's

2722:17

going to be equals to or use navigate

2722:19

hook and now let's just call there and

2722:21

now underneath there we are going to be

2722:22

grabbing our register hook or register

2722:25

function rather from or use register

2722:28

hook so I'm going to be just using the

2722:29

use register mutation and then we're

2722:32

going to be just using or ARR

2722:34

structuring syntax right here so I'm

2722:36

going to just write like const it's

2722:38

going to be equals to register we're

2722:40

going to be grabbing our register

2722:41

function and we are going to be also

2722:43

grabbing the is loading property from

2722:45

there so underneath there we would also

2722:47

need the user information so we're going

2722:49

to be getting there from the state and

2722:51

we already defined that inside a state

2722:52

and O and now let me just destructure

2722:55

there so I'm going to be just using the

2722:56

user info it's going to be equals to

2722:58

this use selector and now underneath

2723:01

there we would also need the search so

2723:02

now let me just use the search uh we're

2723:06

going to be destructuring the search

2723:07

from the use location and now let me

2723:09

just execute that and we would also need

2723:11

to use our search parameter so I'm going

2723:13

to just write SP for search parameter

2723:15

it's going to be equals to the new URL

2723:17

search perams and now here we're going

2723:19

to be just passing our search which we

2723:21

are already grabbing from the use

2723:23

location so then we have to just

2723:24

redirect the user so redirect the user

2723:27

by using the search parameter and then

2723:30

we're going to be just providing the get

2723:31

to that and then redirect the user or uh

2723:36

outside from that just redirect the user

2723:38

to the homepage okay so now underneath

2723:40

that we're going to be also defining or

2723:42

use effect and here we just have to

2723:45

provide our aror function right here as

2723:47

for the dependency array we are going to

2723:48

be defining first of all the navigate

2723:50

and we would also need to define the uh

2723:52

what do we call the redirect and also

2723:55

the user info as well and now okay the

2723:58

spelling is incorrect n a v i g i g a t

2724:03

e so now let me just copy there and now

2724:07

let me just place there right here now

2724:10

we get there we go okay so now the

2724:12

spelling is totally correct but now the

2724:14

next thing which you want to do is that

2724:15

we are going to be just searching for

2724:16

the user info if you already have the

2724:18

user info so what do you want to do we

2724:20

just want to navigate the user not like

2724:22

that but now weig get the user to the

2724:25

redirect okay now underneath all of that

2724:27

we're going to just defining a lot of

2724:29

GSX right here so I'm going to just

2724:31

provide a class name of padding for the

2724:33

left of 10 RM I'm going to change that

2724:35

to something else like the UI doesn't

2724:37

matter but yeah here inside there we are

2724:40

going to be just writing margin for the

2724:42

right first of all and it's going to be

2724:43

just I don't know four r or something

2724:46

like that and we're going to be also

2724:47

defining the margin for the top of five

2724:49

R and inside that we're going to be just

2724:51

using our H1 of text 2 Xcel and also the

2724:55

font will be semi Bo come on semi hold

2724:58

and margin for the bottom will be set to

2725:00

four and we're going to be just defining

2725:02

the registered there we go so now let me

2725:04

just save there and now let me just

2725:05

refresh there right here and we are not

2725:08

getting anything I don't know why but we

2725:10

are not getting anything at all so we

2725:13

have a used dis ped we have a set

2725:14

confirmation

2725:16

password and nothing is happening let's

2725:19

just see over errors and we have 16

2725:23

errors wow that's a lot you know I'm

2725:26

going to take care of that because

2725:27

they're just a the name conflix and

2725:31

let's just refresh that you're not

2725:33

seeing anything let me just go ahead and

2725:35

go to my console and we are now getting

2725:37

the requested module loader. GSX does

2725:40

not provide an name export ah God

2725:44

damn we have to just import there like

2725:47

so so now let me just save there and

2725:48

refresh there and still how the hell we

2725:52

Define a loader component let me just go

2725:54

ahead and go to my components then we

2725:56

have a loader right oh we did not even

2725:57

spe if I anything inside there so now

2726:00

let me just create a loader component

2726:02

right here s s file and refresh that and

2726:05

I guess we're going to have to remove

2726:07

these Co braces from there and now let

2726:08

me just rename there to a loader and

2726:10

refresh there and here you can see we

2726:12

are now getting a register right here

2726:13

which is totally awesome so yeah that's

2726:16

cool we are now making a lot of progress

2726:20

we are now getting into creating the

2726:21

user okay so what I want to do is that I

2726:24

want to create a form and inside this

2726:26

form we're not going to be defining the

2726:27

EG and inside this form we are going to

2726:29

be also providing a class name of

2726:31

container first of all and the width

2726:33

will be 40 rim and inside this form

2726:35

we're going to be just creating a div

2726:36

with the class of my and we are going to

2726:39

be just giving it the two rims and

2726:42

inside this div you know let's just

2726:44

close let me just close there and inside

2726:47

this D we're going to be defining our

2726:48

label l a l and we're not going to

2726:51

providing any HT or you know I am going

2726:54

to be providing the HTML for of name and

2726:56

let's just Define our classes like like

2726:58

block of text small font will be medium

2727:02

and text will be totally set to White

2727:04

and now inside this label we're going to

2727:06

be just defining the name now let's just

2727:07

save then here you can see we're now

2727:09

getting the name and now underneath this

2727:11

label what do you want to do we're going

2727:12

to be creating our input and inside this

2727:14

input the type will be set to text and

2727:16

we're going to be also defining the ID

2727:18

of name right here and now let me just

2727:20

provide a class name of margin for a top

2727:22

of one border and also rounded and with

2727:25

will be set to totally full and also the

2727:27

place Holder will be set to enter name

2727:30

okay and also the value we are going to

2727:32

be defining which we already declared

2727:34

above which will be the user name and on

2727:37

change when somebody clicks or writes

2727:39

something not clicks but when somebody

2727:41

start to type something inside this

2727:42

input we're going to just using our set

2727:45

not interval but set username there we

2727:48

go and we're going to be just providing

2727:49

the E target. value inside there so now

2727:53

let me just save that and here you can

2727:54

see we are getting our input but that's

2727:56

looking supremely awful I don't know why

2727:59

but that's looking totally awful let me

2728:01

just right click on that and disable

2728:03

there yeah that's looking nasty you know

2728:07

I'm going to just provide the piring of

2728:09

two to it so now let's just save that

2728:11

and that's looking totally amazing but

2728:13

now let me just take care of this

2728:14

background color so now let me just

2728:16

right click on that and disable the dark

2728:18

force disable the dark force let me just

2728:21

go ahead and go to my index. CSS file

2728:23

and we are going to be just defining

2728:24

these classes and these styling right

2728:26

here so we are just uh first of all

2728:28

providing a background color of this to

2728:30

our body and the text color will be

2728:31

totally set to White and then we're

2728:33

selecting our input field and also our

2728:35

text area and we're making that totally

2728:37

black same for the selecting option we

2728:39

now making that totally black so now let

2728:41

me just cut that from here and let's

2728:43

just preview there and and now let me

2728:45

just right click on there disable force

2728:47

will look like this and also undisabled

2728:49

will look something like this so yeah we

2728:51

are getting there but now the next thing

2728:53

which you want to do is that you want to

2728:54

just uh grab there I'm going to just

2728:57

duplicate I don't know for a few

2728:59

times I'm going to just select this day

2729:01

with a class name of margin for the y

2729:03

axis of two and I'm going to just

2729:05

duplicate there a few times I'm going to

2729:07

duplicate that first of all for the

2729:08

email then for the password then for the

2729:11

confirm password okay so now let me just

2729:13

go to the top and here you can see first

2729:14

of all we have the name right here and

2729:17

then we're going to be changing this

2729:18

value to the email in this case and now

2729:21

let me just type the email as a label

2729:24

and I'm going to also change the type to

2729:26

email as well so now let me just provide

2729:29

the email right here and we are going to

2729:30

be also providing the email right here

2729:32

as well and instead of providing the

2729:33

enter your name we're going to be just

2729:35

defining the enter email and also the

2729:38

email here as well and then we have to

2729:40

just write a set email okay so now let

2729:42

me just save that also we're going to

2729:44

have to change this one to password so

2729:45

I'm going to just change the label to

2729:47

password and we're going to be also

2729:49

changing this one to password as well

2729:50

the type will be password and also the

2729:53

name or ID will be also set to password

2729:56

and enter your pen password like that

2729:59

and it should be the email address

2730:01

rather I'm going to just change this

2730:03

label to email a RS this is a password

2730:07

and then we have to provide a password

2730:08

confirmation but here we're going to

2730:10

have to also remove their username and

2730:12

change that to password and here set

2730:15

password like that and that's totally

2730:18

cool but now the final thing which you

2730:19

have to do is that we have to just write

2730:21

confirm password and also we have WR a

2730:24

confirm come on SO n if I RM password

2730:28

like that and now underneath that we're

2730:30

going to be also providing the password

2730:32

once again and also we have to just

2730:34

provide a confirm password and then we

2730:36

have to just write uh confirm come on

2730:39

confirm password like that and now let

2730:43

me just put a confirm password now let

2730:46

me just copy that or you know let's just

2730:48

Pro Set confirm password right here now

2730:51

let me just save that and here you can

2730:52

see we now getting the input of uh name

2730:55

and also for the email and also for the

2730:56

password and conf conf password and now

2730:59

the next thing which you want to do is

2731:00

that underneath this div we're going to

2731:02

be creating our button right here so I'm

2731:04

going to just create a button and inside

2731:05

this button we're going to be providing

2731:07

a disabled state of lowering if it is

2731:09

lowering then we're going to be just

2731:11

disabling there otherwise we are going

2731:13

to be just providing the type of submit

2731:14

to there and also the classes and the

2731:16

classes are a lot and I'm going to just

2731:19

copy the classes and now let me just

2731:21

place that right here sell file and you

2731:23

can also type there if you wanted to but

2731:25

here what I want to do is that I want to

2731:27

just write uh if is loading so what do

2731:30

you want to do we just want to write

2731:33

registering dot dot dot and if that's

2731:35

not the case we just want to write a

2731:37

registered there we go okay so yeah

2731:40

that's cool but now underneath this

2731:42

button what do you want to do we just

2731:43

want to show our loader so I just want

2731:46

to write is loading and then we have to

2731:49

just write our loader so loader and now

2731:51

let me just close that s file and that's

2731:54

cool but now underneath this form what

2731:55

do you want to do we just want to

2731:57

provide a with a class of margin for the

2731:59

top will be set to totally four and now

2732:01

inside that we're going to be providing

2732:03

a paragraph with a class of text totally

2732:05

white and now inside that already have

2732:08

an account if you already have an

2732:10

account then let's just provide an empty

2732:12

space right here underneath that we're

2732:14

going to be also providing a link and it

2732:16

should redirect us to first of all let

2732:18

me just WR redirect r e r CT and if it's

2732:23

redirect so we're going to be just

2732:24

providing the login question mark and

2732:26

redirect and here we are going to be

2732:28

just rendering or redirect dynamically

2732:30

so now let me just make as a as a

2732:33

template literals and here we're going

2732:35

to just providing or redirect so if

2732:38

that's not the case we are going to be

2732:39

just going into the logging screen okay

2732:41

so now here I'm going to just write uh

2732:44

login right here but I'm going to also

2732:46

provide a classes right here now let me

2732:48

just place this classes right here sell

2732:50

file and here you can see we are now

2732:52

getting a register button and we are

2732:53

also getting this already have an

2732:55

account and we are now getting this

2732:56

login right here okay which is totally a

2732:58

okay and amazing but finally we're going

2733:01

to be also attaching some sort of image

2733:03

right here underneath all of these divs

2733:05

but up above the last one we're going to

2733:07

be just placing this image right here

2733:09

and you can find the same image in my

2733:11

gab repository and now let me show you

2733:13

how that's going to look like and it is

2733:14

looking not okay okay so I'm going to

2733:18

just change the width to I don't know

2733:21

maybe uh 55 or something like this s

2733:25

file and now that's looking totally

2733:26

better and here you can see we have our

2733:28

data right here which is totally a okay

2733:30

but we have to attach our event handler

2733:32

to our form okay so inside this form

2733:35

we're going to be attaching our event

2733:36

handler and the event will be on submit

2733:39

when somebody submit this form so we're

2733:41

going to be just writing submit Handler

2733:43

come on h n d l e r and now let's just

2733:45

create our submit Handler right here so

2733:47

we're going to be just writing a submit

2733:49

Handler it's going to be equals to the

2733:50

asness function and we're going to be

2733:52

just providing a e now let me just use

2733:54

that e right here so we're going to be

2733:55

just writing a prevent default right

2733:58

here now let's check if our password is

2734:02

not equal to the confirm password so

2734:04

what do we want to show to the user we

2734:06

just want to show the toast um. error

2734:08

right here and we're going to be just

2734:10

writing like uh password do not match

2734:14

and if that's not the case so we are

2734:16

going to be just writing our try and

2734:18

catch blocks and inside the catch block

2734:20

we're going to be just writing our err

2734:22

let me just make that as a to err and

2734:24

then we're going to be just writing our

2734:26

conso log of to error and then we have

2734:28

to just write a toast toast. error and

2734:31

we are going to be just proving our

2734:32

error. data. message okay so now inside

2734:35

the tri block what do you want to do we

2734:37

just want to get the response so we're

2734:38

going to be just using AED and now let's

2734:40

just use our register function from the

2734:43

rtk query and we're going to be

2734:44

providing our username which the user

2734:46

will provide and also the email and the

2734:49

password and we are going to just using

2734:50

the unwrap at the end and now underneath

2734:53

that we're going to be just using a

2734:54

dispatch and now we also have to provide

2734:56

our set credential right here because

2734:58

currently we are now dispatching or

2735:00

store okay so now inside that we're

2735:02

going to be providing every single thing

2735:05

which we are providing inside this rise

2735:06

variable if everything is okay so we are

2735:09

going to be also navigating to the

2735:11

redirect okay so now underneath there

2735:13

we're going to just also using the

2735:14

toast. success and now let's just

2735:17

provide a user

2735:19

successfully uh register registered or

2735:22

create new account or something like

2735:24

that now let me just save that and now

2735:26

let's just try this out so I'm going to

2735:27

just reload that and currently we don't

2735:29

have nothing or I guess we have a lot of

2735:32

users right here now let me just go

2735:33

ahead and go to my users so we have five

2735:35

users right here let me just check the

2735:37

last one uh let's just check the last

2735:39

one and the last one is Sprite so I'm

2735:41

going to be creating yet another user so

2735:43

I'm going to just give it the name of

2735:44

like I don't know keyboard or something

2735:46

like that and keyboard at

2735:49

gmail.com and as a password I'm going to

2735:51

be providing a keyboard one come on

2735:53

let's just retype that keyboard one two

2735:56

and key keybard one two and now let me

2735:59

just click on this register button and

2736:01

here you can see it's going to just

2736:02

create a new user and it's going to also

2736:04

set the Json token inside the cookie so

2736:06

now let me just show you that and now

2736:08

let me just go ahead and go to my

2736:11

application right here and now let me

2736:13

just expand there so you guys can see

2736:15

everything a bit better now let me just

2736:16

go ahead and go to my session storage

2736:19

and not not a session storage but a

2736:20

local storage so here you can see we

2736:22

have our user info and we have a

2736:25

specific user ID right here and we also

2736:27

have a user credentials and then we have

2736:29

expiration time which will be that much

2736:31

days okay so yeah we are not toly able

2736:34

to successfully register the user and

2736:36

now let me make sure that we are saving

2736:37

the user to our database so now let me

2736:39

just here you can see we currently have

2736:41

five users right here but now let me

2736:43

just refresh there and here you can see

2736:45

we have a six user and now let me just

2736:47

check this out we have a keyboard as a

2736:49

name and then we have a keyboard at

2736:50

gmail.com as an email and then we have

2736:53

an encrypted password and the user is

2736:55

not an admin so yeah this is how we are

2736:58

going to be registering the user inside

2737:00

our application so that was it about how

2737:02

we are going to be registering the user

2737:04

and now let me just take care of the

2737:05

loader and I'm not going to be wasting

2737:07

your time but I am going to just place

2737:09

this CSS right here and you just have to

2737:11

type this CSS and it's going to give you

2737:13

an amazing loader and now let's just

2737:14

close it okay so that was it about for

2737:16

the loader and now let's just take care

2737:18

of the login okay we already find that

2737:21

now let me just show you this so I'm

2737:22

going to just close that right here and

2737:24

here you can also see by the way we have

2737:26

our name right here and if I click on

2737:28

the name so we have a logout Handler not

2737:31

defined we're going to be also taking

2737:32

care of that in a few seconds but now

2737:34

let me just go ahead and go to my login

2737:36

screen and you know what first of all we

2737:39

going to have to remove our um what do

2737:41

you call our cookie right here then we

2737:43

will be able to log in so I'm going to

2737:44

just remove every single thing from

2737:46

there and now if I just refresh my

2737:48

browser and here you can see it's going

2737:50

to give us that register and also that

2737:52

login now let me just click on this

2737:53

login and here you can see it's going to

2737:55

gives us that login let's just click on

2737:57

on there so I'm not going to be wasting

2737:58

your time but I'm going to go ahead and

2738:00

go to my register component and I'm

2738:03

going to copy every single thing from

2738:04

there I me like from the top and now let

2738:07

me just place it right here but instead

2738:08

of writing a use register we're going to

2738:10

be just using a use login mutation right

2738:13

here and that's everything we need for

2738:15

now when we're logging the user we're

2738:17

going to need the email and the password

2738:19

from the user so we're going to be

2738:20

creating a St for the email first of all

2738:23

it's going to be equals to use T not

2738:25

selector but use T and we have to just

2738:27

Define it as an empty St or empty string

2738:30

rather and we're going to be also

2738:31

getting the password from the user so

2738:33

set password is going to be equals to

2738:36

the US T and we are going to be just

2738:39

providing an empty string inside there

2738:41

and now let me just create an instance

2738:42

of dispatch it's going to be equals to

2738:44

the use dispatch and now let me just uh

2738:47

we're not going to be providing anything

2738:48

inside a dispatch but we are going to be

2738:50

just creating an instance of navigate n

2738:53

AIG is going to be equals to the use

2738:55

navigate and now let's just execute

2738:58

there and now let me just grab the login

2739:00

function from my rtk query which will be

2739:02

the used login mutation and now inside

2739:05

there we are going to be just getting

2739:07

our login and we are going to be also

2739:09

restructuring the is loading now

2739:11

underneath there we're going to be

2739:12

creating our cost user info and it's

2739:15

going to be equals to the use selector

2739:18

and now let me just pass my state first

2739:20

of all and here we're going to be

2739:21

grabbing our state from the state off so

2739:24

now underneath that we are going to be

2739:26

doing the same thing like first of all

2739:27

we're going to have to grab uh the

2739:29

search from the used location so we're

2739:32

going to be just grabbing that from the

2739:33

used location then we have to just

2739:35

create our search parameter by using the

2739:37

URL search pram uh s e r c prams and we

2739:41

are going to be just passing our search

2739:43

inside there and now let me just provide

2739:45

a redirect redirect it's going to be

2739:47

equals to the search parameter and and

2739:49

we are going to be getting the redirect

2739:51

from there and now let me just use if

2739:53

that's not the case we're going to be

2739:55

going into the home and now under Neath

2739:57

them we are going to be just providing

2739:59

our use effect and we are going to be

2740:01

providing our function inside there and

2740:03

for the dependency array we're going to

2740:05

be providing our navigate and the

2740:06

redirect and also the user info inside

2740:09

them and now inside this use effect

2740:11

we're going to be checking if you

2740:12

already have the user info so what do

2740:13

you want to do in that case we just want

2740:15

to navigate to that redirect which we

2740:18

already created up above so now let me

2740:20

just save there and now let's just write

2740:22

a lot of jsx now let me just remove this

2740:26

login from here and I'm going to be just

2740:28

creating a section and I'm going to just

2740:30

give it the class names of first of all

2740:32

the padding for the left will be set to

2740:34

10m and we're going to be also providing

2740:36

a flex and flex off uh totally W and now

2740:39

inside there we're going to be also

2740:40

defining margin for the right and it's

2740:42

going to be equals to 4 RM okay so let's

2740:45

just Pro our four R right here margin

2740:47

for the top will be set to five R and

2740:49

now inside that we're going to be just

2740:51

defining where H1 off sign in baby and

2740:55

also we have to provide the text of 2XL

2740:58

and also the font will be semi bold bold

2741:00

and then we have to provide margin for

2741:02

the bottom of four now let's just save

2741:03

there and here you can see we now

2741:05

getting our sign in button right here or

2741:07

not a button but a label and now

2741:09

underneath that we're going to be

2741:10

creating our form right here and we're

2741:12

not going to be providing any actions to

2741:13

that but we will provide a classes to it

2741:15

so we're going to be defining the

2741:16

container and width will be set to 40

2741:19

rim and now inside there we're going to

2741:21

be just creating a d with a class of

2741:23

margin for the y- AIS of two RAM and now

2741:26

inside there we're going to be creating

2741:28

our label and inside this label we're

2741:30

going to be providing the email and also

2741:32

for the classes we're going to be

2741:34

providing the block and text will be set

2741:36

to totally small and font will be set to

2741:38

medium like that and text will be also

2741:40

set to totally white as well and here we

2741:42

just have to provide our email address

2741:45

like that now let me just save that it's

2741:47

going to look something like this and

2741:48

here you can see we are now getting our

2741:50

email right here and now what I want to

2741:52

do is that underneath this label we are

2741:54

going to be creating our input and let

2741:56

me just for email as a type and now I'm

2741:58

going to also provide the ID of email

2742:01

let me provide a classes of margin for

2742:02

the top of one and pading all around

2742:04

will be set to two border and totally

2742:07

rounded and also width will be set to

2742:09

totally full and I'm going to be also

2742:11

providing a placeholder to that and I'm

2742:13

going to just say like enter email or

2742:15

something like that and I'm going to

2742:17

provide the value of email in this case

2742:20

and now let me just provide when

2742:21

somebody writes something inside there

2742:23

so we are going to be just providing the

2742:24

set email and we are going to be just

2742:26

Prov e. target. value inside there now

2742:30

let me just save that and here you can

2742:31

see we are getting our input field right

2742:34

here which is totally amazing but now we

2742:36

have to duplicate there so I'm going to

2742:38

just select this Dev and I'm going to

2742:40

just duplicate there I don't know maybe

2742:41

two times you know what I'm going to

2742:43

just duplicate the one time and now

2742:45

let's just change there from email to

2742:47

password so I'm going to just write a

2742:49

password in this case and password there

2742:53

we go and also we have to just remove

2742:56

this email from here email from there

2742:59

and we have to just write a password

2743:01

right here and I'm going to also remove

2743:03

this enter email instead of providing an

2743:05

enter email we're going to be just

2743:06

providing enter password and I'm going

2743:08

to also provide the password here and

2743:10

also the set password there we go now

2743:13

let me just save that and here you can

2743:15

see we now getting our password as well

2743:17

now let me just type something inside

2743:19

there so that's a password and that's

2743:20

the email yep that's looking amazing but

2743:23

now underneath that underneath this D we

2743:25

are going to be creating yet another

2743:26

button and now this button will be

2743:29

disabled and we are going to be just

2743:31

checking the loading if it's loading so

2743:33

this button will be totally disabled

2743:35

otherwise we're going to be providing a

2743:36

type of submit and now let me just

2743:38

provide a classes and it has a lot of

2743:40

classes so now let me just copy and

2743:42

place that so I'm going to just copy

2743:44

there and now let me just place these

2743:45

classes right here and I'm going to just

2743:48

save there okay so now inside this

2743:50

button what do you want to do we just

2743:51

want to check if it's loading so we just

2743:53

want to provide a signing come on s i g

2743:56

n i n signing in and then dot dot dot

2743:59

and if that's not the case so we're

2744:01

going to be just providing the sign in

2744:03

okay so now let me just save that and

2744:04

now underneath that we're going to be

2744:06

also providing a loader so underneath

2744:08

this button we are going to be just

2744:09

providing if it's loading then we also

2744:12

have to render or loader okay so now let

2744:15

me just close the word here seller file

2744:17

and underneath this form we are going to

2744:19

be creating or D with the class of

2744:20

margin for the top will be set to four

2744:23

and then we have to just specify the

2744:24

paragraph of text totally white and

2744:27

inside there we're going to just

2744:28

providing a new custom come on

2744:30

CME and then here we just have to

2744:33

provide empty space okay so now inside

2744:36

there we're going to be also providing a

2744:37

link and this link will go to let me

2744:40

just provide a two right here uh first

2744:42

of all the redir come on redirect and if

2744:46

it is a redirect so we just want to

2744:48

provide first of all the register and

2744:50

redirect the user to this specific

2744:53

redirect right here and if that's not

2744:55

the case we are going to be just

2744:57

providing the register there we go and

2744:59

as a level we're going to just providing

2745:01

the register right here I'm going to

2745:03

also provide a few classes right here so

2745:04

I'm going to just say like text of till

2745:07

500 and when somebody how over there so

2745:10

we're going to be just providing the

2745:11

underline right here so now let me just

2745:12

save that and that was a lot of talking

2745:16

and here you can see we are getting word

2745:18

signing in and also the new customer

2745:20

Right Here and Now under underneath this

2745:21

div we are going to be providing our

2745:23

image right here and you can also copy

2745:25

this same image from my gab repository

2745:27

so now let me just save there and here

2745:29

you can see we are getting this image

2745:31

once again which is looking totally

2745:33

awful so I'm going to make the 55 s file

2745:36

and here you can see that's looking a

2745:38

bit better now let me just provide my

2745:40

Handler to this forms so I'm going to

2745:42

just found my form and here we're going

2745:44

to be attaching our event handler when

2745:46

somebody submit this form so we're going

2745:48

to be just attaching the submit Handler

2745:50

and now let me just copy that from here

2745:53

and now let's just create that right in

2745:55

here so cons handle subm Handler handle

2745:58

submit Handler what the hell and we are

2746:00

going to be just putting a prevent

2746:02

default default and now let's just save

2746:04

that and underneath that we're going to

2746:06

be using our try and catch and for the

2746:08

catch block we're going to be putting a

2746:09

toast of error and if we have some sort

2746:12

of error then you know let me just

2746:14

change this one to ER R and then we are

2746:17

going to just getting the specific data

2746:19

from there and then the specific message

2746:21

from that data and if that's not the

2746:23

case we're going to be just providing an

2746:24

error do total error and for a tri block

2746:28

we're going to be just defining a

2746:29

response and aw of login and we are

2746:31

going to be providing this email

2746:33

credential and also the

2746:35

password but this should be an

2746:37

asynchronous function so async there we

2746:40

come on async there we go and here I'm

2746:44

going to just unwrap there so unwrap and

2746:46

now let's just close there and we're

2746:47

going to be also dispatching so set

2746:50

credential and we're going to be sending

2746:52

all of that credential to our store and

2746:54

now let me just navigate that to the

2746:57

redirect okay so now let me just save

2746:59

that and now let's just test this out

2747:01

baby and I'm going to just log in as a

2747:03

keyboard and now let me just provide a

2747:05

keyboard one two now let me just click

2747:08

on this sign in and here you can see we

2747:09

are now successfully sign in and you can

2747:12

also see my name right here so now let

2747:14

me just take care of the log out and

2747:16

also this navigation right here so I'm

2747:18

going to go ahead and go to my

2747:20

navigation and now let me just search

2747:22

for the log out Handler oh we are not

2747:25

okay we are proving one so let's just

2747:28

click on that so we are providing our

2747:30

login Handler but we are not creating

2747:32

one so now let me just copy that from

2747:33

here go to the top and now underneath

2747:36

all of that Above This GSX we're going

2747:38

to be creating our logout uh handlers so

2747:41

we're going to be just defining our

2747:42

asynchronous function and inside there

2747:44

we're going to be just using our try and

2747:45

catch block and for the error we're

2747:47

going to be just logging like console.

2747:49

error uh this specific error right here

2747:52

we're not going to be doing anything

2747:53

else in there and let's just use aw and

2747:56

log out API call which we are already

2747:58

grabbing and now let me just use the

2748:00

unwrap inside there and now let's just

2748:02

execute that then we're going to be also

2748:04

dispatching or uh what you or store by

2748:07

providing this log out function to there

2748:09

and then we are going to be just

2748:10

navigating to an AIG at te we're going

2748:14

to be navigating to the login screen so

2748:16

now let me just save there and if I

2748:18

click on that so it's going to give us

2748:19

the profile which we did not create but

2748:22

if I click on this log out you know

2748:23

first of all let me just show you

2748:24

something I'm going to go ahead and go

2748:26

to my in ECT element and then I'm going

2748:27

to go ahead and go to my application and

2748:30

here you can see we have our user

2748:32

information right here now let me just

2748:33

make it a bit smaller like that we have

2748:36

our user information right here as soon

2748:37

as I click on this log out button and

2748:40

here you can see we are getting an error

2748:43

let's just check it out so we have a log

2748:45

out and we have unauthorized and what's

2748:48

up with that and it took me a while and

2748:50

I finally found it what in the word are

2748:54

we doing in here we are restructuring

2748:57

the logout API call from the used login

2749:01

mutation and that's not correct we're

2749:03

going to have to grab that from the use

2749:04

log out mutation so uh I'm going to just

2749:07

go ahead and go to my users first of all

2749:09

and now let's just create an endpoint

2749:11

for logging out the user and I'm going

2749:13

to create the underneath this register

2749:15

and I'm going to just give it the name

2749:16

of like log out and it's going to be a

2749:19

builder. mutation and here inside there

2749:23

we're going to be providing a query and

2749:25

now let's just Pro

2749:27

uh or Arrow function right here and

2749:29

inside this Arrow function we're going

2749:30

to be defining first of all the URL and

2749:32

the URL will go to the user's URL and

2749:35

then specifically to the log out and

2749:38

then underneath that we're going to be

2749:39

also defining the method of toally post

2749:42

let's just save there I'm going to copy

2749:43

the name of there or even I'm going to

2749:45

just put a comma here and then use log

2749:48

out mutation I'm going to copy there and

2749:50

save that now let me just go ahead and

2749:52

go to my navigation right here let me

2749:53

just place it right here and also

2749:57

I'm going to be grabbing the use log out

2749:59

U mutation right here now let me just

2750:01

save that and I'm going to just refresh

2750:03

that once again and I want to show you

2750:06

that thing once again so I'm going to go

2750:08

ahead and go to my uh what do you call

2750:11

it my application right here and here

2750:12

you can see we have our user information

2750:14

but now if I click on that and click on

2750:16

my log out and here you can see that

2750:18

information is now successfully gone and

2750:20

we are now getting the login or it will

2750:22

redirect us to the login page right here

2750:25

okay so yeah that's looking cool and now

2750:27

we are totally done with the logging in

2750:28

and logging out so now let me just try

2750:30

that once again and in this case I'm

2750:32

going to just uh log in as an apple

2750:35

gmail.com and then we have apple one2 or

2750:38

something like dot let me just click on

2750:40

this it's going to give this like user

2750:41

not defined or if I just remove that and

2750:44

let's just empty out every single thing

2750:46

now let me just click on that so it's

2750:48

going to giv us that this user is not

2750:50

defined you can provide more validation

2750:52

than that but in my case that's going to

2750:53

do it and now let me just log in a user

2750:56

so I'm I'm going to just log in myself

2750:57

like husan gmail.com and we have h12

2751:00

right here and now let me just click on

2751:02

a sign in and here you can see we are

2751:04

now admin so it's going to gives us that

2751:06

dashboard also the profile and also the

2751:08

log out so now if I click on the log out

2751:10

it's going to brings us to this page

2751:11

right here now the next thing which I

2751:13

want to do is that I want to click on

2751:14

this register button and we want to

2751:16

register that Apple users so we have

2751:19

apple uppercase Apple then we have apple

2751:21

at gmail.com and the password will be

2751:24

apple1 12 and Apple come on a PL E12 now

2751:29

let me just click on this register

2751:30

button and it's going to just

2751:31

successfully register that Apple now let

2751:33

me just log out and try there once again

2751:36

so we have that apple and now let me

2751:38

just try the apple one two and hit enter

2751:41

and it's going to log in that specific

2751:43

apple right here okay so this is how we

2751:45

going to be creating a user and this is

2751:47

how we are going to be registering our

2751:48

own users now that's cool but now the

2751:51

next thing which you want to do is that

2751:52

you want to take care of the user

2751:56

profile and also the private route so

2751:58

what I want to do is that I want to go

2752:00

ahead and go to my o one more time and

2752:02

we're going to be creating a separate

2752:03

component for private routes. jsx right

2752:07

here okay so it should be just private

2752:10

route not with the S and now I'm going

2752:13

to be just defining my RFC right here

2752:16

and inside this private route the first

2752:17

thing which I want to do is that I want

2752:19

to go to the top and we're going to be

2752:20

grabbing our navigate uh let's just grab

2752:23

our n a v i g a t e and also the outlet

2752:26

as well from where from the react router

2752:29

and Dom and underneath that we're going

2752:31

to be using the use selector come on the

2752:34

use

2752:35

selector from where from the react and

2752:38

Redux and now underneath that we are

2752:40

going to be just grabbing first of all

2752:42

the user information so we are going to

2752:44

be just using const and let's just

2752:46

destructure our user info from where

2752:48

from our use selector and we're going to

2752:51

be just defining our stat right here and

2752:53

we are going to be just getting our St

2752:54

from the off and now underneath then

2752:56

what I want to do let's just remove uh

2752:59

these stuff from here and I'm going to

2753:01

be using my user info and if you already

2753:03

have the user info then we are going to

2753:05

be providing our Outlet component and if

2753:07

you don't have the user info so we are

2753:08

going to be just navigating our user to

2753:11

the login screen okay so now we are

2753:13

going to be just replacing there and now

2753:15

let's just close there so this is how we

2753:16

are going to be defining our private

2753:18

route and now let's just use the inside

2753:19

our main component okay so now what I

2753:22

want to do is that underneath this

2753:24

register I'm going to be using my rout

2753:26

let me just provide a route in uppercase

2753:28

and path will be totally empty string

2753:30

and I'm going to also provide my element

2753:32

and the element will be just my private

2753:35

route come on p r i v a t e and routes

2753:38

or route and now let me just close that

2753:41

right here like there and now inside

2753:43

that we're going to be doing our magic

2753:45

but first of all let me just copy that

2753:46

from here and we are going to be placing

2753:49

that right here inside this restricted

2753:51

area so private route from there let's

2753:54

just go ahead and go to uh uh go to our

2753:58

uh Pages component inside this Pages

2754:00

component we have o and inside this o we

2754:03

have our private uh routes right here

2754:05

now let me just save that and now inside

2754:08

there we're going to be defining our

2754:09

route for our uh profile component so we

2754:12

are going to be creating our profile

2754:13

component right here I guess we did not

2754:15

create that so here you can see we have

2754:16

a user and inside this user we going to

2754:19

be creating our profile. jsx right here

2754:22

now let me just use my RFC save that and

2754:24

now let's just come back to my and here

2754:27

we're going to be defining a route and

2754:28

let me just provide a path to that and

2754:30

the path will be profile and we're going

2754:33

to be also providing the elements and

2754:35

the elements the element and now let me

2754:37

just provide my profile component let's

2754:40

just autograph that and now let's just

2754:42

save there like so save file and we're

2754:45

going to be taking care of the profile

2754:47

component in a few second but now we

2754:48

have to check this out I'm going to just

2754:50

provide I don't know maybe apple and

2754:52

then we have apple one2 login ah God

2754:56

a E12 okay I just forgot the password of

2755:00

there I'm going to log in with myself so

2755:02

hoseen gmail.com and hosan one2 and here

2755:06

you can see we are now successfully log

2755:08

in now let me just click on there and

2755:10

now if I click on the profile component

2755:11

so it will brings us to this profile

2755:13

right here okay so which is totally

2755:15

amazing and now let me just click on

2755:18

that and now let me just take care of

2755:19

this profile component the first thing

2755:21

which I do is that I'm going to be

2755:22

grabbing first of all my import use

2755:24

effect and also the use State as well

2755:28

and the next thing which I'm going to do

2755:29

is that I'm going to be grabbing my use

2755:32

dispatch and also the use selector come

2755:35

on C from where from the react Redux

2755:39

library and underneath that we're going

2755:41

to be also getting our toast as well

2755:43

from where from our react toasttify

2755:46

there we go okay so now we are going to

2755:48

be also getting our

2755:49

loader which you already created and

2755:52

underneath that we're going to be also

2755:53

getting our set credentials from our

2755:56

features and now I'm going to just save

2755:58

my file let me just go ahead and go to

2756:00

my users and Define our endpoint right

2756:02

here okay so underneath this log out I'm

2756:05

going to Define my profile so profile

2756:08

and I'm going to be using a builder.

2756:10

mutation because we are sending some

2756:12

sort of a data and we have to just

2756:13

provide our query let me just provide my

2756:15

data inside there and inside there we're

2756:17

going to be defining our URL and here we

2756:20

just have to render our user um user URL

2756:23

and we specifically want to go to the

2756:25

profile and now let me just provide a

2756:26

comma here and the method will be a put

2756:29

method because in this case we're going

2756:30

to be changing our data and now let me

2756:32

just provide a body and the body will be

2756:34

that data which we are already grabbing

2756:36

uh as a parameter right here okay so now

2756:39

let me just provide my uh use profile

2756:42

mut no not this one use POF there we go

2756:46

so use profile mutation now let me just

2756:48

copy then save this file now let me just

2756:51

grab that right here so I'm going to be

2756:52

grabbing my Ed profile mutation from no

2756:56

yeah from my redex API and user so now

2756:59

let me just save that and now let me

2757:00

just create a lot of states right here

2757:02

so con username and also set username is

2757:07

going to be equals to the use St and we

2757:09

have to just Define our uh State word

2757:11

here then we have to write our email and

2757:13

set email and it's going to be equals to

2757:15

the use come on use and inside that

2757:19

we're going to be just defining our

2757:21

empty string and then we have to just

2757:23

write our password and set password will

2757:26

be now equals to the use St one more

2757:28

time not selector the use St and here we

2757:32

just have to provide our empty string

2757:34

and then con we have to just Define a

2757:36

confirm so if I F iirm password like

2757:41

that hope the spinning is correct set

2757:43

confirm

2757:45

password is going to be also equals to

2757:47

the used T and let's just Define or

2757:49

empty string right here c n f i r m

2757:53

password there we go now underneath that

2757:55

we're going to also getting the user

2757:57

information so let's just grab that and

2757:59

we're going to be destructuring the user

2758:01

info it's going to be equals to the use

2758:03

selector and here we just have to

2758:05

provide our state and inside the state

2758:07

we're going to be getting our state. off

2758:09

now underneath that let's just use our

2758:11

rtk query and we are going to be

2758:13

destructuring the update profile and we

2758:16

are going to be also destructuring the

2758:17

is loading like that and I'm going to

2758:20

just rename that to loading update

2758:23

profile I'm going to rename my is

2758:26

loading to the Loading update profile

2758:28

and it's going to be equals to the use

2758:30

profile mutation and now underneath that

2758:33

we're going to be also defining our user

2758:34

effect and inside that we're going to be

2758:36

passing our aror function and I'm going

2758:38

to be using the set username it's going

2758:40

to be equals to the user in we are now

2758:42

getting the user information right here

2758:44

and now let me just duplicate oh God

2758:46

damn what the hell am I doing let's just

2758:48

duplicate that and change their user

2758:50

information to the email right here as a

2758:53

dependency array we are going to be just

2758:55

Prov or uh what do we call it the user

2758:58

info do email and also the user info do

2759:02

come on username there we go now the

2759:05

next thing which you want to do is that

2759:06

you want to create an instance of

2759:07

Dispatch they use dispatch hook and now

2759:10

let me just execute there okay so that's

2759:12

cool but finally we have to write a lot

2759:14

of jsx right here let me just remove my

2759:16

profile right here and I'm going to be

2759:18

creating a d with the class of container

2759:20

and margin for the xais will be set to

2759:22

Auto and ping will be four margin for

2759:24

the top will be set to

2759:26

something like 10 Rim okay and now let

2759:30

me just close that inside this div we're

2759:32

going to be defining this div right here

2759:34

I just copied and place it and you

2759:36

should do the same and now let me just

2759:37

close that right here okay so now I'm

2759:40

going to just close that and inside this

2759:42

div we're going to be creating yet

2759:43

another div and I'm going to be just

2759:45

using class name of margin for

2759:47

the not yeah margin for the or not

2759:51

margin but MD screen size will be just

2759:53

withd of 1 over three and and then here

2759:56

we're going to be just defining or H2

2759:58

right here so H2 will be update profile

2760:02

and now as a classes we're going to be

2760:04

defining like text of 2 XEL and font

2760:06

will be semi bold and also margin for B

2760:09

will be set to four now let me just save

2760:10

there and here you can see we are now

2760:12

getting our update profile Right Here

2760:14

and Now underneath that what you want to

2760:16

do we just want to create our form and

2760:18

I'm not going to be attaching any action

2760:19

to it so let's just remove that and

2760:21

inside this form we are going to be just

2760:23

creating a d with the class of margin

2760:24

for a bottom of four and now inside

2760:26

there we're going to be just creating a

2760:28

label and for the label we're not going

2760:30

to be attaching any HTML for to there so

2760:33

let's just remove them and I'm going to

2760:35

be also providing a class name of block

2760:37

and text will be set to totally white

2760:39

and margin for bottom will be set to two

2760:41

and it's going to be a name okay so now

2760:43

let me just provide a name right here

2760:45

sell file and now underneath that we're

2760:47

going to be creating our input and for

2760:49

the input the type will be set to text

2760:51

but the placeholder will say placeholder

2760:54

will say like enter your or enter name

2760:57

would be fine and now I'm going to be

2760:59

also providing a class names of form

2761:02

input and also ping all around will be

2761:04

set to four and totally rounded of small

2761:07

and also the width will be set to

2761:09

totally four okay we're going to be also

2761:11

providing a value and the value will be

2761:13

the username okay so outside from that

2761:15

we're going to be also attaching the own

2761:17

change H right here when somebody types

2761:19

something inside there so we're going to

2761:21

be just pushing there to set username

2761:24

and we are going to be just defining the

2761:26

target. value now let me just save that

2761:28

and here you can see it's going to gives

2761:30

us my uh email like I logged in as a hus

2761:33

right here so that's why we are now

2761:35

getting our hus gmail.com now let me

2761:37

just refresh that and we are still

2761:38

getting this email right here okay so

2761:41

that's cool but I want to duplicate this

2761:43

div right here one more time not one

2761:45

more time but I'm going to be

2761:46

duplicating there for the email the

2761:48

password and also for the confirm

2761:50

password okay so let's just go ahead and

2761:52

go to the top so this is going to be my

2761:54

name and then we have email address so

2761:57

email if I can write email a d r e s

2762:01

like and let me just provide an email

2762:03

right here and enter your email email

2762:07

there we go and everything is totally

2762:09

okay let me just put my email let's just

2762:12

provide our set email right come on not

2762:14

intermediate or something like that but

2762:16

we have a set email what are we

2762:18

providing for the email let's just go to

2762:19

the top and

2762:23

EM set email let me just where is said

2762:26

now let me just copy there go to the

2762:29

bottom and I just lost it okay there we

2762:32

go so here you can see we're going to be

2762:34

using our set email right here in this

2762:35

case and now let's just provide for the

2762:38

password so we have a password right

2762:40

here and now let's just remove that and

2762:43

change that as a password and enter your

2762:46

password so let's just remove that and

2762:48

change that to the password and here

2762:50

we're going to be also using the

2762:51

password and this is going to be the set

2762:54

password there we go not confirm but

2762:56

just a said password I guess I didn't

2762:59

Define the above so we have the God damn

2763:03

it I always forgot this te so we have a

2763:06

set password right here and now let me

2763:07

just use that uh we have a set email and

2763:10

then we have a set uh password right

2763:13

here now let me just change that to

2763:15

confirm password p a s w r d so c n f i

2763:20

RM confirm password and now let's just

2763:23

change this one to the p password as

2763:26

well then I'm going to just write

2763:28

confirm password or something like that

2763:31

c n FM password there we go and let's

2763:36

just change this one to confirm password

2763:39

and this one to the set confirm password

2763:41

as well okay so c o n f i r m and now

2763:47

let me just copy that from here and go

2763:50

to the top and we have to update it

2763:52

right here as well so now let me just

2763:54

save there and that's looking totally

2763:57

cool now underneath this div and up

2763:59

above this form we're going to be just

2764:01

creating a div with the class of flex

2764:03

and just Define will be set to between

2764:06

and now inside there we're going to be

2764:07

just creating a button let's just Define

2764:09

our button and inside that button we're

2764:11

going to be defining the type of submit

2764:13

right here and yeah I'm going to be just

2764:16

grabbing the classes from my on code so

2764:19

now let me just copy that and now let me

2764:21

just place it right here and here let me

2764:23

just put my update sa file and this how

2764:25

we're going to be updating our button

2764:27

and now under underne this div we are

2764:29

going to be just defining the level of

2764:31

if you have the loading update profile

2764:32

then we have to Pride or loader and now

2764:35

let's just close that s file and yeah I

2764:38

guess that's every single thing that we

2764:40

need for the UI so we are now getting

2764:42

the email right here why are we getting

2764:44

the email right here for the name we

2764:46

have to be getting our email right here

2764:47

in this input and now let me just go to

2764:50

the top and what we are doing is that we

2764:53

have a set username we have a set email

2764:55

right here but now let me just go to my

2764:58

ah there we go so we have a set email

2765:00

right here in this case and s file and

2765:03

now let me just check this out so we

2765:06

have a name and then we have a email

2765:08

right here which is totally amazing now

2765:10

let me just provide a functionality for

2765:11

that so when somebody change something

2765:13

inside that then we will be able to

2765:15

update there so I'm going to just log

2765:16

out because this person is an admin and

2765:19

I want to just log in as someone else

2765:20

like I don't know maybe Alex would be

2765:22

fine and I'm going to just WR like Alex

2765:24

Gmail and

2765:26

alex12 and this user is not created

2765:29

let's just check out the Alex I forgot

2765:31

the password of that and we have hen we

2765:35

have the computer let me just log in as

2765:37

a computer so let's just write computer

2765:41

gmail.com and we have a computer one two

2765:43

I guess and there we have it okay now

2765:45

let me just click on this profile and

2765:47

it's going to allows us to change this

2765:49

profile right here but now the first

2765:50

thing which I want to do is that I want

2765:52

to attach my event handler on this form

2765:54

on the on submit not scroll but submit

2765:58

we're going to be attaching the form or

2766:01

not a form Handler submit Handler would

2766:03

be fine now let me just copy that and

2766:05

create that right here so now let me

2766:08

just create that right here I'm going to

2766:10

be creating con uh submit Handler it's

2766:12

going to be equals to the asynchronous

2766:13

function we're going to be just foring

2766:15

our e for the event and now let me just

2766:17

use my e prevent default and execute

2766:20

there now underneath that we're going to

2766:22

be checking if the password is not equal

2766:26

to the confirm password so we're going

2766:28

to be just showing this toast so toast.

2766:30

error and passwords do not match okay

2766:35

and now underneath that we're going to

2766:37

be also providing the else class and for

2766:39

the else class we're going to be

2766:40

defining the TR and catch blocks for the

2766:43

catch we are going to be just writing

2766:44

the

2766:45

RR RR and the err and now let me just

2766:49

use the to. error and now let me just

2766:51

Define my error and we are going to be

2766:53

getting the data from there d at TA and

2766:56

then we going to be also getting a

2766:58

specific message from there and if

2767:00

that's not the case we just have to

2767:01

write error. portal error there we go

2767:05

now for the tri loock what do we want to

2767:06

do we just want to con res and we want

2767:09

to update our profile and how we are

2767:12

going to be updating our profile first

2767:13

of all we're going to be defining the ID

2767:15

it's going to be coming from the user

2767:16

info and then the specific ID and then

2767:19

we're going to be defining the username

2767:21

and we are going to be also providing

2767:22

the email and also the password which

2767:24

the user will gives us and now let me

2767:27

just use the unwrap on there and finally

2767:30

uh here we just have to dispatch or

2767:32

store by just providing the set

2767:34

credentials today so

2767:36

credentials and here we have to pass our

2767:38

response the overall response and we

2767:41

have to also write a toast. success and

2767:44

we are going to be just writing a

2767:45

profile updated

2767:48

successfully okay so now let me just

2767:50

save there and here you can see we have

2767:52

all of the data and I'm going to just

2767:54

change there to like I don't know maybe

2767:56

mango or something like that and mango

2767:59

gmail.com and I'm going to also provide

2768:01

the mango1 12 and mango one two right

2768:05

here and now if I click on this upd

2768:07

button and it's going to gives us an

2768:10

error and what's up with that error now

2768:12

let me just uh check this out we didn't

2768:15

mess up something in this component

2768:18

let's just right click on that and go to

2768:19

my inspect element then I'm going to go

2768:21

ahead and go to my network or you know

2768:23

first of all let me just check out the

2768:24

console the server responded with the

2768:26

status of 401 unauthorized let me just

2768:29

click on that once again so we are now

2768:30

getting that from the profile and we are

2768:32

going into the profile we are providing

2768:34

the payload of uh let's just check this

2768:38

out we're providing the email we're

2768:40

providing the

2768:42

password username oh so we are now

2768:44

getting the error of duplicate key error

2768:47

Collection movie app user and that's

2768:50

because we already created the mango

2768:52

user so now let me just try to create

2768:53

some unique user now let let's just

2768:55

refresh there and what name should I

2768:58

give it I don't

2769:00

know God damn it I just forgot the name

2769:03

I'm going to just provide a James and we

2769:05

have a James gmail.com and I'm going to

2769:08

just write like

2769:09

james12

2769:11

james12 and it should be in lowercase j

2769:15

and now let me just click on this update

2769:17

button and it's going to just give us

2769:18

that profile updated successfully and we

2769:20

are also getting that James right here

2769:22

so here you can see we are now getting

2769:24

this James and this how we are going to

2769:25

be updating a specific user so now let

2769:27

me just search there inside my database

2769:29

and now let me just refresh there and we

2769:32

have the apple right here I'm searching

2769:35

for the James so I guess that computer

2769:37

was the first one and we now updated

2769:39

there to the James right here and yeah

2769:41

this how we are going to be updating a

2769:43

specific user and this is how we are

2769:45

going to be getting a specific user

2769:46

information and updating that so now let

2769:48

me just log out and yeah this we are

2769:51

going to be updating a specific user so

2769:53

that was it about for the user

2769:54

management and now let's talk about how

2769:56

we're going to be making a genres so I'm

2769:59

going to just uh close my terminal and

2770:02

I'm going to be just using the npm run

2770:04

back end in this case and it's going to

2770:06

just start our back end because

2770:07

currently we're going to be working with

2770:08

the back end and now let me just go

2770:10

ahead and go to my index and now we're

2770:12

going to be using app. use first of all

2770:14

you want to go to the API like that then

2770:16

you want to go to the version one and

2770:18

then JRE okay and then genre routes and

2770:22

now let me just copy that we're going to

2770:24

be importing there right here but first

2770:26

of all we have to create there but

2770:28

before we create there first of all we

2770:30

have to create a model for that so I'm

2770:32

going to just create a model given name

2770:33

of like genre. JS I'm going to grab my

2770:36

Mongoose from the Mongoose and now let

2770:39

me just create my genre schema like that

2770:42

it's going to be equals to the new

2770:44

do not this one Mong come on Mongoose do

2770:48

schema and here inside that we're going

2770:50

to be providing the name and this name

2770:52

will take the type of string and also

2770:54

the trim will be set to true and also it

2770:57

should be required and it's going to be

2770:59

equals to true the maximum length which

2771:01

you are going to be providing is L GTH

2771:04

is going to be just 32 and now let me

2771:06

just also make it as unique and it's

2771:09

going to be set to true and now finally

2771:11

we're going to be just exporting that by

2771:12

using model and then we have to

2771:16

just write a genre and here we just have

2771:18

to pass our genra schema now let me just

2771:20

save that and this is how we going to be

2771:22

creating our genre now let me just go

2771:23

ahead and create my r right here which

2771:26

will be the genre routes.js and now

2771:30

inside the first of all we're going to

2771:31

be importing the express from the

2771:33

express CHS and then we're going to be

2771:36

creating uh con router it's going to be

2771:38

equals to express. come on xs. router

2771:43

now underneath that we're going to be

2771:44

getting our controllers and yeah that's

2771:47

going to be and also we would get our

2771:48

middle Wares as well I forgot to show

2771:50

you there uh middle Wares there we go

2771:54

you know let me just get my middlewares

2771:56

right here so authenticate and also

2771:59

authorizes an admin so now we are

2772:01

successfully grabbing that let's just

2772:02

remove that from the end and now let me

2772:04

just Define my route so router. route

2772:07

and when somebody go to that specific

2772:09

route so we want to just post and the

2772:11

user should be authenticated and also

2772:13

authorize as an admin then they would be

2772:15

able to create the genre so now let me

2772:18

just export that so export uh default

2772:21

and router okay so that's cool but now

2772:24

we have to grab that inside our index

2772:26

file and I'm going to be getting there

2772:28

so I'm going to just write a genre

2772:30

routes

2772:32

gnrs routes from where let's just go

2772:35

ahead and go to um or routes not this

2772:40

one come on routes and inside there we

2772:42

have our genre routes right here I'm

2772:44

going to copy that and I'm going to just

2772:46

make sure that I just provide there

2772:48

right here s file and let me just check

2772:50

and we don't have any errors we have

2772:54

error right here because we are not

2772:56

providing this controller right here so

2772:57

we're going to have to grab that but

2772:59

first of all we have to create our

2773:00

controller file and I'm going to name

2773:02

that as a genre

2773:05

controller.js and now inside there first

2773:08

of all I'm going to be getting my genre

2773:10

from where from let's just go ahead and

2773:12

go to my models and then we have to go

2773:14

ahead and go to the genre. JS and then

2773:16

we also have to get our asynchronous uh

2773:19

Handler sync Handler and now let me just

2773:21

copy that and here we're going to be

2773:23

just creating this genre is going to be

2773:26

equals to this ASN Handler and we're

2773:28

going to be just passing our as

2773:29

synchronous request response and inside

2773:31

there we're going to be using a try and

2773:33

catch for the catch block we're going to

2773:35

be just passing these errors and for the

2773:37

triy block first of all we're going to

2773:38

be destructuring the name from where

2773:40

from the request and body which the user

2773:43

is going to be specifying or the admin

2773:45

in this case is going to be specifying

2773:46

and now let me just check if we don't

2773:48

have the name like if the user did not

2773:50

specify the name so we just have to

2773:52

return the r. Json and we are going to

2773:55

putting some sort of error word here and

2773:57

name is required and now underneath that

2774:00

we're going to be searching for the

2774:02

existing ex uh is s t iing genre it's

2774:06

going to be equals to the aware and

2774:08

genre and then we have to just use our

2774:10

method which will be find one and

2774:13

we are going to be finding our genre by

2774:15

using this specific name and if we

2774:17

already have the genre so existing genre

2774:20

so we just want to return to the user

2774:22

like r. Json and it is going to be the

2774:24

error and now let me just pass like

2774:26

already exist like so and now underneath

2774:30

that what you want to do we just want to

2774:31

create a new genre so genre will be now

2774:34

equals to A and then new genre and here

2774:36

we are going to be just specifying the

2774:38

name and we have to just save that to

2774:40

our database and finally we have to show

2774:42

something to the user so that the user

2774:43

can see that we created something right

2774:46

here so now let me just save that and

2774:48

yeah we have to just export that I'm

2774:50

going to copy that and go to the bottom

2774:52

and Export or genre right here now let

2774:55

me just save that and I'm going to go

2774:57

ahead and go to my routes and here we're

2774:59

going to have to import that right in

2775:01

here so we're going to have to import

2775:03

our genre like so I'm going to copy that

2775:06

but at the end I'm going to also have to

2775:08

specify this JS right here and we're

2775:10

already using there so now let me just

2775:12

save there and let's just restart npm

2775:15

run back in in this case so it's going

2775:17

to just okay we have some error and

2775:20

what's the error we have the error

2775:21

inside a genre routes okay

2775:25

what are we doing wrong create genre I'm

2775:27

going to copy then place it right here

2775:30

and I guess we are not pring the JS

2775:33

right here that's why let me just

2775:35

provide this JS and let's just restart

2775:37

that um by using the npm run back in and

2775:40

here you can see everything is working

2775:41

as expected and now what I want to do is

2775:44

I want to create a separate folder right

2775:45

here and create a folder G name of like

2775:49

users or users management or something

2775:53

like that I'm going to just grab every

2775:55

single thing that I currently have right

2775:57

here let me just select all of that and

2776:00

grab that from here and now let me just

2776:02

put the inside users management and

2776:04

let's just close that okay let me just

2776:07

close this one as well and now inside

2776:08

there we're going to be creating here

2776:10

another folder I'm going to give the

2776:11

name of like

2776:12

genres and inside there we're going to

2776:15

be just creating a first request which

2776:17

will be create uh genre okay so I'm

2776:22

going to just copy the name from there

2776:25

or URL from there I'm going to copy

2776:27

there and now let me just place that

2776:28

right here in this case we're now

2776:31

posting the data so we are going to have

2776:32

to change that to post okay and we are

2776:35

now providing the user instead of

2776:36

providing a users we're going to have to

2776:37

provide a genres was that s or just a

2776:41

singular okay it's just a singular I'm

2776:43

going to have to copy that now let me

2776:45

just place it right here and we have to

2776:47

post some sort of a name right here

2776:49

inside there and now let me just post

2776:51

some sort of name like movies like The

2776:54

sure it's not a movie by the way uh it's

2776:57

a game and also uh what do we call it

2777:00

let me just close that right here and

2777:02

let me just refresh this we only have

2777:04

the users right here but once I click on

2777:06

this send b right here it's going to

2777:08

give us not authorized as an admin we

2777:10

have to first of all login as an

2777:12

admin so the admin is hosan so I am

2777:16

going to be just logging in as hosan

2777:18

right here okay yeah hoseen one2 now let

2777:21

me just click on there and we

2777:23

successfully logged in let me just show

2777:25

you there we successfully logged in and

2777:27

this person is an admin and now if I

2777:29

click on the send button so it's going

2777:30

to just create this genre for us and now

2777:33

let me just refresh my database and here

2777:35

you can see it's going to giv us their

2777:36

genres and inside there we have a

2777:38

document and now let me just show you

2777:39

that and here you can see we have this

2777:41

unique genre so this is how we are going

2777:43

to be creating a unique genre and now

2777:45

let me just go ahead and update the

2777:47

genre what I want to do is I want to

2777:49

write my router. route and we are going

2777:51

to be going into a specific ID and here

2777:54

we have have to provide some sort of ID

2777:56

and we are going to be providing the

2777:57

method of put because in this case we

2777:59

are now what we call we now updating our

2778:01

genre user should be authenticated and

2778:03

also authorize as an admin so authorize

2778:06

as an admin then they would be able to

2778:08

update the genre okay so now let me just

2778:11

copy there save this file but I'm going

2778:13

to also have to paste it right here s

2778:15

file and now let me just create this

2778:17

genre right here but before I do I'm

2778:19

going to have to pass it right here as

2778:20

well and now let me just create this so

2778:23

we have a Asing Handler and we're going

2778:25

to have to pass for SN request response

2778:28

and inside there we're going to be

2778:29

passing the try and catch block so try

2778:32

and catch blocks for the triy block

2778:34

first of all we're going to be grabbing

2778:35

the name from where from the request.

2778:38

body and what else do we have to do we

2778:40

have to also get the ID from where from

2778:43

come on let me just put equal to sign

2778:45

from the request. prams okay so here you

2778:48

can see we are providing this ID right

2778:50

here inside of parameters and we are

2778:52

going to be destructuring that from this

2778:54

request PRS and now we are going to have

2778:56

to search for the ID so we're going to

2778:58

be just writing a genre it's going to be

2778:59

equals to A and then genre do find one

2779:03

and inside that we're going to be just

2779:04

placing our ID is going to be equals to

2779:06

that ID which we are already getting

2779:08

right here okay so we're now searching

2779:10

for the genre and now let me just check

2779:12

if you don't have the genre already so

2779:15

what you want to show to your user we

2779:16

just want to return response. status of

2779:19

404 and then Json here we just have to

2779:22

provide the error of error and genre n

2779:25

phone okay so if that's not the case we

2779:28

are going to be just updating the name

2779:30

of our genre so genre. name will be

2779:32

equals to this newly added name and

2779:35

underneath that we're going to be also

2779:36

updating our database so for that we're

2779:38

going to be just using updated genre and

2779:40

it's going to be equals to A and then

2779:42

genre do save okay now let me just

2779:45

execute that and finally we have to show

2779:46

something to the user so we're going to

2779:48

be just writing like response. response.

2779:51

Json and update genre that's a lot of

2779:53

talking and and for the catch block

2779:55

we're going to be just placing these

2779:56

console logs now let me just save there

2779:59

and now let me just test this out but

2780:01

I'm going to copy there and place it

2780:03

right here update to genre and here you

2780:05

can see we have The Witcher name I'm

2780:07

going to just create a new file or not a

2780:09

file but request and now let me just

2780:12

create a request right here I'm going to

2780:14

just give a name of like update genre

2780:17

let me just copy all of that let me just

2780:20

place it right here and change that from

2780:22

get to put so now the first thing which

2780:24

you have to do is that we have to

2780:26

provide a specific genre ID right here

2780:28

because we are providing that ID right

2780:31

here and we are getting that ID right

2780:33

here from uh or prams so now let me just

2780:36

go ahead and go to my database and now

2780:38

let me just click on there let's just

2780:41

click on what the hell am I doing oh my

2780:43

God let me just click on that now let me

2780:45

just copy that from here and now let me

2780:47

just place it right here so we are going

2780:49

to be just updating this specific genre

2780:52

and I'm going to just change the name of

2780:53

there to like um what was that the name

2780:56

yeah the name come on the name and I'm

2780:59

going to update that to like something

2781:01

else okay so now let me just click on

2781:03

this send button right here so here you

2781:04

can see our genre is now successfully

2781:07

updated to this something else so now

2781:08

let me just show you that here you can

2781:10

see this set to one and now if I refresh

2781:12

that it is going to be still set to one

2781:15

and now let me just click on that and

2781:16

here you can see our genre name is now

2781:18

set to something else right here okay so

2781:21

we can just um write another one like uh

2781:24

I don't know we have different kind of

2781:26

movies like God father and now let's

2781:30

just save there click on that send

2781:33

button so it's going to just make it as

2781:34

a Godfather let's just refresh that and

2781:37

here you can see it's going to make it

2781:38

as a Godfather and yeah this is how we

2781:40

are going to be updating our genre now

2781:42

let me just collapse it right here I

2781:43

don't want to waste your time now let's

2781:45

talk about how we are going to be

2781:46

removing our genre so for they we're

2781:48

going to be using like router. route and

2781:51

here we have

2781:52

to uh route and here we have to specify

2781:56

the specific ID and we're going to be

2781:58

using a delete method inside there the

2781:59

user should be authenticated and also

2782:01

authorizes an admin and remove genre

2782:05

okay so now let me just copy that from

2782:06

here and now let me just place it right

2782:09

here sell file and now let me just go

2782:11

ahead and register that right in here

2782:14

okay so I'm going to be just creating my

2782:15

remove genre by using the asynchronous

2782:18

Handler and provide our snc request and

2782:21

also the response as well and now inside

2782:23

there we're going to be using our try

2782:24

and catch block so for the try block or

2782:27

you know first of all let me just write

2782:29

like console. error and let me just

2782:31

place this error right here and also

2782:32

rest. status will be set to just 500 and

2782:36

Json will be set to error come on e r

2782:40

and then interal server error or

2782:43

something like that for the tri block

2782:45

what do you want to do we just want to

2782:47

get the ID first of all from where from

2782:49

the request are progams and also we have

2782:51

to just remove the specific ID is remove

2782:54

moved uh is going to be equals to A and

2782:56

then we are going to be just using our

2782:58

genre model so genre and then we are

2783:00

going to be using like find by ID and

2783:03

delete so we have this method on mongus

2783:05

and we're going to be specifying that

2783:07

specific ID right here and now what I

2783:09

want to do is that I'm going to be just

2783:11

checking if we don't have removed uh

2783:14

removed in this case what do you want to

2783:16

do we just want to show to the user like

2783:17

res. status status and it's going to be

2783:20

set to 404 not found okay so we have a

2783:24

error and we're going to be just

2783:25

specifying like genre not found it

2783:28

should be e rather and underneath that

2783:32

we're going to be just showing to the

2783:33

user like Json and removed their genre

2783:37

so now let me just save there and this

2783:38

is how we going to be removing a

2783:40

specific genre and now what I want to do

2783:42

is that I want to just go ahead and

2783:44

create a new request right here I'm

2783:46

going to give it the name of like delete

2783:48

genre and now I'm going to be just

2783:51

copying all of that now let me just play

2783:54

place right here and change that to

2783:56

delete so it is already taking this ID

2783:58

right here so we're going to have to

2783:59

specify the ID and now let me just click

2784:02

on that so here you can see we only have

2784:04

one movie and now let me just copy the

2784:06

ID of that and now let me just place

2784:08

this ID right here s our file and click

2784:11

on this send button and here you can see

2784:13

that Godfather is now successfully

2784:15

removed now let me just refresh that and

2784:18

here you can see we have zero documents

2784:20

which means like overall genre is

2784:22

totally empty so now let me just create

2784:23

the here and I'm going to be just

2784:25

creating a few more movies like

2784:28

extraction 2 and uh Jonathan Wick so

2784:33

John Wick uh John Wick 4 chapter 4 and

2784:38

also we have different kind of movies

2784:40

like I kind of just forgot the name like

2784:42

Spider-Man and we also have a

2784:45

Spiderwoman we have a Superman we have a

2784:49

Batman we have hosan man hosan is just a

2784:53

boy but very soon he will become a man

2784:56

and now let me just refresh that let me

2784:58

just go ahead and refresh that right

2785:00

here and here you can see we now

2785:02

successfully created these seven genres

2785:04

right here so yeah this is how we are

2785:06

going to be creating updating and

2785:08

deleting the genres finally not finally

2785:10

but we're going to have to do two more

2785:12

things now let's just list our genres

2785:14

I'm going to go ahead and go to my

2785:16

genres routes and also to these

2785:18

controllers and here we are going to

2785:20

just defining like router. route we're

2785:22

going to have to go ahead and gen GN r s

2785:26

like that and we're going to be getting

2785:28

all of the genres so I'm going to be

2785:30

using like get and here we have to just

2785:32

WR a list genres now let me just copy

2785:34

that and here we are going to be placing

2785:37

that right here I'm going to also

2785:39

provide a space here and also there

2785:41

let's just save there go to our genres

2785:43

controllers now let me just register

2785:45

there right here and now let me just

2785:46

create my controller con genre Or List

2785:49

genres will be equals to the

2785:51

asynchronous Handler and we're going to

2785:52

be also passing the request resp

2785:54

response and inside there we're going to

2785:56

be using our try and catch block and for

2785:58

the catch we're going to be using like

2786:00

cons. log in this case come on cons log

2786:02

of error and also the return will be set

2786:05

to response. status of 400 and also the

2786:10

Json will be set to error. message okay

2786:13

and now up above this Tri block I mean

2786:15

like inside this Tri block we are going

2786:16

to be just getting all of the genres by

2786:18

using aw and genre model and using the

2786:21

find method which you already have

2786:22

inside among use and we going to be just

2786:24

rendering all of that genres so now let

2786:26

me just save that let me just go ahead

2786:28

and create a new request right here I'm

2786:31

going to give it the name of like all

2786:33

genres like so and now let me just copy

2786:36

that and now let me just place it right

2786:39

here and in this case we're going to be

2786:40

getting there are weone getting there

2786:43

let's just see yep we are getting there

2786:45

so in this case we're going to have to

2786:46

remove this ID from there and it should

2786:48

be Johan Ros with the S and now let me

2786:51

just click on the send button and it's

2786:53

going to gives us

2786:54

error and I wasn't expecting this one to

2786:56

be honest uh okay so we have a genres I

2787:00

just misspelled I guess I'm going to

2787:01

have to copy there and now let me just

2787:03

place it right here and now let me just

2787:05

click on the genr button okay we have to

2787:08

specify the genre first of all and then

2787:11

we have to provide the genr okay so now

2787:14

let me just uh provide it once again

2787:16

with s you can rename that to like all

2787:18

genres or something like that but in my

2787:20

case this would do it for me so I'm

2787:22

going to just click on this send button

2787:23

and it's going to use all of their

2787:24

genres for me okay so we have The

2787:26

Witcher extraction Spider-Man

2787:28

Spiderwoman Batman and all of that now

2787:30

let me just sa this how we are going to

2787:32

be getting all of the genres and now

2787:34

let's talk about how we are going to be

2787:35

reading a specific genre so I'm going to

2787:38

go ahead and go to my genres and inside

2787:40

there or underneath there we're going to

2787:42

be just creating yet another route for

2787:44

what for a specific ID and we're going

2787:46

to be just reading a specific genre okay

2787:50

so I'm going to copy that and now let me

2787:52

just place it right here save my file

2787:55

and go to my controller and now let me

2787:57

just register there right here and

2787:59

create there so I'm going to create my

2788:01

read genre by using my asynchronous

2788:03

Handler we're going to be providing our

2788:05

asyn request response and inside there

2788:08

we're going to be using our try and

2788:09

catch block for the catch we're going to

2788:11

be using like error and also return of

2788:14

response status of

2788:16

400 and also the Json will be set to

2788:18

error do message and inside this Tri

2788:21

block what do you want to do we just

2788:22

want to get the Gen ra and it's going to

2788:24

be coming from aware and genre do find

2788:28

one method which is coming from the

2788:30

and we are going to be using the

2788:32

ID and request. progams and then

2788:34

specific ID right here and then we are

2788:37

going to have to just show that to the

2788:38

users so now let me just save that and I

2788:40

guess that should do it I'm going to

2788:42

just go ahead and go to my collection

2788:44

let's just create a new request right

2788:46

here and I'm going to just hide there

2788:51

and specific General something like that

2788:55

I'm going to also have to copy that and

2788:57

now let me just place it right here

2788:59

let's just remove that and here we are

2789:01

using oh we are providing the ID in this

2789:03

Cas I forgot to do this so now let me

2789:04

just go ahead and go to uh I don't know

2789:07

maybe this specific genre which is John

2789:09

Wick I'm going to copy that and now let

2789:11

me just place that right here okay so

2789:13

now if I click on this send button it's

2789:15

going to gives us that specific ID or

2789:17

their specific genre

2789:20

oh oh my God what the hell am I doing I

2789:24

providing the movie's name instead of a

2789:27

specific genr so God damn it I I'm going

2789:31

to just save this file now let me just

2789:34

go ahead and remove uh a specific oh you

2789:37

know I can do that by using right clicks

2789:40

oh my God that's a big mistake I just

2789:42

made I'm going to just delete all of

2789:44

them and that was the final part but

2789:46

thank God I realized that I made a

2789:48

mistake I was providing the movie's name

2789:51

instead of a shandra's name oh oh my god

2789:54

let's just remove that we can provide a

2789:56

Sci-Fi we can provide the acting I mean

2789:59

like romantic and there are a lot of

2790:01

them but yeah for now I am going to be

2790:05

just creating one for I don't know

2790:08

um oh

2790:10

God uh action would be fine and then

2790:13

we're going to be also creating for

2790:15

adventure I don't even know how to spell

2790:17

adventure but yeah I guess that two

2790:19

would be fine so yeah this is how we're

2790:21

going to be creating and updating and

2790:22

deleting and all of that kind of stuff

2790:25

with genres so that was the back end of

2790:27

genres so now we are totally done with

2790:29

the genres back end now let's just use

2790:32

that inside or front end so I'm going to

2790:34

go ahead and go to my front end then go

2790:36

to my SRC then I'm going to go to my

2790:39

store I mean like constants in this case

2790:42

and now let me just create a constant

2790:43

for that so I'm going to be using like

2790:45

genre URL and it's going to be equals to

2790:47

API first of all and then the version

2790:49

one and genre there we go so now let me

2790:52

just save there and now the which you

2790:54

have to do is that we have to create API

2790:55

slice for there so I'm going to be just

2790:58

creating a genre. JS and now inside

2791:01

there the first thing which you have to

2791:02

do is that we have to import our API

2791:04

slice from where from our API slice

2791:08

right here we're going to also have to

2791:09

import our genre URL and now let me just

2791:12

copy that we're going to be just

2791:14

exporting our con genre API slice and is

2791:18

going to be equals to the API slice and

2791:20

then we're going to be injecting our end

2791:22

points right here and here we just have

2791:24

to use our endpoints and we're going to

2791:25

be just passing our Builder it's going

2791:27

to be equals to or Arrow function and

2791:29

inside there first of all we're going to

2791:31

be creating the endpoint of create genre

2791:34

and it's going to be equals to Builder

2791:35

do mutation and inside there we're going

2791:38

to be just specifying the query and it's

2791:40

going to take the new genre and based on

2791:43

that new genre we are going to be

2791:44

creating a specific new genre okay so

2791:47

it's going to take the URL and in this

2791:49

case we're going to be just specifying

2791:50

our genre URL it's not going to go to

2791:53

anywhere

2791:54

but I'm going to also provide a comma

2791:55

and Method will be totally a post and

2791:59

then we're going to also have to specify

2792:00

the body of new genre and there we have

2792:03

it okay so this is how we're going to be

2792:04

creating a genre and you know what I'm

2792:06

going to just create all of the end

2792:08

points right here for all of that back

2792:10

end now let me just show you there so we

2792:12

have a genres routes right here so we

2792:14

are going to be just creating all of

2792:16

that uh and points right here so now let

2792:19

me just do that so that was for the

2792:20

first one now let me just take care of

2792:22

updating the genre and to update genre

2792:24

we are going to have to write update

2792:26

genre and then builder. mutate come on

2792:29

let's just remove the and update genre

2792:32

is going to be equals to the Builder do

2792:34

mutation because we are changing

2792:36

something inside there we're going to

2792:38

have to pass our query and we're going

2792:39

to have to past the ID and the update t

2792:42

or update gen would be fine and inside

2792:45

them uh we're going to be just passing

2792:47

our Arrow function the URL will be

2792:49

equals to or uh what do we call a genre

2792:52

URL and it's going to go to the specific

2792:54

ID and then we're going to also have to

2792:56

P our method it's going to be equals to

2792:58

the put method and now let me just P my

2793:01

body is going to be equals to the update

2793:03

genre okay so we are now totally done

2793:05

with updating the genre now let's talk

2793:07

about how we are going to be deleting a

2793:09

specific genre okay so to do that we're

2793:11

going to have to write a delete genre

2793:14

and then we have to just write a

2793:15

builder. mutation and what we want to do

2793:18

is that we're going to be using our

2793:19

query and we're going to be specifying

2793:21

the ID to that and inside there what do

2793:24

you want to do we just have to specify

2793:25

the URL and the URL will be or genre URL

2793:30

and it's going to go to the specific ID

2793:32

right here in lower case now let me just

2793:34

provide my comma and then the method uh

2793:37

will be equals to delete method because

2793:39

we are just deleting our genre now let

2793:41

me just put my comma Here and Now

2793:43

underneath that we're going to be just

2793:45

creating yet another genre for fetch

2793:47

genres like for all of their genres so

2793:50

we're going to be just using like query

2793:51

in this case we are not going to be

2793:53

doing doing anything with that but we

2793:54

are now just querying our product so I'm

2793:58

going to just write uh what do we call

2794:00

it my

2794:01

genre and it's going to go into the Gen

2794:04

R right here okay so I guess that's

2794:06

every single thing that we have to do so

2794:08

now let me just save that and yeah I

2794:10

guess that's every single thing that we

2794:12

need to do for the genres and points now

2794:15

the last thing which I want to do is

2794:16

that I want to export all of that hooks

2794:17

so I'm going to be using export con and

2794:20

we are going to be exporting this genre

2794:22

API slide nice and we are going to be

2794:25

exporting all of that hooks which is use

2794:27

create uh genre then we have the use

2794:29

update one then we have the use delete

2794:32

one and also we have the use Fetch and

2794:35

now I guess that's it save our file and

2794:38

now we are totally done with uh all of

2794:40

their genres endpoint and rtk query and

2794:43

to use that the first thing which you

2794:45

want to do is that you want to go ahead

2794:46

and go to or Pages inside these Pages

2794:49

we're going to have to create a new

2794:50

folder I'm going to give the name of

2794:52

like admin and side that we're going to

2794:54

be just creating two components the

2794:55

first one will be for the admin uh

2794:58

routes and this kind allows us to

2794:59

protect our routes the next one will be

2795:01

for the genre list. jsx right here so

2795:04

now let me just use the RFC right here

2795:07

and I am going to be using there right

2795:09

here in this component as well now let

2795:11

me just go ahead and go to my main and

2795:12

register there right here but I'm going

2795:15

to do that underneath this private

2795:17

routes right here so I'm going to just

2795:19

writing like route I'm going to also

2795:21

provide a path it's not going to go to

2795:23

anywhere and now let me just point my

2795:25

element and the element will be U my

2795:28

admin uh admin routes if I can get there

2795:32

was there routes or just route I forgot

2795:35

the name of

2795:36

that okay it's not going to be a routs

2795:40

but just a route a singular I'm going to

2795:42

also have to just rename that to let me

2795:45

just select that and rename that to just

2795:47

a specific route okay so I'm going to

2795:50

just close there and yep I'm going to

2795:52

take care of there right here I'm I'm

2795:53

going to copy that let me just go to the

2795:55

top and grab that right here so we're

2795:58

going to be just grabbing our admin

2795:59

route from where from let's just go

2796:01

ahead and go to our pages and inside

2796:04

this Pages we're going to have to go to

2796:05

the admin then we have to go to our

2796:08

admin route right here okay so we are

2796:10

now successfully grabbing our admin

2796:11

route now inside there we are going to

2796:13

be just defining another route and the

2796:15

path is going to take is something but

2796:17

we're going to also have to provide the

2796:18

element and the element will be

2796:21

genre uh list and now let me just close

2796:24

there and close this one as well and now

2796:26

for the path I'm going to be passing my

2796:28

admin and then movies and then the genre

2796:32

now let me just copy that and now I am

2796:35

going to go into the top and now let me

2796:37

just place it right here from where

2796:40

let's just go ahead and go to my pages

2796:42

once again then admin then we have our

2796:44

general list and now we are totally able

2796:47

to do there so now let me just first of

2796:48

all take care of this admin routes and

2796:50

then we are going to be jumping into

2796:52

this genre list so now let me just click

2796:54

on there and the first thing which I

2796:55

want to do is that I want to get my

2796:57

navigate or not navigation what the hell

2797:00

let me just get my navigate from the

2797:04

react router and not react router but

2797:07

react router Dom and we are going to be

2797:09

also getting the outlet from the react r

2797:12

d just a Dom there we go and now

2797:15

underneath that we're going to be also

2797:16

getting our use selector from where from

2797:20

or H God from uh or react Redux okay and

2797:26

now we are going to be using that right

2797:28

here the first thing which you have to

2797:29

do is that we have to grab the user

2797:31

information from our store which will be

2797:33

the use selector and we're going to have

2797:35

to pass our St and inside there we're

2797:37

going to be using the st. off and we're

2797:39

going to be getting our information from

2797:41

our store and now the next thing which I

2797:43

want to do is that I want to delete this

2797:45

uh return statement from there and I'm

2797:47

going to be just supporting my return

2797:49

statement right here but if you already

2797:51

have the user and if you have the user

2797:53

information and if the user is an admin

2797:56

so what do you want to do in that case

2797:57

we just want to provide the outlet and

2797:59

let's just close them but if the user is

2798:01

not an admin what do you want to do in

2798:03

that case we're going to just navigating

2798:05

that user to the login page okay and

2798:08

then we have to replace the not relative

2798:11

but replace the and let's just close it

2798:14

right here so this is how we are going

2798:15

to be protecting our admin routes and

2798:17

now let me just close them and now the

2798:19

next thing which you want to do is that

2798:20

we want to take care of this genre list

2798:22

and we going to have to do lots of stuff

2798:24

inside there like how we're going to be

2798:26

creating the genre updating the genre

2798:28

and all of that so the first thing which

2798:31

I want to use that I want to grab a lot

2798:33

of things so we're going to be just

2798:34

grabbing the use St uh St like that and

2798:38

then we would also need to grab or let's

2798:41

just grab import or something from the

2798:45

Redux toolkit so let's just go ahead and

2798:48

go to the Redux then the API and then

2798:50

the

2798:51

genres uh

2798:54

yeah I guess the genre would be fine and

2798:57

we're going to be getting our use create

2798:59

um genre mutation use update and yeah

2799:02

also the use uh come on let me just put

2799:05

a space in here and use

2799:07

update update genre mutation use delete

2799:11

one is also fine and we're going to also

2799:13

have to get the use fet genre as well so

2799:15

now let me just save that and there's

2799:17

all of the hook which we have to grab

2799:19

and then we also have to grab the toast

2799:22

from where from from the react toasttify

2799:24

because we're going to be also using the

2799:26

toast and yeah that's going to be fine

2799:28

and now we're going to have to take care

2799:30

of the actual component now inside this

2799:32

genre list what I want to do is that I

2799:34

want to get my uh come on I want to get

2799:38

my data and I want to rename that data

2799:40

to genres and then we're going to be

2799:43

also using the refetch uh to refetch our

2799:46

product once again and then we're going

2799:48

to be grabbing that from us genre query

2799:51

and underneath that we're going to be

2799:52

just creating a for the name and set

2799:54

name is going to be equal to the use

2799:56

selector and we're going to be just

2799:58

passing our empty string right here and

2800:00

then the next thing which we have to do

2800:01

is that we have to just write a selected

2800:03

genre and then we have to just write a

2800:05

set selected genre status going to be

2800:09

equals to the used stad and we're going

2800:11

to be providing the initial value of

2800:13

null to it now let me just create one

2800:15

for the update or updating upd a t n

2800:20

updating the name and set updating the

2800:23

name it's going to be equals to the usad

2800:26

and we're going to be just providing the

2800:27

empty string now let me just provide one

2800:29

for the model which we're going to be

2800:31

creating in a few seconds so we have a

2800:33

model visible and it's going to be

2800:35

equals to set model v i s IBL e it's

2800:38

going to be equals to or use St and

2800:42

we're going to be just passing the

2800:43

initial value of false to it okay so v i

2800:45

s i b e yep the spelling is correct now

2800:48

we have to use our rtk query and we're

2800:50

going to have to destructure our

2800:52

functions from there so we're going to

2800:54

be just uh restructuring our create

2800:57

genre come on create genre and we are

2801:00

going to be just getting there from the

2801:01

use create genre mutation and now we

2801:05

going to be also getting uh what do we

2801:07

call it uh update genre it's going to be

2801:10

equals to the use first of all and

2801:13

update genre and then we have to just

2801:15

get one for the delete uh genre it's

2801:18

going to be equals to the use delete

2801:21

genre and now let me just execute the

2801:23

now I'm going to go ahead and go to my

2801:25

jsx area right here and I'm going to be

2801:27

just placing this div can and I want you

2801:30

to do the same so now let me just save

2801:31

there and I'm providing The Styling

2801:33

right here now inside there we're going

2801:35

to be just placing this D and I want you

2801:37

to do the same and that's because I

2801:39

don't want to write my styling so now

2801:40

let me just write my H1 and now let me

2801:42

just provide my height uh or yeah h of

2801:45

12 and uh genres and now let me just

2801:48

save there restart there so I'm going to

2801:50

be using npm run full stack in this case

2801:53

case and it's going to just start our

2801:54

server on this port and now let's just

2801:56

click on that and it's going to just

2801:58

start our server and now let me just log

2802:00

in as an admin uh log in as an admin so

2802:04

I am going to log in as husan

2802:08

gmail.com and hosan one2 so now let me

2802:10

just click on there now I am going to go

2802:13

ahead and go to my dashboard but before

2802:16

I do you know I am going to go ahead and

2802:19

go to my genres and not allowed let me

2802:21

just go ahead and go to my

2802:23

and we're going to have to WR Airman and

2802:25

then genres I mean like Airman movies

2802:27

and then genres so let's just remove

2802:29

that from here and now let me just place

2802:31

that and hit enter and here you can see

2802:33

it's going to give us that manage genres

2802:35

right here and that's totally cool and

2802:38

now the next thing which I want to do is

2802:39

that I want to create a separate form

2802:40

component for the specific genre so I am

2802:43

going to be just passing that right here

2802:45

so we have a genre form and we're going

2802:47

to be just passing the value of value I

2802:50

like the value of name the state which

2802:52

we are already creating up above and

2802:54

then the set value v l is going to be

2802:57

equals to the set value and we're going

2803:00

to be just also passing the handle

2803:02

submit to that and the handle submit

2803:04

will be the handle and we are going to

2803:07

be creating this function in a few

2803:08

seconds but I'm just wondering should I

2803:11

create it right now or

2803:12

later I don't know man oh this shouldn't

2803:16

be a set value but instead should be a

2803:18

set name rather and now let me just take

2803:20

care of this genre form I'm I'm going to

2803:23

go ahead and go to my components and I'm

2803:25

going to be just defining a new

2803:26

component which will be a genre form.

2803:29

jsx and now let me just use my RFC sell

2803:32

my file and now let me just grab that

2803:35

right in here okay so now let me just

2803:37

Auto Import that it's going to just

2803:39

import it right here so now let me just

2803:41

save this file and now let me just go

2803:43

ahead and go to my genre form and take

2803:46

care of that so the first thing which I

2803:49

want to do is that I want to restructure

2803:50

a few things like the value the Set uh

2803:54

set was there a set value or the name

2803:57

set value and also the

2804:01

hand uh handle submit and we are going

2804:04

to be also passing the button text as

2804:06

well but I'm going to just specify the

2804:08

initial value of submit to there we're

2804:10

going to take care of that bit later and

2804:11

we're going to be also passing the

2804:13

handle delete to there as well okay so

2804:16

now let me just save there and I guess I

2804:18

have to specify the comma I forgot to do

2804:21

there let me just save there now inside

2804:23

this return statement I'm going to be

2804:24

just passing the padding of three all

2804:26

around and then I'm going to just remove

2804:29

that from here inside this D we're going

2804:31

to be creating a form it's not going to

2804:33

take any actions it's going to just take

2804:35

only the own submit and when somebody

2804:37

submit this form so we're going to be

2804:38

just spacing our own I mean like handle

2804:40

submit button right here and it's going

2804:42

to take the on submit Handler and we're

2804:44

going to be just passing the handle

2804:45

submit right here and then the classes

2804:48

will be just space for the Y AIS of

2804:51

three and now inside this form we're

2804:52

going to just spacing our input and the

2804:55

type will be text but we're going to

2804:56

also have to specify the class name of

2804:58

pairing for the y axis of three pairing

2805:00

for the xaxis of four and also the

2805:03

Border uh rounded totally large and with

2805:06

will be set to 60 rim and now let me

2805:10

just close that and we're going to be

2805:12

also providing the placeholder for that

2805:14

which will say right uh right genre name

2805:18

now let me just save that so that we can

2805:20

see everything a bit better and we're

2805:21

going to be also ping the value of value

2805:23

today and then the on change we're going

2805:26

to be just passing the E and also it's

2805:29

going to take the set value and we're

2805:31

going to have to paste the E target.

2805:33

value right here in this case and now

2805:35

let me just save there underneath this

2805:37

input what you have to do we're going to

2805:39

be just creating yet another day with

2805:40

the class of F and I am going to also

2805:43

providing the justify of between to that

2805:46

and now inside there we're going to be

2805:47

just creating a button and it's going to

2805:49

be a huge

2805:50

button let's just remove that and now me

2805:52

just copy that button right here and now

2805:55

let me just place it right here sa file

2805:57

and you should do the same and now the

2806:00

need this button what do you have to do

2806:01

we're going to be just creating a handle

2806:03

delete button and inside that we're

2806:07

going to have to provide our button

2806:08

right here so now let me just put my

2806:09

button let's just close there like so

2806:13

and we're going to be also attaching the

2806:14

on click event hander on there and

2806:17

handle delete we're going to be just

2806:18

passing and it's going to be just

2806:19

responsible for deleting a specific

2806:21

genre and now let me just provide the

2806:23

styling to it so now let me just save

2806:25

that and you should also provide the

2806:26

styling right here as well and I am

2806:29

going to be also providing this delete

2806:32

right here and this should be F

2806:35

ooc us there we go and I guess that's it

2806:39

because we are going to be creating a

2806:41

genre and we're going to be also able to

2806:43

delete a specific genre right here okay

2806:46

so yeah we are doing every single thing

2806:48

right here but we have to take care of

2806:49

this handle create genre and we're going

2806:51

to do that in a few seconds but now

2806:53

underneath there oh you know let me just

2806:56

take care of that other stuff because we

2806:58

want to also show the specific genas

2807:01

right here if you just create that I

2807:02

don't want to show everything in the

2807:04

console I want to show every single

2807:05

thing inside the desktop so I'm going to

2807:07

be just using a div with the class of

2807:09

flex so now let me just use a flex and

2807:11

also the flex will be set to wrap and

2807:13

inside there we are going to be just

2807:14

iterating over the genres if we already

2807:17

have there so we're going to be just

2807:18

using the map method and we're going to

2807:20

be just passing our specific genre and

2807:23

then we have to just use our div and

2807:25

inside this div we're going to be also

2807:27

providing a specific key of uh the genre

2807:32

and ID a specific genre ID right here

2807:35

and now let me just close the uh I don't

2807:37

know why it didn't close itself but now

2807:39

inside this D what do I have to do I'm

2807:42

going to be creating a button right here

2807:43

and now let me just close that and I am

2807:45

going to be providing a lot of CSS so

2807:48

now let me just save there and you

2807:49

should provide the same and now let me

2807:51

just use the on on click on click event

2807:54

handler on there and we're going to just

2807:56

passing this uh what do we call it this

2807:59

function right here and it's going to

2808:00

just take the object of set model

2808:05

visibility or visible and it's going to

2808:07

be set to true now let me just save

2808:09

there and I'm going to be also providing

2808:10

the set

2808:12

selected um genre right here it's going

2808:14

to be also set to genre and we're going

2808:16

to be also providing the set updating

2808:19

name it's going to be equals to the

2808:20

genre. name because we are are already

2808:24

defining the right in here okay so we

2808:27

are already defining them and that's why

2808:30

we are now providing there right here

2808:31

and as a button label we're going to be

2808:33

just rendering our genre name okay so

2808:36

this is going to be the label of our

2808:37

button so genra name and this is how we

2808:40

going to be rendering there now

2808:41

underneath this div what do I have to do

2808:44

I'm going to be just creating a new

2808:45

component for the specific model and

2808:47

we're going to be providing the

2808:48

attribute of is open and if it's open

2808:51

we're going to be passing the model

2808:53

visible right here in this case and when

2808:55

it's close on close we are going to be

2808:59

just passing our aror function in this

2809:01

case and it's going to just take like

2809:03

set model visible and it's going to be

2809:05

set to false in this case and now let me

2809:07

just close that like so okay we're going

2809:10

to be just creating there but inside

2809:11

that we're going to also have to pass

2809:12

for genre form or yeah genre form and

2809:16

now let me just close there and we're

2809:18

going to be providing a lot of prop St

2809:20

so the value will be set to updating

2809:22

name and also the set value will be also

2809:25

set to the value and then the set

2809:29

updating name will be also taking the

2809:31

Valu so now let me just save there and

2809:33

this is how it looks like for now but

2809:34

we're going to be also passing the

2809:35

handle submit and it's going to be

2809:38

taking that handle update genre and

2809:41

we're going to be creating there in a

2809:42

few seconds but I want you to bear with

2809:44

me so update

2809:47

genre and then we have to also specify

2809:50

the button text off set to update in

2809:53

this case and underneath that we're

2809:55

going to be also providing the handle

2809:57

delete in this case and it should be the

2810:00

handle come on handle delete genre in

2810:04

this case Okay so yeah that's cool but

2810:07

we're going to have to create these

2810:08

three uh what do you call these three

2810:11

function in a few second we're going to

2810:12

be creating there but first of all now

2810:14

let me just create this model component

2810:16

inside my components folder right here

2810:19

I'm going to create my model. jsx and

2810:22

now let me just use my RFC sell my file

2810:25

and now let me just grab that right here

2810:27

so we have a model and it's going to

2810:28

just Auto Import that for me sell file

2810:31

and now let me just take care of the the

2810:33

first thing which you have to do is that

2810:34

we have to do our destructuring so we

2810:36

have the is open and then we have the on

2810:39

close and then we also have a children

2810:41

right here okay so now let me just

2810:43

remove that from here I'm going to also

2810:44

remove these divs and I'm going to just

2810:46

leave it as a fragments and inside there

2810:49

is open and we're going to have to

2810:51

specify some sort of a GSX right here

2810:53

inside there and what I want to do is I

2810:56

want to create a div and it's going to

2810:58

just take the class name of fixed and

2811:01

also the inser will be set to zero and

2811:05

also we have a flex and items will be

2811:06

set to Center justify will be set to

2811:08

Center Z index will be set to 50 and now

2811:11

inside that we're going to be just

2811:12

creating yet another div for a separate

2811:15

so I'm going to be just creating a d

2811:16

with the class of fixed and inser will

2811:19

be set to zero and also we have a

2811:21

background totally black and opacity

2811:24

will be set to 50 okay and now

2811:26

underneath that what do you want to do

2811:28

we just want to create another D with a

2811:30

class of absolute and the top will be

2811:33

just this arbitrary value which is

2811:35

40% let's just close that and left will

2811:38

be also set to uh 20% let's just close

2811:42

that background will be set to totally

2811:44

white pading all around will be set to

2811:46

four and rounded will be set to totally

2811:48

large Z index will be set to 10 and text

2811:52

Will set to totally right okay so inside

2811:55

there we're going to be just creating a

2811:56

button now let me just create a button

2811:58

and I'm going to just put a class names

2811:59

off there like text will be set to

2812:01

totally black and also the font will be

2812:04

set to semi bold

2812:06

and how will be set to text of totally

2812:09

gray of 700 I'm going to be also

2812:12

providing the focus stat on there and

2812:14

when it's focused the outline will be

2812:16

none and margin for the right will be

2812:18

set to two and for the label or you know

2812:21

uh yeah for the label we're going to be

2812:22

just providing this x word here and when

2812:24

somebody clicks on that on click uh

2812:27

we're going to just closing or St so now

2812:30

let me just save there and underneath

2812:32

this but we're going to be just

2812:34

providing our children right here okay

2812:36

now let's just save there and there was

2812:38

about 4 model let's just close that and

2812:40

now let me just create these functions

2812:42

right here okay so now let me just close

2812:44

this let me just comment this line out

2812:46

this line and I'm going to also comment

2812:48

this line out as well now let me just

2812:50

save that and here you can see it's

2812:51

going to giv us this UI right here so if

2812:53

I click on that it's going to open that

2812:54

specific uh genre we can update that we

2812:57

can delete that we can do a lot sort of

2812:59

stuff with there if I click on this

2813:00

action we can just open and close our

2813:02

model right here and now let me just

2813:04

take care of creating the genre so now

2813:07

let me just save there copy the name of

2813:10

that and now let me just create my genre

2813:12

right here I'm going to just write a con

2813:15

create handle create genra will be now

2813:16

equals to the asynchronous function it's

2813:19

going to take the event and inside there

2813:21

we're going to be just preventing the

2813:23

default so prevent default DFA ul and

2813:28

now let me just execute them and we're

2813:30

going to be checking if we don't have

2813:32

the name so what we want to do in that

2813:33

case we just want to show to the user

2813:35

this toast dot come on toast. error and

2813:39

we just want to say that genre name is

2813:42

required okay and we just have to return

2813:46

then there will be able to specify a new

2813:47

genre name to there and now let me just

2813:49

use my try and catch blockings

2813:51

underneath there let me provide a conso

2813:53

loog for the catch blocks and now let me

2813:55

take care of const result is going to be

2813:59

equals to the A and create genre uh

2814:02

which we are getting from the rtk query

2814:04

and we're going to have to past this

2814:06

name right here and just unwrap that and

2814:08

now underneath that what do you have to

2814:09

do we just have to check if you already

2814:11

have the result. error so what you want

2814:13

to do in that case you just want to show

2814:15

this toast to the user like we have some

2814:17

sort of error which is coming from the

2814:19

result and now if that's not the case

2814:21

what do you want want to do we just want

2814:22

to set the name to totally empty string

2814:25

and we also have to just write a toast

2814:27

and then we have to show some sort of a

2814:29

success toast right here so we just want

2814:31

to show to the user that uh r. name uh

2814:35

is created so it's going to just give us

2814:37

the genre name is created and then we

2814:39

also have to refetch all of our genre so

2814:41

that we can see the newly created data

2814:44

so now let me just save there and it's

2814:45

going to just allows us to create this

2814:47

genre but we would not able to see that

2814:50

and to see that for that we're going to

2814:51

have to create this

2814:53

function uh which we have right here so

2814:55

we have a handle update one so you know

2814:57

what let me just create a genre right

2814:58

here so I am going to just say like I

2815:01

don't know another action or something

2815:03

like that and now if I click on the

2815:05

submit button so it's going to give us

2815:06

that toast and it's going to also gives

2815:08

us that another button right here but if

2815:10

I click on that we cannot update that

2815:12

and we cannot delete there now let me

2815:14

just create my con uh handle up there

2815:18

genre it's going to be equals to the as

2815:20

synchronous function and we're going to

2815:21

have to re our event and now let me just

2815:24

use the prevent default and now

2815:26

underneath what you want to do we just

2815:27

want to check if we have I mean like if

2815:29

you don't have updating name so we're

2815:31

going to be just writing a toast. error

2815:33

and we're going to be just saying like

2815:35

genre name is required like so RQ uied

2815:42

and we just have to return it out and

2815:45

underneath that we're going to also have

2815:46

to just write our trying catch block and

2815:48

for the catch block we're going to just

2815:50

saying this eror conso ER of error and

2815:53

for the tri block you know let me just

2815:54

save there for the tri block we're going

2815:56

to be just getting the result so con

2815:59

result will be now equals to the A and

2816:01

we're going to be using our update genre

2816:04

from the rtk query and we are going to

2816:05

be just specifying the ID of selected

2816:07

genre and their specific ID and then we

2816:11

also have to just write a uh updated

2816:12

genre and then we have to specifically

2816:15

Define that name which we are getting

2816:17

from the updating name not genre but

2816:19

updating name what was

2816:22

updating name okay so now let me just

2816:25

put a comma here and we just have to

2816:27

unwrap that okay and now let me just

2816:29

execute that underneath that we're going

2816:31

to be just checking for the error so if

2816:33

you have the result. error so what do

2816:34

you want to do in that case we just want

2816:36

to show this toast. error to the user so

2816:39

we have the result. error and now if

2816:41

that's not the case so what do you want

2816:43

to do in that case we just want to show

2816:44

the success message to the user and

2816:47

we're going to be just saying that uh

2816:49

result. name is updated

2816:52

okay and now underneath there what do

2816:54

you want to do we just want to refesh or

2816:56

data so

2816:57

refet or data and that was a lot of

2817:01

talking but now let me just uh empty out

2817:04

all of our state and visibility and now

2817:06

let me just place it right here okay so

2817:08

now let me just save that I'm going to

2817:10

just refresh my browser and now let me

2817:12

just click on this another action I'm

2817:13

going to just say another

2817:17

adventure okay now if I click on this

2817:19

update it's going to give us their toast

2817:21

and it's going to ALS gives that another

2817:23

adventure right here so I can totally

2817:25

remove this adventure right here and I

2817:28

can just write update and now let me

2817:29

just click on there it's going to just

2817:31

update it right here now let me just

2817:33

take care of deleting the specific uh v

2817:36

i s i b God damn it I'm going to have to

2817:39

rename that again and again so we have

2817:41

model v i s i b so we're now changing

2817:46

that right here and we are also changing

2817:50

that right in here

2817:52

okay so now let me just show you there

2817:55

we're also changing that right here so

2817:57

now let me just save that and test this

2817:59

out one more time I'm going to click on

2818:00

that and we have another so I'm going to

2818:03

just change that to hosan movies I'm

2818:05

going to click on that so everything is

2818:07

working totally a okay and yeah that's

2818:10

cool but now let me just take care of

2818:11

deleting a genre I'm going to just

2818:14

uncomment there let's just check this

2818:16

out I'm going to go ahead and go to my

2818:17

genre form and you know what I am going

2818:20

to just change that to oh c us save this

2818:24

file I'm going to go ahead and create

2818:25

that let's just copy that from here

2818:29

and excuse me and CPS it right

2818:33

here delete genre what the hell d e l

2818:38

e at t e d l e t genre there we go I'm

2818:44

going to have to copy this one first of

2818:45

all and check out or delete Focus F OC

2818:50

us and we we have a delete come on

2818:54

delete

2818:58

genre and we're not using that that's

2819:01

because we did not create this function

2819:02

now let me just copy that and we are

2819:05

going to be just creating that right

2819:06

here and now let me just place right

2819:08

here it's going to be equals to this as

2819:09

synr function and inside that we're

2819:12

going to be using our try and catch

2819:13

block for the catch we're going to be

2819:15

copying there and we're going to just

2819:18

placing this console. error and these

2819:20

errors right here and for the tri block

2819:23

what do you want to do you just want to

2819:24

get the result first of all C result and

2819:26

it's going to be coming from the event

2819:28

and delete genra which we just corrected

2819:31

a few seconds ago and we're going to

2819:33

have to proide our selected genre and

2819:35

then there specific ID inside there and

2819:37

let's just unwrap there and we're going

2819:39

to have to check for the errors first of

2819:41

all so if you have some sort of error

2819:42

like result. error so we're going to be

2819:44

using the toast. error right here and

2819:47

the result. error okay so now outside

2819:50

from that that's not the case so we're

2819:52

going to be using our to. success and

2819:55

then we have to just specify the result.

2819:57

name is deleted so is deleted

2820:01

d

2820:03

o and we're going to also have to

2820:05

refetch or I God r e f e t c and now

2820:10

let's just execute the insert selected

2820:13

genre we be now set to totally now and

2820:16

then we have a set model method or

2820:18

visible will be now set to totally false

2820:20

so now let me just save that let me just

2820:22

click on this hosen and now if I click

2820:24

on this specific genre so it's going to

2820:26

just delete it right here so if I check

2820:28

out my database so now let me just go

2820:30

ahead and go to my mongodb right click

2820:32

on there and click on refresh so it's

2820:33

going to gives us that uh genres and

2820:36

here you can see we only have these two

2820:37

genres right here now let me just delete

2820:39

them as well click on delete and also

2820:43

click on delete as well refresh them and

2820:46

refresh this database so this is how

2820:48

we're going to be just removing every

2820:50

single thing from our database

2820:52

and yeah what I want to do is that I

2820:54

want to create a few genres so we have a

2820:57

action we have

2820:58

romance we have uh comedy c m a d y I

2821:03

guess this how you spell comedy I don't

2821:05

even know how to spell comedy and then

2821:08

uh we have

2821:10

Adventure H I forgot the name but now

2821:13

let me just change that to

2821:15

Adventure and yeah I guess that would be

2821:17

fine and now let me just refresh that so

2821:19

it's going to gives us that four genres

2821:20

right here so yeah that was it about for

2821:23

the genres in this m project we are now

2821:26

totally done with the genres so now let

2821:27

me just close all of these files and I'm

2821:30

going to go ahead and go to my back end

2821:31

folder so I'm going to collapse that let

2821:34

me just go ahead and go to my back end

2821:35

and we're going to be first of all

2821:36

creating a model so I'm going to just

2821:38

give the name of like movie. JS and

2821:40

inside there first of all you need

2821:42

mongus from the mongus and then we are

2821:44

going to be destructuring the object ID

2821:46

from where from the come on mongus

2821:51

M s so we are going to be destructuring

2821:53

our object ID and now underneath that

2821:56

we're going to be creating our movie

2821:57

schema right here it's going to be

2821:59

equals to the new mongus do schema and

2822:02

inside there what you want to do our

2822:04

movie will have some sort of a name so

2822:06

the name will be type of string and also

2822:08

totally required and also we're going to

2822:10

be taking care of the image which we're

2822:12

going to be doing in a few second but it

2822:14

should also be a type of string and then

2822:16

we have to take care of the year and now

2822:19

let me just put a type of number in this

2822:21

case and also this should be required to

2822:24

and now underneath that we're going to

2822:26

be also taking care of the genre and we

2822:28

are going to be going into the object ID

2822:31

and now we're going to be providing a

2822:32

reference to our genre uh model we've

2822:35

already created right here okay so now

2822:37

let me just Prov required and it should

2822:40

be required and now underneath that what

2822:42

do we have to do we're going to be

2822:43

providing our detail and the detail will

2822:46

be type of string and also totally

2822:48

required will be now said to True let me

2822:50

just provide a cast and the cast will be

2822:53

array of objects so type of string and

2822:56

now inside that we're going to be also

2822:58

providing reviews and for the reviews we

2823:00

are going to be just creating this

2823:02

review schema in a few second but I want

2823:05

you to just bear with me for a few

2823:06

seconds so now underneath that let me

2823:08

just also provide the number of reviews

2823:11

on a specific movie so then we're going

2823:13

to be providing a type of uh not string

2823:15

but number to that and also required

2823:17

will be set to three and the default

2823:19

value we're going to be specifying zero

2823:21

and it should be required there we go

2823:24

now let me just provide a comma and

2823:27

create it at create come on

2823:30

created at will be equals to the type of

2823:33

date and then the default date will be

2823:36

just date do now okay we're not going to

2823:39

be executing there now underneath there

2823:41

let me just put my timestamps and it

2823:43

should be true now let me just save

2823:45

there and now let me just take care of

2823:47

this review schema so I'm going to just

2823:49

create that right here and I'm going to

2823:51

just the name of like review r v i e w

2823:54

schema it's going to be equals to mongus

2823:57

do schema and inside there we're going

2823:59

to have to provide the name first of all

2824:01

and the name will be the type of string

2824:04

and also totally required will be set

2824:07

true underneath that we're going to be

2824:09

also providing a rating for the review

2824:11

so I'm going to just say the type uh of

2824:14

number and also required to true and now

2824:18

underneath that let me just provide a

2824:19

comment and the type will be set to

2824:21

string and also the required come on

2824:25

required will be set to true as well now

2824:27

underneath that we're going to be also

2824:29

providing a specific user like who is

2824:31

writing this specific review so we're

2824:33

going to be just writing a type of

2824:35

mongus and then schema and then types

2824:39

let me just get my types and then the

2824:41

object ID and now underneath that we're

2824:43

going to be providing the required of TR

2824:46

and also the reference will be set to

2824:48

user time Stamps will be now set to true

2824:51

and now let me just save there and this

2824:52

is how we're going to be creating both

2824:54

of our schemas so now let me just export

2824:56

it right here I'm going to be using

2824:58

export movie and it's going to be equals

2825:01

to model and here we're going to

2825:04

be just passing over movie let's just go

2825:06

back and now let me just for my movie

2825:08

schema oh God chtm and now let me just

2825:13

export or you know it should be const

2825:15

and now let me just export that right

2825:17

here so export default of movie Okay so

2825:21

movie there we go now let me just save

2825:23

that and we are now totally done with

2825:25

the schema right in here now let me just

2825:28

add a route for myself and now here

2825:30

we're going to be just using like app.

2825:32

use and first of all we're going to be

2825:33

going into the API then the version one

2825:36

and then okay now let me just paste my

2825:38

movies routes or yeah movies route would

2825:41

be fine let me just copy this save this

2825:43

file and now let me just create the file

2825:45

right here I'm going to just name it the

2825:47

m routes.js and now inside there first

2825:50

of all let me just grab my Express prom

2825:53

Express and also let me just create an

2825:55

instance of a router so we're going to

2825:57

be using Express dot come on what the

2826:00

hell and now let me just execute that

2826:03

we're going to be importing our

2826:04

controllers and also the Middle where as

2826:07

well and you know what I'm going to just

2826:09

import my authenticate and also

2826:11

authorizes an admin middleware right and

2826:14

you know what we're going to be also

2826:15

creating yet another middleware so I'm

2826:17

going to go ahead and go to my middle

2826:18

wees and I'm going to be creating my

2826:20

middleware of

2826:22

uh what do we call it the check id. JS

2826:24

and now inside there first of all we're

2826:26

going to be importing something from the

2826:29

Muse and that something will be uh is

2826:33

valid object ID okay so we're going to

2826:36

be grabbing that and now let me just

2826:38

create my middleware right here come on

2826:40

we can't even create a function what the

2826:41

hell is wrong let me just create my

2826:43

function right here and I'm going to

2826:45

just give it the name of like check ID

2826:46

is going to take the request and also

2826:48

response and we're going to be also

2826:49

providing a next to it because this uh

2826:51

middleware and now we're going to be

2826:52

checking if we don't have the is uh

2826:55

valid object we're going to be

2826:56

specifying or request or prams and then

2826:59

ID and if that's not the case what do

2827:01

you want to do we just want to show to

2827:03

user like r. status or 404 underneath

2827:07

that we just have to throw new error and

2827:09

we would say uh come on error and we

2827:11

will say that uh invalid object off and

2827:16

then let's just pass our request. pr. ID

2827:19

right here and now finally we just just

2827:21

have to use our next and provide our

2827:23

middle right here and now let me just

2827:24

export that export default of check ID

2827:27

and now let me just save there and here

2827:29

we have to use that I'm going to close

2827:31

this file and we're going to have to

2827:32

grab that right here so I'm going to be

2827:34

using check ID check ID from where from

2827:38

let's just go ahead and go to our midw

2827:40

right here and then we have to grab that

2827:42

from the check id. JS yeah we also have

2827:46

to specify the do JS right here because

2827:49

it's going to just throw us an error now

2827:51

let me just save that and I'm going to

2827:53

go back and the first thing which you

2827:54

want to do is that we want to create our

2827:56

public routes so we have a public routes

2827:59

then we are going to be creating a

2828:01

restricted uh routes as well and we're

2828:04

going to be also creating a routes for

2828:05

the admin specifically okay so now let

2828:08

me just create a public routes like

2828:09

those route which will be accessible for

2828:11

all of the users so now let me just

2828:12

create a router. g and we're going to be

2828:15

specifying all movies and here we just

2828:17

have to specify the get all movies let

2828:20

me just copy that from here

2828:21

and we're going to be restructuring

2828:23

there but first of all we have to create

2828:24

our controllers and I'm going to just

2828:26

create the name of like movie

2828:29

controller.js and now inside there the

2828:31

first thing which you would do is that

2828:32

we would grab our movie R uh let's just

2828:36

go ahead and go to our model where is

2828:38

our model and now inside that we're

2828:40

going to be grabbing our model from our

2828:42

model right here okay so the first thing

2828:44

which you have to do is that I just made

2828:47

a mistake uh I'm not going to be

2828:49

providing my you know I'm going to just

2828:51

just comment this line out for a second

2828:52

because first of all we have to create

2828:54

something then we would be able to

2828:56

access that so now let me just save the

2828:57

word here like only the admin would be

2828:59

able to create a new movie so we're

2829:01

going to be just using like router.

2829:02

poost and now let me just provide a

2829:04

create movie and first of all the user

2829:06

should be authenticated and then

2829:08

authorize as an admin then they would be

2829:10

able to create a movie okay m o v i e

2829:14

now let me just copy that from here sve

2829:16

my file and let me just go ahead and

2829:18

create that right here and to create a

2829:20

movie it is totally simple so we're

2829:22

going to be just creating our create

2829:24

movie let's just pass our as synness I

2829:26

mean like asking function request and

2829:28

response and then inside there we're

2829:30

going to be just using our TR and catch

2829:32

block and for the catch block we're

2829:34

going to be just providing like pr.

2829:35

status of 500 and also the do Json and

2829:39

now let me just pass my error and here

2829:41

we're going to be using the error do

2829:42

message M Ms AG G and now let me just

2829:46

create a new movie and it's going to be

2829:47

equals to the new movie schema and we're

2829:50

going to or model we're going to be

2829:52

providing our request. body and then we

2829:55

have to just provide a saved movie it's

2829:57

going to be equals to the await and

2829:59

let's just save that new movie to our

2830:02

database by using the same method which

2830:04

will be coming from Mose and then we

2830:06

have to use our response. Json and let's

2830:08

just P our Ser come on Ser movie oh my

2830:12

God Ser movie there we go okay so now

2830:15

let me just save that and finally we

2830:16

have to export this we're going to be

2830:18

using export create movie and now let me

2830:20

just cop copy this sa there right here

2830:22

let me just go ahead and go to my movies

2830:25

controller I me like movies routes and

2830:27

we're going to be grabbing our

2830:28

controller right here from where we're

2830:31

going to be grabbing there from let's

2830:33

just go ahead and go to our controllers

2830:35

and we're going to be grabbing there

2830:36

from the movies controller okay so now

2830:38

let me just pass my um movies control I

2830:40

mean like create movie and we're going

2830:42

to be also passing the right here which

2830:44

we are already doing there but finally

2830:46

we have to export default or router okay

2830:49

so now let me just save there and we

2830:50

also have to grab the inside this index

2830:52

so we're going to be just grabbing that

2830:53

right here so we have a movies routes

2830:56

from let's just go ahead and go to

2830:59

routes uh routes and inside there we

2831:02

have a movies routes right here so now

2831:03

let me just save that we're going to be

2831:05

using npm run backend and now let me

2831:07

just hit enter and we are indeed getting

2831:10

an air inside a movie controller

2831:13

so huh let's just go ahead and go to our

2831:15

movie controllers and I just messed up

2831:19

something no nothing so we have some

2831:21

error right

2831:23

okay yeah we are grabbing there right

2831:26

here what's wrong oh here you can see we

2831:29

are not providing the do JS now let me

2831:31

just PR that and let's just restart our

2831:34

npm run back it one more come on npm run

2831:37

back and there we go so it's going to

2831:39

just restart our back end and now let me

2831:41

just test in my post man and let's just

2831:43

close all of them right here and now let

2831:46

me just take care of the movies so we're

2831:48

going to be just creating a new folder

2831:50

I'm going to just give the name of um

2831:53

movies detail or movies will be fine

2831:55

rather and we are going to just creating

2831:57

a new request right here inside there

2831:59

and I'm going to just create the name of

2832:00

like create movie there we go and let's

2832:04

just close this one and we're going to

2832:06

just grabing or uh link from there and

2832:09

now let me just place it right here let

2832:10

me just put my post method right here

2832:13

and in this case we're going to have to

2832:14

go to the movies let me just see uh

2832:18

we're going to be going into the movies

2832:20

right here and then we have to

2832:22

specifically specify the create movie

2832:24

right here okay so let's just write a

2832:26

create movie and now let me just go

2832:28

ahead and go to my body let me just

2832:30

click on the raw and it is already set

2832:31

to adjacent so we're going to be just

2832:33

proving a few things for the movie Let

2832:35

me just go ahead and go to my movie so

2832:37

is taking the name the image the year

2832:40

and genre detail cast reviews new uh

2832:43

reviews and also the created ad so you

2832:46

know first of all let me just provide a

2832:48

name so I'm going to just provide the

2832:49

name of uh name of

2832:54

extraction uh two or something like that

2832:56

now let me just click on the send button

2832:58

so it's going to just give us like movie

2832:59

validation P detail is required genre is

2833:02

required and also the year is required

2833:04

so we're going to also have to provide

2833:06

that so now let me just provide all of

2833:07

them so the next one we have is the

2833:10

image so we're going to be just

2833:11

specifying the random image right here

2833:13

let me just provide like image.png which

2833:16

we don't have right here but we are just

2833:18

providing there for the string and now

2833:20

let me just proide the e here and the

2833:21

year I don't know when this movie was

2833:23

released but I'm going to just provide a

2833:25

2024 or 23 would be fine and now we have

2833:29

to also provide a genre and then for the

2833:31

genre we are going to have to

2833:32

specifically specify our genre let me

2833:34

just go to my mongodb let me just open

2833:37

there let me just go to my genres and

2833:39

I'm going to just go ahead and go to

2833:40

this action R right here let me just

2833:42

copy that and we're going to be just

2833:44

providing there right here okay so let's

2833:46

just close there and that was required

2833:48

so now we are totally providing there

2833:50

now the next next one we have is a

2833:51

detail and we are now going to be

2833:53

providing some sort of a detail right

2833:55

here like um

2833:58

detail detail and it was the best action

2834:04

movie ever or something like that let me

2834:06

just provide a comma and then we have to

2834:08

provide a cast and the cast will be I

2834:11

don't know uh

2834:13

John do and Alex now let me just provide

2834:19

what else reviews so

2834:21

uh I'm going to just leave the review

2834:22

right here we will provide the later but

2834:24

not right now so yeah I'm going to just

2834:28

leave the review right now let me just

2834:30

for a number of or you know we're not

2834:31

going toing number of review and

2834:33

everything else should be fine now let

2834:35

me just close that let me just remove

2834:37

that from here go back let's just zoom

2834:39

in a bit so we are not providing all of

2834:41

that data right here now let me just

2834:42

click on the send button and here you

2834:44

can see that movie is now successfully

2834:46

created right here so we have extraction

2834:48

two we have the image here the genre

2834:51

detail cast and every single thing right

2834:53

here so yeah let me just see if you

2834:55

already have the movie and I'm going to

2834:57

just refresh that and it's going to

2834:59

gives us that movies right here we only

2835:01

have one movie right here and now let me

2835:02

just check this out we have the ID we

2835:05

have the movie name we have the image

2835:07

then we have the year genre detail and

2835:09

also the cast and we're not providing

2835:12

the rest of the stuff so it's going to

2835:13

just take the D4 one word here okay so

2835:15

yeah this is how we are going to be

2835:17

creating the movie now let me just go

2835:19

back let's just close this one the next

2835:21

thing which you have to take care of

2835:22

this get all movies but first of all

2835:24

we're going to have to create a lot of

2835:25

movies then we would be able to see all

2835:27

of them so I'm going to just proide like

2835:29

I don't know

2835:31

Transformer come on

2835:34

Transformers and then I don't know maybe

2835:37

2025 or something like that it's going

2835:40

to be also an action movie and I'm going

2835:42

to just leave the rest of them totally

2835:44

the same and now let me just change

2835:45

there to like John Wick or something

2835:48

let's just provide them and here you can

2835:50

see we only have three movies right here

2835:53

so now let me just uncomment this line

2835:54

of code let me just copy that from here

2835:56

let me just go to the top and provide

2835:59

there right here copy this save this

2836:01

file let me just go ahead and go to my

2836:02

controllers and I'm going to just

2836:04

collapse that and now let me just

2836:06

register there right here and now let me

2836:08

just create my controller so I'm going

2836:10

to just giving it the name of like get

2836:11

all movies it's going to be equals to

2836:13

the async and now let me just put a

2836:14

request response and now inside there

2836:17

we're going to be just using our try and

2836:18

catch block for the catch block we're

2836:20

going to be using like first. status of

2836:22

500 and now let me just put a Json and

2836:26

the error will be the error do message

2836:29

right here okay so it should be e r like

2836:32

so and for the tri block what do you

2836:34

want to do you just want to use our

2836:35

Mongoose method which will be just use

2836:38

the model and then the find method on

2836:40

there and we're not going to be

2836:41

providing anything to that and now let

2836:43

me just use a rest. status of M is right

2836:45

here okay so now let me just save them

2836:47

and now let me just test this out so I'm

2836:49

going to just save this file and now I'm

2836:51

going to just create a new request right

2836:53

here I'm going to just give the name of

2836:55

like Get or you know all movies right

2836:59

here okay so now let me just copy that

2837:01

and now let me place it right here and

2837:03

we're going to be using the get request

2837:05

in this case and instead typing a create

2837:07

movie let me just close there we are

2837:09

going to be just passing the

2837:12

movies so we're going to be passing all

2837:14

movies and now let me just hit ENT right

2837:16

here so it's going to gives us all of

2837:18

the movies right here inside our

2837:19

database so yeah this is how we going to

2837:21

be getting all of the movies and now let

2837:23

me just save this file let's just uh you

2837:26

know I'm not going to close there and

2837:28

now let me just take care of a specific

2837:30

movie so for that we are going to be

2837:31

just creating a R.G and we are going to

2837:33

be going into specific movie and then

2837:37

we're going to be providing ID for the

2837:39

specific movie get specific movie and

2837:42

now let me just copy that from here and

2837:44

I'm going to just place that right here

2837:47

okay now let me just uh save this file

2837:49

let's just copy there and now let me

2837:52

just oh you know let me just close this

2837:53

file let me just register there right

2837:55

here and register there and I'm going to

2837:58

be creating that route right here it's

2838:00

going to be equals to the asnc request

2838:01

response and now inside there we're

2838:04

going to be using our try and catch

2838:05

block for the catch we're going to be

2838:07

using a restart status of 500 and

2838:10

provide our Json and for the Json we're

2838:12

going to be providing the error of error

2838:14

message for the tri block we're going to

2838:16

be destructuring our ID from where from

2838:19

the request. prams and now underneath

2838:21

that we're going to be also getting our

2838:23

specific movie and it's going to be

2838:25

equals to A and movie. find by ID and we

2838:29

are going to be passing our ID right

2838:31

here in this case and then we are going

2838:32

to be checking if we don't have the

2838:35

specific movie then we're going to be

2838:37

just returning let me just return the

2838:39

response. status of 404 404 and then

2838:43

Json let me just provide my message and

2838:46

the message will be movie nor found okay

2838:49

so now let me just save that and also we

2838:51

are going to be showing something to the

2838:52

user so we're going to be using like

2838:54

rest. Json and specific movie now let me

2838:58

just save that and now let me just try

2838:59

this out so I'm going to go ahead and go

2839:01

to I know Transformers so I'm going to

2839:04

copy there and now let me just go ahead

2839:06

and create my new request right here

2839:09

let's just collapse that and I'm going

2839:11

to just give it the name of like

2839:13

specific M something like that and I'm

2839:16

going to go ahead and copy there let me

2839:18

just test it right here and we not going

2839:20

to be recording the all movies but a

2839:22

specific movie which was this uh let me

2839:26

just show you there which was specific

2839:28

movie and then we are going to be

2839:29

providing our ID right here okay so then

2839:32

we have to specify our ID so in this

2839:34

case we are going to be providing our ID

2839:37

from or mongod DV and you know in this

2839:39

case we're going to be providing the ID

2839:41

of this John Wick and now let me just

2839:43

copy them and place it right here and

2839:45

click on the send button so it's going

2839:46

to gives us that specific movie which

2839:48

was John Wick okay so this how we are

2839:50

going to be getting a specific movie by

2839:52

using the ID so now let's talk about how

2839:54

we're going to be updating our movie so

2839:56

we're going to be using the R.P and now

2839:58

let's just provide our endpoint of

2840:00

update movie and we're going to be

2840:02

providing a specific ID right here in

2840:03

this case and now we have to end the

2840:06

user should be authenticated and also

2840:08

authorize as an admin so authorize as an

2840:11

admin and then they would be able to

2840:12

update the movie so now let me just copy

2840:14

that from here and now let me just

2840:16

register there right here sell file and

2840:19

now let me just create them

2840:21

right here produ comma and also the

2840:25

update movie and now let me just create

2840:27

my update movie it's going to be equals

2840:29

to snc and request response and now

2840:32

inside there we're going to be using our

2840:34

try and catch block for the catch block

2840:35

we're going to be using like r. status

2840:37

of 500 and also the Json so now let me

2840:41

just put a Json of error and also the

2840:44

error. message in this case and now for

2840:47

the tri block what do you want to do you

2840:48

just want to restructure first of all

2840:50

our ID from where from or request our

2840:54

prams and also we have to just get the

2840:56

updated movie and going to be equals to

2840:59

A and let's just go ahead and use our

2841:01

model and we're going to be using like

2841:03

find by ID and update this method which

2841:07

is coming from the mongus first of all

2841:09

we're going to be providing our ID then

2841:11

the request. Bor like how we are going

2841:13

to be updating our data and then we're

2841:15

going to be using the new toor now we're

2841:18

going to be checking if we don't have

2841:20

the updated movie or updated movie there

2841:24

we go so what do you want to do in that

2841:26

case we're going to be just returning

2841:28

the response. status and we will say 404

2841:31

and then let's just provide with Json

2841:33

response and message and for the message

2841:35

we would say like movie not found okay

2841:38

and now underneath there finally we're

2841:40

going to just sending to the user like

2841:42

updated movie and now let me just save

2841:44

them so what I want to do is that I want

2841:46

to test this out so I'm going to go

2841:47

ahead and copy this update from

2841:51

it and now let me just go ahead and

2841:53

create new request right here I'm going

2841:55

to just uh give it the name of update

2841:59

come on update movie and now let me just

2842:02

change that to put and I'm going to copy

2842:05

all of that now let me just place it

2842:06

right here and instead of ring a

2842:09

specific movie I'm going to just say

2842:10

like update and I want to update a

2842:13

specific movie which will be I don't

2842:14

know maybe instead of a Transformers I'm

2842:16

going to just give it the name of like

2842:18

something else oh I'm gonna have to copy

2842:21

that and now let me just place it right

2842:23

here and let me just go to the body and

2842:25

I'm going to just update the movie name

2842:28

in this case so I'm going to just say

2842:30

like uh the name and the name will be

2842:33

like I don't know which kind of name

2842:34

should I provide Godfather would be fine

2842:38

and now let me just click on the send

2842:40

button so here you can see everything

2842:42

else will be totally the same and only

2842:44

the name is totally changed right here

2842:46

okay so if you want to change the image

2842:48

or the year or the genre you can totally

2842:50

do that but in my case I want to just

2842:52

show you how we going to be changing the

2842:54

name of the movie if you want to change

2842:56

the other stuff so you can just proide

2842:57

like uh I don't know you can provide the

2842:59

image first of all and then you can say

2843:01

like um let's just go ahead and my

2843:05

image.png or jpg or something like that

2843:08

and here you can see it's going to also

2843:09

update there for you so now let me just

2843:11

save there and this is how we're going

2843:13

to be updating our movie now let's just

2843:14

close this out and now let me just take

2843:16

care of the movie review so we're going

2843:17

to be just using like router. poost and

2843:20

we're going to be providing the specific

2843:21

movie ID and then reviews and now the

2843:24

user should be authenticated not

2843:26

authorizes an admin like not only the

2843:28

admin will be able to provide the review

2843:30

everyone can provide the review for a

2843:32

specific movie and check ID which we are

2843:35

already grabbing and then we have to

2843:36

also proide the movie review k r e v i e

2843:40

w and now let me just copy that from

2843:42

here let me just place that right here

2843:44

save this file and let's just collapse

2843:47

that and I'm going to be just placing

2843:49

there right in in here okay and now let

2843:51

me just create them and to create there

2843:53

first of all we're going to be just

2843:54

writing our movie review and it's going

2843:57

to be equals to the as synchron request

2843:58

response and now inside there we're

2844:00

going to be using our try and catch

2844:02

block and for the tri block first of all

2844:04

let me just take care of the tri block

2844:05

we're going to be just restructuring the

2844:07

rating and also the comment from where

2844:09

from the request. body okay and then we

2844:12

would also have to just use one movie

2844:15

not movies but just a movie and a wait

2844:17

for movie and then find by ID and we are

2844:20

going to be providing request or Rams

2844:22

and a specific ID okay which we are

2844:24

already taking in this case not yeah

2844:28

there we go which we are already taking

2844:30

in this case and now the next thing

2844:31

which you want to do is that we want to

2844:33

check the movie if we have the movie so

2844:35

what do you want to do in that case

2844:37

we're going to be using like already uh

2844:39

reviewed so if the movie is already

2844:41

reviewed so what you want to do in that

2844:42

case you just want to use our movie.

2844:45

reviews uh. find and r e v i e w Ed I

2844:51

guess yeah already reviewed and for this

2844:53

find method we are going to be passing

2844:55

our call back function and we're going

2844:57

to be just checking like if wrting user

2844:59

to string we're going to be converting

2845:01

that to string is triple equal to the

2845:04

request. user come on let me just use

2845:06

the user and the specific user ID and

2845:09

we're going to be also converting that

2845:11

to string as well now let me just save

2845:13

them and underneath we're going to be

2845:15

just checking if the movie is already

2845:17

reviewed so what do you want to do in

2845:18

that case we just want to send to the

2845:20

the user like response. status of 400

2845:23

and now underneath that we're going to

2845:24

be just throwing a new error to the user

2845:27

which will say like movie

2845:29

already

2845:31

reviewed I don't know how to spell this

2845:33

reviewed r e v i e w d I guess this is

2845:36

how you spell it and now underneath that

2845:38

what do you want to do we just want to

2845:39

create our review so we are going to be

2845:41

just writing a review and it's going to

2845:42

be equals to the name like the specific

2845:45

username who is doing or who is writing

2845:47

that review and then we have to provide

2845:49

the rate in and for the rating we're

2845:51

going to be converting that to number

2845:53

let me just provide a rating inside

2845:55

there and then we have to just provide a

2845:56

comment and also the user so we would

2845:59

say like request. user do specific ID

2846:02

okay so this how we're going to be

2846:04

creating a review and now underneath

2846:05

that let me just push that to or movies

2846:08

we're going to be using like movie.

2846:10

reviews R ews and then let's just push

2846:13

over review which we just created right

2846:15

here up above and now underneath that

2846:18

we're going to be also using our

2846:20

movie. number of reviews will be now

2846:23

equals to movie. reviews reviews. length

2846:27

Okay so we're going to be incrementing

2846:29

there or decrementing there by using

2846:31

this line of code let me also take care

2846:33

of the rating as well so we're going to

2846:35

be using like mov rating it's going to

2846:37

be equal to the movie. reviews uh

2846:40

reviews like that and we going to be

2846:42

using a reduce method reduce first of

2846:44

all we are going to be providing the

2846:46

accumulator and then the item name and

2846:48

we are going to be just using like item

2846:50

rating plus accumulator and then here we

2846:53

have to just specify the zero and then

2846:55

we're going to be dividing them by

2846:57

movie. reviews and then length Okay so

2847:00

now let me just save there and it should

2847:02

be l e n GT and now let me just save

2847:05

there to our database so for that we are

2847:07

going to be using like a and then movie.

2847:10

sa to the database and now underneath

2847:12

that we're going to be using like rest.

2847:14

status of 2011 and then we have to use

2847:17

our do Json let me just provide my

2847:19

message message to that message and

2847:22

review added by the user so if that's

2847:26

not the case what you want to do we just

2847:27

want to send to the user like 404 and

2847:30

then throw a new error of movie not

2847:35

found okay and for the catch block what

2847:37

you want to do we just want to use our

2847:39

console. error and we just want to set

2847:42

the error we're going to be passing the

2847:43

error and also the response. status of

2847:46

400 and then Json will be set to or you

2847:49

know like error and error just. message

2847:53

there we go so now let me just save

2847:55

there and we are already exporting there

2847:56

and we are already grabbing there right

2847:58

here everything is okay so now let me

2848:00

just test this out and I'm going to just

2848:02

create a new request right here and now

2848:04

I'm going to just give it the name of

2848:06

like movie review or review movie would

2848:10

be fine and now let me just copy all of

2848:13

that now let me just place the right

2848:16

here and I'm going to just change there

2848:18

to post in this case it is is now first

2848:20

of all requiring the ID and then we have

2848:23

to specify the reviews in this case so

2848:24

now let me just remove that and also the

2848:27

update movie as well so first of all

2848:29

we're going to have to provide a

2848:30

specific movie ID so that we would be

2848:32

able to review that specific movie so

2848:35

here you can see our reviews are now set

2848:37

to zero and we are not providing any

2848:39

review to that so what I want to do is

2848:41

that I want to grab this specific movie

2848:43

ID from there let me just copy that from

2848:45

here let me just put that right here and

2848:47

now let me just add the reviews at the

2848:49

end so was there reviews or just a

2848:51

review yep that's a review so now let's

2848:54

just provide a review for that so I'm

2848:56

going to go ahead and go to my raw and

2848:58

here we just have to specify a new

2849:00

review right here let me just zoom in a

2849:01

bit and we have to just say that review

2849:06

and first of all I want to make sure

2849:07

that I am logged in and let me just

2849:10

click on the cookie and yeah we are

2849:11

already logged in so I'm going to just

2849:13

say the reviews we are going to be

2849:15

providing there for this review so I'm

2849:17

going to copy there and now let me just

2849:19

place it right here

2849:20

and I'm going to just say like uh one of

2849:23

the best movie or action movie so far or

2849:28

something like that and now if I click

2849:30

on this send button right here so here

2849:32

you can see review. Z rating gu number

2849:36

fail and I just debug my application and

2849:38

found two mistake we are now taking or

2849:40

destructuring the rating and also the

2849:42

comment and here we can see we not

2849:44

providing a reviews right here now let

2849:46

me just change that to comment and then

2849:48

we're going to also provide the reviews

2849:50

right here so uh what's that no not

2849:52

reviews but rating and now let me just

2849:54

provide a rating of like I don't know

2849:55

maybe two would be fine or five would be

2849:58

fine rather now let me just click on

2849:59

this send button and here you can see

2850:01

message and review edit right here in

2850:03

this case and now let me just go ahead

2850:05

and check this out but first of all I'm

2850:07

going to have to close this one and now

2850:09

let me just reopen that and now let me

2850:11

just go to the bottom and here you can

2850:13

see we have the rating of five and we

2850:16

have the comment of one of the best

2850:17

action movies so far so yeah this is how

2850:20

we're going to be adding a comment to

2850:22

our specific movie so now let me just

2850:23

comment or not comment but now let me

2850:25

just collapse it right here and now

2850:27

let's talk about how we're going to be

2850:28

deleting a specific movie and to do that

2850:31

first of all we're going to have to go

2850:32

ahead and go to our admin and we're

2850:34

going to be just providing a router.

2850:36

delete method and for this delete we're

2850:38

going to be just providing a delete

2850:39

movie and we would also need to provide

2850:41

a specific movie ID and the user should

2850:44

be authenticated and also authorizes an

2850:46

admin and then they will be able to

2850:48

delete a movie now let just copy that

2850:51

and save my file but I'm going to also

2850:53

have to put there right here s file and

2850:55

now let me just register there right

2850:57

here and also let's just create the

2851:00

right in here so now let me just create

2851:02

my delete mov and it's going to be

2851:04

equals to ning function request response

2851:07

and also inside there we're going to be

2851:10

just using our try and catch block for

2851:12

the catch block we would just select

2851:13

response. status of 500 and also the

2851:17

Json would be set to the eror and we're

2851:20

going to be just passing the error.

2851:21

message okay so now for the tri block

2851:24

what we want to do we just want to just

2851:25

destructure the specific ID of the movie

2851:28

and it is going to be coming from the

2851:29

request. prams and we're going to be

2851:32

just using the delete movie it's going

2851:33

to be equals to the event and movie uh

2851:36

scheme or model whatever you want to

2851:38

call that and we're going to be using

2851:40

the Mongoose method which will be find

2851:41

by ID and delete not update find by ID

2851:45

and delete there we go and now let me

2851:48

just pass my specific ID right here

2851:50

inside there and now let me just check

2851:52

if we don't have the delete movie so

2851:55

what we want to do we just want to

2851:56

return to the user the response. status

2851:59

or 404 and movie not found so let me

2852:02

just use the Json and message uh will be

2852:06

equals to movie come on movie not found

2852:10

in this case and now underneath this F

2852:12

statement we're going to be using a

2852:13

rest. Json and now let me just pass the

2852:15

message

2852:16

off um movie delete

2852:21

successful come on s u c e s f u l y

2852:25

successfully and now let me just save

2852:27

there and now let's just try this out

2852:30

okay so we're going to be just using

2852:31

this delete movie copy there and now let

2852:34

me just create a new route right here

2852:36

I'm going to just give the name of like

2852:38

uh Delete movie let me just change the

2852:41

name of that to delete movie right here

2852:43

in this case and now let me just Place

2852:45

uh something like that let me just

2852:48

remove the reviews and all so that we're

2852:50

going to be using our delete movie and

2852:52

now let me just provide a specific movie

2852:54

which you want to delete okay so we have

2852:56

the Godfather and I want to remove that

2852:58

movie so I'm going to just copy the ID

2852:59

from there and now let me just place

2853:01

that ID right here let me just change

2853:03

that to delete and say bye-bye to the

2853:06

godfa and here you can see we're now

2853:08

getting the movie deleted successfully

2853:10

and now let me just save this one and

2853:12

save this one and this is how we going

2853:13

to be deleting here you can see we have

2853:15

three movies and now if I refresh that

2853:17

so it's going to only gives us that two

2853:19

movies okay so this is how we going to

2853:21

be deleting a specific movie so now let

2853:23

me take care of deleting a movie review

2853:25

or the comment whatever you want to call

2853:27

that so we're going to be just using

2853:29

like review and delete not review but r.

2853:32

delete and we're going to be just

2853:33

passing the delete comment in this case

2853:36

and the user should be authenticated and

2853:38

also authorizes an admin then they would

2853:40

be able to delete the comment okay so

2853:43

now let me just copy that from here and

2853:45

now let me just place it right here save

2853:47

this file and now let me just go ahead

2853:49

and collapse it right here let me just

2853:52

place that right here and now let's just

2853:54

create that right in here so I'm going

2853:57

to just say cons delete comment and it's

2853:59

going to be equals to the request

2854:01

response and now inside that we're going

2854:03

to be using our try and catch block

2854:04

we're going to take care of the catch in

2854:06

a few seconds but now we have to

2854:08

destructure the movie ID and also the

2854:10

review ID as well okay so we're going to

2854:13

be just using the request. body and now

2854:15

we have to just use like movie and it's

2854:17

going to be equals to the A and move M

2854:20

v. findind by ID and provide our movie

2854:24

ID right here in this case let's just

2854:26

remove that empty space from there and

2854:28

now let me just check if you don't have

2854:30

the movie so what do you want to show to

2854:31

your user we just want to say the

2854:32

response and also the status of 404

2854:37

movie not found so we're going to be

2854:39

just using like message and then movie

2854:42

not found now underneath there what do

2854:44

you want to do you just want to get the

2854:45

review index in this case and it's going

2854:47

to be coming from the movie and then the

2854:50

reviews let me just show you that I'm

2854:52

going to go ahead and click on this one

2854:54

right here so we have this movie entire

2854:56

object and we have this reviews inside

2854:58

there and then inside this reviews what

2855:01

we want to do we just want to use our

2855:02

find index method and inside there we're

2855:05

going to be just passing our error

2855:06

function it's going to take the review

2855:08

and then the review and a specific ID

2855:10

which we have for that specific movie

2855:12

and we're going to be converting that to

2855:14

string and if it's equal to the review

2855:17

ID so we're going to be just removing

2855:19

that and if that's not the case what do

2855:21

you want to do in that case we just want

2855:22

to use our if statement one more time

2855:24

and review come on uh review index which

2855:28

we have right here uh triple equal 2us

2855:31

one if it gives us minus one so what do

2855:33

you want to do in that case we're going

2855:34

to be using like response. status and we

2855:36

are going to be just providing that um

2855:39

come on let me just provide a message

2855:41

right and we would say like comment not

2855:44

found and now underneath that we're

2855:46

going to be just checking like movie and

2855:48

reviews do splice and we're going to be

2855:51

just providing our review index come on

2855:53

not ID but review index in this case and

2855:56

also one to okay so we are now splicing

2855:59

our comment and then we have to just

2856:00

increment or decrement our number of

2856:03

reviews so we're going to just writing

2856:04

our number of reviews and it's going to

2856:05

be equals to the movie and then reviews

2856:08

and then the dot length and underneath

2856:11

there oh what the hell now underneath

2856:14

that what do you want to do you just

2856:15

want to take care of the movie rating so

2856:17

movie. rating is going going to be

2856:19

equals to or not movie rating but yeah

2856:22

movie rating will be now equals to the

2856:25

movie. reviews reviews uh do length is

2856:31

greater than zero if that's the case let

2856:33

me just put the length uh l n GT if

2856:37

that's the case so what you want to do

2856:39

we just want to write m. reviews right

2856:41

here in this case and then we are going

2856:43

to be using the reduce method and we are

2856:45

going to be providing our accumulator

2856:47

and also the item itself and now in side

2856:49

there we're going to be using the item

2856:51

do rating uh plus the accumulator and

2856:56

we're going to be passing zero and now

2856:57

let's just divide there by movie and

2856:59

then reviews The Dot come on dot length

2857:04

and then finally we're going to be just

2857:05

providing a zero if that's not the case

2857:07

and the final and final thing which we

2857:10

have to do is that we have to save or

2857:12

comment to the database so we're going

2857:14

to be using like movie. save and here

2857:17

let's just use that and now I'm going to

2857:18

be also using the rest. Json and provide

2857:21

our message to them and I'm going to

2857:22

just say like comment deleted deleted

2857:27

successfully there we go and yeah that

2857:31

was it but now let me just also take

2857:32

care of the uh what do we call it the

2857:34

catch statement and I'm going to just

2857:36

say console dot come on Console do error

2857:40

of error in this case and underneath

2857:42

that we're going to be using like uh

2857:44

response. status of 500 and now let me

2857:46

just put the Json right here and we're

2857:48

going to be ping the error and error

2857:50

message if you have one so now let me

2857:52

just save that and we are going to be

2857:54

testing this out in a few seconds but we

2857:56

are going to have to Prov the movie ID

2857:58

and also the review ID in this case so

2858:00

now let me just close that and you know

2858:02

what first of all let me just go ahead

2858:03

and create a new request right here and

2858:06

I'm going to give it the name of delete

2858:09

comment so delete review would be fine

2858:13

rather and now let me just change that

2858:15

to delete method and I'm going to also

2858:17

copy that from here let me just place

2858:19

right here and what are we doing is that

2858:22

first of all we are now providing the

2858:25

come on we are just using this uh Delete

2858:27

comment right here now let me just copy

2858:28

that from here let's just remove all of

2858:31

that and we're going to be just

2858:32

providing a delete comment in this case

2858:34

now let me just click on the body and

2858:35

inside this body we're going to be just

2858:37

providing first of all the movie ID and

2858:40

then the review ID so now let me just go

2858:42

ahead and go to there so in this case if

2858:44

I want to remove okay so we only have

2858:46

review for uh this specific movie which

2858:49

is which is extraction so now let me

2858:50

just show you there we only review this

2858:52

movie so the first thing which you want

2858:54

to do is that we want to get the

2858:55

specific movie ID so we have that ID

2858:58

right here so I'm going to copy that

2858:59

from here and now we are going to be

2859:02

just using the movie ID right here so

2859:04

movie ID and now let me just place it

2859:07

right here come on let me just place it

2859:09

right here and now let me just also

2859:11

provide the review ID right here in this

2859:14

case so the review ID is uh this ID

2859:17

right here so we have this user ID and

2859:19

we also have this um movie or not movie

2859:22

but review ID right here now let me just

2859:24

copy that and I'm going to just say

2859:26

review ID and now let me just place my

2859:29

review ID right here in this case so

2859:31

it's going to just remove this comment

2859:32

and also this entire review right here

2859:35

okay so now if I click on this send

2859:36

button so it's going to just give us us

2859:38

like comment deleted successfully now

2859:40

let me just close that and now let me

2859:42

just reopen that once again and here you

2859:44

can see the reviews are zero the reviews

2859:47

are totally gone okay so that was for

2859:50

the extraction and now let me just also

2859:52

show you that John Wick and we don't

2859:54

have no reviews inside that so this is

2859:56

how we going to be removing a specific

2859:58

comment okay so that's there now let me

2860:01

just take care of the rtk query specific

2860:04

um end points so I'm going to just

2860:07

create a comment right here and I'm

2860:08

going to just give it like rtk

2860:11

query uh end points or something like oh

2860:14

you know we don't have to do that now

2860:15

let me just write a router. get and

2860:18

we're going to be getting the latest

2860:19

movies so we will sayell like new movies

2860:22

but first of all we'll also have to

2860:23

provide this slash right here and then

2860:25

I'm going to just say like get new

2860:28

movies right here movies and now let me

2860:30

just copy that from here and now let me

2860:33

just place it right in here save this

2860:35

file and now let me just register there

2860:37

and now underneath that what we want to

2860:38

do we're going to be using our get new

2860:40

movies and asking request response and

2860:43

now inside there we're going to be using

2860:45

our try and catch block for the catch

2860:46

block we will s like response. status of

2860:49

500 and now let me just proide my Json

2860:52

off error and also error. message and

2860:55

for the tri block what we want to do we

2860:57

just want to use our new movies it's

2860:59

going to be equals to A and then the

2861:01

movie. find and now let me just sort

2861:04

that by what by the created ad and now

2861:08

let me just provide the minus zero so

2861:10

it's going to gives us the latest movies

2861:12

and now let me just also limit that to

2861:14

10 movies you can just limit that to

2861:16

like how many movies that you like but

2861:18

in Mye I'm going to just limit that to

2861:20

10 and now let me just use the rest.

2861:22

Json and now let me just provide my new

2861:23

moves inside the semi file and now let's

2861:26

just create endpoint or not Endo but now

2861:28

let me just test this out I'm going to

2861:30

save this file and I'm going to remove

2861:33

all of them from here so that we can see

2861:35

everything a bit better and now let me

2861:37

just go ahead and create a new request

2861:39

right here I'm going to give it the name

2861:40

of like uh new movies or something like

2861:43

that and now I'm going to copy that from

2861:46

here and now let me just place that

2861:48

right here and and we are going to be

2861:49

using the get so now let me just show

2861:51

you the end point once again we are

2861:53

going to be sending a request to this

2861:55

new movies so now let me just copy that

2861:58

and now let me just place it right here

2862:00

and as soon as I click on this send

2862:02

button so it's going to gives us only

2862:04

the latest movie right here so the

2862:05

latest movie was John Wick and then it's

2862:08

going to also gives us that extraction

2862:09

too and you know what let me just create

2862:12

new oh you know that's it that's it you

2862:14

can create new movie and then you can

2862:16

see the result but here you can see it

2862:17

is now giving us the new movie right

2862:20

here so yeah that's that now let me just

2862:22

take care of the top movies so I'm going

2862:25

to just say like router. or get and then

2862:28

we are going to be just providing the

2862:30

top movies in this case and get top

2862:32

movies and now let me just copy that

2862:34

from here and now let me just place it

2862:36

right here save my file and now I'm

2862:39

going to also register that here and now

2862:42

let me just create the controller right

2862:44

here I'm going to just say like get toop

2862:46

movies and async request resp PS and now

2862:50

inside that we're going to be using our

2862:51

try and catch block for the catch we're

2862:53

going to be using like press. status of

2862:55

500 and then the Json let me just proide

2862:58

my error and also the error. message and

2863:01

now for the tri block what do we want to

2863:02

do we just want to use like con stop

2863:05

rated movies and going to be equals to

2863:08

the aent and then movies or not movies

2863:11

but just a movie and find okay so then

2863:13

we're going to be sorting that by using

2863:16

the number come on the number of reviews

2863:19

and then we're going to be just

2863:20

providing the minus one right here and

2863:22

then let's just limit that to 10 movies

2863:25

and we are going to be just sending that

2863:26

to the user so we will say the top rated

2863:29

movies save this file but first of all

2863:31

we're going to have to just review

2863:33

specific movie and then we will be able

2863:35

to see that specific movie so what I

2863:36

want to do is I want to go ahead and go

2863:38

to my review movies and I'm going to

2863:41

just review a specific movie so I'm

2863:43

going to just refresh that from here and

2863:45

we want to review this extraction 2 mov

2863:47

right here so I'm going to just copy

2863:49

there and now let me just place it right

2863:51

here and then I'm going to just give it

2863:54

the review of two and I'm going to just

2863:56

remove that from here and I'm going to

2863:58

just say yeah it was cool cool movie or

2864:03

something like that and now let me just

2864:05

click on the send button so it's going

2864:06

to gives us that movie edit I mean like

2864:08

that review edit right here let me just

2864:10

reopen that and it's going to gives us

2864:12

that specific review made by hosan now

2864:15

let me just close there and now let me

2864:17

just test this get toop mve is out so

2864:20

here you can see we already reviewed one

2864:21

of our movie so it's going to use that

2864:23

extraction on the top so now let me just

2864:25

go to that and that was for the new

2864:28

movie and now let me just take care of

2864:31

the top rated movie so I'm going to just

2864:33

create new request I'm going to give it

2864:35

the name of like uh

2864:37

top R rated movies or something like

2864:40

that and I'm going to go ahead and copy

2864:42

that and now let me just place it right

2864:44

here and I'm going to just say that this

2864:48

is going to be the top movie so I'm

2864:51

going to just copy there place it right

2864:53

here and now let me just click on this

2864:55

so it's going to gives us the top movie

2864:57

which was extraction why is that because

2865:00

only for this movie we have some sort of

2865:02

a revie right here not for this one and

2865:05

not for the rest of them so we have only

2865:07

reviewed this specific movie so that's

2865:09

why we are now getting this extraction

2865:10

on the top so this how we're going to be

2865:12

getting the top rated movies and now

2865:15

finally we're going to have to take care

2865:17

of the random movies

2865:19

so I'm going to go ahead and go to yeah

2865:22

that's fine uh go to my movies routes

2865:25

and I'm going to just say like r. getet

2865:28

and in this case we're going to be using

2865:29

like random movies and now get random

2865:32

movies let me just copy there from here

2865:35

and now let me just place it right here

2865:37

seller file and now let me just register

2865:40

that here and I'm going to also create

2865:43

there right here so const uh this movie

2865:46

provide a request response to that

2865:49

and let's just use our Arrow

2865:52

function and now I'm going to be using

2865:54

the try and catch block for the catch

2865:55

block we will say like response. status

2865:57

of 500 and then the dot Json and we will

2866:01

say the error of error message and also

2866:05

we going to be just putting a cons

2866:06

random movie and it's going to be equals

2866:09

to the aent and we are going to be

2866:10

getting the movie and then the aggregate

2866:12

function a g r e g a t we're going to be

2866:16

using our aggregate function and it

2866:18

shouldn't be a movies but just a movie

2866:21

and now we are going to be just

2866:22

providing first of all the sample and

2866:26

then we're going to be providing the

2866:27

size and the size will be 10 in this

2866:30

case so we're going to be just getting a

2866:31

random movies and then we are going to

2866:33

be just providing a rest. uh Json and

2866:36

let's just Pro our random movies in this

2866:38

case so now let me just save that and

2866:40

now let me just test this out so I'm

2866:41

going to go ahead and copy there random

2866:44

movies and now let me just test this out

2866:46

so I'm going to just create a new

2866:48

request right here here add request and

2866:51

I'm going to just say like uhuh random

2866:54

random movies and now let me just copy

2866:58

that from here let's just place that and

2867:00

now instead of writing a top I'm going

2867:02

to just change that to random okay so

2867:04

now let me just click on the send button

2867:06

so it's going to just gives us that John

2867:07

wig and then it's going to gives us that

2867:10

extraction but if I click on that once

2867:11

again and here you can see it's going to

2867:13

giv us that extraction and then it's

2867:15

going to gives us that John Wick but if

2867:16

you have a lot of movies so it's going

2867:18

to just give you a random movie Inside

2867:21

from that um what do you call it from

2867:23

that entire database so now let me just

2867:24

save that and I guess that was it about

2867:27

for all of the back end of the movies

2867:29

now we are able to create a movie get

2867:31

all of the movies get a specific movie

2867:32

update a movie review a movie delete a

2867:34

movie delete a comment from a movie get

2867:37

new movies get top movies and random

2867:39

movies as well so that was the entire

2867:42

flow of the back end of the movies so

2867:45

now let me just take care of the front

2867:46

end so those are about the random movies

2867:48

and now let's talk about the image

2867:49

upload so for that we're going to be

2867:51

creating our route right here so we're

2867:53

going to have to provide the version one

2867:55

and then upload and now let me just

2867:57

provide my upload routes right here I'm

2867:59

going to copy that sa my file and then

2868:01

I'm going to go ahead and go to my

2868:02

routes and here we're going to be

2868:04

creating a route of upload routes.js now

2868:08

let me just show you that I'm going to

2868:09

hit enter right here and the first thing

2868:11

we would need is a path from path and

2868:14

then we would also need the express CH

2868:16

from the express

2868:19

JS and we would also need the molter so

2868:22

now let's just grab that and now what I

2868:24

want to do is that we're going to be

2868:25

creating a router and it's going to be

2868:27

just the instance of Express and router

2868:30

and now let's just execute that now

2868:31

underneath that let's create our storage

2868:33

so I'm going to be creating my storage s

2868:36

r a and it's going to be equals to the

2868:38

molter do disk uh storage right here

2868:41

this is a method on the molter now let

2868:43

me just put my destination of request

2868:45

and file and also the Callback function

2868:48

now inside there what I want to do is

2868:50

that for the Callback function we not

2868:52

going to be providing anything for the

2868:53

first parameter and for the next

2868:54

parameter we're going to be providing

2868:56

the uploads folder which we're going to

2868:58

be creating right here inside our route

2869:00

so now let me just create a folder of

2869:03

upload or uploads with s I'm going to

2869:06

just create that and now what I want to

2869:08

do is that underneath uh these C braces

2869:11

I'm going to be writing my file name and

2869:13

it's going to be equals to request and

2869:14

also the file and the Callback function

2869:17

and now inside there we're going to just

2869:18

creating our extension name so EXT name

2869:21

is going to be equals to the path.

2869:22

extension name this is the method which

2869:24

we have on the nodejs and we're going to

2869:26

be just grabbing the file and original

2869:29

name okay so now underneath that we're

2869:31

going to be passing our callback

2869:32

function for the first parameter we're

2869:34

not going to providing anything to that

2869:36

for the second parameter we are going to

2869:37

be providing the file do uh field name

2869:40

and then we're going to be just

2869:42

providing the dash and here for the

2869:43

uniqueness we're going to be just

2869:44

providing a DAT now and then finally we

2869:47

just have to add extension name okay so

2869:50

that's now let's just save our file so

2869:51

that was it for the storage and now

2869:53

let's just take care of the file filter

2869:55

so I'm going to just creating a function

2869:57

I'm going to give the name of like file

2869:59

filter and it's going to be taking the

2870:00

request and the file and this cack

2870:03

function as well and now inside there

2870:05

we're going to have to first of all take

2870:06

care of the file types and it's going to

2870:08

be not like that but file types in lower

2870:10

case and it should be um the JP G and

2870:15

also the PNG and also the w

2870:18

BP and that's a different file formats

2870:21

and then we have to write a MIM type MIM

2870:24

types it's going to be equals to the

2870:26

images or image and then we can also

2870:29

provide the type of JP JP question mark

2870:33

G and then we can also use the image and

2870:36

let's just provide um what do we call it

2870:39

the PNG as well and we can also provide

2870:41

the MIM type of uh wbp okay so now let

2870:45

me just close that and I guess we're

2870:47

missing something I don't know why but

2870:48

but it feels a bit off you know let me

2870:49

just close it right here and there we go

2870:52

so that's then now the next thing which

2870:53

you want to do is that we still want to

2870:55

get or uh what do we call it or

2870:57

extension so now let me just grab that

2870:59

from here and now let me just place that

2871:01

and what else do I have to do is that

2871:02

I'm going to be just typing the M type

2871:05

not with s but just mime type okay so

2871:08

just a singular and now let me just P my

2871:10

file and then M type come on M M and

2871:14

then type there we go now underneath

2871:16

that what do we have to do uh we are

2871:18

going to just just writing a file types

2871:20

and then we have a test okay so we are

2871:22

going to be testing the extension name

2871:24

and let me just write and the mime types

2871:28

in this case and we're going to be also

2871:30

testing the mime uh what do we call MIM

2871:32

type as well now inside that we're going

2871:35

to be also creating our cback function

2871:36

now let me just pass my null and also

2871:38

the true and then for the else Clause

2871:40

what I want to do I'm going to be

2871:42

passing my callback function and new

2871:44

error and now in this case I'm going to

2871:46

be just passing the error of images on

2871:48

and now let me just pass my file right I

2871:51

mean like false right here in this case

2871:53

now let me just save this file and

2871:55

underneath this function we're going to

2871:56

be creating our upload it's going to be

2871:58

equals to the molter and now let me just

2872:00

put the storage and also the file types

2872:03

or not a file type but a file filter and

2872:05

now let me just take care of uploading a

2872:07

single image so I'm going to just write

2872:08

like con upload single image image and

2872:12

it's going to be equals to upload do

2872:13

single and now let me just pass my image

2872:16

right here inside there so underneath

2872:18

there we we're going to be just

2872:18

providing our uh method of post on this

2872:21

Endo we're going to be posting our image

2872:24

and let me just provide my request and

2872:25

also the response and now what I want to

2872:27

do is that we're going to be using

2872:28

upload single image which we just

2872:30

created up above and now let me just Pro

2872:32

my request response and also the error

2872:35

as well and now inside this error

2872:37

function we're going to be checking if

2872:38

we have some sort of error then what you

2872:40

want to show to user we just want to

2872:42

show that response. status of 400 to the

2872:45

message and then we have to just write a

2872:47

err of message there specific error

2872:49

message and if that's not the case so

2872:51

we're going to be checking for the

2872:52

request. file and inside there we're

2872:55

going to be sending the response of

2872:56

status of 200 and now let me just send

2872:59

my uh Json I mean like uh my object and

2873:03

we're going to be sending the message

2873:04

off uh image uploaded come on uploaded

2873:08

uh successfully there we go now let me

2873:11

just Pro my image and we are going to be

2873:13

providing our image of first of all we

2873:15

are going to be providing this random

2873:17

path which will be request. file. path

2873:20

and now let me just save that okay so

2873:22

now if that's not the case what do you

2873:23

want to do in that case so we are going

2873:25

to be just sending this response like

2873:27

send out uh send. status of 400 and now

2873:31

let me just send the error message right

2873:33

here so we're going to be sending the

2873:34

message of uh no image file provided

2873:38

there we go okay so now let me just save

2873:40

that and everything is looking totally a

2873:42

okay and we don't have any errors right

2873:44

here so finally now let me just export

2873:46

my router so I'm going to be just

2873:47

writing export default of our right here

2873:50

so now let me just save that and now we

2873:52

totally done with this file now let me

2873:53

just close that and we have to grab that

2873:56

right here so I'm going to just remove

2873:58

that okay so it's not going to give me

2873:59

the auto complete so I'm going to just

2874:02

grab that manually so now let me just

2874:04

write import upload routes and then

2874:06

let's just go ahead and go to our routes

2874:08

and then we have to go to the upload

2874:10

routes routes.js word here we're going

2874:13

to be first of all getting the directory

2874:15

name so we are going to be using like

2874:17

thir name it's going to be equal to

2874:18

path. resolve and now let me just

2874:20

execute that and now we are going to be

2874:22

making that static so we are going to be

2874:24

using like app. use and for this uploads

2874:27

folder what do we want to do we're going

2874:29

to be using like express. static and

2874:31

then we have to just use a path. join

2874:34

and here we just have to provide our uh

2874:36

directory name and then we have to add

2874:38

this uploads folder inside this uploads

2874:41

there we go and now let me just save

2874:42

there and that's everything we need to

2874:44

do for what do we call it um

2874:48

for the image upload there we go now let

2874:51

me just close these and what I want to

2874:53

do is that I want to create yet another

2874:55

um what do you call it yet another yet

2874:58

another request and now inside that

2875:00

request we're going to be testing our

2875:01

file upload and now let me just get the

2875:03

name of like file or image upload and

2875:07

now let me just um make that as a post

2875:09

request I'm going to just copy that and

2875:11

now let me just place it right here and

2875:14

for the API we are going to be using

2875:16

this API so I'm going to just copy there

2875:19

and we're not going to be providing the

2875:20

version ones and all of that let's just

2875:22

remove there we're going to be providing

2875:24

the upload and provide something right

2875:26

here so what I want to do is that I'm

2875:28

going to just click on the body and then

2875:30

I'm going to just click on the form data

2875:32

and now let me just provide like some

2875:34

sort of an image right here and the

2875:36

image will be some sort of a file so now

2875:38

let me just click on that add new file

2875:40

from your local machine I'm going to

2875:41

click on there and then I'm going to

2875:43

just go to my images and I'm going to

2875:45

just add this image right here click on

2875:47

the open and now let me just click on

2875:48

this send button right here so here you

2875:50

can see it's going to give us that image

2875:51

is now successfully uploaded and now

2875:53

let's just test this out and here you

2875:56

can see inside this uploads folder we

2875:58

have our image right here which is

2875:59

Jonathan Wick and shout out to this uh

2876:02

website I just grabed this image from

2876:04

that website now let me just test

2876:05

another image so I'm going to just go

2876:07

ahead and remove that uh let's just

2876:10

remove that from here let me just uh

2876:12

close that and let me just add another

2876:14

image word here and I'm going to just

2876:15

add the Spider-Man let me just add that

2876:18

and click on the send button so here you

2876:19

can see it's going to add this another

2876:21

image to my folder right here which is

2876:23

the Spider-Man okay so yeah this how

2876:26

we're going to be adding our images by

2876:28

using node Jazz we are now totally done

2876:30

with the back end functionality now

2876:31

let's go ahead and go to our front end

2876:33

and I'm going to go ahead and go to my

2876:34

SRC then the redex and then the

2876:36

constants and now let me just create my

2876:38

constant right here and we're going to

2876:40

be creating a constant first of all for

2876:41

the movies so we'll just write a movie

2876:43

URL it's going to be equals to the API

2876:46

and then version one of mov movies and

2876:48

the next one which we going to be also

2876:49

creating is for the upload URL it's

2876:53

going to be equals to first of all let's

2876:55

just go ahead and go to the API then

2876:56

version one and then upload now let me

2876:58

just save there let's just close it

2877:00

right here and I want you to get rid of

2877:01

yourself for creating a lot of endpoints

2877:04

so we're going to be just creating a mu.

2877:06

JS file inside this API and now the

2877:08

first thing which you have to do is that

2877:09

we have to grab our API slice let's just

2877:12

grab them manually and now let's go

2877:14

ahead and go to our API slice and now

2877:15

underneath that we're going to also need

2877:17

the movie URL and also the upload come

2877:21

on up God damn it up L upload URL there

2877:26

we go and now underneath that what we

2877:28

have to do let's just go back we just

2877:30

have to export our con of movies um M's

2877:34

API slice it's going to be equal to the

2877:36

API slice and now let me just inject my

2877:39

endpoints right here now let me just

2877:40

save that and inside there we're going

2877:42

to have to pass our object and now

2877:44

inside this object we're going to be

2877:45

defining our end points so now for the

2877:48

points we are going to be providing the

2877:49

Builder and now inside that uh let me

2877:52

just provide my get all movies and it's

2877:55

going to be equals to the builder. query

2877:57

and now let's just provide our query

2877:59

right here inside them and now inside

2878:01

this error function we're going to be

2878:02

providing first of all our M URL and

2878:05

then we have to provide our all uh come

2878:07

on all m in lowercase now let's just

2878:10

close that and Prov a comma here and

2878:13

that was our first endpoint now let me

2878:15

just go back and let's just create a

2878:17

movie okay okay so we are going to be

2878:18

creating an endpoint for that so to

2878:20

create a movie for that we are going to

2878:21

be using the create movie let me just

2878:23

pass my builder. mutation and inside

2878:26

there uh we're going to be passing our

2878:28

query let me just pass my query and

2878:30

we're going to be also providing the new

2878:32

movie and it's going to be inside let me

2878:35

just put the inside and we're going to

2878:37

be providing the URL first of all and

2878:39

the URL will be uh the movie URL and

2878:42

we're going to be specifically go to the

2878:44

create movie and now let me just put a

2878:47

comma here and now let me just provide

2878:49

the method of post so we're going to be

2878:51

posting there and we would also need to

2878:52

provide some sort of a body inside the

2878:54

body we're going to be providing a new

2878:56

movie so that was it about for creating

2878:58

the movie now let's just take care of

2879:00

updating the movie so to do that first

2879:02

of all we're going to be using the

2879:03

update update mov and we're going to be

2879:07

passing the Builder down mutation

2879:09

because we are changing something inside

2879:10

there and we have to just specify the

2879:12

query and we have to P the ID and also

2879:15

the updated movie and as well okay so

2879:19

now inside there we are going to be just

2879:22

passing our Arrow function and first of

2879:24

all we have to provide our url url and

2879:26

for the URL we are going to be first of

2879:28

all providing our movie URL and then we

2879:31

are going to be going into the update

2879:33

movie come on in lower case uh update

2879:37

and movie and then we have to specify

2879:39

their specific ID of the movie and then

2879:41

we have to specify the method and I'm

2879:44

going to be just passing the method of

2879:45

put to it and then finally we have to

2879:47

provide the body of update movie or it

2879:50

should be updated movie rather now let

2879:52

me just put a comma here now underneath

2879:55

that what we have to do we're going to

2879:56

be creating yet another endpoint for

2879:58

update movie review R ew and now let me

2880:03

just provide my Builder H not this one

2880:06

but builder. mutation and for the

2880:09

mutation we're going to be passing the

2880:11

query and inside that we're going to be

2880:13

passing the ID the rating and also the

2880:15

comment and we are going to be providing

2880:17

the URL first of all so for the URL

2880:19

we're going to be passing the movie URL

2880:22

and then we're going to be also

2880:23

providing a specific ID inside there and

2880:25

then finally our reviews there we go now

2880:27

underneath that we're going to also

2880:29

provide the method of post because we're

2880:31

now posting our data and now let me just

2880:33

put the body and inside the body we're

2880:35

going to be providing the rating ID and

2880:37

also the comment okay so now let me just

2880:39

save there and I just want to make sure

2880:41

that this is a put method and yeah it is

2880:44

now underneath that we're going to be

2880:45

providing yet another endpoint for

2880:47

deleting the comment okay so now let me

2880:50

just for my builder. mutation and inside

2880:52

this mutation we're going to be

2880:53

providing the query and it's going to

2880:56

take the movie ID and also the review ID

2881:00

as well okay so now inside there we're

2881:02

going to be providing our URL and the

2881:04

URL will be uh the movie URL and also

2881:08

we're going to have to pass the delete

2881:09

comment and now underneath that we're

2881:11

going to be providing the method of

2881:13

delete to it because we are deleting

2881:15

something so the method will be uh DED

2881:18

so now let me just provide my movie ID

2881:20

and also my review ID as well now let me

2881:24

just save that let me just create an

2881:25

endpoint for uh deleting the entire

2881:28

movie so we're going to be using like

2881:29

delete movie and it's going to be a

2881:31

builder. mutation and now inside there

2881:33

we're going to be passing the query and

2881:36

for the query is going to take the ID

2881:37

and based on that specific ID we're

2881:40

going to be deleting our movie so now

2881:41

let me just provide my movie URL come on

2881:45

movie URL there we go

2881:48

and we also have to provide the delete

2881:49

movie and then we are going to be

2881:51

deleting the specific movie by this

2881:53

specific ID okay so now let me just

2881:55

provide a comma and the method should be

2881:58

a delete because we are deleting a movie

2882:00

so we have to provide the method of

2882:02

delete to now underneath that we're

2882:04

going to be also adding uh what do we

2882:06

call it we're going to be also adding

2882:08

end point4 get specific movie okay so

2882:12

we're going to be using a builder. query

2882:14

in this casee because we are only

2882:15

fetching some sort of data we are not

2882:17

rotating that data and now let me just

2882:19

specify the ID inside there and then we

2882:22

have to specify the arrow function and

2882:24

I'm going to be passing my movie URL and

2882:26

then inside there we're going to be

2882:28

defining our specific movie and then the

2882:31

ID of their specific movie okay so now

2882:33

let me just save there underneath this

2882:35

endpoint we have to create yet another

2882:36

endpoint now underneath there we're

2882:38

going to be defining yet another

2882:40

endpoint for upload image and now let me

2882:43

just take care of this we're going to be

2882:44

using like builder. mutation and now

2882:46

inside that we're going to be proving

2882:48

the query of aror function of form data

2882:51

okay so now inside that uh let me just P

2882:54

my data and also my aror function we're

2882:57

going to be defining our URL and the URL

2882:59

will take the upload URL and it's not

2883:02

going to take anything else in that and

2883:04

now let me just provide my method of

2883:05

totally poost and then also we have to

2883:07

Define our body and the body will be

2883:09

there form data okay so now we totally

2883:11

done with that now let me just put my

2883:13

comma here now underneath that we're

2883:15

going to be creating an endpoint for get

2883:16

new movie

2883:18

or movies rather and we're going to just

2883:20

using like um builder. mut not mutation

2883:24

but in this case we're now getting some

2883:25

sort of data so we have to use the query

2883:28

and now if you want a query that for

2883:29

that we're going to be using this Arrow

2883:31

function and we're going to be using the

2883:33

endpoint of the movie URL first of all

2883:36

and then we have to just write a new

2883:38

movies there we go okay so now let me

2883:40

just you know I'm not going to duplicate

2883:42

that let me just provide a comma here

2883:44

and let's just remove that from here and

2883:45

now the next thing which you want to do

2883:47

is that you want to get the top movies

2883:49

and we're going to be using like Builder

2883:51

do query and we going to be using almost

2883:55

the same function as the previous one so

2883:57

now let me just add my arrow function

2883:58

inside there and we are going to be

2884:00

using like my movie URL and then we want

2884:02

to go to the top movies there we go okay

2884:05

so now let me just duplicate this one

2884:07

what the hell and now let me just put a

2884:09

comma here and I'm going to just change

2884:10

the name of that to like get random

2884:13

movies now let me just change this top

2884:16

and change that to random mov M right

2884:18

here so now let me just save that and

2884:20

that was a lot of endpoint right here

2884:23

but we did that now let me just create a

2884:25

hooks based on these end points and then

2884:26

we're going to be using the inside our

2884:28

component so now let me just use the

2884:30

export con and now let me just grab that

2884:32

from the M API slice okay so now inside

2884:36

there first of all we're going to be

2884:38

exporting the use get all movies then

2884:40

we're going to be also um exporting the

2884:43

use create movie mutation and then also

2884:46

the use update movie mut

2884:48

then also use add uh movie review and uh

2884:52

use delete comment and also they use get

2884:57

specific movie query and also they use

2885:00

upload image uh mutation and now let me

2885:03

just provide a comma and use get new

2885:05

movies and you know let me just save

2885:07

that and I'm going to just provide my

2885:09

comment right here uh this is going to

2885:12

be for the dashboard or you know I'm not

2885:14

going to provide their dashboard right

2885:15

here because we can use that in other

2885:17

places if you wanted to so use get top

2885:20

movies and also they use get uh random

2885:24

movie come on random movies as well so

2885:27

yeah that was all of the end point we

2885:29

have to create and also uh that was a

2885:32

lot of hooks okay so that was a long

2885:35

journey but we did that so that's to

2885:37

you're done now the next thing which you

2885:38

have to do is that we have to create a

2885:40

movie so for that we're going to have to

2885:42

go ahead and go to our pages and inside

2885:44

this Pages we're going to be going into

2885:45

the admin and inside this admin we're

2885:48

going to be creating or uh what do you

2885:49

call it or create come on let me just

2885:52

remove this cursor we're going to be

2885:53

creating or create movie. jsx so now let

2885:57

me just write my RFC inside there let me

2885:59

just save there and we're going to have

2886:00

to go ahead and go to the main and

2886:02

register there right here okay so now

2886:04

let me just duplicate there and instead

2886:06

of writing this genre I'm going to just

2886:07

write a create right here and I'm going

2886:10

to just remove there and change there to

2886:11

create movie and it's going to Auto

2886:14

Import there for me let me just go back

2886:16

and now let me just save there and I'm

2886:18

going to copy that from here let me just

2886:20

copy that entire thing from here and I'm

2886:23

going to place it right here but first

2886:25

of all I'm going to have to just stop my

2886:26

server and I'm going to be using The npm

2886:29

Run full stack in this case not just a

2886:31

backend but the full stack and it's

2886:32

going to run my front end and also my

2886:35

back end so now let me just place it

2886:37

right here and I'm going to be just

2886:39

placing the hit enter and here you can

2886:41

see it's going of just gives us first of

2886:42

all we have to log in as an admin I

2886:44

forgot to do this so now let me just log

2886:46

in as an admin and I'm going to just

2886:48

write h12 and it's going to log in as an

2886:50

admin right here now the next thing you

2886:52

have to do is that we have to place this

2886:54

endpoint right here and now let me just

2886:55

hit enter and here you can see it's

2886:57

going to gives us that create movie

2886:59

right here okay which is totally amazing

2887:02

so yeah what I want to do is that I'm

2887:04

going to go ahead and go to my create

2887:05

movie and now let's just take care of

2887:07

that and the first thing which I want to

2887:09

do is that I want to grab my use effect

2887:11

and also the use T and the next thing

2887:14

which I want to grab is the use navigate

2887:16

from the react router D in this case re

2887:19

router Dom let's just close that and we

2887:21

are going to be also importing a few

2887:23

hooks from our rtk query which will be

2887:26

something but I'm going to show you

2887:27

there in a few second let me just go

2887:29

ahead and go to my Redux then let me

2887:30

just go to my API and then um movies and

2887:34

now inside there uh we are going to be

2887:36

just grabbing two so we're going to be

2887:38

grabbing like use create mutation create

2887:40

movie mutation and then use upload image

2887:43

uh mutation word here so that's that now

2887:45

let me just also get um

2887:47

all of the movies so for that we're

2887:49

going to be getting there from same path

2887:52

let's just go ahead and go to the redex

2887:54

then the API and we're going to be

2887:55

getting the genre not the movies but the

2887:58

genre and I'm going to be just using

2887:59

like us PCH uh genre query right here so

2888:03

it's going to giv us all of their genres

2888:04

and now let me just import my toast from

2888:07

where from the react toasttify okay so

2888:09

now let me just save that and that's

2888:11

everything we need for now and now let

2888:13

me just create an instance of my

2888:15

navigate so cons navig again and it's

2888:17

going to be equals to the use navigate

2888:19

and now let me just execute the N AIG G

2888:22

which is totally correct and now let me

2888:24

just create my state for the movie so

2888:26

we're going to be just writing like

2888:27

movie data and then we have a set movie

2888:30

uh data there we go and we're going to

2888:33

be using the used St and now let me just

2888:34

provide my object first of all we are

2888:36

going to be providing the name of the

2888:38

movie then the year and the initial

2888:40

value will be set to zero then the

2888:42

detail will be also set to uh d e t t a

2888:46

i come on D e t a i l but now let me

2888:50

just check my uh come on my model and

2888:53

let me just check was that a detail or

2888:56

details okay that was just a detail now

2888:58

let me just copy that and let me just

2889:00

place it right here and that was correct

2889:02

and now let me just put the cast and the

2889:04

cast was an empty object uh empty array

2889:06

rather and now let me provide my rating

2889:08

of zero and also the image will be

2889:10

totally know and also the genre will be

2889:13

set to empty string now let me just also

2889:15

create a state for the selected image so

2889:17

I'm going to just say like selected

2889:20

image and also set selected image uh

2889:23

will be now equals to the use St and

2889:25

we're going to be just providing the

2889:27

null inside there and now underneath

2889:29

there we're going to be destructuring

2889:30

something from our rtk query end points

2889:33

and we're going to be destructuring

2889:34

there first of all from the use create

2889:36

movie and we are going to be first of

2889:38

all destructuring our create movie and

2889:41

then not in not in upper case but in

2889:43

lower case so we have a create movie and

2889:46

then we're going to be doing next

2889:47

destructuring so we're going to be

2889:49

destructuring the is loading and we are

2889:50

going to be renaming that to is uh

2889:53

creating movie so we are now renaming

2889:56

that and now let me just also

2889:57

restructure the error and also I'm going

2890:00

to just rename that to like mie uh error

2890:04

detail or something like that and yeah

2890:06

you can give it any name you like but in

2890:08

my case that's totally fine and now let

2890:10

me just destructure something from the

2890:12

use upload image mutation and we're

2890:15

going to be destructuring first of all

2890:16

the upload load um come on upload image

2890:20

and then we would also do a NE

2890:21

destructuring of is loading and then we

2890:24

have to just give it some sort of name

2890:25

so I'm going to just give the name of

2890:26

like is uploading image and then also

2890:29

the for the error we're going to be also

2890:31

providing the name of like upload um

2890:34

image error E R R details there we go

2890:40

okay so now underneath there what do you

2890:41

want to do we just want to Fitch all of

2890:43

our genres so we're going to be

2890:44

destructuring there from the what do we

2890:48

call it from the use pitch genres query

2890:51

and now let me just fetch that and we're

2890:53

going to be just getting the data I'm

2890:54

going to rename that to genres and also

2890:57

we going to be fetching over is loading

2890:59

and we are going to be renaming that to

2891:01

like is loading genres okay so now

2891:04

underneath that we're going to be using

2891:05

the use effect to get all of the genres

2891:07

in the first render let me just Pro my

2891:09

arrow function inside there and here for

2891:12

the dependency array we are going to be

2891:13

just foring our genres and inside there

2891:15

we are going to be checking if we have

2891:17

the genres so what do you want to do in

2891:19

that case we just want to set movie data

2891:22

and here we're going to be just passing

2891:23

our previous um previous St or previous

2891:27

data right here and now inside that what

2891:29

we want to do we just want to provide

2891:30

our previous data first of all previous

2891:33

data and then we are going to be

2891:34

providing or we are going to be mutating

2891:36

our genre and we are going to be just

2891:38

setting that to like genres and here

2891:40

we're going to be taking the first index

2891:42

and if we have that we're going to be

2891:44

just getting the ID from there and if

2891:46

that's not the case so we're going to be

2891:48

just setting there to empty string okay

2891:49

so that's there now let me just save

2891:51

that and I'm going to just Place The

2891:53

Styling right here and you should do the

2891:55

same now inside there we're going to be

2891:56

creating our form let's just remove this

2891:58

action from there and now inside this

2892:00

form we're going to be just creating our

2892:02

paragraph and I'm going to just say like

2892:03

create movie I'm going to also proide

2892:05

The Styling to it so now let me just

2892:07

save there and let's just check this out

2892:09

and here you can see we are now getting

2892:10

our create movie right here which is

2892:12

totally amazing now onne that we're

2892:13

going to be creating our D with the

2892:15

class is of mar for the bottom of four

2892:18

and now inside that we're going to be

2892:19

providing a label and for the label

2892:21

we're not going to be providing any HTML

2892:23

4 but we will provide some sort of a

2892:25

class to it so I'm going to just provide

2892:26

a class of block to it and now inside

2892:28

there we're going to be just providing

2892:29

the name and let me just also provide my

2892:32

input inside there type will be set to

2892:34

text and now inside there we're going to

2892:36

be also providing the name to it and the

2892:38

name will be a name and I'm going to

2892:40

also provide the value of movie data do

2892:44

name let me just also attach the event

2892:46

handler on that so I'm going to just

2892:47

pass the handle uh change event hand

2892:50

right here and which we did not create

2892:52

by the way but we will create there in a

2892:53

few second and now let me just attach

2892:55

some classes to it so pairing for the

2892:57

xais will be set to two and pairing for

2892:59

the Y AIS will be set to one and with

2893:01

will be totally full now let me just

2893:02

save there and comment this line out for

2893:04

a second s there and here you can see we

2893:07

are now getting one name right here and

2893:09

that's looking totally amazing you can

2893:10

change the UI if you want it to but in

2893:12

my case that's going to do it let me

2893:14

just copy this div and duplicate there a

2893:17

few times so first of all we're going to

2893:19

be duplicating that for the year then

2893:20

for the detail then for the genre and

2893:23

one time for the cast and I guess that's

2893:25

going to do it so I'm going to go to the

2893:26

top and first of all we have a name and

2893:29

now the next one we have is year so I'm

2893:31

going to just type the year right here

2893:33

I'm going to also change the type of

2893:35

number and also let me just provide uh

2893:39

here in this case and inside the movie

2893:41

data we're going to be just parting over

2893:43

here and we also have a handle change

2893:46

right here for this one as well and

2893:47

we're not going to be changing anything

2893:48

inside there now the next one we have is

2893:50

a detail so now let me just change there

2893:52

to detail uppercase D and then tails in

2893:56

lower case and I'm going to be just

2893:57

removing this input field from here and

2893:59

now let me just put my text area and

2894:02

inside this text area we're going to be

2894:04

providing for the name as a detail and

2894:06

for the ID we're not going to be

2894:08

providing any IDs to it and we're not

2894:09

going to be providing any rows and

2894:11

columns inside there okay so now let me

2894:13

just provide the value and the value

2894:15

will be like movie data and then we have

2894:17

our detail right here inside there now

2894:20

let me just attach my own change event

2894:22

hander on there and we're going to be

2894:24

passing our handle change event handler

2894:27

which we did not create yet okay so now

2894:29

let me just um copy some styling from

2894:31

here and let me just place it right here

2894:34

God damn it let's just cut that from

2894:38

here and let me just place it right here

2894:40

s my file and comment this line out okay

2894:43

so that's that instead of writing this

2894:45

name let's just remove this name and I'm

2894:47

going to just provide a cast of comma

2894:51

separated s e p a r a t e d and let's

2894:55

just put our separate right here and

2894:57

everything else should be the same but

2894:59

let me just Prov for the name of cast

2895:01

and then we have a movies data and then

2895:04

cast and we're going to be just

2895:05

providing the join method on there and

2895:07

let's just provide a comma and space

2895:09

okay so that's there and we're going to

2895:11

be also attaching our event handler but

2895:13

now let me just remove that from here

2895:15

and we're going to be attaching the

2895:16

event

2895:17

and now let me just use my set movies

2895:19

data and here we're going to be first of

2895:21

all providing the movie uh let me just

2895:23

use my spread operator and now let me

2895:25

just provide my movie data first of all

2895:27

we're going to be providing there and

2895:28

then we're going to be just changing the

2895:30

cast to the event. target. value and now

2895:33

and now let me just split all of that

2895:35

and we're going to be splitting there

2895:37

and now let me just provide a comma and

2895:38

space so that's everything that you have

2895:40

to do let's just take care of the genre

2895:42

so let me just write a genre and also uh

2895:45

we have to just remove

2895:47

uh uh this entire input field right here

2895:50

I'm going to just remove this entire

2895:52

input field and I'm going to just change

2895:53

that to select and inside the select

2895:55

we're going to be providing the name of

2895:57

genre to it and for the ID we're not

2895:59

going to providing the ID uh we're going

2896:01

to be providing the value and the value

2896:03

will be movie data. genre and now inside

2896:06

there we're going to be also providing

2896:07

the on change when Handler on there and

2896:10

that same handle change event handler

2896:12

which we're going to be creating in a

2896:13

few second okay so yeah let me just copy

2896:17

that entire thing from there and now let

2896:19

me just place it right here and that's

2896:21

going to do it but now let me just save

2896:24

there I'm going to comment this line out

2896:25

for a second like so and now inside the

2896:28

select statement uh what do you want to

2896:30

do you just want to check for is loading

2896:32

genre if it's uh if it has this genre

2896:35

right here we're going to be passing our

2896:37

option let me just pass my option right

2896:39

here and close there okay and we're

2896:41

going to be just saying like loading

2896:43

genres dot dot dot okay so if that's not

2896:46

the case what do you want to do in that

2896:48

case we're going to just iterating all

2896:50

through all of the genres that we

2896:51

currently have by using the map method

2896:53

and let me just provide my genre name

2896:55

and now inside that we're going to be

2896:57

just passing our Arrow function and

2896:59

that's looking awful but let's just

2897:02

remove there so we have our genre and

2897:06

yeah you know let me just close that

2897:09

that's looking totally

2897:11

awful let's just remove that and let me

2897:13

just try that once again it read over

2897:15

through all of the genres by us using

2897:16

the map method and we are going to be

2897:19

also passing the genre and inside that

2897:22

what do you want to do you just want to

2897:23

attach our option so now let me just

2897:25

attach my option and I'm going to be

2897:27

attaching the key first of all and the

2897:29

key will be my genre and then there's

2897:32

specific ID from that genre and then we

2897:35

are going to be also providing the value

2897:37

right here and the value will be genre

2897:39

and then that specific ID from their

2897:41

genre okay so then we have to also write

2897:44

a genre. name and now let me just SA

2897:46

there okay so that's every single thing

2897:48

that we have to take care of right now

2897:51

but you know what underneath this select

2897:53

and also this label and also this D but

2897:56

inside this form and let me just with a

2897:59

class of margin for the bottom will be

2898:00

set to four and we're going to just

2898:02

passing the label off we're not going to

2898:04

be providing any HTML 4 to that but we

2898:06

will provide a styling to that so for

2898:08

the styling we're going to be checking

2898:09

if we don't have the selected image then

2898:12

what do you want to do we just want to

2898:13

attach the border of um one pixel solid

2898:18

come on solid and then

2898:20

888 come on 88 come on 888 there we go

2898:25

and also let me just provide a comma

2898:26

here I'm going to be also passing the

2898:28

Border radius B Rd r r a d us s and for

2898:32

the Border radius we're going to be

2898:34

passing the five pixel border and also

2898:36

we're going to be adding the adding of

2898:38

at pixel okay that's not the case what

2898:42

do you want to do in that case so now

2898:43

inside that we're going to be adding

2898:45

these styling right here just a border

2898:47

of zero and the Border radius of zero

2898:49

and ping will be also set to zero okay

2898:51

so yeah that's cool but now inside this

2898:53

label uh we are going to be rendering

2898:56

our image and also that input so we're

2898:58

going to be checking if you don't have

2898:59

the selected image and we just want to

2899:02

show that upload come on upload image

2899:06

come on let me just type image right

2899:07

here and underneath that we're going to

2899:09

be just providing our input and the type

2899:11

will be just set to file and now we are

2899:13

going to be also accepting all of the

2899:15

images so now let me just add image and

2899:18

every single image and on change we're

2899:20

going to be just typing our

2899:22

handle handle image change which we're

2899:25

going to be creating in a few seconds

2899:27

and now let me just add a bit of styling

2899:28

to it display we be now set to not

2899:33

selected image and if that's not the

2899:36

case so we are going to be just writing

2899:37

a none and if that is the case we are

2899:39

going to be setting there to block okay

2899:41

so now let me just save there and now

2899:43

let me just comment this line out we're

2899:45

going to be creating there in a few

2899:46

seconds but it will take a bit of time

2899:48

now underneath this level and also this

2899:50

de we're going to be creating our button

2899:52

so now let me just finally create my

2899:54

button right here and we are going to be

2899:56

providing the type first of all and the

2899:58

type will be set to button and we're

2899:59

going to be also attaching the on click

2900:01

event handler on there and handle create

2900:04

movie in this case and now let me just

2900:07

add these classes so I'm going to just

2900:09

copy there and now let me just place it

2900:11

right here and you should do the same

2900:13

let me just comment this line out we're

2900:14

going to be also attaching the disabled

2900:16

as well and if that is not creating a

2900:20

movie so what do you want to do in that

2900:22

case or is uploading the image okay so

2900:24

if that's the case so now inside that

2900:26

we're going to be just attaching or is

2900:28

creating a movie or uh is uploading the

2900:32

image and if that's the case we're going

2900:34

to be just saying like creating dot dot

2900:36

dot and if that's not the case so we're

2900:38

going to be just saying like create

2900:40

movie in this case Okay so yeah now let

2900:42

me just save that and that was it about

2900:44

for this entire UI

2900:47

and that's a lot of coding and a lot of

2900:49

explanation of every single line and

2900:52

yeah now let me just check this out and

2900:54

here you can see we have the UI right

2900:55

here you can totally definitely change

2900:57

the UI if you want it to but currently

2901:00

we have every single thing that we

2901:01

currently need right here so now let me

2901:03

just finally attach the functionality

2901:05

and first of all we're going to be just

2901:07

starting from uh what do you call it

2901:10

creating a movie but we are going to be

2901:11

starting from the handle change now I'm

2901:14

going to just uncomment there and let me

2901:16

just see we have this handle change

2901:18

right here now let me just uncomment

2901:20

this line out as well now let me just

2901:22

select that hit contr d one more time

2901:24

let me just select this handle change

2901:25

one more time and hit control D we have

2901:27

yet another ah God let me just select

2901:30

that hit contr D so we have yet another

2901:32

handle change right here let's just

2901:34

uncomment that and let me just hit contr

2901:35

d one more time and yeah we are now

2901:38

totally done with that but now let me

2901:39

just copy that and let's just create our

2901:41

handle change up above this jsx right

2901:44

here okay so we're going to be just

2901:45

creating like con handle change and

2901:48

we're going to be just passing the event

2901:50

object inside there and we're going to

2901:51

be destructuring two things from the

2901:53

event. target object okay so we're going

2901:56

to be just restructuring first of all

2901:57

the name and also the value from there

2902:00

okay so now underneath there what do you

2902:01

want to do we have to first of all put

2902:03

the equal to sign right here now

2902:05

underneath there what do you want to do

2902:07

we just want to check if name is triple

2902:10

equal to the genre then what you want to

2902:12

do in that case we just want to first of

2902:14

all take the selected genre

2902:16

and come on g e n r e come on

2902:21

selected genre it's going to be equals

2902:23

to the genres. come on

2902:26

genres. find method and we're going to

2902:28

be passing our genre in this case and

2902:30

here we are going to be just checking

2902:31

like genre. name is triple equal to the

2902:34

value okay so then it's going to gives

2902:35

us that selected genre we can totally

2902:37

log there you can totally log there if

2902:39

you wanted to but I'm not going to and

2902:41

you guys already know all of that stuff

2902:43

so that's why I'm going a bit fast now

2902:44

let me just add my set mov data and here

2902:47

inside there we're going to be just

2902:48

providing the previous data for the

2902:50

previous St and now let me just pass my

2902:52

arrow function inside there come on

2902:55

Arrow function there we go and now first

2902:57

of all we're going to be just adding our

2902:59

previous data and then inside come on

2903:01

previous data let me just copy the

2903:04

preview data from there and now let me

2903:06

just place it right here but then we're

2903:08

going to be mutating our state or

2903:10

changing word stad by using the genre if

2903:12

the selected genre selected genre so

2903:16

what you want to do in there we're going

2903:17

to be just providing like selected genre

2903:20

let me just add a genre and then the

2903:22

specific ID from there and if that's not

2903:24

the case we're going to be just setting

2903:25

that to empty string okay so that's the

2903:28

now let me just save this file but

2903:29

something is not okay and that's because

2903:32

we forgot to include the curly braces

2903:35

let me just add the curly brace there

2903:37

and let's just add it right here sell

2903:39

file

2903:40

uh let me just copy that place it one

2903:43

more time what the hell am I doing and

2903:47

uh that was for the F statement but now

2903:49

for the L statement what do you want to

2903:50

do in that case we're going to be adding

2903:52

the set movie data let me just add my

2903:54

previous um data one more time and now

2903:57

let me just pass my arrow function

2903:58

inside there and let's just add our

2904:00

previous data and we're going to be just

2904:03

adding the name and value to that name

2904:05

okay so that's that and we are now

2904:07

totally done with this function now let

2904:09

me just save there and we are not going

2904:11

to be testing that right here because it

2904:13

will create a movie for us without any

2904:15

specific there and it's going to just

2904:16

gives us an error now let me just take

2904:18

care of the image and also the create

2904:21

movie function so now let me just take

2904:22

care of that I'm going to just uh

2904:24

collaps it right here for a few seconds

2904:26

uh image change so we have that handle

2904:30

image change in one area which you can

2904:32

see right here now let me just copy the

2904:34

name and let me just go to the top and

2904:36

here we're going to be just creating

2904:38

that function right here okay so

2904:40

underneath this function we're going to

2904:42

be creating our handle image change so

2904:44

now let me just create there and this is

2904:46

totally simple function you will see

2904:48

that so first of all we need the file

2904:50

and we're going to be getting that file

2904:52

by using e. target. files and we only

2904:54

need the first one and then we going to

2904:56

be just changing our set selected image

2904:58

and we're going to be just passing our

2904:59

file inside there and that was it about

2905:01

this function baby that was it and now

2905:04

let me just take care of this handle

2905:06

create movies we have that in one place

2905:09

and now let me just click on there and

2905:10

here you can see we have that let me

2905:12

just uncomment this semi file and copy

2905:15

there let let me just go to the top one

2905:17

more time and let me just create their

2905:19

function right here and this is going to

2905:20

be the big one okay so underneath this

2905:23

function let me just collapse that right

2905:25

here we're going to be creating our uh

2905:28

handle create movie so now let me just

2905:29

create like con handle create movie it's

2905:32

going to be asynchronous function as syn

2905:34

function and now let me just add my

2905:36

arrow function inside there we're going

2905:38

to be also attaching the try and catch

2905:40

block but we have to check for a lot of

2905:42

different things so I'm going to just

2905:44

remove that and hit enter right here and

2905:46

now let me just place it right here so

2905:48

first of all we are checking if we don't

2905:49

have the movie name the year detail the

2905:52

case or the selected movie so what do we

2905:54

want to do in that case we're going to

2905:55

just finding the toast so we would just

2905:57

say like toast. error and we would just

2905:59

say like please fill all required Fields

2906:04

okay so then we're going to just

2906:05

returning there and if that's not the

2906:07

case let me just save that if that's not

2906:09

the case what you want to do we're going

2906:11

to be creating a variable with the name

2906:12

of like uploaded up l o a d d upad Ed

2906:16

image path and it's going to be

2906:18

currently set to no okay and now the

2906:20

next thing which you want to do is that

2906:22

you want to check if the movie is

2906:23

selected or if you have the selected

2906:25

image so what do you want to do in that

2906:27

case we're going to just creating our

2906:28

form data it's going to be a new form

2906:32

data okay and this is a Constructor and

2906:34

now we have to append data inside this

2906:35

form so we're going to be using our form

2906:37

data not this one but form data and

2906:41

we're going to be appending our image

2906:43

first of all and the image will be this

2906:45

selected image so now underneath that

2906:47

we're going to be just making another

2906:49

variable so which will be upload image

2906:52

response it's going to be equals to the

2906:56

r r p n there we go it's going to be

2906:59

equals to A and then upload image and

2907:02

now let me just provide a form data

2907:03

inside there okay so now underneath

2907:06

there we're going to be just checking

2907:08

that if we have the upload image

2907:09

response let me just see copy that from

2907:12

here and now let me just place it right

2907:13

here so if we have the upload image

2907:15

response and then we have a data inside

2907:17

there so what do you want to do in there

2907:19

we're going to just setting our uploaded

2907:21

image path image path which we just

2907:23

created and we just set there to n let

2907:25

me just show you there I'm going to copy

2907:27

there and now let me just place it right

2907:29

here and it's going to be equals to the

2907:30

upload image response oh my God there's

2907:33

a lot of uh long variables right here so

2907:36

now let me just get the data from there

2907:38

and then the image inside there okay so

2907:40

if that's not the case what do you want

2907:42

to do in that case console. error and we

2907:44

would just say like failed uh to

2907:47

upload come on f a i l Ed fail to upload

2907:52

image and now let me just add my uh

2907:55

upload image uh error detail right here

2908:00

okay and also we will just say like

2908:02

toast. error so if you have some sort of

2908:04

error so we're going to just saying like

2908:06

fail to upload image right here okay and

2908:10

now finally we just also have to return

2908:13

that so that it will not execute no more

2908:15

and finally we just have to take care of

2908:17

creating a movie we're going to be just

2908:19

calling our create movie function and we

2908:22

just have to specify first of all with

2908:24

movie data and then also we have to set

2908:26

the image and then the upload image uh

2908:30

upload image path let me just show you

2908:32

that I'm going to copy that from here

2908:34

now let me just place it right here sa

2908:36

my file and then we have to navigate or

2908:38

user two let me just WR navigate to this

2908:41

admin and then um movies then Dash list

2908:45

which we're going to be reading later

2908:46

but we did not have that not right now

2908:49

okay so now the next thing which I want

2908:51

to do is that I wanted to place that

2908:53

right here we're going to be also

2908:55

emptying out our input field even though

2908:57

we don't have to do that but I am going

2908:59

to do that I don't know if you come back

2909:01

to the same page and if you have a k so

2909:04

that will be already erased and finally

2909:06

let me just write my toast. sucess and

2909:10

here we're going to just adding like

2909:12

movie addit or add it to database right

2909:17

here okay so now if that's not the case

2909:20

and if we are inside a catch block we're

2909:22

going to be first of all proving our

2909:24

console. error and now let me just

2909:26

provide like fail to create movie and

2909:31

I'm going to also provide a separate

2909:33

right here and then we're going to be

2909:34

just passing our create movie error

2909:36

detail which we're getting from the rtk

2909:39

query and also we're going to be just

2909:41

passing our toast. error and the toast

2909:43

error will say like failed to create

2909:46

movie and now let me just render my

2909:49

movie movie there we go let me just

2909:52

render the create movie come on create

2909:55

movie detail uh eror detail if we have

2909:59

there we're going to be just getting the

2910:00

message from there and finger

2910:04

crossed that was all the thing that we

2910:06

have to do for just creating the movie

2910:09

and now let me just test this out so I'm

2910:10

going to just refresh there and now uh

2910:13

currently let me just check my database

2910:15

where here I'm going to go ahead and go

2910:17

to my mongi B and we have only two

2910:20

movies inside there and finger cross

2910:23

first of all we're going to be just

2910:24

creating a movie of uh I don't know

2910:28

um black AR would be fine let me just

2910:31

add this image and I'm going to just say

2910:33

like Black Adam and I don't know when

2910:36

this movie was released so I'm going to

2910:37

just add like

2910:38

2023 amazing movie of the rock or

2910:43

something and the guest was hosan

2910:45

because I was a Black Adam and

2910:49

John uh and also come on John oh my God

2910:53

John and then Alex and now let me just

2910:56

add some sort of a genre right here let

2910:58

me just select that and I'm going to

2911:00

just add that inside the romance that

2911:03

was a romantic movie oh my God let me

2911:06

just add that right here and let me just

2911:07

click on this uh create movie right here

2911:10

so it's going to just create one movie

2911:12

and then it's going to just brings us to

2911:13

this movie list right here which is a a

2911:15

good sign but we did not create that

2911:17

right here not right now let me just

2911:19

check my database right click on there

2911:20

and refresh that and the movie was not

2911:23

created I don't know why and I just

2911:26

found out that I made a mistake right

2911:28

here let's just remove that and let's

2911:30

just also remove that and now let me

2911:32

just go ahead and create a new movie

2911:34

let's just close them and what I want to

2911:36

do is I want to create a new movie Black

2911:38

Adam and it was released I guess in

2911:41

2023 and one of the best

2911:46

superhero H movie ever or something like

2911:49

that let me just add rock paper and

2911:55

hosen or something like that and now let

2911:57

me just click on this genre click on the

2911:59

REM remains and click on the image and

2912:01

let me just add my black itam image and

2912:03

click on this create button and it's

2912:04

going to just create that movie for us

2912:06

and now let me just check this out here

2912:08

you can see we have these two movies

2912:09

right here now let me just right click

2912:11

on there and click on the refresh so we

2912:13

have now three movies so now let me just

2912:14

check this out let me just click on this

2912:16

one so here you can see we have a black

2912:18

itum we have the image we have the year

2912:20

genre and we also have the cast and the

2912:23

detail the number of review we have zero

2912:26

and yeah that was it about how we're

2912:28

going to be creating a new movie We're

2912:30

Not totally done with the movie creation

2912:32

process now the next thing you have to

2912:33

do is that we have to create another

2912:35

component and I'm going to just create

2912:36

the name of like admin um movies list.

2912:39

jsx and inside there we're going to be

2912:41

using our RFC now let me just go ahead

2912:44

and go to my main and register there

2912:45

right here and I'm going to remove this

2912:48

um come on this genre list and I'm going

2912:50

to just provide my admin uh movie list

2912:53

right here and it's going to Auto Import

2912:55

that for me and now let me just remove

2912:56

this genre from here and also this

2912:58

movies and I'm going to just replace

2913:00

that with movies and then Dash list so

2913:02

now let me just save that and let's just

2913:04

test this out so here you can see it's

2913:06

going to just gives us that admin movie

2913:08

list right here and why is then when we

2913:10

successfully create our movie it's going

2913:12

to redirect the user to this movie list

2913:14

right here okay so now let me just take

2913:16

care of that so the first thing we would

2913:17

need is the link so I'm going to just

2913:19

grab my link from the re Dom now we

2913:22

would also need to use or rtk hook so

2913:24

for that I'm going to just go ahead and

2913:26

go to first of all my Redux and then I'm

2913:29

going to go ahead and go to my API and

2913:31

then movies right here and we're going

2913:33

to be just grabbing this hook right here

2913:35

which will be the use get all movies

2913:38

query now let me just grab there and now

2913:40

let me just create an instance of there

2913:42

yeah we are going to be creating the

2913:43

instance of there but we will also have

2913:46

to uh destructure the data right here so

2913:49

we're going to be just destructuring the

2913:51

data and I'm going to just rename this

2913:52

data to movies okay so now we are

2913:54

totally done with that and now let me

2913:56

just remove this label from this GSX and

2913:58

we're going to be first of all creating

2914:00

a container now let me just put a class

2914:02

name of container and margin for the

2914:04

x-axis will be set to nine rim and now

2914:07

inside them we're going to be just

2914:09

creating a day with the class of flex

2914:10

and also the flex of column and for the

2914:12

medium screen what you want to do we

2914:14

just want to set that two let me just

2914:16

write a medium screen and flex row we're

2914:18

going to be also creating yet another

2914:20

day with a class of padding all around

2914:21

will be set to three and inside that

2914:24

we're going to be just also creating

2914:25

margin for the left and also it's going

2914:28

to be just set to Two Rim and now let me

2914:30

just put a text of totally extra large

2914:32

and font will be set to totally bold and

2914:35

and the heart will be just set to 12 and

2914:37

inside there I'm going to just say like

2914:38

all movies and here let me just pass my

2914:42

uh come on movies if you have that we're

2914:45

going to be grabbing the movies L like

2914:47

how many movies we currently have so now

2914:49

and here you can see it's going to gives

2914:50

us their three movies right here now

2914:52

underneath this D we're going to be

2914:53

creating yet another div and I'm going

2914:55

to just placing these uh classes right

2914:57

here and inside this div we're going to

2914:59

be iterating over through all of the

2915:00

movies and now let me just itate over

2915:02

through there by using the map method

2915:04

and we're going to be just passing our

2915:05

movie right here in this case and now

2915:07

inside there first of all we're going to

2915:09

be creating your link and now let's just

2915:10

close there let me pass my key and the

2915:13

key will be just set to movie and a

2915:15

specific movie ID and now let me just

2915:17

provide a two so it will go to first of

2915:19

all let me just write my back Tex it's

2915:21

going to go to the admin then the movies

2915:23

then the update and now let me just pass

2915:26

my uh movie then do specific movie like

2915:29

specific movie ID and then inside there

2915:32

or you know what first of all let me

2915:33

just provide this classes right here

2915:35

let's just save there and these are

2915:37

going to be the classes for this link

2915:38

and now inside there we're going to be

2915:40

just creating yet another da with a

2915:41

class of flex and now inside this Flex

2915:43

we're going to be creating yet another

2915:45

div with the key of uh let me just pass

2915:48

my movie and then a specific movie ID

2915:50

let me also place these classes right

2915:52

here now let me just save there and

2915:53

inside this div let me just put that

2915:55

right here inside this div we're going

2915:57

to be creating our image and for the

2915:59

image SRC like for the source we're

2916:01

going to be providing our m. image and

2916:03

for the alternative text we're going to

2916:05

be providing our mu. name okay and also

2916:09

I'm going to be just placing the class

2916:10

name of width will be set to totally

2916:12

full and also height will be set to 48

2916:15

48 there we go and object will be also

2916:17

set to totally cover and now let me just

2916:19

save there and here you can see for

2916:21

these two movies we don't have the

2916:23

images but we do have the names but for

2916:25

this movie we added the image so that's

2916:27

why we can see that okay and this is

2916:28

also a link so if I click on that it's

2916:30

going to brings us to that specific

2916:31

movie and we're going to take care of

2916:33

that a bit later underneath this image

2916:35

we're going to be creating yet another

2916:36

div and I'm going to be placing these

2916:38

classes right here for the styling and

2916:40

inside this div we're going to be

2916:42

creating yet another div and I'm going

2916:43

to just give a class name of font will

2916:45

be set to to bold and text will be set

2916:47

to extra large and margin for the bottom

2916:50

will be set to two Okay and here we are

2916:51

going to be just rendering the movie.

2916:53

name and now let me just save that and

2916:56

now underneath this D what you want to

2916:57

do we just want to add a paragraph and

2916:59

for this paragraph you're going to be

2917:00

attaching the class name of text totally

2917:02

gray let me just pass a gray of

2917:05

700 and also text will be set to base

2917:08

and now inside there we're going to just

2917:10

passing the movie. detail uh D come on D

2917:15

detail detail let me just save that and

2917:19

underneath that what do you want to do

2917:21

we're going to be creating yet another

2917:22

div and let me just place the class name

2917:24

of margin for the top will be set to Two

2917:26

Rim and also margin for the bottom will

2917:28

be set to one Rim okay so now let's just

2917:30

close there and now inside there we're

2917:32

going to be creating our link and this

2917:34

link will go to that specific movie so

2917:37

I'm going to just pass first of all my

2917:39

admin then I'm going to just past the

2917:41

movies then update and it's going to

2917:43

just allows us to update a specific

2917:45

movie so we're going to be just passing

2917:46

the movie and then ID okay so now inside

2917:49

there or you know let me just also add

2917:51

the classes and now let me just place

2917:52

these classes right here let me just

2917:54

save that and it's going to just say

2917:56

that update movie now let me just save

2917:59

that and here you can see this how we

2918:00

going to be getting our UI and that's

2918:03

looking better but you can change the UI

2918:05

like however you want but I'm going to

2918:07

just delete these two movies right here

2918:08

so let's just go ahead and go to my

2918:11

database uh and then we have the

2918:14

extraction to and wi so now let me just

2918:16

remove these movies let's just remove

2918:18

that and I'm going to also remove this

2918:20

movie as well let's just leave this

2918:21

black Aram right here let me just

2918:23

refresh there so it's going to just

2918:24

gives us this movie right here which is

2918:26

totally looking cool and yeah that was

2918:28

it about the admin movies and next we're

2918:30

going to be taking care of I guess uh

2918:33

all the comments I'm not sure but we are

2918:35

going to be taking care of something so

2918:37

that was it about the admin movie list

2918:38

so now we are totally done with the

2918:40

admin movie list now the next which you

2918:41

have to do is we have to take care of uh

2918:44

update movies so I'm going to be just

2918:46

creating a component I'm going to just

2918:47

give the name of like update movie do or

2918:50

movie. jsx right here and I'm going to

2918:53

be using my RFC now let me just save

2918:55

that and what I want to do is that I

2918:57

want to register that right here so now

2918:58

let me just duplicate that and we're

2919:00

going to just placing like update movie

2919:02

and it's going to Auto Import that for

2919:04

us and now let me just remove that from

2919:05

here and I'm going to be ping my movies

2919:08

and then update and specific movie so

2919:10

now let me just save that and now let me

2919:12

just go ahead and check this out so if I

2919:14

click on the specific movie so it's

2919:16

going to just give us that update movie

2919:17

right here which is something that we

2919:19

want so I'm going to go ahead and go to

2919:20

my component and we're going to be

2919:22

grabbing a lot of things the first thing

2919:23

which you have to grab is the use effect

2919:26

and we would also need to grab the use

2919:28

St as well now underneath that we would

2919:30

also need to get the use per Rams and

2919:32

also they use navigate as well and we

2919:34

are going to be grabbing that from the

2919:36

react router Dom and we are going to be

2919:37

also importing our Hook from the rtk

2919:39

query which we have like use get

2919:41

specific movie query and use update

2919:43

movie mutation use upload image mutation

2919:46

and use delete movie mutation now

2919:48

underneath there we are going to be also

2919:50

importing let's just remove that from

2919:51

here we're going to be also importing

2919:53

the toast uh from the react toasttify

2919:56

okay so now let me just save there and

2919:58

now inside this update movie what do you

2920:00

want to do we just want to restructure

2920:01

the ID from the use prams and now let me

2920:04

just uh create an instance of that use

2920:06

navigate and store the inside of

2920:08

navigate and now let me just create my

2920:10

state we already created the state so

2920:12

now let me just place a right here so we

2920:13

have a movie data and we also have a set

2920:15

movie data and inside there we have a

2920:17

name year detail Cast rating and also

2920:20

the image okay so that's the now the

2920:22

next which you have to do that we have

2920:23

to also make a St for the selected image

2920:27

and also the set selected image as well

2920:31

and we're going to be grabbing that from

2920:32

the used St and now let me just pass my

2920:34

null initial value and now we are going

2920:36

to be destructuring the data and we're

2920:38

going to be changing the name of that

2920:40

data to the initial i n i t i l initial

2920:44

movie uh data it's going to be coming

2920:47

from the use get specific movie uh movie

2920:50

query and we're going to be passing a

2920:52

specific ID to that specific movie so

2920:54

now let me just use the use effects so

2920:56

that we can see something when the

2920:58

component first renders so now let me

2920:59

just proide the dependency array and for

2921:01

the dependency array we're going to be

2921:03

just providing the initial movie data

2921:05

and inside there we're going to be just

2921:07

checking if we have the initial movie

2921:08

data what do you want to do in that case

2921:10

we're going to be just setting our movie

2921:12

data to the initial movie data right

2921:14

here okay so that's that now let me just

2921:16

save this file so now there we're going

2921:18

to be just destructuring a lot of things

2921:20

from the use update mutation or movie

2921:22

mutation and now inside there we are

2921:24

going to be just passing the update

2921:25

movie and let me just Pro the is loading

2921:28

and we are going to be just renaming

2921:30

that to something like is updating movie

2921:33

would be fine okay so now we are going

2921:36

to be just destructuring there now the

2921:38

next thing which you have to do is we

2921:39

also have to destructure something from

2921:41

the use upload image mutation and we're

2921:44

not going to be ping anything to that

2921:45

but we're going to be just destructuring

2921:47

the upload uh up a upload image and we

2921:52

are going to be just also destructuring

2921:53

the is loading and let me just rename

2921:56

that to like is uploading image and also

2921:59

the error okay so we're going to be just

2922:01

passing the upload let me just pass

2922:03

upload image error details or yeah

2922:07

details will be fine now let me just

2922:09

save that it's going to look a bit

2922:10

horrible so now let me just go back and

2922:13

that's totally different things so now

2922:16

I'm going to also destructure my

2922:17

deletion so let me just zoom in a bit

2922:19

once again and I'm going to be just

2922:21

destructuring there but first of all we

2922:23

have to use the use delete uh movie

2922:25

mutation and then we're going to be just

2922:27

destructuring the delete movie right

2922:30

here come on delete m o v i e there we

2922:32

go let me place my styling right here

2922:34

and inside there we're going to be

2922:36

creating a form and we're not going to

2922:37

be providing any action to there and

2922:39

inside this form we are going to be

2922:40

creating a paragraph which will say the

2922:42

update movie right here and now let me

2922:44

just place the these classes right now

2922:46

let me just save there and let's just

2922:48

refresh there and here you can see we

2922:49

are not getting anything but now let me

2922:51

just right click on there and go to my

2922:52

inspect element let's just go to the

2922:54

console and we are getting the error it

2922:57

is saying the requested module SRC uh M

2923:01

does not provide an export name use

2923:03

delete movie mutation why

2923:07

not let me just go to the

2923:09

top movies does not provide the use

2923:12

delete mve mutation use delete yeah we

2923:15

do have the used delete comment but we

2923:17

are already defining or used delete I

2923:21

guess we're not exporting that let me

2923:23

just check so let me just type the use

2923:26

once again use

2923:27

delete and we have a movie mutation

2923:30

right here now let me just provide a

2923:31

comma save this file and now let me just

2923:33

refresh that and here you can see we are

2923:35

now getting the movie right here updated

2923:37

movie rather so we are now getting there

2923:39

which is totally cool but now let's just

2923:41

take care of the jsx right here so now

2923:43

underneath this paragraph gra we are

2923:45

going to be creating our dat with the

2923:46

class of margin for the bottom will be

2923:47

set to four and now inside that we're

2923:49

going to be just providing the label of

2923:52

um let's just remove that HTML 4 and now

2923:54

we me provide a class name of block to

2923:56

it and inside there we're going to be

2923:57

providing the name and also the input

2923:59

field so this input field will have the

2924:01

type of text but we're going to be also

2924:03

providing the name of name as well and

2924:06

also the value will be set to the mie

2924:09

data and then we have to specifically

2924:11

specify the name and then the on change

2924:14

property we're going to be passing the

2924:15

handle change okay something which we're

2924:17

going to be creating in a few second but

2924:19

now let me just provide a bit of styling

2924:20

to it so border and ping for the xaxis

2924:22

will be set to two pairing for the y

2924:24

axis will be set to one and withth will

2924:26

be set to totally full so now let me

2924:27

just save there let's just count this

2924:29

line out save our file and here you can

2924:31

see we are now getting our black arum

2924:33

right here and which is looking totally

2924:35

a okay but now let me just duplicate

2924:37

this line of code maybe three times so

2924:39

this is going to be one two and three

2924:42

now let me just take care of the first

2924:43

one so we have a name but now let's just

2924:46

change this name to year so I'm going to

2924:49

just change that to year let's just

2924:51

provide a year right here and the type

2924:53

will be set to number and also this is

2924:56

going to be set to year and from the

2924:58

movie data we're not going to be taking

2925:00

the name but in this case we're going to

2925:01

be providing the year and I guess the

2925:04

rest of them will be totally the same

2925:05

but now let me just change that to

2925:08

detail and we're not going to be

2925:10

providing any input to that so now let's

2925:12

just remove that from here we're going

2925:14

to be providing text area and let's just

2925:17

provide a name of detail to it and for

2925:19

the ID we're not going to be providing

2925:21

any ID and colums and rows so let's just

2925:24

remove that and now we are going to be

2925:27

also providing the value and the value

2925:28

will be movie data do detail there we go

2925:33

now let me also provide the own change

2925:34

Handler on there so handle change which

2925:37

we're going to be commenting in a few

2925:38

second now let me just copy the same

2925:41

styling from there let's just copy that

2925:43

from here and now let me just place it

2925:45

right here same my file and now let me

2925:48

just uh comment this line out and inside

2925:50

this text area what I want to do uh and

2925:53

we're not going to be closing our text

2925:54

area like that but now let me just close

2925:56

them manually so now let me just save

2925:58

this file and that's there and finally

2926:01

let's just take care of the cast so you

2926:05

would have a cast and then the comma

2926:09

separated cast s e p a r a t d and now

2926:15

underneath that we're going to be just

2926:16

passing the cast and then we have to

2926:19

specifically provide the cast and then

2926:21

the join and now let's just split that

2926:23

by using the comma and now what I want

2926:26

to do I'm going to just uncomment that

2926:28

let me just remove that from here let me

2926:30

just P my event object to there and the

2926:32

set movies data and we are going to be

2926:34

first of all providing all of the movies

2926:36

so let's just provide let's just remove

2926:38

there movie data and now let me just

2926:41

change the cast and the cast will be ER

2926:43

Target do value and now let's just split

2926:47

that by using this comma and there we go

2926:50

okay so now let me just save there and

2926:52

underneath this label and div we are

2926:55

going to be defining our classes I mean

2926:57

like that same styling once again so now

2926:59

let me just go back and now let me just

2927:01

Place The Styling right here so here you

2927:03

can see we are now providing their div

2927:05

and we are now providing their classes

2927:07

to it and then we have a level and we're

2927:08

now providing this inline styling to

2927:10

that and if we don't have the selected

2927:12

image so then we are providing these

2927:13

classes but if we have there so then we

2927:15

are providing these classes right here

2927:17

okay now inside they we're now providing

2927:19

if we have the selected image so we're

2927:21

going to be just saying like upload

2927:22

image and otherwise we're going to be

2927:24

just taking care of the handle uh image

2927:27

upload so now let me just save that and

2927:29

that's exactly what you have to type

2927:31

okay so I'm just uh copying and placing

2927:33

there because I already written this

2927:35

code and I'm rewriting there once again

2927:37

so I don't want to waste your time and

2927:39

not mine so now let me just save that

2927:41

and underneath this dat what do I have

2927:43

to do I can totally copy the the button

2927:45

as well but you know what let me just

2927:46

retype there so I'm going to just

2927:48

placing the button and now let me just

2927:50

put a type of button to it I'm going to

2927:52

also provide the on click Handler to

2927:54

that and then we have a handle update

2927:56

movie and we are going to be providing

2927:58

there in a few second but now let me

2928:00

just provide a b of classes to it and

2928:02

then outside from there we are going to

2928:03

be also attaching the disabled State on

2928:05

there if we have the is updating movie

2928:08

or we have the is upload uh movie right

2928:11

here so now let me just save that and

2928:13

inside there

2928:15

uh inside the level of this bone what do

2928:17

you want to do we just want to check if

2928:18

you have is updating movie or we have

2928:21

the is uploading movie is uploading

2928:26

movie right here uh this should be

2928:29

uploading so is uploading movie so what

2928:32

you want to do in that case we just want

2928:35

to check if we have the updating dot dot

2928:37

dot or we are going to be attaching the

2928:39

update movie there we go okay and now

2928:42

underneath this button we're going to be

2928:44

creating a another button and I'm going

2928:46

to just um WR the type of button to it

2928:49

and also the on click event handler will

2928:51

say the handle delete uh come on handle

2928:56

delete uh movie right here and we're

2928:59

going to be also attaching the same

2929:00

classes so now let me just copy that and

2929:03

now let me just place it right here and

2929:05

the disabled state will say there is

2929:08

updating movie or there is uploading

2929:12

movie okay and now here inside that

2929:14

there we are going to be just ping that

2929:16

is updating movie or that is uploading

2929:20

uploading movie and so we are going to

2929:22

be just spacing like uh either deleting

2929:24

come on d e l e a d e l e t i n g dot

2929:28

dot dot or we're going to be just

2929:30

passing like delete movie d e l e t e

2929:34

delete movie as a label so now let me

2929:35

just save there and now let me just

2929:37

comment this line out sa file and here

2929:39

you can see we now getting all of the

2929:40

movie detail but we going to have to

2929:43

provide a bit of more classes to there

2929:45

so now let me just place these classes

2929:47

to these classes right here so now let

2929:49

me just save there and here you can see

2929:50

we're now getting this red button right

2929:52

here they are not doing anything because

2929:54

we're not attaching any event listener

2929:56

on there and yeah that's the UI but now

2929:59

let me just take care of the

2930:00

functionality I'm going to go to the top

2930:02

and first of all we're going to be just

2930:04

defining the handle change functions we

2930:07

have this handle change function in

2930:08

three area so now let me just uncomment

2930:10

that now let me just click on that once

2930:12

again so we have that right here now let

2930:14

me just uncomment there here and now let

2930:17

me just uncomment there right here at

2930:18

the final stage now let me just go to

2930:21

the top and create the same function

2930:23

which we are defining for all of their

2930:25

components so we are going to be just

2930:26

providing first of all the handle change

2930:29

it's going to take the event and now

2930:30

inside there uh what do you want to do

2930:32

we just want to grab the name and also

2930:34

the value from where from the ER Target

2930:38

okay and now underneath that we're going

2930:39

to be just defining like set mie data

2930:41

and let's just provide our previous uh

2930:43

data right here and inside there let's

2930:46

just remove that from here and inside

2930:49

there we're going to be providing our

2930:50

previous data so prev data and now let

2930:53

me just provide my name and let's just

2930:55

Define a specific value for that okay so

2930:59

now let me just save that and that's it

2931:00

about for this function now let me just

2931:02

take care of the handle image change and

2931:05

I'm going to just search for that so we

2931:07

have the instance of there in one place

2931:09

and now let me just uncomment that and

2931:12

I'm going to go to the top once again

2931:13

and now let me just create this function

2931:15

right here underneath this handle change

2931:17

now let me just create that function and

2931:18

this one is going to be totally simple

2931:20

so we're going to be just creating like

2931:22

um the function name and now let me just

2931:24

provide our event object and inside

2931:26

there we're going to be just providing

2931:27

the file and that will be the e. target.

2931:30

files and we're going to be getting the

2931:32

first one and now need that we're going

2931:34

to be using like say selected image and

2931:36

we're going to be providing the type of

2931:38

file okay so that's the now let me just

2931:40

search for the handle update movie and

2931:43

here you can see we have the instance

2931:44

off there now let me just uncomment

2931:46

there go to the top and let's just go to

2931:49

the top once again and we are going to

2931:52

be creating this function right here at

2931:54

the top of this jsx so we're going to be

2931:56

just creating like uh handle update

2931:58

movie and this is going to be the

2931:59

asynchronous function and now inside

2932:01

there we're going to be using our try

2932:03

and catch loock for the catch loock

2932:05

we're going to be taking care of there

2932:06

in a few seconds but first of all we're

2932:08

going to be just checking if we already

2932:10

have these properties so let's just

2932:12

remove that and hit enter right here and

2932:14

let's let's just check if you don't have

2932:15

the name or the year or the detail or

2932:18

the case so what you want to do in that

2932:20

case we just want to throw some sort of

2932:21

a to so we are going to be just saying

2932:23

like toast. error and now let me just

2932:25

Define like please uh fill in all

2932:28

required Fields okay and now I need that

2932:31

we're going to just returning that or

2932:33

you know what that's exactly the same

2932:35

logic as the create movie so I'm going

2932:38

to go ahead and go to there and we have

2932:40

that exact same logic of how

2932:44

uh handle CH not this one you know

2932:48

there's a bit of different so you know

2932:50

let me just remove that from here and

2932:51

underneath these curly braces what do

2932:53

you want to do first of all we going to

2932:54

be defining like uploaded u l o a d e d

2932:58

uploaded image path and it's going to be

2933:00

equals to the movie data. image okay so

2933:04

now let's just close that and now let's

2933:05

just search for the selected image and

2933:08

now inside there we're going to be just

2933:10

creating our form data and it's going to

2933:12

be equals to the new form

2933:15

uh data which we're going to be creating

2933:16

by using this new form data and now

2933:18

underneath that what do you want to do

2933:20

we just want to append our image so form

2933:22

data and let's just append or image in

2933:25

there okay and the image will be that

2933:27

selected image okay so now underneath

2933:30

there we're going to be defining our

2933:31

upload upload image response is going to

2933:36

be equals to the A and then upload image

2933:38

and now let me just P my form data

2933:40

inside there now underneath there we're

2933:42

going to be just checking if we have the

2933:44

Lo image response and then inside there

2933:47

we're going to be just searching for

2933:48

their data then what you want to do we

2933:50

just want to check for the uploaded uh

2933:53

not this one but the

2933:55

uploaded image path and it's going to be

2933:58

equals to the uploaded not upload it but

2934:01

upload image response image response and

2934:04

we are going to be getting the data do

2934:06

image so we're going to just setting

2934:08

that to the data image and now if that's

2934:10

not the case what do you want to do you

2934:12

just want to pass the lock and also the

2934:14

toast of this error right here now to

2934:16

need this FNL statement what do you want

2934:17

to do we are going to be just creating

2934:20

or not creating but updating our movie

2934:22

so aw and then update movie and now

2934:25

let's just pass our ID of ID and also

2934:28

the update uh yeah update T movie will

2934:31

be now equals to let's just first of all

2934:33

Define over all of the movies so movie

2934:36

data and then we have to just write a

2934:38

image and then

2934:39

uploaded uh image path in this case and

2934:42

if everything is totally successful F

2934:44

then we want to navigate our user to the

2934:46

movies okay so we're going to be just

2934:48

taking care of that in a few second but

2934:50

now let me just take care of the error

2934:52

and now we are going to be just

2934:54

attaching this error right here okay so

2934:56

now let me just save there and the final

2934:58

thing which you have to take care of

2934:59

this handle leate movie let me just go

2935:02

ahead and search for that and let me

2935:03

just uncomment this line of code and

2935:05

then we want to go to the top let me

2935:07

just copy the name of that let me just

2935:09

go to the top and here you can see

2935:11

underneath this function we're going to

2935:13

just cre our handle delete function so

2935:15

now let's just do that so we have a c

2935:18

handle delete movie it's going to be

2935:19

also a synchronous function and inside

2935:21

this function what do you want to do uh

2935:23

let's just provide or try and catch

2935:26

block and for the catch block I'm going

2935:28

to just provide these logs I'm going to

2935:30

just Define this console. error and also

2935:32

this error of toast and for the triy

2935:34

block what do you want to do we just

2935:36

want to try the toast. success and now

2935:38

let's just provide like movie deleted

2935:42

successfully there we go and now

2935:44

underneath that we're going to be

2935:45

attaching the delete come on delete

2935:49

movie right here and now let me just

2935:51

past the ID inside then and finally we

2935:53

have to just navigate our user to that

2935:56

specific movies page which we're going

2935:58

to be creating in a few seconds now let

2936:00

me just save there and that was a lot of

2936:03

explanation uh so what I want to do is

2936:05

that I want to test this out so here you

2936:06

can see we have only one movie which is

2936:08

a black AR movie so now let me just

2936:10

change that to like um white AR or

2936:13

something like that let me just change

2936:14

that to White item and it is going to be

2936:17

releasing in

2936:19

2025

2936:21

and one one of the awful movies so far

2936:26

or something like that instead of

2936:28

writing the rock paper scissors I'm

2936:30

going to just P like John and Jordan and

2936:33

Peterson or something like that and let

2936:35

me just also change the image of there

2936:38

to like this saw X but this is a white

2936:40

Arrow so now let me just click on this

2936:42

movie button I mean like the update

2936:44

movie but now let me just right click on

2936:45

there and go to my inspect element and

2936:47

then I'm going to go ahead and go to my

2936:49

security and let's just search if we

2936:51

don't have any error okay so let's just

2936:54

go back and click on this update movie

2936:58

and here you can see everything is now

2936:59

successfully updated and now let me just

2937:01

show you there okay so now let me just

2937:03

go ahead and go to my database and let's

2937:05

just refresh that let me just go ahead

2937:07

and here you can see we're now getting

2937:08

the white item we're getting the image

2937:11

and we're also getting the year and also

2937:13

the detail and the cast and every single

2937:16

thing so yeah the updation or the update

2937:19

is totally working but now let me just

2937:20

delete this movie from the database so

2937:22

I'm going to just go ahead and delete

2937:24

that but you know what first of all let

2937:27

me just create another movie so I'm

2937:28

going to just go to a dashboard oh we

2937:30

did not create a dashboard so now let me

2937:32

just go ahead and go to my main and

2937:35

thank God I came here I accidentally

2937:37

remove uh what do you call it the create

2937:39

movie right here I guess we did that let

2937:42

me just see here you can see we already

2937:44

created but I don't know I accidentally

2937:46

deleted that so now let me just grab

2937:48

that right here once again so I'm going

2937:50

to copy that and now let me just grab

2937:52

that right here so import create movie

2937:55

let's just go ahead and go to our comp

2937:57

not component but Pages ah go to the

2938:00

pages and then we have to go to the

2938:02

admin then we will be able to create a

2938:04

new movie so now let me just save there

2938:06

first of all you want to create a movie

2938:08

but now let me just grab all of that

2938:11

from here and now let me just place that

2938:13

right here

2938:14

and remove that uh Slash and now let me

2938:17

just hit enter and now we can totally

2938:19

create a movie so now let me just click

2938:21

on this upload image and I'm going to

2938:23

just paste this John Wick and provide a

2938:25

name for there like John Wick and I

2938:28

don't know when this was release so I'm

2938:30

going to just past like 2018 or

2938:32

something like that and best action

2938:36

movie so far by

2938:39

Jonathan or John Wick would be fine and

2938:42

now let me just WR John on and Wick and

2938:45

for the genre we're going to be adding

2938:47

that to the adventure or something like

2938:49

that and now let me just create that

2938:51

movie okay so we have now two movies

2938:53

right here and we can totally update

2938:55

there and you know what let me just

2938:57

delete one of the movies so like in this

2938:58

case I'm going to just remove this white

2939:00

item now let me just click on there let

2939:02

me just right click on there and go to

2939:04

my network panel once again because I

2939:07

don't want to take my chances and now

2939:08

let me just click on this delete button

2939:11

and yeah that is totally working and the

2939:13

movie is now successfully deleted let me

2939:16

just show you there and let's just

2939:17

refresh there and here you can see we

2939:19

only have that John Wick movie and what

2939:22

was that white item is now successfully

2939:24

gone okay so yeah this is how we're

2939:26

going to be creating a movie updating a

2939:28

movie and deleting a movie so yeah here

2939:30

you can see we only have this uh John

2939:32

Wick right here which is totally looking

2939:34

awesome I just went to IMDb and I grab

2939:37

the same actual information about these

2939:39

specific movies so I just created a few

2939:41

movies and I want you to do the same

2939:43

okay so you can find the images in my

2939:45

gab repository you can also find the

2939:47

description and also the title and all

2939:48

of that kind of stuff in my gab

2939:50

repository so what I want to do is that

2939:53

um we're going to be focusing on the

2939:55

home first of all so now let me just

2939:56

remove that and now let me just go ahead

2939:58

and go to my home and here you can see

2940:00

we are now at home which is totally

2940:02

amazing but now we're going to have to

2940:04

split that into a few components so I'm

2940:06

going to be just creating a folder and

2940:08

I'm going to just give it the name of

2940:09

like movies and now inside there I'm

2940:11

going to be creating my header first of

2940:13

all so header jsx now let me just use my

2940:15

RFC s my file and now let me just grab

2940:18

that right here so I'm going to be just

2940:19

grabbing my header let's just copy there

2940:22

let's just remove these deals and I'm

2940:24

going to just make there as a react

2940:25

fragments and now inside there we're

2940:27

going to be passing our header now let

2940:29

me just save there and here you can see

2940:31

we're now getting our header right here

2940:33

instead of the home so that's cool now

2940:35

let me just go ahead and go to my header

2940:36

component and inside there we're going

2940:38

to be writing a lot of GSX so so you can

2940:41

find all of that GSX in my gab report

2940:44

tree because I'm not planning to type

2940:45

all of that GSX so I'm going to just

2940:47

copy and paste a lot of things so now

2940:49

let me just go ahead and go to my redex

2940:51

and you know not like that let me just

2940:54

go ahead and go to my redex like that

2940:55

then we have to go to the API and then

2940:57

the movies okay so we're going to be

2940:59

grabbing um the use get yeah get new

2941:03

movies and now let me just grab them and

2941:06

we would also have to grab our link and

2941:08

now let me just grab my link from there

2941:11

let me just go ahead and write react

2941:13

router and then D and we are going to be

2941:15

grabbing there by using these curly

2941:17

braces okay so now let me just save

2941:19

there what you want to do we just want

2941:21

to grab the data and we are going to be

2941:23

grabbing there from use get new movies

2941:25

query okay so now inside this header jsx

2941:28

now let's just remove there and now let

2941:31

me just style there by using these

2941:32

classes and now inside there we're going

2941:34

to be creating yet another nav and now

2941:36

let me just style there as well and I

2941:38

want you to provide the same styling as

2941:40

I'm doing right here and now let me just

2941:42

provide a link and and now it's going to

2941:44

go to let me just go to the home screen

2941:49

and we're going to be providing these

2941:50

classes and now let me just add these

2941:52

classes right here and it's going to

2941:53

just go to the home so now if I sell my

2941:56

file and now let me just check this out

2941:58

and here you can see we're now getting

2942:00

this home button and when I H my mouse

2942:01

over to that so it's going to gives us

2942:03

that kind of tail color or something

2942:05

like that and the UI doesn't matter you

2942:07

can change the UI like however you want

2942:10

and now the next thing which I want to

2942:11

do is that I want to grab that and

2942:13

duplicate there instead of going to the

2942:15

home I'm going to go to the movies and

2942:18

then let's just change there to like

2942:19

browse B SE browse movies and now let's

2942:24

just save that and here you can see

2942:26

we're also getting the browse movies as

2942:28

well which is also looking totally okay

2942:30

now underneath this nav we're going to

2942:32

be creating yet another div so now let

2942:34

me just create my div right here and now

2942:36

let me just style that by using these

2942:38

CSS classes or t CSS classes and inside

2942:41

there we're going to be passing our

2942:43

component which we are going to be

2942:44

creating in a few second and we're going

2942:46

to be also providing a data which we are

2942:48

already graving from the rtk query so

2942:50

now let me just create this uh slider

2942:52

UIL I'm going to copy that and then I'm

2942:54

going to go to my components and inside

2942:57

this component we are going to be

2942:58

creating our slider ut. jsx okay and now

2943:02

let me just use my RFC sell my file and

2943:06

here what I want to do is that I'm going

2943:07

to also save this file but first of all

2943:10

let me just import it right here uh so

2943:12

it's going to Auto Import it for for me

2943:13

and now let me just save that and now

2943:15

let's just work with the slider UT tail

2943:17

and here you can see this how it looks

2943:19

like like currently we have these

2943:20

buttons and we also have our slider

2943:22

right here so now let me just take care

2943:24

of these sliders so the first thing

2943:25

which I want to do is that I want to

2943:27

grab my sliders so let me just grab my

2943:31

let's just import my slider from where

2943:33

from the react and silk okay and the

2943:35

next thing which you want to do is that

2943:36

we are going to be also importing the

2943:39

CSS so silk s l i c k c a r o u usal and

2943:44

now let's just go ahead and go to the

2943:46

SLI i k and then silk. CSS come on do

2943:51

CSS there we go and we are going to be

2943:53

also importing the theme so we have a

2943:55

silk well you know let me just remove

2943:57

that from here and duplicate that and

2943:59

then I'm going to go ahead and go to my

2944:01

silk Das theme. CSS in this case Okay so

2944:05

yeah that's looking cool now let me just

2944:06

save there and now let's just use our

2944:08

slider so what I want to do is that I

2944:11

want to first of all provide a settings

2944:12

so now in inside the on settings for my

2944:15

care cell so now let me just provide a

2944:17

dots and dots will be set to true and

2944:20

we're going to be also providing the

2944:21

infinite like scroll infinitely i n f i

2944:24

n it t and it's going to be set to three

2944:27

and now let me just provide a speed to

2944:29

that and speed will be just 500 and also

2944:31

the slides to show will be now set to

2944:34

four and slides to

2944:37

scroll r o l will be set to two as well

2944:41

okay so that's there and now let me just

2944:42

take care of my GSX right here so now

2944:44

let me just remove that and now in this

2944:46

case let me just remove that and I'm

2944:48

going to also remove that from here and

2944:50

instead I'm going to be using my slider

2944:53

and now let me just provide my dot dot

2944:54

dot of settings like all of that

2944:56

settings which we are already grabbing

2944:58

or already creating so now let me just

2944:59

copy and paste that right here and now

2945:02

inside there uh I'm going to also

2945:04

provide a slider not slice but why am I

2945:07

providing a slice I mean slider let's

2945:10

just copy that and place that right here

2945:13

and inside the slider we're going to be

2945:15

just iterating over through all of that

2945:16

data if we have the data then we're

2945:18

going to be iterating over through all

2945:20

of that data let me just pass my movie

2945:23

and then inside there we're going to be

2945:24

creating yet another component which

2945:26

will be the movie card and let's just

2945:28

put our key to that and I'm going to be

2945:30

just passing my movie. ID okay so now

2945:33

let me just provide a movie and movie

2945:35

will be set to movie and now let's just

2945:37

close them but first of all we're going

2945:39

to also have to grab that right here

2945:41

let's just destructure that data and

2945:43

we're going to be passing that data

2945:45

right here and we are going to be

2945:46

iterating over through that data and

2945:48

based on that data we are going to be

2945:49

creating this component now let me just

2945:51

take care of this movie card component

2945:53

and I'm going to just go ahead and go to

2945:55

my movies once again and now let me just

2945:57

create my movie card. GSX and now inside

2946:00

that we're going to be using our RFC s

2946:03

file and now let's just import that

2946:06

right here okay so now let me just

2946:07

import that s file and here you can see

2946:10

we now getting our Carousel and we are

2946:12

also getting these m is right here which

2946:14

is totally looking a okay so yeah that's

2946:17

cool but now let me just take care of

2946:20

the movie cards the first thing we would

2946:22

do is that we're going to be grabbing

2946:23

our link from the react R Dom and now

2946:26

let me just also destructure that movie

2946:29

which we already specifying right here

2946:31

as a prop and now we're going to be

2946:32

using that so now let's just remove this

2946:34

movie car from here and we're going to

2946:36

be passing the key of the movie and

2946:39

their specific movie ID and now let me

2946:41

just put a classes of relative r e e l a

2946:44

t i v e and group also margin will be

2946:48

Auto will be set to two R and now inside

2946:50

this D we're going to be creating a link

2946:52

and it should go to the specific movie

2946:55

so let's just go ahead and go to the

2946:57

movies and then the specific movie. okay

2947:01

so now inside there uh I'm going to be

2947:03

also placing my image so now let me just

2947:05

add the image and now inside this image

2947:08

for the source we're going to be passing

2947:10

our movie. image and then for the

2947:12

alternative text we're going to be

2947:14

passing the movie. name and now for the

2947:16

classes I'm going to be placing these

2947:18

classes right here I don't know why it

2947:20

is giving me this error movie name is

2947:22

missing in the prop oh that's because we

2947:24

did not specify the prop validation we

2947:26

don't have to do that no more in the

2947:28

react 18 we're not going to do that okay

2947:31

so now underneath this link what do you

2947:33

want to do I'm going to be placing this

2947:34

paragraph and it has a lot of styling

2947:36

right here but inside that we are going

2947:38

to be just providing our movie name okay

2947:40

so that's exactly what we have to do and

2947:42

now let's just save there and once we

2947:44

sell that and here you can see it's

2947:45

going to gives us all of their movies

2947:47

right here I can click here on these

2947:49

small dots and it's going to just giv us

2947:51

that slider or I can just click on this

2947:53

button or just click on this button

2947:56

right here okay so it's going to just

2947:57

giv us that amazing slider and we can

2947:59

browse through the movies or we can go

2948:01

to the home okay so yeah that was the

2948:04

first header component and now let me

2948:06

just take care of uh what do you call it

2948:09

the movies container so what I want to

2948:12

do is that I'm going to be just placing

2948:13

the section and now let me just a bit of

2948:15

classes to it so margin for the top will

2948:17

be set to 10 R and inside this section

2948:20

we're going to be just placing our

2948:21

movies container page and now let's just

2948:24

close that and we're going to be

2948:26

creating this component in a few second

2948:27

and now let me just do that and inside

2948:29

this movies folder we're going to be

2948:31

creating this uh movies container page.

2948:34

GSX and now let me just write my RFC

2948:36

inside there sve my file and now let's

2948:39

just autog grab there and now let me

2948:41

just hit iner so it's going to just grab

2948:43

the right here for me sell my file and

2948:45

here you can see we're now getting our

2948:47

movies container page now let me just

2948:48

hide there and here you can see that's

2948:51

looking a bit better and now the next

2948:52

thing which I want to do is that I

2948:54

wanted to take care of this component so

2948:57

now let me just grab my use St first of

2948:59

all not store but

2949:01

s from the react J and now let me just

2949:03

also grab a lot of uh hooks so you know

2949:06

what I'm going to just copy and now let

2949:08

me just place it right here so we only

2949:10

need the use get new movies query the

2949:13

get top movies and random movies right

2949:15

here so that's that and we would also

2949:17

need to grab our genre so let's just

2949:20

import something from let's just go

2949:22

ahead and go to the Redux and then go to

2949:24

our API and then genre okay so we're

2949:27

going to be grabbing or use fetch genre

2949:31

query and now let me just save that

2949:32

underneath that we're going to be just

2949:34

importing our slider UIL from or

2949:37

component and slider UT tail now let me

2949:39

just use my rtk query hooks so for that

2949:42

we're going to structuring our data from

2949:44

the use get new movies and now let me

2949:47

just execute that we're going to be also

2949:49

restructuring this data once again and

2949:51

I'm going to just rename that to top

2949:52

movies it's going to be coming from the

2949:54

use get top movies query and now let me

2949:57

just also destructure the data and it's

2950:00

going to be coming from the genres and

2950:02

now we are going to be getting there

2950:03

from the use fetch genre query and also

2950:08

uh let's just get the data rename that

2950:10

to like random movies it's going to be

2950:12

coming from the use get

2950:14

random um mov s right here and now let

2950:17

me just execute that and now underneath

2950:20

that we're going to be just creating a

2950:21

state for the selected genre and also

2950:25

for the set selected genre it's going to

2950:29

be equals to the US St and now let me

2950:31

just pass my null initial value to there

2950:33

now let me just save there and now let's

2950:35

just take care of this jsx now let me

2950:37

just remove that and now let me just

2950:39

provide a lot of claes to that okay now

2950:42

a lot of you will like H you just

2950:44

copying and placing there you should

2950:45

also do the same because I already

2950:47

written this code and you don't have to

2950:50

just rewrite again and again because

2950:51

this is just a UI not a logic so you

2950:53

don't have to write your UI from scratch

2950:55

so I already did that just thank me and

2950:58

write there or copy there okay so now

2951:00

let me just place this um come on this

2951:03

classes right here now let me just save

2951:04

there and inside this navigation we're

2951:06

going to be iterating over through all

2951:08

of our genres and we are going to be

2951:10

just using the map method to iterate

2951:11

over through there and and for each

2951:13

genre we are going to be passing our G

2951:15

and for each genre we are going to be

2951:17

just creating a button and now let's

2951:19

just close that now let me just pass my

2951:21

key and the key will be genre. ID that

2951:24

specific genre and now I'm going to be

2951:26

passing the styling right here so we

2951:29

have all of these default styling but

2951:31

here in this case we're now checking if

2951:32

we have a selected genre is equal to

2951:35

genre ID then we're going to be passing

2951:37

our background color of 200 if that's

2951:40

not the case so we're going to be just

2951:41

passing nothing okay so that's there and

2951:43

when somebody clicks on there what you

2951:45

have to do on that case and now let me

2951:47

just write my on click event hander and

2951:49

we're going to be just passing or handle

2951:51

genre uh in a few second we're going to

2951:54

be creating there and now let me just

2951:56

past my genre ID inside there and for

2951:58

the label of this button we're going to

2952:00

be just creating our genre name okay so

2952:02

now let's just save there and now let me

2952:05

just go ahead and go back let's just

2952:07

comment this line out and underneath

2952:08

this navigation we're going to be

2952:10

creating a section now let me just

2952:12

create a section and I'm going to be

2952:13

just placing these classes right here

2952:15

and now inside that we're going to be

2952:17

creating yet another div and inside this

2952:19

div uh let me just P these classes and

2952:22

now inside there we're going to be just

2952:24

creating our H1 and choose uh for you

2952:28

and for this H1 we are going to be just

2952:30

providing a class name of margin for the

2952:32

bottom of five and now underneath there

2952:34

we're going to be just using our slider

2952:35

UIL and now let me just put a data of

2952:39

this random movies and there we have it

2952:42

okay so now let me just save there and

2952:44

now underneath this section I'm going to

2952:46

just duplicate there for a few times so

2952:48

should I do that or not you know what

2952:50

I'm not going to duplicate that I'm

2952:52

going to be creating a div and inside

2952:54

this div now let me just provide a bit

2952:55

of classes to it so I'm going to be just

2952:57

passing like with of totally full and

2952:59

also on the large screen what do you

2953:00

want to do uh we just want to add the

2953:02

width of 100 rim and then we're going to

2953:06

be also providing the margin for the

2953:08

bottom will be now set to add and inside

2953:10

that we are going to be just passing our

2953:11

H1 of top movies and now let me just

2953:15

pass my class name of margin for the

2953:17

bottom will be now set to five and now

2953:19

underneath that we're going to be also

2953:21

providing our slider and now let me just

2953:23

past the data and the data will be top

2953:25

movies in this case and now let's just

2953:27

close the okaye now underneath there I'm

2953:29

going to just duplicate this one uh one

2953:31

more time like that and everything is

2953:34

totally cool but now here let me just

2953:37

pass my Choose movie and now let me just

2953:41

proide my slider your K and we're going

2953:44

to be just passing the data of fil come

2953:47

on f i l t e r e d filter movies which

2953:50

we're going to be creating in a few

2953:52

seconds so yeah I'm going to just save

2953:54

this file and first of all let me just

2953:55

take care of this one oh you know what

2953:58

first of all let me just take care of

2953:59

this uh handle genre click so now let me

2954:03

just create that functions right here so

2954:04

I'm going to be just creating this

2954:06

handle genre click and we're going to be

2954:08

just spacing our genre ID and now it's

2954:11

going to take the arrow function set

2954:13

selected uh genre and we are going to be

2954:16

just passing our genre ID in this case

2954:18

Okay so that's the now let me just take

2954:20

care of this filtered movies okay so now

2954:24

we are going to be just creating this

2954:25

filtered movies it's going to be set to

2954:27

if we have the data then we are going to

2954:29

be just filtering that data and I'm

2954:31

going to be just passing the movie like

2954:33

a specific movie and if the selected

2954:36

genre is triple equals to null or the

2954:39

movie. genre come on not ID but genre is

2954:44

triple equals to the selected genre so

2954:47

it's going to just gives us that

2954:48

filtered movie so now let me just save

2954:50

that and we are now totally done with

2954:52

this component as well so now let me

2954:54

just try this out and here you can see

2954:55

it's going to gives us this UI but

2954:57

that's not something that I want uh I

2955:00

don't know where did I miss spill

2955:01

something or what did I do wrong we have

2955:04

our div then we have our navigation and

2955:06

here you can see I just made a mistake

2955:08

I'm going to cut this section From Here

2955:10

and Now underneath this D we're going to

2955:12

just spacing our section right here or

2955:14

you know and on the top of this Dev now

2955:17

let me just save there first of all it's

2955:18

going to give us that choose for you

2955:20

these are going to be the random movies

2955:22

so if I just refresh that and here you

2955:24

can see it's going to giv a Spider-Man

2955:25

in this case and now let me just refresh

2955:27

that once again and in this case it's

2955:29

going to give us that Transformers and

2955:31

now let me just refresh T once again so

2955:33

it's going to give us that s okay so

2955:35

these are going to be totally different

2955:37

I mean like random movies then we have a

2955:39

top movies so these are going to be just

2955:40

the top movies and then we have uh

2955:44

choose movies right here like we can

2955:45

also choose them by using these genres

2955:48

so I can just click on the action so

2955:49

it's going to just only giv us the

2955:51

action movies I can click on the

2955:53

adventure so I'm going to just click so

2955:54

it's going to just giv us the adventure

2955:56

movies right here and I can just click

2955:57

on these genres and it's going to gives

2955:59

us that different movies okay so yeah we

2956:02

are totally done with this uh first home

2956:04

or you can say the Herer and the home

2956:07

whatever you want to call that and we

2956:09

can also use these small sliders or we

2956:11

can also use the the slider as well so

2956:14

we now totally done with the home screen

2956:16

and now let me just take care of the

2956:17

browse movies okay so what I want to do

2956:20

is that I'm going to just review that

2956:22

from here and also from here and now let

2956:25

me just go ahead and go to my movies

2956:26

once again let me just zoom in a bit and

2956:28

now let me just create a component of

2956:30

all movies. jsx and I'm going to just

2956:33

writing like RFC s my file and now let

2956:36

me just go ahead and go to my main and

2956:38

now let's just register there right here

2956:40

underneath this home now let me just

2956:41

register this I'm going to be just

2956:43

passing the route and then the path will

2956:45

be let's just go ahead and go to the not

2956:48

the movies yeah go to the movies and

2956:51

then let's just pass our element and the

2956:53

element will just take all movies and

2956:56

now let's just close it like so and now

2956:58

let me just save that and we have to

2957:00

grab them manually so let's just import

2957:04

that so now let me just save there and

2957:05

here you can see we're now getting that

2957:07

all movies instead of that error okay so

2957:10

that's to resolve and now the next thing

2957:12

which I want to do is that I'm going to

2957:13

go ahead and go to my own movies and we

2957:16

are going to have to write a lot of

2957:18

stuff okay so the first thing we would

2957:21

need is the use get all movies query and

2957:24

we would also need the use fch genre

2957:27

queries and we're going to also import a

2957:29

lot more than that so use get new movies

2957:32

uh get new movies query and use get top

2957:35

query top movies squarey and also the

2957:38

use get random ones as well now let me

2957:42

just remove this SK Li bra s file and

2957:44

now let me just also import my movie

2957:46

card as well now let me just save that

2957:48

I'm going to be also importing my use

2957:51

effect and also my use selector but we

2957:55

also have to register that inside our

2957:58

store bar you know let me just import it

2958:00

right here I'm going to be using my used

2958:01

dispatch d s ptch and it's going to be

2958:05

coming from let's just write or react

2958:07

Redux okay so now let me just save there

2958:09

now here you can see I have my banner

2958:11

picture I'm going to cut that from here

2958:13

and now let me just go ahead and go to

2958:15

my front end and inside this front end

2958:17

I'm going to go ahead and go to my SRC

2958:19

and now let me just create a separate

2958:20

folder which will be the assets I'm

2958:23

going to just place my banner right here

2958:25

and now let me just check this out so

2958:26

here you can see we have our assets a s

2958:29

TS and we have this banner picture right

2958:33

here let me just show you that and what

2958:35

I want to do is that I want to grab the

2958:37

right here so now let me just import

2958:38

that so I'm going to be using import

2958:40

Banner from where from let's just go

2958:42

ahead and go to our assets and then

2958:45

inside this asset we have a

2958:47

banner.jpg okay so we need there now let

2958:51

me just save there and now let's just

2958:52

take care of the Redux side okay so I'm

2958:55

going to go ahead and go to my Redux and

2958:57

inside there we're going to be

2958:59

introducing a new feature which will be

2959:01

movies okay so now let me just create a

2959:03

new folder I'm going to just give a name

2959:04

of like movies and inside this movies

2959:07

folder we're going to be creating a new

2959:09

movies uh s. JS file right here here

2959:13

okay and the first thing which I have to

2959:14

do is that I'm going to be grabbing my

2959:16

create slice God damn it so create slice

2959:22

from where from let's just go ahead and

2959:24

go to the redex toolkit and we're going

2959:25

to be grabbing our create slice from

2959:27

there and now let me just create my

2959:28

movie slice and it's going to be equal

2959:30

to the create slice function and now

2959:33

inside there first of all we have to

2959:35

give it some sort of a name so in this

2959:36

case I'm going to just giving it the

2959:38

name of like movies now the next which

2959:39

you have to do is that we have to

2959:40

specify the initial state and for the

2959:43

initial State we are going to be just

2959:44

passing with movies uh M come on movies

2959:48

filter it's going to be equals to this

2959:50

object and then we have to specify first

2959:52

of all the search term and the search

2959:54

term will be set to empty string and now

2959:56

let me just remove that from here and

2959:58

now the next thing which you want to do

2959:59

is that we want to also take care of the

2960:01

selected genre it's going to be also set

2960:04

to empty string and then we have a

2960:06

selected year come on selected year and

2960:09

now let me just add the word here and

2960:11

also the select

2960:13

sord as well it's going to be equals to

2960:15

this array okay so now underneath that

2960:18

let me just add my filter um movies

2960:21

filter movies will be now equals to this

2960:23

array and we can also just write a movie

2960:25

years um movie years and it's going to

2960:29

be equals to this array as well and now

2960:31

let me just use my unique here and it's

2960:34

going to be equals to this array as well

2960:36

so now let me just save that and then

2960:38

was there about four or initial State

2960:40

and now let me just take care of the

2960:41

reducer and in actions and inside this

2960:44

reducer uh let me just pass my reducers

2960:47

right here and inside this reducer the

2960:49

first action which I'm going to be

2960:50

introducing is the set movies filter and

2960:53

it's going to take the St and also the

2960:55

action as well and now inside there I'm

2960:58

going to be using the state do movies

2961:01

filter okay it's going to be equals to

2961:03

dot dot dot and state first of all and

2961:05

we're going to be grabing our movies

2961:07

filter and then we have to provide our

2961:09

uh come on dot dot dot of action.

2961:11

payload like all of the filter movies

2961:14

and also the payload as well okay so

2961:16

that's then now underneath that we're

2961:19

going to be also creating uh set

2961:21

filtered movies as well so set filtered

2961:24

movies is going to be equals to the

2961:26

state and also the action and now inside

2961:29

there we're going to be using our st.

2961:32

filtered uh f i l t e r e d filter

2961:35

movies and it's going to be coming from

2961:36

the action. payload okay and now

2961:39

underneath there we are going to just

2961:41

also create a set movie year uh or years

2961:45

with plural and we're going to be

2961:47

passing the state and also the action

2961:49

and now let me just provide my st. movie

2961:53

or movie years and it's going to be

2961:55

equals to the action. payload there we

2961:57

go and yeah that's cool but now let me

2962:00

just finally provide My Last Action

2962:03

which will be set unique uh come on set

2962:07

u n i qu e ears okay and set unique ears

2962:11

will be St and also the action and

2962:13

inside there we're going to be just

2962:15

carrying our state and then their unique

2962:17

years from there is going to be equals

2962:19

to the action. payload okay so now let

2962:22

me just save that and finally we have to

2962:23

export all of these sections from this

2962:26

slice right here and now let me just

2962:28

place there right here so we are now

2962:29

exporting the set movies filter the set

2962:31

filter movies and also the set movie

2962:34

here and also the set unique Here and

2962:36

Now underneath there let's just use our

2962:38

export default of movie slice and we are

2962:41

going to be just exporting the reducer

2962:43

and now let me just save my file and now

2962:45

we have to go to our store and register

2962:48

there let's just grab our U movie oh

2962:52

yeah movies reducer and we are going to

2962:54

be grabbing that from uh reducer then we

2962:57

have to go to the feature then we have

2962:58

to go to the movies then we have to go

2963:00

to the movie slice okay and now let's

2963:03

just register that right here underneath

2963:05

this o I'm going to be just introducing

2963:07

there by using the movies and then the

2963:09

movies uh reducer like this one and now

2963:11

let me just my comma let me just save

2963:14

this file and there you have it that's

2963:16

it about the redu side let's just close

2963:19

that and now we're going to be importing

2963:21

all of their actions right here and now

2963:23

let me just place a right here so we're

2963:24

now importing all of their actions from

2963:27

this specific file so now let me just go

2963:28

ahead and go to that we now exporting

2963:31

there right here and now in this file we

2963:33

are importing there so that's there now

2963:35

the first thing which I want to do is

2963:37

that I want to create an instance of

2963:38

that used dis space so I'm going to be

2963:41

using like disp at and it's going to be

2963:43

equals to God use dispatch and now let

2963:46

me just execute that now we are going to

2963:48

be also destructuring our data let's

2963:51

just destructure that from where from

2963:53

the use get all movies uh query right

2963:58

here and now let me just also

2963:59

restructure my data and let's just

2964:01

rename that to genres and we are going

2964:04

to be pitching that from or use get or

2964:08

not get but use fetch genre squarey

2964:11

right here under that we are going to be

2964:13

also destructuring our movie once again

2964:15

and we are going to be just renaming

2964:17

that to new movies it's going to be

2964:19

coming from the use get new movies in

2964:22

this case and now let me just also

2964:24

restructure my data once again and then

2964:26

we have a random movies right here and

2964:28

we're going to be just destring that

2964:30

from the random uh come on use get

2964:34

random movies and now let me just

2964:37

execute them now let me just create a St

2964:39

for my filter movies so now let me just

2964:41

provide my um movies filter and also we

2964:46

have a filtered movies as well it's

2964:48

going to be equals to the use selector

2964:51

and we're going to be just getting that

2964:53

from the stad and we have our st. movies

2964:57

right here inside there and now

2964:59

underneath there let's just create our

2965:01

movie years and it's going to be equals

2965:03

to the data if you have the data then

2965:05

we're going to be just iterating over

2965:07

through the movies and then let's just

2965:09

provide a specific movie inside there

2965:11

and now let me just pass my movie year

2965:13

okay and now underneath let's space for

2965:15

Unique years it's going to be equals to

2965:18

the

2965:19

array. and now here we have to just use

2965:21

the new set because it is a data

2965:23

structure it's going to only giv us a

2965:25

unique movies right here in this case

2965:27

it's going to just remove their

2965:28

duplication and we totally want that

2965:31

okay so now let's just save that and

2965:33

that was a lot of logic okay so now the

2965:36

next thing which I want to do is that I

2965:38

want to first of all dispatch my action

2965:40

by using my use effect so use effect and

2965:43

inside this use effect we're going to be

2965:45

just providing our Arrow function and

2965:47

for the dependency array we're going to

2965:49

be passing our data and also our

2965:52

dispatch is ptch in this case and now

2965:56

inside there let's just dispatch first

2965:57

of all our set filter movies and we're

2966:00

going to be passing our data or the

2966:02

empty string okay and now let me just

2966:04

dispatch my uh set movie ear and now

2966:08

let's just execute that I'm going to be

2966:10

passing my movie ear and now underneath

2966:13

that let's just dispatch there one more

2966:14

time and then set unique years okay so

2966:17

now let me just P my unique years in

2966:18

this case and save there okay so that's

2966:21

there now let me just go ahead and go to

2966:23

my GSX and remove there and I'm going to

2966:25

be providing these classes right here

2966:27

now inside there let me just P my react

2966:29

fragments and inside there let me just

2966:31

create my section and inside this

2966:33

section let's just create a div and

2966:35

inside this D I'm going to be providing

2966:37

this uh what do we call it these

2966:39

statement CSS classes and also the this

2966:42

inline class of just adding a banner to

2966:44

it which we are already grabbing from

2966:46

the assets folder here you can see we

2966:49

have this Banner right here and now we

2966:50

are providing there as inline CSS so now

2966:53

let me just save there and inside this

2966:54

div now let me just add yet another div

2966:56

for the CSS class so here you can see we

2966:58

have these classes right here I'm going

2967:00

to sve that and now underneath that let

2967:03

me just uh create yet another div and

2967:05

I'm going to passing these class Nam St

2967:07

it and let's just pass that and now

2967:09

inside this div uh let's just create our

2967:12

one and I'm going to just provide a

2967:14

class names of like text at pixel like

2967:17

at Excel like 8% extra large and now let

2967:20

me just proide a font of totally bold

2967:22

and merge for B will be set to four and

2967:24

now let me just proide the movies Hub

2967:27

underneath that let's just provide our

2967:28

paragraph and I'm going to be providing

2967:30

my class names to it so we have a text

2967:32

of 2 Excel and now inside there let me

2967:34

just P this slogan right here save my

2967:37

file and let's just check this out and

2967:39

we are now getting the set movie here is

2967:42

not defined so let's just check this out

2967:44

and it shouldn't be movies but just a

2967:47

movie let's just remove there and now

2967:49

let me just save there and here you can

2967:51

see it's going to gives us that amazing

2967:53

look right here which is amazing now let

2967:56

me just close that and let's just go

2967:58

back to our topic so now underneath this

2968:00

paragraph we're going to be creating

2968:01

another section and I'm going to just

2968:03

past the class name of f so loot there

2968:07

and the bottom will be just set to five

2968:10

rim and it is negative bottom and now

2968:12

inside there let me just provide my

2968:14

input field and then inside there we're

2968:17

going to be providing a class name of

2968:19

first of all the width will be set to

2968:20

totally 100% and now we also have to

2968:23

provide the height of five frame toade

2968:26

and the Border then we have pass or

2968:28

pairing for the xaxis of 10 and then

2968:30

outline will be set to totally none and

2968:32

totally rounded okay so now let's just

2968:34

saell there and we are now getting this

2968:36

input field right here which is not

2968:38

looking that cool but we will take care

2968:40

of them later

2968:42

and now let me just add my placeholder

2968:44

so we have a placeholder of search movie

2968:48

now underneath this placeholder let me

2968:49

just P my value and it is going to be

2968:52

the movies filter. search term DM there

2968:57

we go and now let me just also pass my

2968:59

own change Handler to that which we're

2969:01

going to be creating in a few seconds so

2969:03

we have a handle search change and I'm

2969:06

going to just comment this line out so

2969:07

let's just save there now underneath

2969:09

this section or not a section but

2969:12

underneath this input field we going to

2969:14

be creating a section and I'm going to

2969:16

be just adding these classes to it let

2969:18

me just add these classes and now inside

2969:20

there we would have first of all our

2969:22

select so now let just pass my select

2969:24

it's not going to take any name and ID

2969:27

so I'm going to just remove that is

2969:28

going to be taking the class name of

2969:30

border and and also padding will be all

2969:32

around set to two and let's just put

2969:34

around it text will be set to totally

2969:36

black and I'm going to be also providing

2969:38

the value of M filter do select ected uh

2969:43

card s e e c t e d selected genre and

2969:47

then uh outside from there I'm going to

2969:50

be providing the own change event hander

2969:51

on there c h n g come on yeah there we

2969:54

go and now let me just provide my event

2969:57

and now I'm going to be providing my

2969:59

handle genre click which we are going to

2970:01

be creating in a few seconds so we have

2970:03

a handle genre click event. target.

2970:07

value inside there okay so now let me

2970:09

just save there and I'm going to just

2970:11

comment this line out and now inside

2970:13

this select we're going to be passing

2970:14

our option let's just pass our option

2970:17

and for the value we're not going to be

2970:18

providing anything to that then we have

2970:20

our genres so now underneath this option

2970:23

let's just it over through all of our

2970:24

genres and now let's just get map and

2970:27

now let me just provide my genre to it

2970:29

and inside there we're going to be just

2970:31

passing our option once again so let's

2970:33

just pass our option and close there I'm

2970:36

going to be also providing the key of

2970:38

that specific genre ID right here and

2970:41

also the value will be that specific

2970:44

genre and ID okay so now inside there

2970:47

let me just add my genre. name let's

2970:50

just save them and here you can see it's

2970:51

going to just make our input fi a bit

2970:53

bigger and it's going to also giv us all

2970:55

of their genres which I currently have

2970:57

okay so we took care of that now the

2970:59

next thing which I want to do is that

2971:01

underneath this select we're going to be

2971:03

creating yet another select so let's

2971:05

just create select and it is not going

2971:08

to be taking any name or ID but it will

2971:10

take that same CSS classes so I'm going

2971:13

to just copy that and I'm going to just

2971:16

place that right here and now let me

2971:18

just provide my value and the value will

2971:20

be the movies filter do

2971:24

selected uh selected here in this case

2971:27

and now let me just pass my own change

2971:28

event hander and we're going to be just

2971:30

passing the event and also the handle

2971:34

year come on year change and now let me

2971:38

just pass my e. target. value in this

2971:41

case and so now inside this select we're

2971:43

going to be passing our option and now

2971:45

let me just P my year in this case and

2971:47

for the value which will be totally

2971:49

empty string and now let me just iterate

2971:51

over through all of my unique years and

2971:54

then let's just iterate over through the

2971:56

let me just P my year inside them let's

2971:58

just pass each of the option for each of

2972:00

the Year okay so for the key we're going

2972:02

to just passing our year and now let me

2972:04

just also pass the year for the value as

2972:07

well and for this label we're going to

2972:10

be just also passing our unque year okay

2972:13

so let's just sa our file and now let me

2972:15

just comment this line out s my file and

2972:17

here you can see it's going to give us

2972:18

that year and we have all of their years

2972:21

right here okay and they are totally

2972:23

unique and we don't have any duplicates

2972:25

inside there and I guess I'm going to

2972:27

also add the margin for the left right

2972:29

here okay so now let me just save that

2972:31

it's going to gives us a bit of spacing

2972:32

right here in this case Okay so that's

2972:35

done now underneath this select what do

2972:36

you want to do we just want to create

2972:38

our final select and now let me just

2972:40

create the let's just remove our name

2972:43

and also the ID from there we're going

2972:45

to just attaching that same classes so

2972:48

I'm going to just copy and place that

2972:50

right here and now let me just add my

2972:52

value and for the value let me just pass

2972:54

my movie filter and then we are going to

2972:57

be just selecting our selected selected

2972:59

sword okay so let's just use our s e l e

2973:03

c t e d selected sword and now for the

2973:06

on change uh we're going to just spacing

2973:09

our event and also this handle sort

2973:12

change something which we're going to be

2973:13

creating in a few seconds so either

2973:15

target. value let's just save that

2973:18

comment this line out and now inside

2973:20

this select we're going to be just

2973:22

passing our option so now let me just

2973:23

pass my option of with the value of

2973:26

nothing but we have a sort by and then

2973:30

I'm going to just duplicate that a few

2973:31

time right here and now the next one we

2973:33

have is a new movies m o v and also we

2973:38

have a top movies and we also have have

2973:42

the random movies as well so now let me

2973:45

just save that and it's going to giv us

2973:46

this input field right here so we have a

2973:48

new movie we have the top movie and we

2973:51

also have the random movies okay so yeah

2973:54

we are not totally done with that but

2973:56

now let me just create these uh what do

2973:58

we call it these function so now let me

2974:00

just start from this first one which is

2974:01

a handle search change so I'm going to

2974:04

copy there and now let me just create

2974:06

that right here and what I want to do is

2974:07

that I'm going to just passing my cons

2974:09

handle search change it's going to be

2974:11

equals to the event and now inside there

2974:13

let's just dispatch or set movies filter

2974:17

not years but set movies filter and

2974:19

inside that let's pass our search term

2974:22

and this search term will be equals to

2974:24

the E Target and then that specific

2974:26

value now underneath that let's just

2974:28

filter our movies so I'm going to be

2974:30

using like con

2974:32

filtered uh movies it's going to be

2974:34

equals to the data data. filter and now

2974:38

let me just attach my movie inside there

2974:41

and movie. name. to lower case so we're

2974:45

going to be converting our name to or

2974:46

lower case and it shouldn't be movies

2974:50

but just movie singular movie let me

2974:53

just also attach the includes method on

2974:55

there if it includes the e. target.

2974:58

value do2 lower case and now let's just

2975:01

execute that so it's going to only giv

2975:03

us that filtered movies okay and now

2975:06

let's just dispatch our uh store by

2975:09

providing our set filtered movies and

2975:11

now let me just provide my filtered

2975:13

movies okay so now let me just save

2975:15

there and we would not able to see

2975:18

anything not right now because currently

2975:20

we don't have any data right here so you

2975:22

know what let me just take care of that

2975:25

and what I want to do is that underneath

2975:27

this uh section and div I'm going to be

2975:30

creating yet another section and let's

2975:32

just attach a bit of styling to that let

2975:34

me just Place The Styling and for the

2975:36

section uh I'm going to just provide a

2975:39

filtered movies and now if we have there

2975:42

then we're going to be iterating over

2975:43

through there so now let me just attach

2975:45

my movie inside there let me just

2975:47

provide my movie card which you already

2975:48

created and for the key let me just pass

2975:51

my movie ID and I'm going to also pass

2975:54

my movie as a movie and now let's just

2975:56

close that so I'm going to just sell

2975:58

that and here you can see it's going to

2975:59

gives us all of their movies right here

2976:01

but if I just search for a specific

2976:02

movie like I don't know maybe a

2976:04

Spider-Man so I'm going to just type

2976:06

like a spider and it's going to giv us

2976:08

their Spider-Man right here so now let's

2976:10

just close that and if I just search for

2976:12

like black atom so I'm going to just

2976:14

write a b and we only have one movie

2976:18

right here inside a databas by using the

2976:20

b word so that's why we have our black

2976:23

atom right here so if I just search for

2976:25

Transformers trns so it's going to gives

2976:28

us that Transformers right here so let's

2976:31

just go ahead and take care

2976:34

of uh what do we call it this handle

2976:37

genre click okay so now let me just copy

2976:40

that and I'm going to go to the top and

2976:42

now let me just take care of that and

2976:44

this one is quite simple and easy so

2976:45

what I want to do is that I'm going to

2976:47

just pass my genre click and it's going

2976:49

to take the genre ID and now let me just

2976:52

P my arrow function and inside there I'm

2976:55

going to be using my filter come on

2976:58

filter by uh genre and now let me just P

2977:02

my data. filter and we're going to be

2977:04

filtering through all of the movies I

2977:06

mean like the data and now let me just

2977:08

get my movie. genre is triple equals to

2977:12

the genre ID so we only need that

2977:14

specific movie so I'm going to just

2977:16

write like dispatch and set filtered

2977:18

movies and now let me just pass my

2977:21

filter by genre so now let me just save

2977:23

that and now let me just refresh there

2977:25

so it's going to gives us all of their

2977:26

movies but if I click on this genre and

2977:29

if I select like I don't know maybe the

2977:30

action so it's going to only gives us

2977:32

their action movies and if I click on

2977:34

the comedy so it's going to only gives

2977:36

that com this is not a comedy movie but

2977:39

I just put that inside a comedy category

2977:41

or genre so that's why we're not getting

2977:43

there so now let me just click on the

2977:45

adventure so it's going to give us the

2977:47

adventure movie If I click on the horror

2977:49

it's not going to gives us anything

2977:50

because we don't have any horror movies

2977:53

if I click on the

2977:55

romance and watch what happened it's

2977:57

going to giv us that song movie because

2977:59

I already put in the romance but anyways

2978:03

you get the idea so here you can see

2978:04

it's going to gives us all of their

2978:06

action movies now let me just take care

2978:08

of this one which is called the handle

2978:11

year so I'm going to copy the name of

2978:13

that and now let me just go to the top

2978:15

and create the right here and let's just

2978:18

create our handle year change and it's

2978:20

going to take the year and now let me

2978:22

just pass my uh aror function right here

2978:27

and con filter or filter by year it's

2978:32

going to be equals to the data. filter

2978:35

and I'm going to be just passing my

2978:36

movie and movie. here is triple equals

2978:39

to and now we have to convert this year

2978:42

from the string to a number so to do

2978:44

that we can either use the number

2978:47

Constructor or we can just use a plus

2978:49

right here okay so now let me just pass

2978:51

that as a dispatch and let's just use

2978:54

our set filtered movies and now let me

2978:56

just pass my filter by year so now let

2978:58

me just save there let's just refresh

2979:00

there and now if I click on the year if

2979:03

I click on the 2004 so it's going to

2979:04

give us there Jonathan Wick and then we

2979:06

have a 2009 and we can just click on

2979:09

there and it's going to gives us all of

2979:11

that movies based on a specific year

2979:14

right here okay so yeah that was filter

2979:16

by year and now

2979:18

finally let me just take care of this

2979:22

one and this is going to require a lot

2979:24

more coding than the other ones so now

2979:26

let me just copy there and now let's

2979:28

just take care of this one so underneath

2979:31

this handle here change we're going to

2979:33

be creating our handle sort change now

2979:35

let me just write con handle uh sord

2979:38

change it's going to be equals to the

2979:39

sord option okay so sort option and now

2979:43

let me just provide my switch statement

2979:45

you can use like the if and else

2979:46

statement if you wanted to but in my

2979:48

case I'm going to be using my switch

2979:49

statement and now let me just provide my

2979:51

sord option and now for the new what do

2979:54

you want to do we just want to dispatch

2979:56

let's just dispatch was stored by

2979:58

providing a set filtered movies and I'm

2980:01

going to be just providing a set I mean

2980:02

like new movies and now I'm going to

2980:05

copy there and for this one you know I'm

2980:07

going to just duplicate there a few time

2980:09

so we have a new now the next one we

2980:11

have is the top and for that we're going

2980:15

to be just passing the top movies come

2980:18

on top m o v i e s we already have there

2980:22

didn't we let's just check this out so

2980:24

we have that we have a new movie and

2980:28

we're not grabbing the top movies so now

2980:30

let me just take care of that underneath

2980:32

this one we're going to be also

2980:33

destructuring our data and now let me

2980:35

just grab my top movies it's going to be

2980:37

coming from the use get top movies query

2980:41

and now let's just save there underneath

2980:43

there let's just go to the bottom and

2980:45

we're now going to be passing our top

2980:47

movies and finally let's just add

2980:49

another one for the random so now let me

2980:51

just change that to random and I'm going

2980:54

to be also passing my random movies and

2980:57

for the default St what do you want to

2980:59

do we just want to dispatch or set come

2981:02

on set filter movies and let's just

2981:05

empty there so now let me just save

2981:07

there and refresh my browser so it's

2981:09

going to give us all of their movies but

2981:10

if I click on sorted by new movies so

2981:12

it's going to just gives us nothing

2981:15

because we made some

2981:18

mistake uh okay so we have a new one are

2981:22

we even providing there or not let's

2981:24

just check this out oh we are now we are

2981:26

not providing anything inside there so

2981:28

this is going to be the new one this is

2981:30

going to be the top one and this is

2981:32

going to be the random one okay so now

2981:34

let me just save there and now let me

2981:36

just refresh there so it's going to

2981:37

gives us all of that movies but if I

2981:39

click on there and if I click on the new

2981:40

movie movie so it's going to gives us

2981:42

all of the latest movies but if I click

2981:44

on the and click on the top movies so

2981:47

it's going to only gives us the top

2981:48

movies and then if I click on there and

2981:50

click on the random movies so it's going

2981:52

to just uh gives us that random movies

2981:54

if I just refresh them and if I just

2981:58

click on there once again let me just

2981:59

click on there once again so it's going

2982:00

to just giv us that John we one more

2982:03

time let me just refresh that once again

2982:05

and now let me just click on there and

2982:06

click on the random so it's going to

2982:07

just gives us that random movies so now

2982:09

let me just refresh that once again

2982:11

and now if I click on the random so it's

2982:13

going to just gives us the flash John

2982:15

Wick and all of that so yeah we are now

2982:18

totally done with all of their movies so

2982:20

I can totally search for a movie like I

2982:22

don't know Black Adam so now let me just

2982:24

write like a black so it's going to give

2982:26

us that Black Adam and I can also search

2982:29

by year or genre or anything like that

2982:33

so yeah that was about all of the movies

2982:35

that's cool but now let's take care of a

2982:37

specific movie detail so I'm going to

2982:39

just click on this Jonathan Wick right

2982:41

here so here you can see it's going to

2982:42

just gives us that specific movie and ID

2982:45

so now let me just create a new

2982:46

component right here inside my component

2982:49

folder and not in the component folder

2982:52

but inside my movies folder right here

2982:54

inside there okay so I'm going to be

2982:55

just creating a component I'm going to

2982:57

just give the name of like movie

2982:59

details. jsx right here now let me just

2983:02

use my RFC register this s my file and

2983:05

now let's just go ahead and go to my

2983:07

main and now let me just register that

2983:10

right in here okay so I'm going to just

2983:11

duplicate this line of code and I'm

2983:13

going to just write my movie detail and

2983:16

if I hit enter so it's going to Auto

2983:17

Import there for me and now let me just

2983:19

remove all of that and I'm going to also

2983:22

remove the admin right here in this case

2983:24

and now let me just pass my movies and

2983:26

then a specific ID right here so now let

2983:28

me just save that and here you can see

2983:30

we now getting our movie detail right

2983:31

here which is totally amazing okay so

2983:34

now let me just go ahead and go inside

2983:36

this component and now let me just take

2983:38

care of that okay let's just zoom in

2983:41

and the first thing we would need is the

2983:42

use t uh use T like that and we would

2983:46

also need the use pram and also the link

2983:50

so now let me just write a link and we

2983:52

will grab that from the react router and

2983:55

um okay now underneath that we're going

2983:56

to be also grabbing or use selector so

2984:00

that it allows us to select our data

2984:02

from the Redux toolkit so now let me

2984:04

just use the react Redux and we're going

2984:06

to be grabbing them from the react Redux

2984:07

now let me just also grab my toast and

2984:09

it's going to be coming from from the

2984:11

react toasttify and now underneath that

2984:13

you would also need something from the

2984:16

Redux toolkit so now let me just go

2984:17

ahead and go to my Redux and then I'm

2984:19

going to go ahead and go to the API and

2984:21

then movies okay now inside there what I

2984:24

want to do I want to get my use get

2984:26

specific movie query and also the use

2984:29

add uh movie review mutation as well and

2984:32

that's every single thing that we

2984:33

currently need for now now let me just

2984:34

sve that and now inside this movie

2984:37

detail what do you want to do we first

2984:39

of all want to grab the ID and I'm going

2984:40

to just rename there to like movie ID

2984:43

it's going to be coming from the use

2984:44

perams and now let me just execute that

2984:46

now inside there we would also want to

2984:48

get the rating and also the set rating

2984:51

okay is going to be coming from the use

2984:53

State and now let me just P zero inside

2984:56

the initial St now let me just also

2984:57

create a state for the commment andert

2985:00

comment as when it's going to be coming

2985:02

from the US St not selector but Us St

2985:05

and we are going to be providing the

2985:06

initial value of totally empty string

2985:08

and now let me just destructure my data

2985:11

and I'm going to just rename that to

2985:12

movie and we're going to be refining

2985:15

there so it's going to just gives us all

2985:16

of the latest movies and we're going to

2985:18

be grabbing that from the use get

2985:20

specific movie query and now let me just

2985:22

pass my movie ID inside there so we are

2985:24

now requiring a specific ID right here

2985:27

in this case we are now getting that ID

2985:29

and we are now passing that ID right

2985:31

here so now underneath that we would

2985:33

also want to get a specific user

2985:34

information as well so we're going to be

2985:36

getting there by using the use selector

2985:39

uh selector hook right here and now let

2985:41

me just P my state and now let me just

2985:43

get there from the state. off okay now

2985:45

underneath there we're going to be also

2985:47

uh destructuring or create review and

2985:51

also let me just destructure my is

2985:53

loading and I'm going to just rename

2985:54

that to like

2985:56

loading loading movie uh review there we

2986:00

go it's going to be coming from the use

2986:03

add movie and there we go okay so it's

2986:06

going to just auto complete that for me

2986:08

and now let me just sell that let me

2986:09

just go back and yeah yeah that's it but

2986:11

now let me just take care of my GSX and

2986:13

the first thing which I want to do is

2986:15

that I want to make it as total the

2986:17

react fragment so now inside there we're

2986:20

going to be creating our div and now

2986:22

inside this div we're going to be

2986:23

creating our link and it's going to be

2986:24

going into the home okay and now inside

2986:27

there I'm going to also add The Styling

2986:29

to it and now inside there it's going to

2986:31

just say like go back and now let me

2986:33

just save this file and here you can see

2986:35

we are now getting this go back button

2986:36

right here which is totally looking

2986:38

amazing now underneath this D we are

2986:40

going to creating yet another div and

2986:42

I'm going to just provide the class

2986:43

names of like margin for the top we we

2986:45

set toor and now inside this div we're

2986:48

going to be creating yet another div

2986:50

let's just do that and I'm going to be

2986:51

providing these classes to it and now

2986:53

let me just provide my image and that

2986:55

image will take the source off uh let me

2986:58

just for this God damn it the movie if

2987:01

we have there we're going to be grabbing

2987:03

the image from there and for the

2987:04

alternative text we're going to be

2987:06

providing our movie if we have there

2987:07

we're going to be grabbing the name from

2987:09

there now let me just provide a class

2987:10

names today so we are going to be

2987:12

providing the width of uh 70% and now

2987:16

let's just close there and totally round

2987:19

de okay now let me just save there and

2987:21

here you can see we are now getting this

2987:23

Jonathan which is looking totally

2987:25

amazing so now underneath we're going to

2987:27

be creating yet another div so I'm going

2987:29

to just give it the name of like

2987:30

container one and now underneath that

2987:33

we're going to be creating yet another D

2987:35

and now let me just style there and now

2987:36

inside there we're going to be creating

2987:38

our section and now inside this section

2987:40

let me just for my H2 and for the label

2987:42

we're going to be providing the movie if

2987:44

we have the movie we're going to be

2987:45

providing the specific name let me just

2987:47

add The Styling to that let's just add

2987:50

there right here and now underneath this

2987:51

H2 we're going to be creating yet

2987:53

another paragraph and here let me just

2987:55

get the movie detail detail right not

2987:58

just details but just a singular details

2988:01

and I'm going to also style that right

2988:02

here as well now let me just sell there

2988:05

and here you can see we now getting the

2988:06

movie name and also the movie

2988:08

description which is also looking

2988:10

totally amazing so now underneath this

2988:11

section what do you want to do we just

2988:13

want to create a div and I'm going to be

2988:15

just providing a class name of margin

2988:17

for the right of five frame and now let

2988:19

me just close there and now inside there

2988:21

we're going to be creating our paragraph

2988:23

and it's going to just say text of 2

2988:24

Excel and I'm going to be also providing

2988:27

the font of semibold and now inside

2988:30

there I'm going to just say like uh

2988:32

release come on r e l e a s i n

2988:36

releasing that will be the movie if we

2988:39

have that we are going to be getting the

2988:40

ear from there now let me just save

2988:42

there and now underneath this paragraph

2988:44

we're going to be creating yet another

2988:46

div and inside this div we're going to

2988:48

be just iterating over through all of

2988:49

the movies and I just want to get a

2988:51

specific cast and now let me just

2988:53

iterate over through there and now let

2988:55

me just proide a specific cast inside

2988:56

there and now I'm going to be just

2988:59

creating a UL let's just create our UL

2989:01

right here and now let me just close

2989:03

that as well and I'm going to be passing

2989:04

the key and the specific cast ID now

2989:08

inside there we're going to be also

2989:10

creating Ali and now let me just pass my

2989:12

character character what the hell the

2989:15

cast now let me just provide the class

2989:17

name of margin for the top of one rim

2989:19

and now let me just save there and here

2989:21

you can see we are now getting all of

2989:23

that cast right here and we are also

2989:25

getting the releasing de okay so yeah

2989:28

that's looking totally cool now

2989:29

underneath this div we're going to be

2989:31

creating yet another div which will be

2989:33

for the movie tavs okay so now let me

2989:36

just create a div I'm going to just give

2989:38

the name of like or you know a class

2989:40

name of container and margin for the

2989:41

left will be set to 20 rim and now let

2989:44

me just close there and inside there

2989:46

we're going to be creating our movie D

2989:49

not detail but movie tabs component in a

2989:51

few seconds but I'm going to just pass a

2989:53

few props so we have a loading movie

2989:56

review it's going to be equals to that

2989:58

loading movie review right here and now

2990:00

let me just pass the user info it's

2990:02

going to take the user info and I'm

2990:04

going to also past the submit Handler

2990:06

it's going to be also equals to uh this

2990:08

sub ummit Handler

2990:11

which we're going to be creating in a

2990:12

few second and now let me just also put

2990:14

the rating and the rating will be equals

2990:16

to the rating as well and now we have a

2990:18

set rating it's going to be also set to

2990:21

the set rating and now I'm going to be

2990:23

also passing the comment and let's just

2990:25

pass the comment prop and we have a set

2990:28

comment prop and I'm going to be also

2990:30

providing the set comment prop right

2990:31

here and finally let me just P the movie

2990:34

and movie so now if I sve that and we

2990:37

did not create none of this stuff I'm

2990:39

going to just comment this line out and

2990:41

now let me just create this component

2990:42

and inside this movies folder I'm going

2990:45

to be creating a component G the name of

2990:46

like movie tabs. jsx and I'm going to

2990:49

just write that RFC and now let me just

2990:52

save that and let's just go back to our

2990:54

component and now let me just Auto grab

2990:56

there so now let me just save there and

2990:59

let's just destructure all of that stuff

2991:01

well you know first of all we would need

2991:03

a link so now let me just grab the link

2991:05

by using just uh re CR D that's totally

2991:08

cool and now let's just destructure all

2991:10

that thing so we would need the user

2991:12

info come on the user info we would also

2991:15

need the submit Handler and the common

2991:18

set comment and also the movie itself so

2991:21

now let me just save that and now let me

2991:23

just use all of that right here so I'm

2991:25

going to just remove there and inside

2991:27

this D we're going to be creating our

2991:29

section and inside this section now

2991:31

inside this section now let's just check

2991:32

if we have the user info we're going to

2991:34

be passing this content and inside there

2991:37

I'm going to just passing the form right

2991:39

here we're not going to be reiding any

2991:40

action to that and now I'm going to be

2991:43

also attaching the on submit Handler on

2991:45

there on submit and that submit Handler

2991:48

will be submit Handler Right Here and

2991:50

Now inside this form we going to be just

2991:52

putting the label and it's going to just

2991:54

say the comment okay and I'm going to

2991:56

also provide the class name of block and

2991:58

text will be set to extra large and

2992:00

margin for the bottom will be set to two

2992:02

and as a label we would just say like

2992:03

write your review review there we go and

2992:06

now let me just save there but we would

2992:07

also have to take care of the else

2992:09

clause and and we're not going to be

2992:11

providing anything for now let's just

2992:13

provide empty string for now so now let

2992:15

me just save there and here you can see

2992:17

we are now getting right your review

2992:19

okay which is looking totally amazing

2992:21

but now underneath this label what do

2992:23

you want to do first of all we're going

2992:24

to be creating our text area and we're

2992:26

not going to be providing any of that

2992:28

stuff so let's just remove that and I'm

2992:30

going to be just passing the ID of

2992:32

comment and also the rows will be set to

2992:35

three and I'm going to be also making it

2992:37

so it should be required and also let's

2992:40

just provide a value to that and the

2992:41

value will be set to comment and now

2992:43

when somebody change that we're going to

2992:45

be just passing the event object and set

2992:48

comment will be now equals to the e.

2992:50

target. value and now let me just save

2992:52

there and underneath this own change now

2992:54

let me just P this uh classes right here

2992:57

we're not going to be typing anything

2992:58

inside there and we're going to be also

2993:00

creating a button so you know what I

2993:02

just made a mistake let me just wrap

2993:04

there inside the div so I'm going to be

2993:07

creating a div and now let me just

2993:08

provide a class name of mar for the one

2993:10

access will be set to two and now let me

2993:12

just cut that From Here and Now

2993:14

underneath this text area I'm going to

2993:16

be just placing my div Right Here and

2993:17

Now underneath this text area we're

2993:19

going to be also creating a button so

2993:21

now let me just create a button I'm

2993:22

going to be providing the type of submit

2993:24

to there and now let me just add a few

2993:26

classes right here or you know what let

2993:27

me just copy and place there place there

2993:30

right here s file for the label I'm

2993:32

going to just P the submit and now let's

2993:34

just sa there and here you can see we

2993:35

are getting our Tex area and we are also

2993:38

getting that button but you cannot see

2993:39

that

2993:40

you know what we're going to take care

2993:42

of that in a few second but yeah that's

2993:45

when we have the user information this

2993:47

is going to be the form which we are

2993:48

going to be providing but if you don't

2993:50

have the user information then we're

2993:52

going to be taking care of that right

2993:54

now so I'm not going to do anything

2993:55

crazy but I'm going to just provide a

2993:57

paragraph which will just say please and

2993:59

then visit to this link okay so just

2994:01

provide a two and should go to the login

2994:05

page and now inside there we would just

2994:07

say sign in okay and now let me just

2994:09

past my to write a review okay r e v i e

2994:14

w and now let me just save there and we

2994:16

cannot see that because we are already

2994:18

logged in and yeah that's then now

2994:20

underneath this section what do you want

2994:21

to do we just want to create another

2994:23

section and now let me just uh provide a

2994:25

classes to that so the class will be

2994:27

just margin for the top will be set to

2994:28

three RAM and I'm going to be also

2994:30

providing the div now let's just Pro a

2994:32

div and this div will say if we have the

2994:35

movies then we're going to be getting

2994:37

the reviews and then let's just check

2994:38

the length and if the is triple equals

2994:41

to zero then we have to provide this

2994:43

paragraph which will say like no reviews

2994:46

like if you don't have any reviews then

2994:48

we're going to be providing this

2994:49

paragraph which will just say like no

2994:51

reviews and what is wrong movie review

2994:54

is missing a

2994:55

propil we don't have to worry about that

2994:58

what the hell now underneath that we're

2995:00

going to be creating our new de and

2995:01

inside that let's just pass our movie

2995:04

and if we have the movie reviews and now

2995:06

let's just it right over through there

2995:07

let me just pass a specific review

2995:09

inside there and now inside there let's

2995:11

just pass our error function and I'm

2995:13

going to just passing the div come on

2995:15

let's just pass the div and I'm going to

2995:17

close there God let's just close that

2995:20

like that and now let me just also paste

2995:22

the review and a specific review ID and

2995:26

now inside there I'm going to be also

2995:28

providing a we of classes to them and

2995:29

now let me just pass all of their

2995:31

classes now inside this div we're going

2995:34

to be creating our da with the class of

2995:36

flex and justify will be set to between

2995:39

okay and now inside there let's just for

2995:41

our strong tag and inside there we just

2995:44

say the review. name like the person who

2995:46

is doing their review and I'm going to

2995:48

just passing the class name of text and

2995:52

uh B 0 B 0 come on and I'm going to just

2995:56

copy there for a few times so we have

2995:57

one two and three and now let me just

2995:59

close that okay so now underneath there

2996:02

we're going to be creating our paragraph

2996:03

and I'm going to copy this entire class

2996:06

from there and now let me just paste

2996:07

there and inside this paragraph you

2996:09

would say the review come on review and

2996:12

when that review was created so we have

2996:14

created add and let's just put our sub

2996:16

string inside there and I'm going to be

2996:18

passing the zero and 10 okay so now let

2996:21

me just save that and we don't have any

2996:23

reviews so we cannot see that right now

2996:25

but we will create a review in a few

2996:27

second okay so now underneath this

2996:29

paragraph or even underneath this div

2996:31

we're going to be just creating another

2996:32

paragraph which will just say the review

2996:36

comment data okay and now let me just

2996:38

also add the margin for the Y ACC will

2996:40

be now set to four now let me just save

2996:42

there and test every single thing out

2996:44

okay so here you can see we have our uh

2996:47

come on we have our input field right

2996:49

here so I can just write like this is

2996:52

one of the greatest come on great God

2996:55

damn greatest movie so far let me just

2996:59

make that a bit smaller because I cannot

2997:00

see the

2997:01

button let me just make the totally

2997:04

small we are doing something wrong I'm

2997:07

going to open my inspect element and and

2997:10

now let's just go ahead and go to my

2997:12

network Tab and I'm going to just for

2997:14

the review of like something now let me

2997:16

just click on the submit

2997:18

so what just happened are youone

2997:21

providing the reviews let's just uh

2997:23

refresh

2997:24

there what is going on oh that's because

2997:28

we did not create anything like any

2997:31

Handler for that I just realized I

2997:33

thought I just made a mistake but I

2997:34

didn't now let me just make the a bit

2997:36

bigger and now let me just take care of

2997:38

all of that event handlers now me just

2997:40

close there and I'm going to also

2997:42

uncomment there right here s my file I'm

2997:44

going to copy the name of there and now

2997:46

I'm going to go to the top and now let

2997:48

me just create that submit Handler so we

2997:50

have a const uh const submit Handler

2997:53

it's going to be asynchronous function

2997:55

now let me just for my event object and

2997:56

we have event pre come on prevent

2998:00

default and now let me just execute that

2998:02

and now underneath there we're going to

2998:04

be using our trying catch block for the

2998:05

catch block we're going to be just

2998:07

passing like Toast of error and now let

2998:09

me just say error if we have one so

2998:12

we're going to be just getting the data

2998:13

from there otherwise we just have to

2998:15

show the error message m e s a g e and

2998:18

if that's not the case so for the tri

2998:20

block we're going to be just creating

2998:21

our review so let's just write a create

2998:23

review and inside there we just have to

2998:26

pass the ID which will be the movie ID

2998:29

and also I'm going to be passing the

2998:30

rating and also the comment as well now

2998:33

let me just provide my unwrap to them

2998:36

and I'm going to be also fetching all of

2998:37

that data so let's just use a refetch

2998:40

and now let's just execute that and

2998:42

finally we're going to be just also

2998:43

showing some sort of a toast to the user

2998:45

so we have a toast. success and I'm

2998:47

going to just say like uh re come on r e

2998:50

v i e w review created

2998:54

successfully okay so c e c e c r e at

2999:00

there we go now let me just save there

2999:02

and now we will be able to add the

2999:03

review so what I want to do is that I

2999:05

just wanted to show where is that button

2999:09

oh my God I cannot see that but I don't

2999:12

know what the hell is going on right

2999:14

here I must have proed that button

2999:16

inside there and yep I guess I did let's

2999:20

just see where is our button let's just

2999:21

search for that we don't have that

2999:23

button right here but I'm going to have

2999:25

to go ahead and go to my component which

2999:27

we have that movie Tab and now let me

2999:29

just search for a button right here and

2999:31

we have that right here so underneath

2999:33

this text area we are not forwarding our

2999:35

button but now let me just cut that from

2999:37

here and underneath this D now let me

2999:39

just pass the and here you can see there

2999:41

we go and our button is looking amazing

2999:44

and now let me just provide a review

2999:46

right here finally so I'm going to just

2999:48

say like this is one of the

2999:51

greatest greatest action movie so far I

2999:56

don't care about the spelling and now

2999:57

let me just click on submit and here you

2999:59

can see we are getting our toast and we

3000:01

are also getting like who is doing that

3000:03

um review and we are also getting the

3000:06

review comment and we can also see that

3000:08

what do you call it that spe specific

3000:10

dead so what I want to do is that I'm

3000:11

going to just log out and I'm going to

3000:13

just log in as someone else like uh I

3000:15

don't know mango

3000:17

gmail.com and let's just uh provide the

3000:21

mango one two and the password is

3000:25

invalid I don't know which kind of

3000:26

password I provide M ngo1 123 one two

3000:32

yep nothing is working so I'm going to

3000:34

just log in as Alex maybe Alex gmail.com

3000:37

and let me just proide alex12 and now

3000:39

let me just click on sign in ah all of

3000:41

their user not found ah I just forgot

3000:45

the passwords and email of the users

3000:47

because it took me a lot of time to uh

3000:50

record all of that videos so we have a

3000:52

James now let me just log in as James

3000:55

let's just try there so we have a James

3000:59

gmail.com and we have a james12 and now

3001:01

let me just sign in and there we have it

3001:04

okay and now what I want to do is that

3001:05

I'm going to just click on that and now

3001:07

let me just go to a specific movie like

3001:09

John we one more time and we have a bug

3001:13

if I click on there it's going to just

3001:15

reload the page and I don't know why let

3001:18

me just try this out and I just found

3001:19

out the bug and the bug was when I log

3001:23

out and when I log in as someone else

3001:25

like in my case I'm going to just log in

3001:26

as James gmail.com and we have uh

3001:30

james12 and if I log in and now if I

3001:33

click on a specific movie we cannot go

3001:35

to that movie but now let me just log

3001:37

out and now let me just log in as hosen

3001:39

which is an admin and if I just fight

3001:41

husen2 and here now if I click on a

3001:44

specific movie so it will brings us to

3001:46

that uh specific movie right here so now

3001:49

let me just log out and show you where

3001:51

in the world was that error so now let

3001:52

me just log in as James

3001:55

gmail.com and let's just log in as James

3001:58

gmail.com and now let me just write a

3002:00

james12 now let me just log in there and

3002:03

now if I click on a specific movie we

3002:05

cannot go to there that's because I made

3002:08

a mistake right here inside this man I'm

3002:10

going to cut this line of code from here

3002:12

and now let me just make that as a

3002:14

public so that everybody can access that

3002:16

specific movie now let me just sell

3002:18

there and now if I refresh there and

3002:20

here you can see if I click on a

3002:21

specific movie so now we can totally go

3002:23

to the specific movie so now let me just

3002:25

go back and write or review so I'm now

3002:28

logged in as James and I'm going to just

3002:30

write a review for this movie so I'm

3002:32

going to just say like yeah yeah best

3002:35

action movie so far and now let me just

3002:37

click on submit and here you can see

3002:39

there review is added and we have that

3002:42

uh come on we have that review right

3002:44

here so which is made by hoseen and we

3002:46

have that specific comment and we also

3002:48

have that dead when this re was added so

3002:50

now let me just log out and log in as

3002:52

someone else like I don't know how many

3002:54

people we have inside our database let

3002:56

me just check this out I'm going to go

3002:58

ahead and log in as Jordan and now let

3003:02

me just write Jordan gmail.com and

3003:05

Jordan And1 to let me just go ahead and

3003:09

go to to my Jonathan Wick and I can just

3003:11

write like one of the awful movies so

3003:16

God

3003:18

damn now if I click on that so Jordan is

3003:21

a bit rude and here you can see we now

3003:23

getting his review right here so yeah

3003:25

that's cool but if I try to add some

3003:27

other view right here like uh I don't

3003:29

know or something wrong or something

3003:32

like that and we are already logged in

3003:34

this Jordan and we already reviewed this

3003:36

movie but if I try to add another review

3003:39

and if I click on this submit Handler so

3003:40

it's going to give us like movie already

3003:42

reviewed and now let me just go back and

3003:44

review some other movie like I don't

3003:45

know maybe a flash I'm going to just

3003:47

click on there and now let me just

3003:48

review this movie so something uh good

3003:51

or something like that now let me just

3003:53

click on there and here you can see we

3003:55

can totally add reviews to all of their

3003:57

movies so yeah that was it about how

3004:02

we're going to be taking care of all of

3004:03

that stuff so that was about the movie

3004:05

detail and now let me just take care of

3004:08

the movies comments so what I want to do

3004:10

is that I'm going to go ahead and go to

3004:12

my page and inside this page we are

3004:14

going to be going into the admin and

3004:16

inside this we're going to be creating a

3004:18

file I'm going to just name it as all

3004:20

comments. jsx and I'm going to be using

3004:23

the RFC to re come on r r a fce and now

3004:27

let me just save that I'm going to copy

3004:29

that from here and now let me just

3004:31

register that right here and it is going

3004:32

to be only for the admin so now let me

3004:35

just duplicate there and I'm going to be

3004:36

ping my all comments and now let me just

3004:39

import that right here and I'm going to

3004:40

be also removing all of that and I'm

3004:43

going to just write like movies and then

3004:45

we have a comments right here so now let

3004:47

me just sell there and I'm going to copy

3004:49

that from here and first of all I'm

3004:51

going to log in as an admin then we

3004:52

would be able to see there so now let me

3004:54

just log out and log in as an admin so

3004:57

I'm going to be using hosen2 let's just

3004:59

log in and now I'm going to be just

3005:02

providing this link right here which is

3005:04

admin and movies and then comments now

3005:06

if I hit enter so it's going to just

3005:08

gives us all of that comments M so now

3005:10

let me just go back and now let me just

3005:12

take care of that so the first thing

3005:14

which I want to do is that I want to

3005:15

grab a few hooks from my rtk query so

3005:19

let's just go ahead and go to our admin

3005:21

uh I mean like Redux then we have to go

3005:23

to the movies and we're going to be

3005:25

grabbing the use delete uh comment

3005:27

mutation and use get all U movies query

3005:30

okay so now underneath that we're going

3005:32

to be also getting the toast from where

3005:34

from the react now inside this all

3005:36

comments I'm going to be just

3005:38

destructuring my data and now let me

3005:40

just rename that to movies and we are

3005:42

going to be re oh God r e f e r e f e

3005:47

TCS so we are going to be ref fetching

3005:49

that from where from the use get all

3005:52

movies query okay so now the next thing

3005:54

which you have to do is that we have to

3005:55

also destructure or delete comment

3005:58

delete comment from where from or use

3006:03

delete comment mutation okay and now let

3006:05

me just use that so what I want to do is

3006:08

that I'm going to just remove this all

3006:10

comments and now inside there now let me

3006:12

just put a movie if we have there we're

3006:13

going to be iterating all through all of

3006:15

their movies and now let me just pass my

3006:17

movie inside there okay and now inside

3006:19

there we're going to be also passing a

3006:21

section and for each of these section

3006:23

I'm going to be passing the key and the

3006:25

key will be movie and the specific movie

3006:27

ID okay so let's just press the m and

3006:30

there we go and now let me just also

3006:32

style that a bit now inside this section

3006:34

we're going to be just checking the

3006:36

movies if we have there and then a

3006:38

specific review from the specific movie

3006:40

and we're going to be iterating over

3006:41

through all of their reviews let me just

3006:43

pass the review and I'm going to just

3006:46

provide a d right here and inside this

3006:48

div let's just pass our key and for the

3006:51

key we are going to be passing our

3006:53

review. specific review ID and I'm going

3006:56

to also style there and now let me just

3006:58

style there and inside this D now let me

3007:00

just save there and inside this div

3007:02

we're going to be creating yet another

3007:03

day with the class of flex and justify

3007:06

will be set to between and now inside

3007:08

there we're going to be so creating our

3007:10

strong tag and it will be just a text

3007:13

off let's just change that to like uh b0

3007:16

and I'm going to just copy that three

3007:18

times and now let me just pass my movie

3007:21

my review. uh name right here inside the

3007:24

review and now let me just also pass a

3007:26

paragraph and we would also want to get

3007:28

the review and then the created ad and

3007:32

also sub string there to Z and 10 and

3007:35

now let me just also style there so I'm

3007:37

going to be just passing the same X of

3007:40

the same color so now let me just copy

3007:41

that from here and I'm going to just

3007:43

place there right here save my file and

3007:46

here you can see we're getting all of

3007:47

that comments and we can get the name

3007:49

and also the specific dat when this

3007:52

comment was created now underneath this

3007:54

T which is underneath the paragraph

3007:56

we're going to be creating yet another

3007:57

div not a div but paragraph and now let

3008:00

me just pass the review and that comment

3008:03

which was made and now let me just pass

3008:05

like my uh I like margin for the Y AIS

3008:08

of four and now let me just save there

3008:10

and here you can see we are now also

3008:11

getting this specific comment as well

3008:13

and now let's just take care of how we

3008:15

are going to be deleting that specific

3008:16

comment so I'm going to just passess a

3008:18

button and it will just say delete for

3008:20

now and I'm going to be just passing the

3008:22

on click event handler to there and

3008:24

which will just say there delete a

3008:26

comment so handle delete come on handle

3008:30

delete comment which we going to be

3008:32

creating a few second and now let me

3008:34

just pass my movie and specific movie ID

3008:37

and then the review and let let's just

3008:39

pass there okay and now I'm going to

3008:41

also style thereit so I'm going to just

3008:44

pass my class name off text will be set

3008:46

to totally red or 500 and yeah now let

3008:49

me just save that and now let me just

3008:50

create that uh what do you call now let

3008:53

me just create this hook right another

3008:55

hook oh God I just forgot the name of

3008:58

that that event handler there we go and

3009:00

now let's just create that right in here

3009:03

so it's going to be an asynchronous

3009:04

function and now it's going to take the

3009:06

movie ID and the review ID as well okay

3009:09

so we already passed as an argument and

3009:11

now let me just pass my try catch block

3009:13

for the catch block we would just say

3009:14

like console. error and error uh

3009:18

deleting comment and now we are going to

3009:21

be also providing our error right here

3009:23

and for the tri block what do you want

3009:24

to do we just want to a and delete

3009:27

comment and now let me just P my movie

3009:30

ID and also my review ID as well now

3009:34

underneath that let me just pass my

3009:36

toast. success and also we will s like

3009:39

comment deleted and now underneath there

3009:42

let's just refresh every single thing

3009:44

and sell there and here you can see we

3009:46

have this delete B right here but now if

3009:48

I click on that so it's going to just

3009:50

remove that comment from here if I want

3009:52

to just remove this Jordan comment so

3009:54

I'm going to just click on there it's

3009:55

going to totally remove that so yeah

3009:57

that was about all of that comment and

3009:59

how we're going to be just deleting a

3010:01

specific comment and we'll come to the

3010:02

last part of this project in this one

3010:04

we're going to be just taking care of

3010:05

the dashboard so now what I want to do

3010:07

is I want to go ahead and go to my my

3010:09

main and now let me just create my

3010:11

dashboard and it's going to be totally

3010:13

complex like we're going to be creating

3010:15

a lot of components and yeah you will

3010:17

see that so I'm going to go ahead and go

3010:19

to my front end then go to my source

3010:22

then go to my uh yeah Pages then the

3010:25

admin and now inside that let me just

3010:27

create a separate folder and I'm going

3010:29

to just rename that to dashboard okay so

3010:31

I'm going to just hit enter right here

3010:33

and inside this folder we're going to be

3010:35

creating our admin dashboard.

3010:39

X now inside that we're going to be just

3010:41

writing like RFC save my file and now

3010:45

let me just register there right here

3010:46

inside this man so let me just duplicate

3010:49

this line of code and I'm going to just

3010:50

say like admin dashboard and it's going

3010:53

to UT import that for me and I'm going

3010:55

to just delete that from here and admin

3010:58

let's just go ahead and go to the movies

3010:59

then we want to go to the dashboard and

3011:01

I'm going to just put that right here at

3011:03

the top and now let me just save there

3011:05

and now if I click on this drop down

3011:06

menu and if I click on this dashboard so

3011:09

is going to just brings us to this

3011:10

dashboard right here okay so yeah that's

3011:12

looking cool and now let me just uh take

3011:15

care of that right here so the first

3011:17

thing which I want to do is that I want

3011:19

to delete that and I'm going to just

3011:22

make it as a react fragment and inside

3011:24

there we're going to be rendering two

3011:25

component which will be the sidebar and

3011:27

now let's just close there and we're

3011:29

going to be also rendering the main let

3011:31

me just save that and now let me just

3011:32

create both of them now inside this

3011:34

dashboard folder we're going to be

3011:36

creating two nested folder which will be

3011:38

for the the main and also one will be

3011:40

for the sidebar so we would have a

3011:42

sidebar and now let me just hit enter

3011:44

right here and the first thing which I

3011:45

want to do is that I want to create the

3011:47

sidebar component so now let me just

3011:48

create a sidebar. jsx and now let me

3011:51

just use the rafc sem my file and I'm

3011:53

going to be also creating my main. jsx

3011:56

component and now let me just also

3011:58

create this semi file and now let me

3012:00

just go ahead and go to my admin

3012:01

dashboard and now let's just import that

3012:04

right in here okay so let's just import

3012:06

both of them sell file and here you can

3012:08

see now getting the sidebar and also the

3012:10

main component so we're not going to be

3012:12

doing anything craziness but we are

3012:15

going to be just styling there okay so

3012:16

now let me just go ahead and go to my

3012:18

sidebar and the first thing we would

3012:20

need is the link so now let me just grab

3012:22

my link uh let's just grab that from the

3012:25

react router down and now inside there

3012:28

uh let's just sa there and I'm going to

3012:29

just remove this sidebar right here and

3012:31

I'm going to be placing a lot of D CSS

3012:34

classes so now let me just past there

3012:36

and also let me just create a side

3012:38

inside there and I'm going to also style

3012:41

there so now let me just style there and

3012:43

now inside this aside we're going to be

3012:44

creating our Ur and I'm going to just

3012:46

put the pading of for the y axis of four

3012:49

and now inside there we're going to be

3012:51

creating our Li once again and now let

3012:52

me just also style there so I'm going to

3012:55

also style there okay and now inside

3012:58

there we are going to be also creating

3013:00

our link and now let me just provide a

3013:02

specific uh path where it should go so

3013:04

we're going to be providing the admin

3013:06

and then movies and then it should go to

3013:08

the dashboard and now let me just

3013:10

provide dashboard and now let me just

3013:13

also add a few classes to it so we have

3013:15

a block we have a padding for all around

3013:17

of two margin for the left will be 20

3013:19

margin for the bottom will be set to 10

3013:21

so now let me just save that and here

3013:22

you can see we are now getting this

3013:24

dashboard right here but we are now also

3013:26

getting our man right here okay so if I

3013:28

click on this it's going to just brings

3013:29

us to this dashboard right here okay so

3013:32

that was the first link and I'm going to

3013:34

just duplicate there four times so we

3013:36

have this Ali I'm going to just copy

3013:38

there and that was the one so we would

3013:41

have to just one two three four times so

3013:45

we leave The Styling as it is so the

3013:47

first one we have is a dashboard and

3013:48

then we have the create movie so now let

3013:51

me just change that to create movie and

3013:53

I'm going to also change that from admin

3013:56

movies and dashboard to create create

3013:59

there we go and now underneath that we

3014:02

have another dashboard and I'm going to

3014:03

just make that as create genre and I'm

3014:07

going to just change that to genre like

3014:09

so and yeah that's cool but now let me

3014:12

just also take care of the update movie

3014:14

so we would also have the update movie

3014:16

and also let me just go to uh I'm going

3014:20

to just remove that from here and it's

3014:21

going to just brings us to the movies uh

3014:24

list right here and now let me just save

3014:25

that and let me just also go ahead and

3014:28

go to my dashboard once again and the

3014:30

final one we would have is for the

3014:31

comments okay so now let me just click

3014:34

on this dashboard and change that to

3014:35

comments and now let me just save this

3014:37

file and now let's just just check all

3014:39

of that and here you can see we have all

3014:41

of their dashboards right here but

3014:43

that's not something that I want uh what

3014:45

I want to do is that I just have to

3014:48

change the styling so instead of writing

3014:52

these styling so I'm going to just leave

3014:53

the first one as it is but for the

3014:55

second one which we have is the create

3014:57

movie I'm going to just select The

3014:59

Styling hit contrl dtrl d control d one

3015:03

more time and I'm going to just place

3015:05

these styling so now let me just place

3015:07

there and here you can see are now

3015:09

providing when somebody how over there

3015:11

then we are providing a gradient to the

3015:13

bottom from the green to the lamp of 400

3015:15

so now let me just save there and here

3015:17

you can see it's going to just gives us

3015:18

their dashboard but if I click on this

3015:19

create movie so it's going to just

3015:21

brings us to this create movie right

3015:23

here then if I click on the create genre

3015:24

so it's going to just brings us to there

3015:26

if I go to the update movie so it's

3015:28

going to just gives us the list of all

3015:29

of that movies so we can update a movie

3015:31

we can delete a movie if you wanted to

3015:33

and now let me just also go to the

3015:35

comment so it's going to also gives us

3015:36

that comment section right here so from

3015:38

there we can totally see all of the

3015:40

comments or we can totally Del all of

3015:41

the comments and now let me just take

3015:43

care of this main area and trust me it's

3015:46

going to be a lot more fun than the rest

3015:47

of them so I'm going to just close all

3015:49

of that and now inside this man we

3015:52

already create our man right here but

3015:53

I'm going to be creating a lot more

3015:55

components okay so the first thing which

3015:57

I want to do is that I want to create a

3015:59

primary card. jsx then I'm going to be

3016:02

also or you know let me just add my RFC

3016:04

manually so now let me just write my RFC

3016:06

s file and now let me just create

3016:08

another another component for the real

3016:11

time card. jsx and I'm going to be just

3016:14

spacing my RFC seller file and now let

3016:17

me just create here another component

3016:18

for the secondary card. jsx and I'm

3016:22

going to just spacing the RFC s my file

3016:25

and now you're going to be also

3016:28

providing the V card. jsx and now let me

3016:31

just uh write R come on RFC s my file

3016:35

let's just close that let me just go

3016:37

back and now let's get into the Main and

3016:39

start working with the main so the first

3016:41

thing which I would do is that I'm going

3016:43

to be grabbing my secondary card uh CD

3016:47

from where from let's just go ahead and

3016:49

go to the secondary card and I'm going

3016:51

to be also grabbing my videoo card oh I

3016:55

guess I didn't create the r card let me

3016:57

just also do that so we would also

3016:59

create the r card. jsx as well H where

3017:04

you card yeah we already have that we

3017:07

already created that right here but now

3017:08

let me just grab this we have a radio

3017:11

card and we're going to be grabbing that

3017:13

from the radio card okay now the next

3017:16

thing which you have to do that we also

3017:17

have to grab a real time uh card from

3017:20

where from let's just go ahead and go to

3017:22

the real time card now let me just use

3017:24

my rtk hooks right here so we are going

3017:26

to be also importing something from

3017:28

let's just go ahead and go to or redex

3017:31

ah

3017:33

redu oh my God why in the world let's

3017:36

just go back three times and now let me

3017:38

just oh not here let's just go one more

3017:42

time and there we have it then we have

3017:44

to write the redex then we have to go

3017:46

ahead and go to the API and then we have

3017:47

to go to the movies so I'm going to just

3017:50

duplicate this template like three times

3017:52

and I'm going to be just spacing the

3017:53

users in this case and also the movies

3017:56

as well but um you know we don't have to

3018:01

do that so now let me just cut that from

3018:02

here and we are going to be grabbing the

3018:04

used get top movie squarey and we will

3018:07

also get the used get all movies query

3018:09

from there and now inside this users

3018:11

what do you want to do we just want to

3018:13

get like use get users C users query so

3018:17

why it's not giving us the users query

3018:19

let me just test this out so I'm going

3018:20

to just comment this line out and I'm

3018:22

going to go ahead and go to my users and

3018:24

check if we have the use get all the

3018:26

users query or not and yep indeed we

3018:28

don't have that and what I want to do is

3018:30

that underneath this profile now let me

3018:32

just create my endpoint right here and

3018:35

get users and we are going to be using

3018:37

our builder. query and now let me just

3018:39

pass the query and let me just pass my

3018:43

endpoint right here which will be the

3018:44

URL and we're going to just providing

3018:46

the users uh URL right here so now let

3018:49

me just save that and now finally now

3018:51

let me just export that right here so

3018:53

I'm going to be just using like uh use

3018:55

get users query so now let me just copy

3018:58

that save this file and I'm going to

3019:00

just uncomment this line out and I'm

3019:02

going to be just placing my use get all

3019:04

use get uh users query right here now

3019:07

let me just save there so that's all the

3019:10

thing that we currently need for now and

3019:12

now let me just destructure all of that

3019:13

content so we are going to be just

3019:15

destructuring or data and I'm going to

3019:18

just rename that to like top movies and

3019:21

then we're going to be just using like

3019:22

use get top movies query and now let me

3019:25

just also destructure my data once again

3019:27

and I'm going to just rename that to

3019:28

like visitors it's going to be equals to

3019:30

the use get users query and now let me

3019:33

just execute that we're going to be also

3019:35

restructuring all of the movies and I'm

3019:38

going to just uh write a use get on mov

3019:40

query and

3019:42

now that's it but you know first of all

3019:45

let me just also make a variable for uh

3019:48

total total comments length come on t o

3019:52

TL and then C O M N TS l e n GT it's

3019:57

going to be equals to all movies and now

3019:59

we're going to be just iterating over

3020:00

through all of the movies by using the

3020:02

map and now let me just Place the movie

3020:04

and inside there we're going to be just

3020:06

getting the number of comments we have a

3020:09

num uh reviews there we go and now

3020:12

underneath that we're going to be just

3020:13

getting the sum of comments length Okay

3020:17

and now it's going to be equals to the

3020:19

total comments length like this variable

3020:21

which will only gives us all of the

3020:23

reviews and now we have to just use our

3020:25

reduce method on that and let's just

3020:27

provide our accumulator and also the

3020:30

length as well let me just go back and

3020:32

now here we're going to be just adding

3020:34

the accumulator plus the length as well

3020:37

and I'm going to be also recing the

3020:39

comma of zero at the end okay so yeah

3020:41

that's then now let me just save this

3020:43

file and now let's just use that so what

3020:45

I want to do is that I want to go ahead

3020:46

and go to my main and I'm going to be

3020:48

creating a section and for this section

3020:50

now let me just P my Flex and justify

3020:53

will be set to around in this case and

3020:55

now let me just also add my margin for

3020:56

the left of uh

3020:59

14 Rim come on rim and I'm going to be

3021:02

also providing margin for the top of 10

3021:04

and inside there let me just create a

3021:06

div and I'm going to be passing the

3021:08

class name of

3021:10

translate translate for the xais of four

3021:13

and now let me just also pass the flex

3021:15

and now let me just use my secondary

3021:17

card and let's just close that so for

3021:21

the secondary card we are going to be

3021:22

providing these props so now let me just

3021:24

provide the pill and the pill will be

3021:26

users for the first one and also let me

3021:29

just provide the content and the content

3021:31

will be visitors and now let me just

3021:34

provide the length of their visitors and

3021:37

now let me just provide the info you you

3021:38

can provide anything you want but in my

3021:40

case I'm going to just space like

3021:42

20.2k and more more than uh usual U USU

3021:49

come on us there we go and I'm going to

3021:52

be also passing the gradient so g a d n

3021:55

will be from teal of 500

3021:59

500 to the lime 400 okay so now let me

3022:04

just save this file and I'm going to

3022:06

just duplicate there for a few times

3022:07

like three times would be fine so we

3022:10

have the second one for the second one

3022:12

I'm going to be just passing the

3022:13

comments and now let me just pass the

3022:15

sum of all the comments so now let me

3022:17

just remove this so we have sum of all

3022:19

comments and then let's just remove this

3022:22

info from here and I'm going to just

3022:24

spacing like 7 uh

3022:27

42.8 more than usual and let's just

3022:31

change this one two from the from this

3022:34

color of gradient which is CCC 515 four

3022:39

uh to this color so now let me just pass

3022:42

the

3022:43

CD c b add uh e there we go and now let

3022:48

me just save that this is going to be

3022:49

the second color or gradient rather and

3022:51

now let me just also put the movies and

3022:54

then we have to just remove that and all

3022:56

movies if we have that we going to be

3022:59

getting the length from there and now

3023:01

let me just change there to

3023:05

372 uh plus more than us come on

3023:09

usul and now let me just pass the

3023:12

gradient of from Green of 500 to the

3023:16

lime uh of 400 okay so now if I say

3023:20

there nothing will happen because we did

3023:22

not create these components now let me

3023:24

just save that and let's just take care

3023:26

of the secondary card I'm going to go to

3023:28

that and now let me just take care of

3023:30

that so it's going to take the props of

3023:32

first of all the pill then the content

3023:35

then the info and the gradient okay and

3023:38

and now inside there let me just remove

3023:40

the secondary and I'm going to be just

3023:42

providing this class name to there so

3023:43

let's just remove there let me just save

3023:45

there and here you can see we are now

3023:47

going to be passing that gradient which

3023:49

we are already taking right here so we

3023:50

have g r a d i e n t so now we are

3023:53

passing that gradient dynamically and

3023:55

the rest of them will be the same now

3023:57

inside this div we are going to be

3023:58

creating yet another div and now we are

3024:01

going to be just rendering the pill

3024:03

inside the the props which you are

3024:04

already providing today but I'm going to

3024:06

be also providing a classes to them so

3024:08

now let me just go ahead and provide

3024:10

these classes so now let's just save

3024:12

there and now underneath this D what do

3024:14

you want to do we just want to create

3024:16

another div and inside this div we're

3024:18

going to be creating our H2 and now let

3024:20

me just provide first of all the content

3024:22

inside there and now let me just style

3024:23

there so let's just provide this styling

3024:25

to it and for the H2 let me just Pro a

3024:28

space and I'm going to be faing these uh

3024:31

styling to so now let me just save this

3024:33

file and now underneath this div we're

3024:35

going to be just creating our final D

3024:36

which will be for the in info okay so

3024:39

now let me just render the info and also

3024:41

let me just provide the styling to it so

3024:43

let's just paste this styling ah let's

3024:46

just provide that sem my file and now

3024:48

let's just test this out and see it's

3024:49

going to gives us all of that secondary

3024:51

cards so we have for the users then we

3024:53

have for the comments and we also have

3024:55

for the movies okay so we have 10 movies

3024:57

inside our database we have two comments

3024:59

for all of the movies and we have seven

3025:01

users inside our database so yeah that

3025:04

was for the secondary card now let me

3025:06

just remove that and now let me just

3025:08

just go to the bottom and now underneath

3025:10

this div let me just create another div

3025:12

and now let me just style there and

3025:14

inside this div we're going to be

3025:15

creating our paragraph which will select

3025:17

top content and also let's just create

3025:19

another paragraph for the comments as

3025:21

well underneath this div we're going to

3025:23

be itting over through all of the top

3025:25

movies so now let me just itate over

3025:27

through there by using the map and now

3025:29

let me just past the movie name and

3025:31

inside there we are going to be just

3025:32

rendering our video card and now let me

3025:34

just close them first of all let me

3025:36

provide the key and the key was movie

3025:38

and specific movie ID and now let me

3025:40

just P the image and the movie image and

3025:43

I'm going to be also pting the title and

3025:45

the title was movie name and also the

3025:48

date when this was released so now let

3025:50

me just past the movie. year and also we

3025:52

have a comments as well and we have a

3025:55

movie and then number of reviews so now

3025:58

let me just save that and now let me

3026:00

just go ahead and go to this movie I

3026:01

mean like video card and now let me just

3026:03

take care of that okay so now let me

3026:05

just save that first thing we would do

3026:06

is that we would destructure the image

3026:08

the title and also the date uh date and

3026:12

also the comments as well and now let me

3026:14

just use it right here so I'm going to

3026:16

just make the as a react fragments and

3026:18

inside that we're going to be just

3026:19

creating a d with the class of fle and

3026:21

items will be now set to Center and I'm

3026:23

going to be also providing the width of

3026:25

uh let me just put 90% And also margin

3026:28

for top will be set to five and now

3026:30

inside there let me just put a div and

3026:32

for this div we are going to be also

3026:34

rendering the image and now uh I'm going

3026:38

what the hell was that oh God let me

3026:41

just provide the image right here inside

3026:44

there and for the alternative text I'm

3026:46

going to just P like card image or

3026:47

something like that and I'm going to

3026:49

also provide a class to it so class will

3026:51

say like height will be set to three Rim

3026:54

okay so now let me just saell there and

3026:56

that's not something that I want that's

3026:59

not something that I want so now let me

3027:01

just try that and here you can see we

3027:03

are not writing outside from there now

3027:05

let me just cut all of that stuff from

3027:07

here and now underneath this div let me

3027:11

just place that okay so if I just place

3027:13

it right here sa my file and here you

3027:15

can see it is still looking bad but I'm

3027:17

going to just take care of there in a

3027:18

few seconds so so bear with me for a

3027:21

second so now let me just go ahead and

3027:22

go to my video and underneath this div

3027:25

what I wanted to do I want to just

3027:26

create a div with a class margin for the

3027:28

left of four and now inside there let me

3027:30

just put a H2 right here and now let me

3027:32

just render the title and also the

3027:34

paragraph and paragraph will just say

3027:36

the dead and now to need this D we're

3027:38

going to be creating yet another div and

3027:40

now let's just create a div for the

3027:42

comments right here so now let me just

3027:44

put a bit of closing to this one to this

3027:46

one and also to this one as well and now

3027:49

let me just add classes to this one so

3027:51

now let me just save there and we only

3027:53

added classes to this data right here

3027:55

okay so I want you to write that as well

3027:57

and here you can see this is how

3027:59

everything looks like so it's going to

3028:00

gives us all of their movies and it's

3028:02

going also gives us all of their movies

3028:03

comments so here you can see for the

3028:05

first movie we have only two comments

3028:07

and for the rest of them we did not even

3028:08

create any comments so that's why we

3028:10

cannot see there so yeah this how we're

3028:12

going to be taking care of the r card

3028:14

and now let me just take care of the

3028:16

final one which will be underneath this

3028:18

div and now let me just create a div and

3028:20

inside there let's just place a real

3028:22

time card and I'm going to just sell

3028:25

there and now let me just go inside

3028:26

there and inside there that's going to

3028:29

be the final component so let's just

3028:32

grab something from where from let's

3028:34

just go ahead and go to or Redux like

3028:36

three times not like that but I guess

3028:39

four times and then we have to go to the

3028:42

API then we have to go to the users and

3028:44

I'm going to be restructuring the use

3028:46

get users query and we would also need

3028:49

the primary card right here so let's

3028:51

just use our primary card and we are

3028:54

going to be grabbing that from our

3028:55

primary card okay so now inside there

3028:58

let's just get our data and let's just

3029:00

destructure there and I'm going to just

3029:02

change the name of there to like

3029:03

visitors it's going to be coming from

3029:05

where from the use get users query

3029:08

and inside this Dev let me just remove

3029:10

that from here and let's just provide

3029:12

first of all the H2 and I'm going to

3029:15

just s like real time or real time in

3029:18

lower case and then we would have to

3029:20

also write a paragraph which will say

3029:21

like update live uh live and also we

3029:25

will have another div which will not say

3029:27

anything at all but we are going to be

3029:29

just styling there in a few second now

3029:31

let me just Prov H2 and which will just

3029:33

say like visitors and then the length

3029:36

from that visitors uh l n GT and then

3029:40

also finally we just have to write a

3029:42

subscribe

3029:43

su su SC C rbe while I add classes to

3029:48

these I want you to subscribe to also my

3029:50

YouTube channel as well okay so now let

3029:52

me just add classes to each of them so

3029:54

I'm going to just f for the video and

3029:56

now let me just add that for the final

3029:57

one right here so we just added classes

3030:00

to ah let me just highlight so we just

3030:03

added classes to all of their divs okay

3030:06

so yeah that look cool I can totally

3030:09

guarantee that but now let me just ride

3030:11

my HR and now underneath that let's just

3030:13

also print our primary card and close

3030:16

the sell my file and that was the end

3030:20

and here you can see we have our primary

3030:22

card right here you can provide even

3030:24

more details to them

3030:26

and we are getting the primary card and

3030:29

where in the world is that coming from

3030:31

we have a primary card let's just check

3030:33

this out and why in the world you're not

3030:36

taking care of the primary card I

3030:38

thought this is going to be the last

3030:39

component but we also have to take care

3030:41

of this primary card as well so yeah now

3030:44

let me just do that okay so the first

3030:46

thing which I want to do is that I

3030:47

wanted to import something from let's

3030:50

just go to four time let's just go to

3030:53

four time and I'm going to go ahead and

3030:56

go to the API and then uh the users so

3030:58

we are going to be grabbing uh what do

3031:00

we call it uh the use get users query

3031:04

and now let me just create an instance

3031:05

of there or even D structure or data and

3031:08

I'm going to be just spacing the visitor

3031:10

and use get uh users query and now let

3031:13

me just execute that and for this T

3031:16

inside that we going to be just creating

3031:18

our H2 and I'm going to just say like

3031:22

congratulations and I'm going to also

3031:24

provide the paragraph which will say

3031:25

like you have this amount of visitors uh

3031:29

visitors and if you have that we going

3031:31

to be getting the link from there new

3031:33

users and then watching come on watching

3031:37

your content content there we go and now

3031:41

let me just add classes to both of them

3031:43

and first of all I'm going to be adding

3031:44

classes to this one and now let me just

3031:46

add classes to this one so now let me

3031:48

just save there and here you can see we

3031:50

are now getting our

3031:52

congratulations and now let's just click

3031:54

on the movies and that was our entire

3031:57

project and that was a

3032:01

beast

3032:02

finally now I have to do a lot of work

3032:05

like I have to edit these videos and

3032:07

then

3032:08

I'm going to go ahead and put that on my

3032:10

YouTube channel so yeah if you like my

3032:12

content so feel free to subscribe to my

3032:14

YouTube channel and please please follow

3032:17

me on GitHub please I'm saying please

3032:20

I'm begging you please follow me on

3032:22

GitHub So yeah thank you so much for

3032:24

watching this video and and I will do my

3032:26

best to provide more high quality

3032:28

content more than this project and we're

3032:31

going to be creating more projects soon

3032:33

so if you have any idea for a specific

3032:35

course or I don't know for just a

3032:37

specific video or I don't know for a

3032:39

project or something like that so drop

3032:41

that in the comment section and I'm

3032:42

going to do my best to make a specific

3032:45

separate course on there okay so we can

3032:47

go to the dashboard now we can also go

3032:49

to the profile we can change everything

3032:52

and we can totally log out and we can

3032:54

also register so yeah that was

3032:57

everything and thank you so much from

3032:58

the bottom of my heart for watching my

3033:00

content love you all and see you in the

3033:02

next course bye-bye

Interactive Summary

Ask follow-up questions or revisit key timestamps.

Loading summary...