1
00:00:01,580 --> 00:00:02,330
Welcome to the radio.

2
00:00:03,020 --> 00:00:09,170
So in this video, we can see how to implement the remove some part and not some functionality.

3
00:00:09,920 --> 00:00:16,400
So as you can see it, when I'm clicking on add to basket, the the cart division is getting updated

4
00:00:16,400 --> 00:00:17,990
with the number of items in the basket.

5
00:00:20,180 --> 00:00:25,790
So now, once you go to the checkout page, you can see the items that are added to the fact, and you

6
00:00:25,790 --> 00:00:29,240
can see that that is getting dynamically updated on the number of items already.

7
00:00:29,540 --> 00:00:33,620
So if I click remove from the basket, you're going to see the price getting updated and also the number

8
00:00:33,620 --> 00:00:35,630
of elements already here and already it.

9
00:00:36,230 --> 00:00:40,130
So basically, we can see how to implement this feature in our website.

10
00:00:41,060 --> 00:00:46,610
Basically, we use a user that user hooks for this purpose and also use database.

11
00:00:48,540 --> 00:00:53,820
So firstly, to stop with the project, we have to we have to open the court and then we have to create

12
00:00:53,820 --> 00:00:57,450
a file called state provided not just.

13
00:01:04,500 --> 00:01:08,160
So going to how to do this had to cut and remove some card functionality.

14
00:01:09,380 --> 00:01:13,610
So Africans here, basically they are having on one page like this.

15
00:01:15,780 --> 00:01:16,800
It had that.

16
00:01:20,140 --> 00:01:24,070
And then with the like some products, imagine what it.

17
00:01:25,930 --> 00:01:29,830
And then some products like the products and buttons.

18
00:01:34,600 --> 00:01:41,110
So when you click on the button, we want this product details to be sent to the checkout page.

19
00:01:42,080 --> 00:01:42,380
OK.

20
00:01:49,910 --> 00:01:50,330
So.

21
00:01:51,790 --> 00:01:56,530
To send the data of this product to the checkout page will not send it directly.

22
00:01:56,980 --> 00:02:02,530
Like, for example, estimate a cloud over it like a data layer, so we'll be sending the product details

23
00:02:02,530 --> 00:02:03,430
to this data layer.

24
00:02:03,760 --> 00:02:08,890
And you can use the product, the data that is present, the data from any component.

25
00:02:09,070 --> 00:02:14,410
So I can use from the checkout page component down from the header component or inside checkout, as

26
00:02:14,410 --> 00:02:15,730
you can see inside or better.

27
00:02:15,730 --> 00:02:21,750
I have product products already it and then the amount so you can use the data, what here in this component,

28
00:02:22,090 --> 00:02:23,170
here in this component.

29
00:02:23,530 --> 00:02:27,520
So once you push the data into the data layer, you can use it from any component.

30
00:02:27,760 --> 00:02:29,800
So this is what we'll do with this data provider.

31
00:02:30,460 --> 00:02:30,760
OK.

32
00:02:31,960 --> 00:02:36,440
Let me add this Fundstrat provider will basically prepare the data.

33
00:02:37,580 --> 00:02:39,620
So first thing you have to do is import the packages.

34
00:02:49,200 --> 00:02:51,870
Create context in this context.

35
00:02:58,440 --> 00:02:59,300
And use reduced.

36
00:03:18,530 --> 00:03:23,480
So basically, what we mean by clear context and like use context.

37
00:03:23,960 --> 00:03:26,990
So this is what the react context here comes in.

38
00:03:27,380 --> 00:03:34,340
So context provides us a way to parse data through the componenti through the componentry without having

39
00:03:34,340 --> 00:03:37,370
to pass drops down manually at every level.

40
00:03:37,790 --> 00:03:43,760
So like as I said before, if you want to send this data to any component, you have to pass like,

41
00:03:43,760 --> 00:03:49,760
for example, if I want to send this to the checkout product like over here, so then I have to implement

42
00:03:49,760 --> 00:03:54,580
everything like I have to send the props to the below component and then the props to the below components.

43
00:03:54,580 --> 00:03:55,730
So it's like a trillion you have after.

44
00:03:55,730 --> 00:03:59,330
Send the props to every and then the download until it reaches the donor.

45
00:03:59,660 --> 00:04:04,820
So instead of that, to access the data from a certain area, from every component, breakfast, from

46
00:04:04,820 --> 00:04:06,920
every component, we lose this context.

47
00:04:07,310 --> 00:04:09,890
So we have to create a context for the same context.

48
00:04:10,280 --> 00:04:13,340
So basically, that is what we'll be doing here once we import these things.

49
00:04:25,350 --> 00:04:26,730
So to be creating the context.

50
00:04:27,870 --> 00:04:32,090
Will you be exporting it at the same time, creating so this creates the data layer?

51
00:04:32,940 --> 00:04:34,680
OK, so basically we are preparing the data.

52
00:04:37,500 --> 00:04:38,280
iPads, the data.

53
00:04:43,730 --> 00:04:47,790
Now we have to wrap it up and provide the data, right?

54
00:04:48,110 --> 00:04:53,330
So what we have to wrap our app and provide the data with the data.

55
00:04:59,530 --> 00:05:00,760
So this we have to do export.

56
00:05:03,100 --> 00:05:04,360
Gombe State provided.

57
00:05:26,150 --> 00:05:28,880
So we'll be using the Arrow functionality at.

58
00:05:41,350 --> 00:05:45,970
So this is basically the boilerplate code that we have to use for every React project, OK?

59
00:05:46,250 --> 00:05:49,750
So it's going to be the boilerplate quote So what about this?

60
00:05:50,740 --> 00:05:53,650
Complete the court and tell you what the complete code will look.

61
00:05:59,000 --> 00:06:00,530
Our values should be.

62
00:06:05,860 --> 00:06:08,200
Uses revenues that we have to use that due to look.

63
00:06:14,740 --> 00:06:17,530
OK, given capsule, reduce it.

64
00:06:19,020 --> 00:06:20,220
And ActionScript.

65
00:06:29,500 --> 00:06:30,940
And should this will have the children?

66
00:06:42,820 --> 00:06:46,390
So once we are done with this, we have to pull the information from the data, they have to use it

67
00:06:46,390 --> 00:06:47,620
from various components.

68
00:06:48,480 --> 00:06:49,060
Right, so.

69
00:07:09,770 --> 00:07:12,590
So this line of courage to pull information from the retailer.

70
00:07:22,510 --> 00:07:27,040
So this is the boilerplate code that you have to use for every product when you are dealing with the

71
00:07:27,040 --> 00:07:27,880
state providers.

72
00:07:28,510 --> 00:07:34,120
So what the whole code does is it will import very ideas that you already have that that are needed

73
00:07:34,120 --> 00:07:40,570
to implement the functionality that we want and prepares the data so that whenever we use the radio,

74
00:07:40,590 --> 00:07:46,180
that the arguments that the REDUCE-IT have, that is the current state and dispatch method to alter

75
00:07:46,180 --> 00:07:46,900
the current state.

76
00:07:47,410 --> 00:07:53,410
So basically, we'll be getting all the features that are necessary to build this data and to push the

77
00:07:53,410 --> 00:07:56,950
information into the left and then pull the pull back the information from the left.

78
00:07:57,460 --> 00:08:02,020
So once we did this, we have to create a create a file called reduce and address.

79
00:08:09,290 --> 00:08:13,130
And introduce a Dargis here will be building all the application.

80
00:08:17,520 --> 00:08:18,560
I mean, if at all the.

81
00:08:19,740 --> 00:08:20,520
Application.

82
00:08:21,950 --> 00:08:22,910
Eleven states.

83
00:08:25,010 --> 00:08:28,400
And defiant actions to make that statement, yes.

84
00:08:34,230 --> 00:08:35,100
Changes to the state.

85
00:08:38,430 --> 00:08:38,690
Now.

86
00:08:40,670 --> 00:08:44,810
So we we have the first export, the initial step, so this is also the boilerplate code that you have

87
00:08:44,810 --> 00:08:45,890
to use for every project.

88
00:08:46,550 --> 00:08:52,790
Don't worry, if you don't understand it, it basically creates a red alert and it will get the basic

89
00:08:52,790 --> 00:08:54,110
functionality that we want to use.

90
00:09:03,300 --> 00:09:06,240
So this will be a material basket.

91
00:09:07,190 --> 00:09:11,870
Well, will store all the products that are pushed into the retailer and retrieve the products from

92
00:09:11,990 --> 00:09:12,620
that data.

93
00:09:15,450 --> 00:09:16,860
So now we'll be using the selector.

94
00:09:30,030 --> 00:09:34,680
So I said, but then at this hour, we'll get to argument that is stick and action.

95
00:09:37,820 --> 00:09:44,690
So this state has the current current state of our data layer and then action to make the changes relationship.

96
00:09:47,140 --> 00:09:48,640
This will be out of action.

97
00:09:53,470 --> 00:09:56,950
And then here we can perform the methods that we want to do.

98
00:09:57,460 --> 00:10:03,260
So basically, I'll be using this thing in in my checkout, see it.

99
00:10:03,310 --> 00:10:07,540
Check out our gas order and product or where we have to.

100
00:10:07,840 --> 00:10:11,950
When we click on Add to basket, we have to call a function that make changes to the.

101
00:10:12,850 --> 00:10:14,020
So we'll see how we do that.

102
00:10:18,190 --> 00:10:19,420
So today we have to.

103
00:10:20,710 --> 00:10:21,850
Export producer.

104
00:10:27,110 --> 00:10:31,120
So long as we do that, we have to go to Florida just OK.

105
00:10:31,850 --> 00:10:33,770
And then click on the basket like on.

106
00:10:34,130 --> 00:10:35,480
We have to follow function, right?

107
00:10:36,170 --> 00:10:36,980
So we know that.

108
00:10:42,680 --> 00:10:48,590
So I'm clicking the attribute of the button or it will it will call a function when the button is pressed.

109
00:10:50,040 --> 00:10:54,060
Click here I am calling a function, it is a JavaScript functions I have to use collaborative.

110
00:10:56,880 --> 00:11:01,920
So regarding add to basket function, so you have to define the function well defined in this function

111
00:11:01,920 --> 00:11:02,610
product only.

112
00:11:09,200 --> 00:11:14,180
So as I'm working with state television, I have been import them first.

113
00:11:15,680 --> 00:11:21,320
So important as you state value from state provider, basically, then I study this, you will state

114
00:11:21,320 --> 00:11:25,340
value makes the product as a children's component.

115
00:11:25,790 --> 00:11:30,560
So when it runs, it's children component, it can access the data from the parent company and that

116
00:11:30,560 --> 00:11:32,630
is the first thing they are doing in the studio.

117
00:11:32,630 --> 00:11:38,000
And we are making everything children when whenever we use this state provider that we are using in

118
00:11:38,000 --> 00:11:38,630
that context.

119
00:11:38,930 --> 00:11:41,600
So basically, to pull the information, we'll be using this.

120
00:11:42,140 --> 00:11:43,850
So I'm using the state value.

121
00:11:54,800 --> 00:11:58,700
So long as you are importing this now, you can write the code in the function.

122
00:12:11,880 --> 00:12:15,750
So here dispatch means it's alternative name for the action.

123
00:12:15,990 --> 00:12:21,840
OK, is alternative name for action like basically state and action we are using yet a state and dispatch.

124
00:12:22,110 --> 00:12:24,060
So, OK, this dispatch will do this will.

125
00:12:24,360 --> 00:12:32,730
This is like JavaScript object that will have a Typekit type feature, so we'll be seeing how to do

126
00:12:32,730 --> 00:12:32,940
that.

127
00:12:37,430 --> 00:12:39,440
So as to what should we have declared the function?

128
00:12:46,480 --> 00:12:49,890
So when you click on add to basket, we have to change the state.

129
00:12:49,930 --> 00:12:53,470
That means we are introducing a new product data into the state.

130
00:12:53,830 --> 00:12:55,630
So for that, we have to use this action.

131
00:12:55,660 --> 00:12:57,240
That is the dispatch method.

132
00:12:57,880 --> 00:12:58,720
So dispatch.

133
00:13:01,520 --> 00:13:03,110
I started something called item.

134
00:13:03,660 --> 00:13:04,850
Oh, let me show you item.

135
00:13:07,160 --> 00:13:12,830
Typekit, first, we have to use tape and then the tape will be the name that you want to give to the

136
00:13:13,250 --> 00:13:17,540
to the function that you want to perform, so that if you are adding more functions like now, we having

137
00:13:17,810 --> 00:13:21,080
to get information, we never remove that basket.

138
00:13:21,380 --> 00:13:27,260
So to do all this, we have to give it a tape so that we can use that switch inside to reduce our debt

139
00:13:27,260 --> 00:13:29,240
and then do the necessary function.

140
00:13:36,970 --> 00:13:43,480
So I'm studying this, and now I'll give the item item that I want to pull the item is the data that

141
00:13:43,480 --> 00:13:44,620
I want to push into the data.

142
00:13:46,960 --> 00:13:48,040
So this will be an object.

143
00:13:49,400 --> 00:13:50,430
A feisty IED.

144
00:13:53,120 --> 00:13:54,340
I imagine, Maj.

145
00:13:59,620 --> 00:14:00,880
Price will be Price.

146
00:14:02,590 --> 00:14:03,970
And then waiting with bated.

147
00:14:14,700 --> 00:14:15,010
So.

148
00:14:18,730 --> 00:14:21,160
So with this, we have done that to basket.

149
00:14:22,060 --> 00:14:22,210
OK.

150
00:14:22,390 --> 00:14:23,020
Your comment.

151
00:14:23,740 --> 00:14:29,380
So we have rolled the cord in product today, so we have the target of this to basket introduced or

152
00:14:29,380 --> 00:14:30,880
just so we knew this which gets you.

153
00:14:30,880 --> 00:14:36,370
You're here since I've said you once we set up the data layer we can using an agent or not.

154
00:14:36,610 --> 00:14:43,180
So basically, I'm importing the used tech instead value and then using making this having the children.

155
00:14:43,180 --> 00:14:48,580
I can access that data that has been set up so we can see how to do this and reduce it.

156
00:14:58,660 --> 00:15:02,820
As I said, we'll be providing a tape inside a broader digest.

157
00:15:02,860 --> 00:15:05,380
I will be accessing the switch at that type.

158
00:15:09,850 --> 00:15:11,500
So the first time the case will be.

159
00:15:12,690 --> 00:15:13,500
Add to that.

160
00:15:24,110 --> 00:15:28,460
And then we have to return an object like return, the total data that is present inside the data.

161
00:15:29,450 --> 00:15:32,270
So in this reducer, it's like.

162
00:15:34,120 --> 00:15:34,780
What we say.

163
00:15:37,540 --> 00:15:41,800
It is immutable, the state protest, whether they're due to function, is immutable.

164
00:15:42,070 --> 00:15:46,720
So in coming state, coming in as coming in as an argument is never directly changed.

165
00:15:47,110 --> 00:15:51,070
Their lives and function as a route has to render a completely new state object.

166
00:15:51,520 --> 00:15:55,180
So that's why we'll be returning the complete new object over it as it is immutable.

167
00:16:00,600 --> 00:16:06,180
So I'll be returning the previous state that this freight operator does that a lot, it does this that

168
00:16:06,330 --> 00:16:12,890
it will it will return the complete previous trade that we are using and then change the necessary.

169
00:16:12,900 --> 00:16:14,880
I want to do so in the basket.

170
00:16:14,890 --> 00:16:15,840
I will add the product.

171
00:16:19,890 --> 00:16:21,990
Initially, it will be a standard basket only.

172
00:16:24,090 --> 00:16:26,280
And then I landed with action items.

173
00:16:28,290 --> 00:16:34,740
So basically, the basket remains as it is, but I am adding an additional item to the basket, so basically

174
00:16:34,740 --> 00:16:37,830
I'm adding a product, a new product details for the data.

175
00:16:38,370 --> 00:16:39,870
So this is what I can does.

176
00:16:41,880 --> 00:16:45,060
OK, there is no need to have a simple an idea and then.

177
00:16:46,510 --> 00:16:48,030
You need to have a fallen order.

178
00:16:55,500 --> 00:16:58,620
So with this, we have completed that add to basket functionality.

179
00:17:00,670 --> 00:17:05,500
So when you click on add to basket how to like, as you can see, Audiard.

180
00:17:06,480 --> 00:17:13,170
When we pick on October 14, like make this number update dynamically, the items in the basket so we

181
00:17:13,170 --> 00:17:13,980
can see how to do that.

182
00:17:15,310 --> 00:17:17,320
So for that, we have to go to another gas.

183
00:17:18,470 --> 00:17:19,760
And in strategies.

184
00:17:23,210 --> 00:17:24,380
As you can see over here.

185
00:17:27,990 --> 00:17:33,960
Instead of sending a number like zero, I want to have the number of items that are present inside the

186
00:17:33,960 --> 00:17:37,200
data so far this, I have to import the necessary things.

187
00:17:46,350 --> 00:17:51,300
So long as I'm importing this, I'm making this other child components, OK, so that I can access information

188
00:17:51,300 --> 00:17:51,840
from the data.

189
00:18:01,510 --> 00:18:03,310
So long as I can import this, I can now.

190
00:18:05,870 --> 00:18:09,290
Let me make Rick again important, the data let on some.

191
00:18:13,210 --> 00:18:17,020
I'll be putting the basket and then the dispatch method.

192
00:18:22,330 --> 00:18:29,290
From your street value, that is basically I am restructuring the area that is didn't use jet importing,

193
00:18:29,290 --> 00:18:30,310
basket and dispatch.

194
00:18:30,970 --> 00:18:36,310
So in all of the simple thing here, if we want to like the basket, does product details.

195
00:18:36,640 --> 00:18:41,260
So if there are two products inside the basket, there will be two objects with product details.

196
00:18:41,740 --> 00:18:47,800
So if you want to get the number of items and then we just run the basket length so that so that is

197
00:18:47,800 --> 00:18:52,390
what we were doing here when simply said basket doubling since it is JavaScript.

198
00:18:52,570 --> 00:18:54,070
We have to use calibrated.

199
00:18:57,640 --> 00:18:57,940
Yeah.

200
00:18:58,360 --> 00:19:01,810
So with this, like with this, you can see the numbers getting affected.

201
00:19:06,670 --> 00:19:11,400
So there's another object is not a travel cannot trade property symbol to.

202
00:19:13,600 --> 00:19:16,480
So ensure that there's a found in fact, things were collapsed.

203
00:19:20,790 --> 00:19:27,840
So fixed, ever, so that gave me that instead provided ideas like there's a typo in of editions that

204
00:19:27,840 --> 00:19:34,500
I have type any in any physical state, so you have to change that initial step and then I'll change

205
00:19:34,500 --> 00:19:36,330
and reduce any aperture an initial step.

206
00:19:37,020 --> 00:19:39,890
So not like as I said before.

207
00:19:40,290 --> 00:19:46,650
Once we set up the data layer, we can use that data from the data layer from any component.

208
00:19:47,010 --> 00:19:53,260
So basically, we have to set up parent level data architecture from the parent level, all the components

209
00:19:53,280 --> 00:19:56,190
and what is a parent component parent component, this app.

210
00:19:56,580 --> 00:20:03,540
So once we said that Burgess with this data layer, then we can access everything from that children.

211
00:20:03,570 --> 00:20:03,840
OK.

212
00:20:04,290 --> 00:20:09,120
So that is what I and I will be doing not go to in our Jess and add these lines of code.

213
00:20:09,360 --> 00:20:13,040
Add these two lines of everything, but reduce an initial state from it.

214
00:20:13,290 --> 00:20:20,280
State provided that some state provider and insert dodges include these three lines of code like we

215
00:20:20,280 --> 00:20:20,410
have.

216
00:20:20,450 --> 00:20:24,180
We are setting up the state provider with the initial state this and then reduce it.

217
00:20:24,480 --> 00:20:28,740
So once we do this and you have to change the typos, go to the page.

218
00:20:29,790 --> 00:20:34,950
And then when you refresh, you can see like when you click on add to basket, it is getting updated.

219
00:20:36,950 --> 00:20:40,220
We're getting up there today, but when we go to check out, we can see the products.

220
00:20:40,610 --> 00:20:45,920
So now what we have to do is that we have to bring the product data from the data layer and also the

221
00:20:45,920 --> 00:20:50,420
data for amount and then the number of items in the data that we see in the next.

222
00:20:50,850 --> 00:20:51,200
We do.
