WEBVTT

1
00:00:00.160 --> 00:00:03.759
<v Speaker 1>Welcome to the deep dive, where we slice through information

2
00:00:03.839 --> 00:00:06.759
<v Speaker 1>overload to bring you the most important insights from your sources.

3
00:00:07.040 --> 00:00:10.320
<v Speaker 1>Today we're diving deep into reacts core features, drawing from

4
00:00:10.480 --> 00:00:13.880
<v Speaker 1>REACT key concepts and in depth guide to reacts core features.

5
00:00:14.199 --> 00:00:17.600
<v Speaker 1>Our mission to sort of demystify the art of building

6
00:00:17.679 --> 00:00:21.839
<v Speaker 1>dynamic user interfaces from the absolute fundamentals all the way

7
00:00:21.879 --> 00:00:25.640
<v Speaker 1>to cutting edge full stack capabilities. Whether you're a curious learner,

8
00:00:25.719 --> 00:00:28.920
<v Speaker 1>just starting out, or gearing up for a big technical meeting,

9
00:00:29.160 --> 00:00:34.799
<v Speaker 1>we're here to deliver those aha moments and clear actionable insights. Okay,

10
00:00:34.880 --> 00:00:37.320
<v Speaker 1>let's unpack this React as a huge topic. Imagine we're

11
00:00:37.320 --> 00:00:40.759
<v Speaker 1>trying to build some interactive websites starting fresh. What kind

12
00:00:40.759 --> 00:00:42.880
<v Speaker 1>of problems pop up if you try to use just

13
00:00:42.920 --> 00:00:45.079
<v Speaker 1>planal JavaScript? Why not stick with that?

14
00:00:45.200 --> 00:00:47.520
<v Speaker 2>Right? Well, the big challenge with planin JavaScript, especially for

15
00:00:47.560 --> 00:00:50.920
<v Speaker 2>complex UIs, is what we call it's imperative approach.

16
00:00:51.079 --> 00:00:52.719
<v Speaker 1>Imperative meaning you're telling.

17
00:00:52.479 --> 00:00:55.280
<v Speaker 2>The computer every single step to take. Yeah, like construction

18
00:00:55.359 --> 00:00:58.000
<v Speaker 2>after instruction, detailing exactly how to change the UI.

19
00:00:58.159 --> 00:01:02.039
<v Speaker 1>Okay, micromanaging the brain pretty much, and even for fairly

20
00:01:02.079 --> 00:01:03.520
<v Speaker 1>simple things, this can balloon.

21
00:01:03.759 --> 00:01:06.239
<v Speaker 2>You might hit it over underlines the code, and maybe

22
00:01:06.280 --> 00:01:09.560
<v Speaker 2>three quarters of that is just fiddling directly with the dom,

23
00:01:09.840 --> 00:01:13.560
<v Speaker 2>managing its state, all that boilerplate stuff. So naturally this

24
00:01:13.680 --> 00:01:17.280
<v Speaker 2>makes Vanilla JS pretty error prone and honestly just a

25
00:01:17.359 --> 00:01:19.920
<v Speaker 2>huge time sink. It's like being a puppeteer, you know,

26
00:01:20.280 --> 00:01:21.439
<v Speaker 2>pulling every single string.

27
00:01:22.079 --> 00:01:25.680
<v Speaker 1>Yeah, that puppeteer analogy really clicks. Okay, So if that's

28
00:01:25.680 --> 00:01:29.159
<v Speaker 1>the old how what reacts? What what's the philosophy shift?

29
00:01:29.640 --> 00:01:33.640
<v Speaker 2>The shift with React is moving from puppeteer to architect.

30
00:01:33.760 --> 00:01:36.200
<v Speaker 2>Instead of telling the browser how to move every pixel,

31
00:01:36.280 --> 00:01:38.920
<v Speaker 2>you just declare the final blueprint. You focus on the

32
00:01:38.959 --> 00:01:41.120
<v Speaker 2>big picture, the desired end state.

33
00:01:41.480 --> 00:01:41.879
<v Speaker 1>Ah.

34
00:01:42.079 --> 00:01:43.840
<v Speaker 2>So like if a button is clicks, you just tell

35
00:01:43.840 --> 00:01:46.239
<v Speaker 2>React okay, the tech should now be this, and React

36
00:01:46.239 --> 00:01:50.599
<v Speaker 2>figures out the how efficiently it keeps the paragraph updated automatically, so.

37
00:01:50.599 --> 00:01:53.079
<v Speaker 1>It handles the translation exactly.

38
00:01:52.959 --> 00:01:56.480
<v Speaker 2>You describe your ideal UI. React handles the MESSI dom stuff.

39
00:01:56.840 --> 00:01:59.359
<v Speaker 2>It frees you up to focus on your actual business logic,

40
00:01:59.359 --> 00:02:01.680
<v Speaker 2>which is I mean a massive productivity boost.

41
00:02:01.879 --> 00:02:05.280
<v Speaker 1>So for US developers it means letting React handle those

42
00:02:05.439 --> 00:02:09.879
<v Speaker 1>low level dawn interactions. That sounds like a relief. How

43
00:02:09.879 --> 00:02:13.080
<v Speaker 1>do we actually get started. Set up a project good question.

44
00:02:13.560 --> 00:02:16.080
<v Speaker 2>To get going, You typically use a tool like vite.

45
00:02:16.240 --> 00:02:19.039
<v Speaker 2>You run NPM create vite at latest my app in

46
00:02:19.080 --> 00:02:20.960
<v Speaker 2>your terminal than NPM.

47
00:02:20.680 --> 00:02:24.639
<v Speaker 1>Installed Fight Why fyte specifically for learning, It's often recommended

48
00:02:24.680 --> 00:02:26.240
<v Speaker 1>because it's lightweight, super fast.

49
00:02:26.680 --> 00:02:29.960
<v Speaker 2>Frameworks like next dot gs are powerful, absolutely, but they

50
00:02:30.000 --> 00:02:32.240
<v Speaker 2>add their own concepts, their own syntax, which can be

51
00:02:32.280 --> 00:02:33.520
<v Speaker 2>a bit overwhelming.

52
00:02:33.560 --> 00:02:36.520
<v Speaker 1>Right at the start, makes sense, keep it simple initially, right, and.

53
00:02:36.439 --> 00:02:38.719
<v Speaker 2>In that new project, you'll see files like app dot

54
00:02:38.800 --> 00:02:42.319
<v Speaker 2>jsx and main dojsx. That dot jsx just tells you

55
00:02:42.560 --> 00:02:46.919
<v Speaker 2>these files mixed JavaScript with that HTML like syntax called JSX.

56
00:02:47.039 --> 00:02:50.360
<v Speaker 1>Got it JSX, okay, project setup. Now inside the code.

57
00:02:50.360 --> 00:02:52.879
<v Speaker 1>React apps are built with components. What makes them so

58
00:02:53.159 --> 00:02:55.479
<v Speaker 1>well fundamental components.

59
00:02:54.960 --> 00:02:57.960
<v Speaker 2>Are basically reacts, reusable building blocks. Think of them like

60
00:02:58.000 --> 00:03:02.039
<v Speaker 2>specialized Lego bricks. Okay, its own javascrip logic. Often it's

61
00:03:02.080 --> 00:03:05.840
<v Speaker 2>CSS styling too, and it's JSX markup. All self contained.

62
00:03:06.479 --> 00:03:10.080
<v Speaker 2>This makes your code way more manageable, promotes reuse, and how.

63
00:03:09.960 --> 00:03:11.479
<v Speaker 1>Does the browser actually see these?

64
00:03:11.599 --> 00:03:13.840
<v Speaker 2>And that main dot JSX file. There's a bit of

65
00:03:13.879 --> 00:03:18.319
<v Speaker 2>code using reactums, specifically root dot render that's the match

66
00:03:18.360 --> 00:03:21.319
<v Speaker 2>cup part. It takes your JSX components and translates them

67
00:03:21.319 --> 00:03:24.039
<v Speaker 2>into the actual dom instructions the browser understands.

68
00:03:24.120 --> 00:03:26.840
<v Speaker 1>So the index dot html file is just empty much

69
00:03:26.960 --> 00:03:27.360
<v Speaker 1>just a shell.

70
00:03:27.560 --> 00:03:30.719
<v Speaker 2>Yeah, React fills it all in Oh and a neat detail.

71
00:03:31.159 --> 00:03:34.159
<v Speaker 2>Custom components they always start with an upper case letter

72
00:03:34.879 --> 00:03:37.439
<v Speaker 2>pascal case like submit button.

73
00:03:37.639 --> 00:03:38.199
<v Speaker 1>Why is that?

74
00:03:38.599 --> 00:03:41.039
<v Speaker 2>React needs it to tell your custom components apart from

75
00:03:41.080 --> 00:03:44.680
<v Speaker 2>standard HTML tags like div or p when it parses

76
00:03:44.719 --> 00:03:45.800
<v Speaker 2>the JSX ah.

77
00:03:45.800 --> 00:03:48.520
<v Speaker 1>Okay, good tip. And how do you decide what should

78
00:03:48.560 --> 00:03:49.360
<v Speaker 1>be a component?

79
00:03:49.560 --> 00:03:51.719
<v Speaker 2>A good rule of thumb is to think about your data.

80
00:03:51.879 --> 00:03:54.639
<v Speaker 2>Try to create a separate component for every distinct thing

81
00:03:54.719 --> 00:03:57.520
<v Speaker 2>or data entity you can identify, like an individual to

82
00:03:57.599 --> 00:03:59.879
<v Speaker 2>do item in a list. That's a component the list

83
00:04:00.639 --> 00:04:01.360
<v Speaker 2>another component?

84
00:04:01.439 --> 00:04:04.319
<v Speaker 1>Okay, components is building blocks? Great for structure, but how

85
00:04:04.360 --> 00:04:06.800
<v Speaker 1>do we make them? You know dynamics, so they aren't

86
00:04:06.800 --> 00:04:09.680
<v Speaker 1>all identical? How do we pass in different information?

87
00:04:10.120 --> 00:04:13.120
<v Speaker 2>Right? Static blocks aren't very useful. That's where props come in.

88
00:04:13.520 --> 00:04:17.079
<v Speaker 2>Props short for properties, are how you can figure your components.

89
00:04:17.319 --> 00:04:19.639
<v Speaker 2>You pass data down into them, How you pass them

90
00:04:19.920 --> 00:04:22.240
<v Speaker 2>You can pass them like attributes in htmail. Right on

91
00:04:22.319 --> 00:04:25.600
<v Speaker 2>the component tag or even as children between the opening

92
00:04:25.639 --> 00:04:30.120
<v Speaker 2>and closing tags. React automatically bundles these into a props

93
00:04:30.120 --> 00:04:32.439
<v Speaker 2>object that gets passed into your component function.

94
00:04:32.680 --> 00:04:36.000
<v Speaker 1>So inside the component I just use propstock whatever you can.

95
00:04:36.199 --> 00:04:39.680
<v Speaker 2>Yeah, like props dot title, But often developers use a

96
00:04:39.720 --> 00:04:43.839
<v Speaker 2>technique called destructuring right in the function parameters structure. It's

97
00:04:43.839 --> 00:04:46.920
<v Speaker 2>like unpacking the props object immediately. So instead of props

98
00:04:46.959 --> 00:04:51.160
<v Speaker 2>dot title, you just have title. Makes the function definition cleaner,

99
00:04:51.279 --> 00:04:55.199
<v Speaker 2>like function product, title, price. You see exactly what that

100
00:04:55.199 --> 00:04:56.079
<v Speaker 2>component expects.

101
00:04:56.360 --> 00:04:58.000
<v Speaker 1>Let's typing definitely.

102
00:04:58.120 --> 00:05:01.120
<v Speaker 2>Yeah, And there's also this spread up operator. If you

103
00:05:01.160 --> 00:05:03.879
<v Speaker 2>have a JavaScript object with lots of settings, you can

104
00:05:04.000 --> 00:05:06.839
<v Speaker 2>use dot can fee and your JSX to pass all

105
00:05:06.879 --> 00:05:10.480
<v Speaker 2>those object properties as individual props. Really handy for rapper components.

106
00:05:10.480 --> 00:05:13.120
<v Speaker 1>Okay, props seem powerful, but you mentioned a challenge earlier,

107
00:05:13.399 --> 00:05:14.120
<v Speaker 1>prop drilling.

108
00:05:14.439 --> 00:05:18.319
<v Speaker 2>Ah, yes, prop drilling. It's well, it's a bit of

109
00:05:18.319 --> 00:05:19.199
<v Speaker 2>a pain point sometimes.

110
00:05:19.240 --> 00:05:20.079
<v Speaker 1>What is it exactly?

111
00:05:20.240 --> 00:05:22.639
<v Speaker 2>It's when you have to pass a prop down through

112
00:05:22.720 --> 00:05:26.040
<v Speaker 2>multiple layers of nested components, even if the components in

113
00:05:26.079 --> 00:05:28.839
<v Speaker 2>the middle don't actually use that prop themselves, they just

114
00:05:28.879 --> 00:05:30.279
<v Speaker 2>act as carriers.

115
00:05:30.000 --> 00:05:31.839
<v Speaker 1>Like passing a note in class.

116
00:05:31.839 --> 00:05:34.160
<v Speaker 2>Exactly like that. The components in the middle just passed

117
00:05:34.199 --> 00:05:36.480
<v Speaker 2>along until it reaches the component way down the chain

118
00:05:36.639 --> 00:05:38.040
<v Speaker 2>that actually needs the data.

119
00:05:38.079 --> 00:05:39.279
<v Speaker 1>And why is that bad?

120
00:05:39.639 --> 00:05:43.439
<v Speaker 2>It makes the code less reusable, adds clutter makes refactoring harder.

121
00:05:44.079 --> 00:05:46.959
<v Speaker 2>If you decide to change how data flows, you might

122
00:05:46.959 --> 00:05:50.040
<v Speaker 2>have to edit files for components that weren't even directly involve.

123
00:05:50.639 --> 00:05:53.959
<v Speaker 2>It often suggests your state might be better managed elsewhere.

124
00:05:54.000 --> 00:05:57.519
<v Speaker 1>Hmm, okay, avoid the note passing if possible, so props

125
00:05:57.519 --> 00:06:01.879
<v Speaker 1>handle configuration. But how do we make UIs actually react

126
00:06:01.959 --> 00:06:04.680
<v Speaker 1>to things the user does clicks typing?

127
00:06:05.240 --> 00:06:08.920
<v Speaker 2>Excellent question. This is where state becomes crucial. State is

128
00:06:08.959 --> 00:06:13.199
<v Speaker 2>managed primarily using another fundamental React tool, the U state

129
00:06:13.399 --> 00:06:14.360
<v Speaker 2>hook A hook.

130
00:06:14.600 --> 00:06:14.759
<v Speaker 1>Yeah.

131
00:06:14.800 --> 00:06:18.120
<v Speaker 2>Hooks are special functions that let you hook into React features.

132
00:06:18.439 --> 00:06:20.160
<v Speaker 2>U state is the main one for adding state to

133
00:06:20.199 --> 00:06:21.240
<v Speaker 2>functional components.

134
00:06:21.480 --> 00:06:24.240
<v Speaker 1>And what is state in this context?

135
00:06:24.519 --> 00:06:27.680
<v Speaker 2>Think of state as any data within a component that,

136
00:06:27.959 --> 00:06:31.759
<v Speaker 2>when it changes, should cause React to re render that

137
00:06:31.800 --> 00:06:35.480
<v Speaker 2>component and update the UI. It's the memory of the component.

138
00:06:35.600 --> 00:06:37.600
<v Speaker 1>Okay, so how does you state work?

139
00:06:38.040 --> 00:06:41.199
<v Speaker 2>When you call U state you usually pass an initial value.

140
00:06:41.319 --> 00:06:44.600
<v Speaker 2>It then returns in array with exactly two things. First,

141
00:06:45.040 --> 00:06:48.519
<v Speaker 2>the current state value itself, and second a special function

142
00:06:48.560 --> 00:06:50.000
<v Speaker 2>you use to update that value.

143
00:06:50.199 --> 00:06:53.199
<v Speaker 1>So a value and a function to change it precisely.

144
00:06:53.480 --> 00:06:57.480
<v Speaker 2>And here's the key react nose to reevaluate or rerun

145
00:06:57.600 --> 00:07:01.319
<v Speaker 2>your component function only when that state updating function gets called.

146
00:07:01.519 --> 00:07:03.279
<v Speaker 2>That's the trigger for UI updates.

147
00:07:03.360 --> 00:07:05.360
<v Speaker 1>What if I have multiple pieces of data that need

148
00:07:05.399 --> 00:07:06.199
<v Speaker 1>to change.

149
00:07:05.920 --> 00:07:08.279
<v Speaker 2>Good point, you have options. You can call U state

150
00:07:08.360 --> 00:07:11.560
<v Speaker 2>multiple times for each piece of state, creating multiple state slices,

151
00:07:12.199 --> 00:07:14.759
<v Speaker 2>or you could manage a single larger state object with

152
00:07:14.879 --> 00:07:15.279
<v Speaker 2>U state.

153
00:07:15.519 --> 00:07:18.319
<v Speaker 1>Is one better than the other depends multiple use?

154
00:07:18.319 --> 00:07:21.360
<v Speaker 2>State calls are often simpler for unrelated pieces of data

155
00:07:21.439 --> 00:07:23.040
<v Speaker 2>if you use a single object, though, you have to

156
00:07:23.040 --> 00:07:25.480
<v Speaker 2>be careful when updating. When you call the state updating

157
00:07:25.560 --> 00:07:29.000
<v Speaker 2>function with a new object, it completely replaces the old one,

158
00:07:29.279 --> 00:07:31.399
<v Speaker 2>so you need to make sure your new object includes

159
00:07:31.439 --> 00:07:34.879
<v Speaker 2>all the properties, even the ones that didn't change. Usually

160
00:07:34.920 --> 00:07:37.800
<v Speaker 2>you use the spread operator to copy the old state first.

161
00:07:37.959 --> 00:07:41.240
<v Speaker 1>Ah okay, got to remember to copy the old stuck.

162
00:07:41.079 --> 00:07:44.800
<v Speaker 2>Exactly And another best practice. If your new state depends

163
00:07:44.839 --> 00:07:48.839
<v Speaker 2>on the previous state value like incrementing a counter, you

164
00:07:48.839 --> 00:07:51.680
<v Speaker 2>should pass a function to the state setter like set

165
00:07:51.720 --> 00:07:55.079
<v Speaker 2>counterpreve counterpost count plus one. This ensures you're working with

166
00:07:55.120 --> 00:07:57.839
<v Speaker 2>the latest value, especially if updates happen quickly.

167
00:07:58.000 --> 00:08:00.920
<v Speaker 1>Got it? Use the function form for updates based on

168
00:08:01.000 --> 00:08:03.759
<v Speaker 1>previous state. What about calculating things from state?

169
00:08:04.240 --> 00:08:06.519
<v Speaker 2>You can just derive values. If you have user input

170
00:08:06.639 --> 00:08:09.240
<v Speaker 2>in state, you can calculate its length directly in your

171
00:08:09.240 --> 00:08:13.120
<v Speaker 2>component cont snumb chars user input dot length. No need

172
00:08:13.160 --> 00:08:15.279
<v Speaker 2>for separate state for that derived value.

173
00:08:15.439 --> 00:08:18.800
<v Speaker 1>Okay, And what if multiple components need the same state,

174
00:08:19.360 --> 00:08:21.240
<v Speaker 1>like that prop drilling problem.

175
00:08:21.319 --> 00:08:23.399
<v Speaker 2>That's where the pattern of lifting state up comes in.

176
00:08:23.720 --> 00:08:26.480
<v Speaker 2>You find the closest common ancestor component of all the

177
00:08:26.480 --> 00:08:29.480
<v Speaker 2>components that need the state, and you manage the state there.

178
00:08:29.680 --> 00:08:32.799
<v Speaker 1>So the parent component holds the state right, and.

179
00:08:32.759 --> 00:08:35.440
<v Speaker 2>Then it passes the state value down as props and

180
00:08:35.519 --> 00:08:38.840
<v Speaker 2>passes the state updating function down as props too, so

181
00:08:38.919 --> 00:08:42.039
<v Speaker 2>the child components can still read and update the shared state.

182
00:08:42.440 --> 00:08:43.679
<v Speaker 2>It centralizes control.

183
00:08:44.000 --> 00:08:48.360
<v Speaker 1>Lifting state up makes sense. Okay, we have components props state.

184
00:08:48.759 --> 00:08:52.919
<v Speaker 1>Now how do we handle dynamic displays showing or hiding things,

185
00:08:53.200 --> 00:08:54.200
<v Speaker 1>rendering lists?

186
00:08:54.360 --> 00:08:57.879
<v Speaker 2>Yeah, very common. Need for conditional content like showing an

187
00:08:57.919 --> 00:09:00.000
<v Speaker 2>error message only when there's an error or a life

188
00:09:00.000 --> 00:09:02.360
<v Speaker 2>oding spinner. You can just use standard JavaScript logic right

189
00:09:02.399 --> 00:09:04.039
<v Speaker 2>inside your JSX.

190
00:09:03.559 --> 00:09:04.879
<v Speaker 1>Like if statements yep.

191
00:09:04.960 --> 00:09:08.519
<v Speaker 2>If statements work fine outside the return inside JSX. Ternary

192
00:09:08.600 --> 00:09:12.200
<v Speaker 2>expressions conditioning JSX one true, JSEX one false are super common,

193
00:09:12.799 --> 00:09:15.879
<v Speaker 2>or the logical A and D operator conditioned JSX one true.

194
00:09:15.919 --> 00:09:16.200
<v Speaker 1>Okay.

195
00:09:16.440 --> 00:09:19.440
<v Speaker 2>You can even store ENTIREJX structures and variables and render

196
00:09:19.480 --> 00:09:22.320
<v Speaker 2>them conditionally, or even change the HTML tag itself based

197
00:09:22.360 --> 00:09:24.720
<v Speaker 2>on a prop, like rendering a button or a tag

198
00:09:24.840 --> 00:09:26.080
<v Speaker 2>dynamically flexible.

199
00:09:26.120 --> 00:09:28.519
<v Speaker 1>What about lists of data like an array of items?

200
00:09:28.879 --> 00:09:33.000
<v Speaker 2>For lists, you'll almost always use the JavaScript dot map method.

201
00:09:33.320 --> 00:09:35.840
<v Speaker 2>You take your array of data, map over it, and

202
00:09:35.919 --> 00:09:39.360
<v Speaker 2>return a JSX element for each item. Simple enough, but

203
00:09:40.600 --> 00:09:44.120
<v Speaker 2>there's a very common warning. You'll hit React complaining about

204
00:09:44.159 --> 00:09:44.919
<v Speaker 2>missing keys.

205
00:09:45.159 --> 00:09:46.440
<v Speaker 1>Keys. What are those?

206
00:09:46.600 --> 00:09:49.720
<v Speaker 2>Keys? Are special unique identifiers you need to add as

207
00:09:49.720 --> 00:09:52.279
<v Speaker 2>a prop to each element you render inside a list

208
00:09:52.320 --> 00:09:54.440
<v Speaker 2>map like like key, item, dot id.

209
00:09:54.639 --> 00:09:55.840
<v Speaker 1>Why does React need them?

210
00:09:56.039 --> 00:09:58.919
<v Speaker 2>They help React identify which items in the list have changed,

211
00:09:59.039 --> 00:10:02.559
<v Speaker 2>been added, or removed. Without keys, React might have to

212
00:10:02.600 --> 00:10:05.720
<v Speaker 2>re render the entire list unnecessarily. With keys, it can

213
00:10:05.759 --> 00:10:09.279
<v Speaker 2>be much smarter even just rearranging existing dom elements. If

214
00:10:09.279 --> 00:10:12.639
<v Speaker 2>the order changes. It's a performance optimization.

215
00:10:12.159 --> 00:10:14.120
<v Speaker 1>And the key has to be unique.

216
00:10:13.799 --> 00:10:16.720
<v Speaker 2>Unique among good siblings in that list. Yes, yeah, and stable.

217
00:10:16.759 --> 00:10:19.320
<v Speaker 2>It shouldn't change between renders for the same item. That's

218
00:10:19.320 --> 00:10:21.320
<v Speaker 2>why using the array index is a key is often

219
00:10:21.360 --> 00:10:23.759
<v Speaker 2>a bad idea, especially if the list can be reordered

220
00:10:24.000 --> 00:10:27.120
<v Speaker 2>or items removed from the middle. The index doesn't stick

221
00:10:27.159 --> 00:10:29.519
<v Speaker 2>with the data item. Use a unique id from your

222
00:10:29.600 --> 00:10:31.279
<v Speaker 2>data if possible.

223
00:10:31.080 --> 00:10:35.840
<v Speaker 1>Got it? Use stable unique IDs for keys. And you

224
00:10:35.840 --> 00:10:39.080
<v Speaker 1>mentioned immutability before with state objects, does that apply to

225
00:10:39.159 --> 00:10:40.360
<v Speaker 1>a rays in the state too?

226
00:10:40.519 --> 00:10:42.519
<v Speaker 2>Absolutely? If you have an array in state and you

227
00:10:42.559 --> 00:10:45.840
<v Speaker 2>want to add an item, you must not use methods

228
00:10:45.879 --> 00:10:48.960
<v Speaker 2>like dot push that modify the original array. Why not

229
00:10:49.240 --> 00:10:52.559
<v Speaker 2>because React to text changes by comparing objector ray references.

230
00:10:52.759 --> 00:10:55.279
<v Speaker 2>If the reference hasn't changed because you modified it in place,

231
00:10:55.559 --> 00:10:57.600
<v Speaker 2>React won't see the change and won't re render.

232
00:10:57.720 --> 00:10:58.440
<v Speaker 1>So what should I do?

233
00:10:58.600 --> 00:11:00.840
<v Speaker 2>You need to create a new array. Use methods like

234
00:11:00.879 --> 00:11:04.159
<v Speaker 2>concat or more commonly, the spread operators at my array

235
00:11:04.240 --> 00:11:06.600
<v Speaker 2>dot old array new item. This creates a brand new

236
00:11:06.679 --> 00:11:09.519
<v Speaker 2>array reference, signaling the change to React.

237
00:11:09.639 --> 00:11:13.159
<v Speaker 1>Always immutable updates okay, immutable updates for objects and a

238
00:11:13.240 --> 00:11:16.480
<v Speaker 1>raised and state crucial now styling. How do we make

239
00:11:16.519 --> 00:11:19.960
<v Speaker 1>our components look good without CSS rules bleeding everywhere?

240
00:11:20.080 --> 00:11:22.600
<v Speaker 2>Styling? Right, you can just in court standard CSS files

241
00:11:22.679 --> 00:11:25.320
<v Speaker 2>import a component on CSS. But like you said, those

242
00:11:25.320 --> 00:11:28.519
<v Speaker 2>styles are global by default, easy to get accidental clashes,

243
00:11:28.639 --> 00:11:29.919
<v Speaker 2>especially in larger apps.

244
00:11:30.000 --> 00:11:31.159
<v Speaker 1>So what are the alternatives?

245
00:11:31.279 --> 00:11:33.919
<v Speaker 2>You can use inline styles in JSX you use the

246
00:11:33.919 --> 00:11:37.720
<v Speaker 2>style prop, but it expects a JavaScript object, not a string,

247
00:11:38.080 --> 00:11:42.639
<v Speaker 2>so it looks like style color red, padding top tenpx.

248
00:11:42.759 --> 00:11:44.639
<v Speaker 2>Notice the cambl case for CSS.

249
00:11:44.279 --> 00:11:47.840
<v Speaker 1>Properties inline styles. Okay, what about CSS classes?

250
00:11:47.960 --> 00:11:50.519
<v Speaker 2>The CSS classes you use the class name prop, not

251
00:11:50.679 --> 00:11:53.759
<v Speaker 2>class because class is a reserved word in JavaScript.

252
00:11:53.960 --> 00:11:55.759
<v Speaker 1>Ah, class name, got it, And you.

253
00:11:55.720 --> 00:11:58.399
<v Speaker 2>Can set class name dynamically based on state or props,

254
00:11:58.440 --> 00:12:00.480
<v Speaker 2>which is really useful for conditionals.

255
00:12:00.519 --> 00:12:03.559
<v Speaker 1>But that still doesn't solve the global clash problem if

256
00:12:03.559 --> 00:12:05.840
<v Speaker 1>we import CSS files right correct?

257
00:12:06.120 --> 00:12:08.879
<v Speaker 2>For that, CSS modules are a great solution. You name

258
00:12:08.919 --> 00:12:12.039
<v Speaker 2>your CSS file like my component dot module dot css.

259
00:12:12.360 --> 00:12:15.480
<v Speaker 2>When you import it, the build process automatically transforms your

260
00:12:15.480 --> 00:12:19.240
<v Speaker 2>class names into unique strings, effectively scoping them to that component.

261
00:12:19.399 --> 00:12:22.120
<v Speaker 1>So title in one component won't clash with dot title

262
00:12:22.159 --> 00:12:22.600
<v Speaker 1>in another.

263
00:12:22.879 --> 00:12:25.480
<v Speaker 2>Exactly, it becomes something like my component title A three

264
00:12:25.519 --> 00:12:29.360
<v Speaker 2>to seven B prevents clashes entirely. Other popular options include

265
00:12:29.480 --> 00:12:33.039
<v Speaker 2>CSS and JS libraries like style components, which let you

266
00:12:33.080 --> 00:12:36.960
<v Speaker 2>write actual CSS inside your JavaScript files, often using tag

267
00:12:37.000 --> 00:12:41.000
<v Speaker 2>template literals, and utility first libraries like Tail and thess

268
00:12:41.039 --> 00:12:44.759
<v Speaker 2>are also very popular, giving you lots of small, reusable classes.

269
00:12:44.399 --> 00:12:47.480
<v Speaker 1>Lots of options there. Okay, what if? What if I

270
00:12:47.559 --> 00:12:50.559
<v Speaker 1>really need to directly touch a DOM element, like to

271
00:12:50.639 --> 00:12:53.879
<v Speaker 1>focus an input field or measure its size. Escape reacts

272
00:12:53.879 --> 00:12:54.720
<v Speaker 1>control for a moment.

273
00:12:54.840 --> 00:12:57.000
<v Speaker 2>Sometimes you do need that. That's where refs come in,

274
00:12:57.120 --> 00:13:00.240
<v Speaker 2>using the use ref another hook yep use ref lets

275
00:13:00.240 --> 00:13:02.440
<v Speaker 2>you create a reference, a sort of pointer to a

276
00:13:02.519 --> 00:13:06.159
<v Speaker 2>value that persists across renders. Commonly, you attach this ref

277
00:13:06.200 --> 00:13:08.559
<v Speaker 2>to a DOM element using the ref prop like input

278
00:13:08.639 --> 00:13:12.000
<v Speaker 2>ref my input ref, and then then inside your component logic,

279
00:13:12.279 --> 00:13:14.600
<v Speaker 2>my input ref dot current will hold the actual DOM

280
00:13:14.679 --> 00:13:17.039
<v Speaker 2>node and you can call methods on it like my

281
00:13:17.200 --> 00:13:18.919
<v Speaker 2>inputref dot current dot focus.

282
00:13:19.080 --> 00:13:22.840
<v Speaker 1>Does changing the ref cause a rerender like state No.

283
00:13:22.919 --> 00:13:27.240
<v Speaker 2>Crucially it doesn't. Updating a ref my input ref dot

284
00:13:27.279 --> 00:13:30.480
<v Speaker 2>current ocals some value does not trigger a component rerender.

285
00:13:30.720 --> 00:13:34.000
<v Speaker 2>That's the key difference from state use res for values

286
00:13:34.039 --> 00:13:36.279
<v Speaker 2>you need to track, but which don't directly affect the

287
00:13:36.360 --> 00:13:37.080
<v Speaker 2>visual output.

288
00:13:37.200 --> 00:13:41.919
<v Speaker 1>Okay. Refs for direct dom access or persistent values without rerenders.

289
00:13:42.080 --> 00:13:45.639
<v Speaker 2>And this leads to the idea of controlled versus uncontrolled components,

290
00:13:45.919 --> 00:13:46.840
<v Speaker 2>especially for.

291
00:13:46.639 --> 00:13:48.600
<v Speaker 1>Forms control versus uncontrolled.

292
00:13:48.639 --> 00:13:51.559
<v Speaker 2>A controlled input component has its value managed by React

293
00:13:51.600 --> 00:13:55.679
<v Speaker 2>state use state. Every keystroke updates the state, which updates

294
00:13:55.679 --> 00:13:59.000
<v Speaker 2>the input's value. Prop React is fully in control okay.

295
00:13:59.039 --> 00:14:01.639
<v Speaker 2>An uncontrolled input doesn't have its value tied to state.

296
00:14:02.000 --> 00:14:04.159
<v Speaker 2>You'd use a rapt to read its value only when needed,

297
00:14:04.240 --> 00:14:07.519
<v Speaker 2>maybe on form submission. React doesn't manage its value moment

298
00:14:07.519 --> 00:14:07.960
<v Speaker 2>to moment.

299
00:14:08.080 --> 00:14:09.039
<v Speaker 1>Which one should I use?

300
00:14:09.279 --> 00:14:12.519
<v Speaker 2>Generally prefer controlled components. It keeps React as the single

301
00:14:12.559 --> 00:14:16.320
<v Speaker 2>source of truth. Uncontrolled can be simpler for very basic forms,

302
00:14:16.600 --> 00:14:20.159
<v Speaker 2>but controlled gives you more power for validation, dynamic changes,

303
00:14:20.159 --> 00:14:20.559
<v Speaker 2>et cetera.

304
00:14:20.960 --> 00:14:26.879
<v Speaker 1>Got it, Prefer controlled? Now one more tricky layout thing, modals,

305
00:14:27.039 --> 00:14:30.519
<v Speaker 1>pop ups, tooltips, things that need to appear on top

306
00:14:30.519 --> 00:14:33.000
<v Speaker 1>but might be deep in the component tree. How does

307
00:14:33.039 --> 00:14:33.840
<v Speaker 1>React handle that?

308
00:14:34.039 --> 00:14:38.360
<v Speaker 2>Ah? Yes, the z index nightmare For that. React offers portals.

309
00:14:38.639 --> 00:14:41.080
<v Speaker 2>You use the create portal function from React.

310
00:14:40.759 --> 00:14:43.600
<v Speaker 1>Tom portals like teleporting UI.

311
00:14:43.759 --> 00:14:47.320
<v Speaker 2>Kind of create portal takes two arguments the JSX you

312
00:14:47.320 --> 00:14:50.000
<v Speaker 2>want to render like your modal component and a reference

313
00:14:50.000 --> 00:14:52.559
<v Speaker 2>to a domnode outside your component's current place in the

314
00:14:52.600 --> 00:14:54.559
<v Speaker 2>dom tree where you want to render it up inside

315
00:14:54.600 --> 00:14:57.440
<v Speaker 2>where typically you'd have an empty DIV somewhere near the

316
00:14:57.480 --> 00:15:00.799
<v Speaker 2>root of your index dot HTML like div ideo modal RUDDIV.

317
00:15:01.360 --> 00:15:04.080
<v Speaker 2>You tell the portal to render your modal inside that div.

318
00:15:04.360 --> 00:15:06.480
<v Speaker 1>So even if my button triggering the modal is nested

319
00:15:06.519 --> 00:15:07.240
<v Speaker 1>deep down.

320
00:15:07.200 --> 00:15:10.120
<v Speaker 2>Exactly, the modal renders visually in that top level DIV,

321
00:15:10.360 --> 00:15:13.679
<v Speaker 2>avoiding CSS decking context issues and making styling much easier.

322
00:15:14.000 --> 00:15:16.320
<v Speaker 2>But logically it still behaves like a child of the

323
00:15:16.360 --> 00:15:19.639
<v Speaker 2>component that created the portal, regarding event bubbling in context.

324
00:15:19.919 --> 00:15:23.559
<v Speaker 1>It's clever portals. Okay, that solves a common headache. Now

325
00:15:23.679 --> 00:15:28.559
<v Speaker 1>let's shift gears slightly. We've talked rendering state. What about

326
00:15:28.639 --> 00:15:33.240
<v Speaker 1>actions that happen besides rendering, like fetching data, setting timers,

327
00:15:33.320 --> 00:15:35.519
<v Speaker 1>interacting with browser APIs.

328
00:15:35.240 --> 00:15:37.480
<v Speaker 2>Right, Those are called side effects. There are actions or

329
00:15:37.519 --> 00:15:40.759
<v Speaker 2>processes that happen in addition to the main rendering process.

330
00:15:41.240 --> 00:15:45.039
<v Speaker 2>Sending HTTP requests, using local storage, setting up timers or

331
00:15:45.039 --> 00:15:47.480
<v Speaker 2>subscriptions all side effects.

332
00:15:47.120 --> 00:15:48.559
<v Speaker 1>And can they cause problems?

333
00:15:48.600 --> 00:15:51.799
<v Speaker 2>Oh? Definitely. A classic newbie mistake is putting a side

334
00:15:51.799 --> 00:15:54.919
<v Speaker 2>effect directly in the component body that also updates state.

335
00:15:55.639 --> 00:15:59.000
<v Speaker 2>If fetching data updates state and the component rerenders, it

336
00:15:59.080 --> 00:16:02.240
<v Speaker 2>might fetch data, get update state again, infinite loop.

337
00:16:02.480 --> 00:16:05.039
<v Speaker 1>Yikes. How do we avoid that with another hook?

338
00:16:05.320 --> 00:16:05.919
<v Speaker 2>That's effect.

339
00:16:06.120 --> 00:16:06.399
<v Speaker 1>Yeah.

340
00:16:06.519 --> 00:16:09.200
<v Speaker 2>Its whole purpose is to manage side effects safely within

341
00:16:09.320 --> 00:16:10.320
<v Speaker 2>functional components.

342
00:16:10.559 --> 00:16:12.039
<v Speaker 1>Okay, how does use effect work?

343
00:16:12.279 --> 00:16:14.399
<v Speaker 2>It takes a function, your effect function, containing the side

344
00:16:14.399 --> 00:16:19.080
<v Speaker 2>effect code, and crucially a second argument, a dependency's.

345
00:16:18.480 --> 00:16:19.720
<v Speaker 1>Array dependencies array.

346
00:16:19.840 --> 00:16:23.919
<v Speaker 2>Yes, this array tells React when to rerun your effect function.

347
00:16:24.320 --> 00:16:27.519
<v Speaker 2>If you provide an empty array, the effect runs only once,

348
00:16:27.919 --> 00:16:30.919
<v Speaker 2>right after the component mounts renders for the first time.

349
00:16:30.759 --> 00:16:34.279
<v Speaker 1>Only once useful for initial data fetching exactly.

350
00:16:34.679 --> 00:16:37.080
<v Speaker 2>If you list variables or props in the array, like

351
00:16:37.200 --> 00:16:40.000
<v Speaker 2>user id, the effect will run after the first render

352
00:16:40.159 --> 00:16:43.200
<v Speaker 2>and anytime the value of user ed changes between renders.

353
00:16:43.279 --> 00:16:47.120
<v Speaker 1>Ah, so it reruns only if specific dependencies change.

354
00:16:47.159 --> 00:16:50.320
<v Speaker 2>Precisely. If you don't provide the array at all, which

355
00:16:50.399 --> 00:16:53.840
<v Speaker 2>is generally discouraged, the effect runs after every render. That's

356
00:16:53.879 --> 00:16:55.759
<v Speaker 2>often how those infinite loops start.

357
00:16:55.960 --> 00:16:59.080
<v Speaker 1>Okay, so always provide the dependency array mpty for once

358
00:16:59.480 --> 00:17:01.679
<v Speaker 1>or list the values used inside the effect.

359
00:17:01.879 --> 00:17:06.319
<v Speaker 2>That's the golden rule. Add all values props, state variables

360
00:17:06.359 --> 00:17:09.039
<v Speaker 2>from the component scope that are used inside your effect

361
00:17:09.079 --> 00:17:10.599
<v Speaker 2>function to the dependency's rate.

362
00:17:10.599 --> 00:17:11.880
<v Speaker 1>All of them, any exceptions.

363
00:17:11.920 --> 00:17:14.880
<v Speaker 2>The main exception is state updating functions the second thing

364
00:17:14.920 --> 00:17:19.519
<v Speaker 2>returned by U state React guarantees these functions themselves never change,

365
00:17:19.640 --> 00:17:22.000
<v Speaker 2>so you don't need to list them as dependencies. Same

366
00:17:22.079 --> 00:17:24.640
<v Speaker 2>for built in APIs like fetch or refs.

367
00:17:24.799 --> 00:17:27.319
<v Speaker 1>Okay, what about cleaning up like clearing a timer?

368
00:17:27.640 --> 00:17:30.640
<v Speaker 2>Use effect candles that too. If your affect function returns

369
00:17:30.640 --> 00:17:34.279
<v Speaker 2>another function, React will run that return function as a

370
00:17:34.319 --> 00:17:35.039
<v Speaker 2>cleanup function.

371
00:17:35.319 --> 00:17:36.799
<v Speaker 1>When does it run the cleanup it.

372
00:17:36.799 --> 00:17:39.680
<v Speaker 2>Runs before the effect runs again if dependencies change, and

373
00:17:39.759 --> 00:17:43.039
<v Speaker 2>also when the component unmounts is removed from the UI.

374
00:17:43.319 --> 00:17:47.799
<v Speaker 2>Perfect for clearing timers, removing event listeners, unsubscribing from things.

375
00:17:48.079 --> 00:17:51.160
<v Speaker 1>Very useful. What if a dependency is a function to

376
00:17:51.200 --> 00:17:54.759
<v Speaker 1>find inside my component? Won't that cause the effect to

377
00:17:54.839 --> 00:17:55.599
<v Speaker 1>run too often?

378
00:17:55.640 --> 00:17:58.599
<v Speaker 2>Good catch. If you define a function inside your component,

379
00:17:58.920 --> 00:18:01.839
<v Speaker 2>it gets recreated on every render. If that function is

380
00:18:01.839 --> 00:18:04.599
<v Speaker 2>a dependency of use effect, the effect will run every time.

381
00:18:05.160 --> 00:18:06.279
<v Speaker 1>So how do we fix that?

382
00:18:06.720 --> 00:18:10.240
<v Speaker 2>We use another hook, use callback. You wrap your function

383
00:18:10.319 --> 00:18:14.319
<v Speaker 2>definition and use callback and provide its dependencies. Use callback

384
00:18:14.359 --> 00:18:16.880
<v Speaker 2>will then return a memoized version of your function, which

385
00:18:16.920 --> 00:18:19.000
<v Speaker 2>only changes if its dependencies change.

386
00:18:19.200 --> 00:18:23.640
<v Speaker 1>So use callback memois as functions preventing unnecessary effect runs exactly.

387
00:18:23.680 --> 00:18:25.799
<v Speaker 2>It works hand in hand with use effect in those cases.

388
00:18:25.960 --> 00:18:31.720
<v Speaker 1>Okay, effects cleanup dependencies. That covers side effects. What if

389
00:18:31.759 --> 00:18:35.640
<v Speaker 1>state management gets really complex, multiple related pieces of state

390
00:18:36.079 --> 00:18:37.480
<v Speaker 1>complex update logic.

391
00:18:37.640 --> 00:18:40.319
<v Speaker 2>When use state starts feeling cumbersome for a related state,

392
00:18:40.720 --> 00:18:44.200
<v Speaker 2>React offers an alternative, the use reducer hook.

393
00:18:44.519 --> 00:18:46.839
<v Speaker 1>Use reducer sounds like redux.

394
00:18:46.599 --> 00:18:49.759
<v Speaker 2>It's inspired by similar patterns. Yeah, it's better suited for

395
00:18:49.839 --> 00:18:53.680
<v Speaker 2>managing complex state logic. You define a reducer function separate

396
00:18:53.720 --> 00:18:56.240
<v Speaker 2>from your component. This function takes the current state and

397
00:18:56.279 --> 00:18:59.440
<v Speaker 2>an action object and returns the new state actions. Yeah.

398
00:18:59.480 --> 00:19:02.680
<v Speaker 2>Instead of calling a state center directly, you dispatch action

399
00:19:02.759 --> 00:19:07.759
<v Speaker 2>objects to your reducer like type increment payload. The reducer

400
00:19:07.799 --> 00:19:09.359
<v Speaker 2>handles the update logic based on.

401
00:19:09.319 --> 00:19:11.119
<v Speaker 1>The action type, So use reducer returns.

402
00:19:11.160 --> 00:19:13.400
<v Speaker 2>It returns the current state and that dispatch function. So

403
00:19:13.599 --> 00:19:17.839
<v Speaker 2>constate dispatch us reducer initial state. It helps centralize and

404
00:19:17.960 --> 00:19:19.759
<v Speaker 2>organize complex state transitions.

405
00:19:20.039 --> 00:19:23.839
<v Speaker 1>Okay, use reducer for complex state. Now what about reusing logic.

406
00:19:23.920 --> 00:19:26.119
<v Speaker 1>If I have some stateful logic, maybe involving state and

407
00:19:26.119 --> 00:19:28.720
<v Speaker 1>effects that I want to use in multiple components, perfect

408
00:19:28.759 --> 00:19:30.960
<v Speaker 1>use case for custom hooks. Custom hooks.

409
00:19:31.039 --> 00:19:34.000
<v Speaker 2>Yeah, these are just regular JavaScript functions, but their name

410
00:19:34.119 --> 00:19:37.200
<v Speaker 2>must start with use, like use fetch or use counter.

411
00:19:37.680 --> 00:19:40.480
<v Speaker 2>Inside a custom hook, you can call other React hooks

412
00:19:40.519 --> 00:19:43.160
<v Speaker 2>like use state, use effect, user ref, etc.

413
00:19:43.519 --> 00:19:46.000
<v Speaker 1>So it's like bundling up hook logic exactly.

414
00:19:46.160 --> 00:19:50.279
<v Speaker 2>You encapsulate stateful logic into a reusable function. Any component

415
00:19:50.319 --> 00:19:53.599
<v Speaker 2>can then call your custom hook like const data I

416
00:19:53.799 --> 00:19:55.480
<v Speaker 2>loading use fetch.

417
00:19:55.680 --> 00:19:59.359
<v Speaker 1>Does every component share the same state from the custom hook? No?

418
00:19:59.599 --> 00:20:02.119
<v Speaker 2>And this is key. Every component that calls your custom

419
00:20:02.160 --> 00:20:04.960
<v Speaker 2>hook gets its own independent instance of the state and

420
00:20:05.039 --> 00:20:09.240
<v Speaker 2>effects defined within that hook. It's reusable logic, but isolated

421
00:20:09.240 --> 00:20:10.559
<v Speaker 2>state per component instance.

422
00:20:10.799 --> 00:20:15.160
<v Speaker 1>Ah. That's powerful custom hooks for reusable stateful logic. Okay,

423
00:20:15.240 --> 00:20:18.519
<v Speaker 1>let's talk performance. We build these complex apps, how to

424
00:20:18.640 --> 00:20:20.559
<v Speaker 1>keep them fast? How does React help and what can

425
00:20:20.599 --> 00:20:20.799
<v Speaker 1>we do?

426
00:20:20.920 --> 00:20:24.400
<v Speaker 2>Performance is crucial? Definitely reacts. First big optimization is the

427
00:20:24.480 --> 00:20:25.640
<v Speaker 2>virtual dom we touched.

428
00:20:25.400 --> 00:20:27.000
<v Speaker 1>On earlier, right, the in memory copy.

429
00:20:27.200 --> 00:20:30.680
<v Speaker 2>Yeah, instead of hitting the real browser dom. For every

430
00:20:30.759 --> 00:20:34.279
<v Speaker 2>little change, which is slow, React builds up changes in

431
00:20:34.319 --> 00:20:38.119
<v Speaker 2>its fast in memory virtual dom. It then compares the

432
00:20:38.160 --> 00:20:39.559
<v Speaker 2>new virtual dom state with.

433
00:20:39.519 --> 00:20:42.119
<v Speaker 1>The previous one, finds the differences.

434
00:20:41.599 --> 00:20:44.799
<v Speaker 2>Right, It performs a diffing algorithm to find the minimal

435
00:20:44.839 --> 00:20:48.599
<v Speaker 2>set of changes needed. Then it applies only those changes

436
00:20:48.640 --> 00:20:52.519
<v Speaker 2>to the actual dom in one efficient batch. It minimizes

437
00:20:52.599 --> 00:20:54.079
<v Speaker 2>direct dom manipulation.

438
00:20:54.559 --> 00:20:56.960
<v Speaker 1>Okay, virtual dom diffing. What else?

439
00:20:57.160 --> 00:20:59.799
<v Speaker 2>State batching is another built in when if you call

440
00:20:59.839 --> 00:21:03.519
<v Speaker 2>set state multiple times in quick succession within the same

441
00:21:03.599 --> 00:21:06.759
<v Speaker 2>event handler or effect, React is smart enough to bash

442
00:21:06.799 --> 00:21:09.839
<v Speaker 2>those updates together into a single rerender cycle.

443
00:21:09.680 --> 00:21:13.160
<v Speaker 1>So it doesn't re render multiple times unnecessarily exactly.

444
00:21:13.319 --> 00:21:15.960
<v Speaker 2>It waits, collects all the state updates for that tick,

445
00:21:16.240 --> 00:21:19.279
<v Speaker 2>and then performs one single rerender reflecting all those changes.

446
00:21:19.640 --> 00:21:20.799
<v Speaker 2>Saves a lot of wasted work.

447
00:21:20.920 --> 00:21:23.960
<v Speaker 1>That's good, But what if a component itself rerenders even

448
00:21:24.000 --> 00:21:26.759
<v Speaker 1>if it's props didn't change just because it's parent re rendered.

449
00:21:26.920 --> 00:21:29.480
<v Speaker 2>That can happen, and it can be a performance bottleneck.

450
00:21:29.720 --> 00:21:33.599
<v Speaker 2>To prevent those unnecessary child component evaluations. React gives us

451
00:21:33.839 --> 00:21:37.279
<v Speaker 2>React dot memo. You wrap your entire component export with

452
00:21:37.440 --> 00:21:42.160
<v Speaker 2>memo like export default React dot memo my component. What

453
00:21:42.200 --> 00:21:45.359
<v Speaker 2>memo does is perform a shallow comparison of the component's

454
00:21:45.400 --> 00:21:49.880
<v Speaker 2>props between renders. If the props haven't changed, React skips

455
00:21:50.039 --> 00:21:52.759
<v Speaker 2>re rendering that component and its entire subtree.

456
00:21:52.920 --> 00:21:55.319
<v Speaker 1>So it stops the rerender cascade.

457
00:21:54.799 --> 00:21:58.599
<v Speaker 2>Precisely, but it's not free. Comparing props also takes time,

458
00:21:58.799 --> 00:22:00.799
<v Speaker 2>so you don't want to wrap everything in memo. Use

459
00:22:00.799 --> 00:22:04.000
<v Speaker 2>it strategically on components that are reasonably complex and are

460
00:22:04.119 --> 00:22:06.640
<v Speaker 2>likely to receive the same props, often even when the

461
00:22:06.680 --> 00:22:07.519
<v Speaker 2>parent rerenders.

462
00:22:07.640 --> 00:22:12.640
<v Speaker 1>Okay, memo for component rerenders. What about expensive calculations inside

463
00:22:12.680 --> 00:22:13.240
<v Speaker 1>a component.

464
00:22:13.440 --> 00:22:16.000
<v Speaker 2>For that, we have the use memo cook use memo

465
00:22:16.039 --> 00:22:19.599
<v Speaker 2>versus memo wraps a whole component. Use memo is used

466
00:22:19.599 --> 00:22:22.200
<v Speaker 2>inside a component to memoize the result of a specific

467
00:22:22.319 --> 00:22:25.400
<v Speaker 2>expensive calculation. You give use memo a function that does

468
00:22:25.440 --> 00:22:28.200
<v Speaker 2>the calculation and a dependency array just like use effect

469
00:22:28.359 --> 00:22:31.799
<v Speaker 2>ah dependency array again yep, use memo only reruns the

470
00:22:31.839 --> 00:22:35.359
<v Speaker 2>calculation function if one of its dependencies has changed. Otherwise

471
00:22:35.359 --> 00:22:38.160
<v Speaker 2>it returns the cash result from the previous render. Great

472
00:22:38.160 --> 00:22:41.000
<v Speaker 2>for complex computations, filtering large arrays, et cetera.

473
00:22:41.240 --> 00:22:43.920
<v Speaker 1>And use callback fits in here too, right, Use.

474
00:22:43.799 --> 00:22:47.680
<v Speaker 2>Callback, memoize as functions, use memo memois as values the

475
00:22:47.720 --> 00:22:51.759
<v Speaker 2>result of a function. Use callback often when passing functions

476
00:22:51.799 --> 00:22:55.440
<v Speaker 2>down as props to memoized components, so the prop function

477
00:22:55.480 --> 00:22:57.160
<v Speaker 2>itself doesn't change unnecessarily.

478
00:22:57.240 --> 00:23:01.480
<v Speaker 1>Okay, memo, use memo, use callback. Yeah, our optimization toolkit,

479
00:23:01.559 --> 00:23:02.079
<v Speaker 1>and what's.

480
00:23:01.920 --> 00:23:05.079
<v Speaker 2>Really exciting is the future. React nineteen is introducing an

481
00:23:05.119 --> 00:23:09.440
<v Speaker 2>experimental React compiler. The idea is that the compiler will

482
00:23:09.440 --> 00:23:13.160
<v Speaker 2>automatically analyze your code and insert memo, use memo, and

483
00:23:13.279 --> 00:23:16.279
<v Speaker 2>use callback where appropriate during the bill process.

484
00:23:16.400 --> 00:23:18.759
<v Speaker 1>WHOA, So React would optimize itself.

485
00:23:18.920 --> 00:23:21.920
<v Speaker 2>That's the goal. It could significantly reduce the need for

486
00:23:22.000 --> 00:23:26.200
<v Speaker 2>manual mammalization, which can be tricky to get right. Still experimental,

487
00:23:26.240 --> 00:23:27.119
<v Speaker 2>but very promising.

488
00:23:27.279 --> 00:23:30.200
<v Speaker 1>Very cool. Okay, that's runtime performance. What about the initial load?

489
00:23:30.559 --> 00:23:33.240
<v Speaker 1>Big JavaScript bundles can make that first page view slow.

490
00:23:33.359 --> 00:23:36.599
<v Speaker 2>Absolutely, initial load time is critical. The main technique here

491
00:23:36.640 --> 00:23:39.240
<v Speaker 2>is code splitting, often called lazy loading.

492
00:23:39.400 --> 00:23:40.039
<v Speaker 1>Lazy loading.

493
00:23:40.160 --> 00:23:42.759
<v Speaker 2>Yeah. Instead of bundling all your application code into one

494
00:23:43.160 --> 00:23:46.720
<v Speaker 2>giant JavaScript file that the user downloads up front, code

495
00:23:46.720 --> 00:23:49.480
<v Speaker 2>splitting lets you load parts of your code on demand,

496
00:23:50.039 --> 00:23:51.319
<v Speaker 2>only when they're actually needed.

497
00:23:51.519 --> 00:23:52.880
<v Speaker 1>How do you do that and React?

498
00:23:53.000 --> 00:23:56.400
<v Speaker 2>You use the React at lazy function combined with dynamic

499
00:23:56.440 --> 00:24:00.720
<v Speaker 2>imports synfacts. So constant my lazy component React dot lazist

500
00:24:00.759 --> 00:24:04.200
<v Speaker 2>my component. Then when you try to render my lazy component,

501
00:24:05.200 --> 00:24:07.960
<v Speaker 2>React won't have the code immediately. You need to wrap

502
00:24:08.000 --> 00:24:12.079
<v Speaker 2>it in a suspense component Suspense. Yes, Suspense takes a

503
00:24:12.079 --> 00:24:16.119
<v Speaker 2>mandatory fallback prop, which is some JSX to display while

504
00:24:16.160 --> 00:24:18.720
<v Speaker 2>the lazy component's code is being downloaded and loaded over

505
00:24:18.759 --> 00:24:21.640
<v Speaker 2>the network like suspense fallback dot loading dot div.

506
00:24:21.519 --> 00:24:23.960
<v Speaker 1>So the user sees a loading indicator instead of an

507
00:24:24.079 --> 00:24:25.680
<v Speaker 1>error or a blank space exactly.

508
00:24:25.759 --> 00:24:28.880
<v Speaker 2>It smoothed the experience. It reduces the initial bundle size,

509
00:24:29.000 --> 00:24:32.480
<v Speaker 2>making the first load faster, but adds more network requests

510
00:24:32.559 --> 00:24:33.960
<v Speaker 2>later when those components are.

511
00:24:33.880 --> 00:24:37.000
<v Speaker 1>Needed trade offs. As always, any tools for debugging performance

512
00:24:37.079 --> 00:24:37.799
<v Speaker 1>or other issues.

513
00:24:38.039 --> 00:24:41.559
<v Speaker 2>Definitely in development you should use the strict mode component.

514
00:24:41.960 --> 00:24:44.839
<v Speaker 2>Wrap your app in it, and React enables extra checks

515
00:24:44.839 --> 00:24:49.119
<v Speaker 2>and warnings for potential problems like identifying unsafe life cycle

516
00:24:49.200 --> 00:24:53.599
<v Speaker 2>methods or unexpected side effects. It doesn't affect the production build.

517
00:24:53.440 --> 00:24:55.359
<v Speaker 1>Trick mode for development checks and.

518
00:24:55.279 --> 00:24:59.000
<v Speaker 2>The React Developer Tools browser extension is absolutely essential. It

519
00:24:59.119 --> 00:25:02.039
<v Speaker 2>lets you inspect them, own a tree, view, props and state,

520
00:25:02.480 --> 00:25:05.920
<v Speaker 2>and critically, it has a profiler tap profiler. Yeah, you

521
00:25:05.920 --> 00:25:08.960
<v Speaker 2>can record interactions in your app and the profiler shows

522
00:25:08.960 --> 00:25:11.960
<v Speaker 2>you exactly which components rendered, why they rendered, and how

523
00:25:12.000 --> 00:25:15.880
<v Speaker 2>long they took invaluable for hunting down performance bottlenecks.

524
00:25:15.319 --> 00:25:16.720
<v Speaker 1>Reactive tools profiler.

525
00:25:16.839 --> 00:25:17.119
<v Speaker 2>Got it.

526
00:25:18.160 --> 00:25:21.160
<v Speaker 1>Okay, we've covered a ton about client side React, but

527
00:25:21.240 --> 00:25:24.799
<v Speaker 1>the landscape is shifting, right. How does React extend beyond

528
00:25:24.839 --> 00:25:26.759
<v Speaker 1>the browser into full stack territory?

529
00:25:26.839 --> 00:25:30.640
<v Speaker 2>Yeah, the lines are definitely blurring. Traditional client side rendering CSR,

530
00:25:30.720 --> 00:25:33.960
<v Speaker 2>where all the React code runs the browser has drawbacks. Well,

531
00:25:33.960 --> 00:25:36.759
<v Speaker 2>the initial HTML page sent from the server is often

532
00:25:36.799 --> 00:25:39.400
<v Speaker 2>just an empty shell with a JavaScript link. The user

533
00:25:39.400 --> 00:25:42.839
<v Speaker 2>sees nothing until the JS downloads, parses, and executes to

534
00:25:42.839 --> 00:25:46.039
<v Speaker 2>build the UI. This can feel slow and it's not

535
00:25:46.160 --> 00:25:50.440
<v Speaker 2>great for Search engine optimization SEO. Plus, if JS fails

536
00:25:50.519 --> 00:25:52.720
<v Speaker 2>or is disabled, the app is just broken.

537
00:25:52.960 --> 00:25:54.799
<v Speaker 1>Right. So the alternative is server.

538
00:25:54.720 --> 00:25:58.319
<v Speaker 2>Side rendering ASSR. With SSR, reaction components are actually rendered

539
00:25:58.319 --> 00:26:01.720
<v Speaker 2>into HTML on the server for the initial request. The

540
00:26:01.759 --> 00:26:05.039
<v Speaker 2>browser receives a fully populated HKML document.

541
00:26:04.720 --> 00:26:07.359
<v Speaker 1>So the user sees content immediately exactly much.

542
00:26:07.279 --> 00:26:10.839
<v Speaker 2>Faster perceived load time better for SEO. Then client side

543
00:26:10.880 --> 00:26:14.720
<v Speaker 2>jobscript hydrates the static HTM, attaching event listeners and making

544
00:26:14.759 --> 00:26:15.440
<v Speaker 2>it interactive.

545
00:26:15.599 --> 00:26:18.359
<v Speaker 1>How do you typically implement SSR with React?

546
00:26:18.519 --> 00:26:22.079
<v Speaker 2>Frameworks like nextjs are incredibly popular for this. Nextjs is

547
00:26:22.079 --> 00:26:25.039
<v Speaker 2>a full stack React framework that provides SSR, static side

548
00:26:25.039 --> 00:26:27.759
<v Speaker 2>generation and many other features essentially out of the box.

549
00:26:27.839 --> 00:26:29.960
<v Speaker 1>Next js. I hear that a lot. How does it work?

550
00:26:30.160 --> 00:26:33.640
<v Speaker 2>He uses file based writing. You create files and folders

551
00:26:33.680 --> 00:26:36.480
<v Speaker 2>inside an app directory in the latest versions, and the

552
00:26:36.519 --> 00:26:40.400
<v Speaker 2>file paths automatically become your application routes like app about

553
00:26:40.440 --> 00:26:43.960
<v Speaker 2>page dot js becomes the about route simple layout dot

554
00:26:44.000 --> 00:26:48.319
<v Speaker 2>js files define shared UI shells for different routes, and

555
00:26:48.400 --> 00:26:50.960
<v Speaker 2>you use a special link component from next link for

556
00:26:51.079 --> 00:26:54.799
<v Speaker 2>client side navigation between pages, which avoids full page reloads.

557
00:26:54.880 --> 00:26:58.119
<v Speaker 1>Okay, but if components are rendering on the server. Now,

558
00:26:58.200 --> 00:27:01.640
<v Speaker 1>what about components that need browsers or use hooks like

559
00:27:01.759 --> 00:27:02.799
<v Speaker 1>use state or use.

560
00:27:02.640 --> 00:27:05.880
<v Speaker 2>Effect ah excellent point. This is where a key next

561
00:27:05.920 --> 00:27:08.799
<v Speaker 2>dot chs and modern React concept comes in the use

562
00:27:08.880 --> 00:27:10.079
<v Speaker 2>client directive.

563
00:27:09.839 --> 00:27:11.160
<v Speaker 1>Use client by default.

564
00:27:11.319 --> 00:27:14.440
<v Speaker 2>Components in nextjs is app router are server components. We'll

565
00:27:14.440 --> 00:27:17.279
<v Speaker 2>get to those. If a component needs client side interactivity,

566
00:27:17.359 --> 00:27:20.640
<v Speaker 2>uses hooks, event handlers. Browser APIs. You must put the

567
00:27:20.640 --> 00:27:22.839
<v Speaker 2>string useed client at the very top of the file so.

568
00:27:22.759 --> 00:27:25.200
<v Speaker 1>That tells next dot js render this one in the browser.

569
00:27:25.480 --> 00:27:29.240
<v Speaker 2>Precisely it marks that component and its entire subtree as

570
00:27:29.279 --> 00:27:32.359
<v Speaker 2>client side components. Their code will be included in the

571
00:27:32.359 --> 00:27:35.839
<v Speaker 2>client JavaScript bundle. The goal is generally to push client

572
00:27:35.839 --> 00:27:38.640
<v Speaker 2>components as far down the tree as possible, keeping server

573
00:27:38.759 --> 00:27:41.119
<v Speaker 2>rendering for as much of the UI as you can,

574
00:27:41.440 --> 00:27:43.880
<v Speaker 2>to minimize the client bundle size.

575
00:27:44.079 --> 00:27:48.440
<v Speaker 1>Minimize client components. Got it? Okay, you mentioned server components,

576
00:27:48.519 --> 00:27:51.000
<v Speaker 1>and I've heard about server actions too. These sound like

577
00:27:51.000 --> 00:27:52.920
<v Speaker 1>the really cutting edge stuff. What's the deal?

578
00:27:53.599 --> 00:27:58.160
<v Speaker 2>They really are a major shift. React Server components rscs

579
00:27:59.039 --> 00:28:00.799
<v Speaker 2>are a new type of compon it designed to run

580
00:28:00.839 --> 00:28:01.960
<v Speaker 2>only on the server.

581
00:28:01.960 --> 00:28:04.519
<v Speaker 1>Only on the server, even after the initial load.

582
00:28:04.680 --> 00:28:07.480
<v Speaker 2>Yes, they can be rendered on the server, fetch data

583
00:28:07.519 --> 00:28:11.000
<v Speaker 2>directly on the server, even accessing databases or file systems,

584
00:28:11.440 --> 00:28:14.759
<v Speaker 2>and then their rendered output, which isn't interactive React components

585
00:28:14.759 --> 00:28:17.160
<v Speaker 2>more like a description of the UI is streamed to

586
00:28:17.200 --> 00:28:17.599
<v Speaker 2>the client.

587
00:28:17.720 --> 00:28:18.920
<v Speaker 1>What's the big advantage?

588
00:28:19.000 --> 00:28:21.799
<v Speaker 2>Their code never ships to the browser, zero impact on

589
00:28:21.799 --> 00:28:25.319
<v Speaker 2>your client bundle size. This makes apps potentially much faster

590
00:28:25.400 --> 00:28:29.720
<v Speaker 2>and lighter. Plus direct back end access simplifies data fetching drastically.

591
00:28:29.960 --> 00:28:33.079
<v Speaker 1>But they can't use state or effects right since their

592
00:28:33.200 --> 00:28:34.039
<v Speaker 1>server only.

593
00:28:33.960 --> 00:28:37.200
<v Speaker 2>Correct no use state, use effects, no browser APIs. They

594
00:28:37.240 --> 00:28:41.319
<v Speaker 2>are purely for rendering UI based on server side data

595
00:28:41.400 --> 00:28:46.440
<v Speaker 2>or logic. Interactivity comes from client components. Use client nested

596
00:28:46.480 --> 00:28:48.319
<v Speaker 2>within or alongside them.

597
00:28:48.400 --> 00:28:52.759
<v Speaker 1>Okay, rscs for server only rendering and data fetching. What

598
00:28:52.920 --> 00:28:56.359
<v Speaker 1>about changing data on the server form submissions?

599
00:28:56.400 --> 00:28:58.839
<v Speaker 2>That's where server actions come in. These are functions you

600
00:28:58.839 --> 00:29:01.799
<v Speaker 2>can define that are guarantee to run only on the server,

601
00:29:01.960 --> 00:29:03.759
<v Speaker 2>even if triggered from a client component.

602
00:29:03.839 --> 00:29:04.599
<v Speaker 1>How do you define them?

603
00:29:04.680 --> 00:29:07.720
<v Speaker 2>You write an ACYNC function and put the directive use

604
00:29:07.799 --> 00:29:09.880
<v Speaker 2>server at the very top of the function.

605
00:29:09.640 --> 00:29:12.200
<v Speaker 1>Body use server inside the function.

606
00:29:12.400 --> 00:29:14.920
<v Speaker 2>Yes, This marks it as a server action. You can

607
00:29:14.960 --> 00:29:17.640
<v Speaker 2>then pass this function down as a prop, maybe to

608
00:29:17.680 --> 00:29:20.200
<v Speaker 2>the action prop of a form, or call it from

609
00:29:20.240 --> 00:29:22.680
<v Speaker 2>an event handler and a client component. When invoked, the

610
00:29:22.720 --> 00:29:24.839
<v Speaker 2>function executes securely on the server.

611
00:29:24.640 --> 00:29:26.680
<v Speaker 1>So you can update a database directly from a server

612
00:29:26.720 --> 00:29:28.400
<v Speaker 1>action triggered by a button click.

613
00:29:28.440 --> 00:29:31.799
<v Speaker 2>Exactly without manually setting up API m points for simple

614
00:29:31.880 --> 00:29:35.759
<v Speaker 2>mutations React handles as a secure communication. You can use

615
00:29:35.799 --> 00:29:39.480
<v Speaker 2>hooks like use action state new and React nineteen in

616
00:29:39.559 --> 00:29:43.960
<v Speaker 2>client components to easily handle pending states and displieve validation

617
00:29:44.119 --> 00:29:45.440
<v Speaker 2>error's return from the server action.

618
00:29:45.599 --> 00:29:49.519
<v Speaker 1>Wow. Rsees and server actions really do blur the lines.

619
00:29:50.000 --> 00:29:53.359
<v Speaker 1>But what about more traditional client side routing for complex

620
00:29:53.400 --> 00:29:56.599
<v Speaker 1>single page apps spas? Does that still have a place.

621
00:29:56.920 --> 00:30:00.359
<v Speaker 2>Absolutely, While frameworks like next jas handle routing if you're

622
00:30:00.359 --> 00:30:03.720
<v Speaker 2>building a pure client side SPA or need more granular control,

623
00:30:04.079 --> 00:30:07.279
<v Speaker 2>React router is still the go to library React router.

624
00:30:07.559 --> 00:30:09.240
<v Speaker 1>How does it handle data loading? Now?

625
00:30:09.319 --> 00:30:12.000
<v Speaker 2>It's evolved a lot. Modern React Router heavily promotes using

626
00:30:12.079 --> 00:30:15.200
<v Speaker 2>loader functions associated with your routes loaders. Yeah, you define

627
00:30:15.200 --> 00:30:17.240
<v Speaker 2>a loader function for a route. React router calls this

628
00:30:17.319 --> 00:30:20.359
<v Speaker 2>function before your component even renders. It can fetch data,

629
00:30:20.559 --> 00:30:23.119
<v Speaker 2>and then the component accesses that data using the use

630
00:30:23.160 --> 00:30:24.640
<v Speaker 2>loader data so.

631
00:30:24.519 --> 00:30:27.559
<v Speaker 1>The data is ready before render. No loading spinners in

632
00:30:27.599 --> 00:30:28.559
<v Speaker 1>the component.

633
00:30:28.359 --> 00:30:33.000
<v Speaker 2>Often Yes, it simplifies component logic because the data is

634
00:30:33.079 --> 00:30:36.319
<v Speaker 2>just there, no need to manage loading and error states

635
00:30:36.440 --> 00:30:39.319
<v Speaker 2>for that initial fetch within the component itself.

636
00:30:39.440 --> 00:30:40.559
<v Speaker 1>What about submitting data?

637
00:30:40.960 --> 00:30:43.720
<v Speaker 2>React rider has action functions too similar In concept of

638
00:30:43.759 --> 00:30:47.720
<v Speaker 2>server actions but running client side or potentially p posting

639
00:30:47.759 --> 00:30:51.839
<v Speaker 2>to an endpoint. You usually trigger these using React router's

640
00:30:51.839 --> 00:30:56.160
<v Speaker 2>own form component, which prevents default browser navigation. Actions can

641
00:30:56.200 --> 00:30:59.119
<v Speaker 2>return data or trigger redirects using redirect.

642
00:30:58.799 --> 00:30:59.559
<v Speaker 1>And error handling.

643
00:30:59.640 --> 00:31:02.079
<v Speaker 2>It has robust error handling. You can define an air

644
00:31:02.200 --> 00:31:05.359
<v Speaker 2>element for routes and use the use root error hook

645
00:31:05.440 --> 00:31:08.240
<v Speaker 2>inside that element to display meaningful air information.

646
00:31:08.480 --> 00:31:12.119
<v Speaker 1>So React router provides data loading, submission, and airror handling

647
00:31:12.160 --> 00:31:14.119
<v Speaker 1>tied to Ritz exactly.

648
00:31:13.680 --> 00:31:16.599
<v Speaker 2>And you can combine its features with newer React capabilities too.

649
00:31:16.839 --> 00:31:19.880
<v Speaker 2>For example, you might use reacts use optimistic hook within

650
00:31:19.920 --> 00:31:23.079
<v Speaker 2>a component to show immediate UI feedback while iraq router

651
00:31:23.160 --> 00:31:25.880
<v Speaker 2>action runs in the background, or use React routers de

652
00:31:25.880 --> 00:31:28.319
<v Speaker 2>fer utility and a weight component to stream data that

653
00:31:28.440 --> 00:31:32.880
<v Speaker 2>might be slow rendering fallback UI while waiting, improving perceived performance.

654
00:31:33.160 --> 00:31:36.440
<v Speaker 1>Okay, lots of powerful tools. Combining there few, we've covered

655
00:31:36.480 --> 00:31:39.319
<v Speaker 1>a massive amount of ground. We went from the basic

656
00:31:39.400 --> 00:31:43.359
<v Speaker 1>problem React solves escaping imperative dominipulation all the way through

657
00:31:43.400 --> 00:31:47.839
<v Speaker 1>components prop state effects, optimization techniques like memmorization and lazy loading,

658
00:31:48.039 --> 00:31:51.680
<v Speaker 1>and then into the full stack world with SSR next JS, React,

659
00:31:51.720 --> 00:31:55.000
<v Speaker 1>server components, server actions, and advance client side routing with

660
00:31:55.119 --> 00:31:58.680
<v Speaker 1>React router. If we try and connect this all to

661
00:31:58.720 --> 00:32:01.519
<v Speaker 1>the bigger picture. For some when listening, they now have

662
00:32:01.640 --> 00:32:06.400
<v Speaker 1>this incredible toolkit conceptually and practically to build really interactive,

663
00:32:06.480 --> 00:32:10.039
<v Speaker 1>really performant web applications. But this raises a question for me.

664
00:32:10.079 --> 00:32:13.079
<v Speaker 1>Looking at things like server components, server actions, the tight

665
00:32:13.119 --> 00:32:16.279
<v Speaker 1>integration and frameworks like next JS, where do you see

666
00:32:16.319 --> 00:32:19.079
<v Speaker 1>that line between front end and back end development blurring

667
00:32:19.119 --> 00:32:21.400
<v Speaker 1>the most for React developers in the next few years.

668
00:32:21.440 --> 00:32:23.359
<v Speaker 1>What's the biggest shift you see coming from all this.

669
00:32:23.680 --> 00:32:26.720
<v Speaker 2>That's a great question. I think the biggest shift is

670
00:32:26.720 --> 00:32:30.400
<v Speaker 2>that the React developer is increasingly becoming a product engineer

671
00:32:30.599 --> 00:32:33.200
<v Speaker 2>who needs to be comfortable thinking across the entire stack,

672
00:32:33.559 --> 00:32:37.359
<v Speaker 2>from UI interactions right down to data fetching and mutations

673
00:32:37.400 --> 00:32:41.319
<v Speaker 2>on the server, server components and actions especially pull back

674
00:32:41.440 --> 00:32:44.400
<v Speaker 2>end concerns much closer to the UI code. The lines

675
00:32:44.440 --> 00:32:48.000
<v Speaker 2>are blurring significantly. You're writing server logic right alongside your

676
00:32:48.000 --> 00:32:51.400
<v Speaker 2>component logic. While you still need specialists. The average React

677
00:32:51.440 --> 00:32:54.920
<v Speaker 2>developer will likely need a broader understanding than before, but

678
00:32:55.000 --> 00:32:58.039
<v Speaker 2>the payoff is potentially much faster development cycles. And more

679
00:32:58.079 --> 00:33:00.920
<v Speaker 2>seamless features. But at the end of the day, my best

680
00:33:00.920 --> 00:33:05.000
<v Speaker 2>advice for anyone listening is simply practice is key. Theory

681
00:33:05.119 --> 00:33:07.000
<v Speaker 2>is great, but you need to build things.

682
00:33:07.119 --> 00:33:07.680
<v Speaker 1>Absolutely.

683
00:33:07.759 --> 00:33:10.559
<v Speaker 2>You should definitely try building small demo projects. Maybe a

684
00:33:10.599 --> 00:33:14.119
<v Speaker 2>shopping cart app that hits state lists, maybe some effects.

685
00:33:14.440 --> 00:33:18.200
<v Speaker 2>An authentication system great for forms state maybe context or

686
00:33:18.240 --> 00:33:21.559
<v Speaker 2>custom books. Even an event management website could involve routing,

687
00:33:21.880 --> 00:33:24.839
<v Speaker 2>data fetching, maybe server components. If you use NEXTJS.

688
00:33:24.960 --> 00:33:26.880
<v Speaker 1>Good project ideas.

689
00:33:26.400 --> 00:33:29.079
<v Speaker 2>And as you build, remember you don't have to reinvent

690
00:33:29.079 --> 00:33:33.839
<v Speaker 2>the wheel. Explore the ecosystem. Libraries like tan stack Query

691
00:33:34.039 --> 00:33:38.000
<v Speaker 2>or React query are fantastic for complex data fetching, caching

692
00:33:38.039 --> 00:33:42.000
<v Speaker 2>and synchronization, Simmer Motion for animations, react to form or

693
00:33:42.000 --> 00:33:45.440
<v Speaker 2>forma for complex forms, and for global state management. Beyond

694
00:33:45.440 --> 00:33:49.240
<v Speaker 2>simple prop drilling or context libraries like redoct zoos, standard

695
00:33:49.279 --> 00:33:52.160
<v Speaker 2>Joe tie are popular choices. Leverage these tools.

696
00:33:52.279 --> 00:33:55.640
<v Speaker 1>Fantastic advice, build things, explore the ecosystem. Well, thank you

697
00:33:55.720 --> 00:33:57.799
<v Speaker 1>for joining us on this really deep dive into React.

698
00:33:57.839 --> 00:34:01.440
<v Speaker 1>For everyone listening, keep building, keep exploring, and keep learning.
