-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmyWork
268 lines (161 loc) · 4.1 KB
/
myWork
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
Date:14/Mar/2022
React RoadMap:
Today Revision Topics:
JSX
Components:
functional components
class components
Props VS State
Functional COmponents:
Basic Syntax
function User()
{
return(
<div>
<h1>USer Component </h1
<h1>Hello</h1>
</div>
)
}
export default User;
we can also use User Component in App.Js
Like that:
import User from './User'
<User />
if we not use export content so, we can use this syntax
import {User} from './User'
we can also use function component in App.js
Class Components
import React,{Component} from 'react'
export default class User extends Component
{
render()
{
return (
<h1> Hello from USer </h1>
)
}
}
Click event fucntion:
change krne kay liye hamara normal variable se kaam nhi chaltha tbhi state & props use krthy hai
Date: 20/04/2022
State in Functional Components:
State is property of React & Var is property of Javascript
(State me data update hojatha hai variable kyy case me update ni hota)
imort {useState} from 'react'
import logo from './logo.svg';
import './App.css';
function App() {
const [data,setData]=useState(0)
function updateData()
{
setData(data+1)
}
return (
<div className="App">
<h1>{data}</h1>
<button onCLick={updateData}>Update Data</button>
</div>
);
}
export default App;
varibale me component update nhi hota state me update hojatha hai
Interview Q:
State ko component se bahir use nhi krskty (Dusray Tareqqay se krskty hai)
State is public
Props:
in props component are resusable and use from outside the component
to give data to Component
Student.JS
function Student(props) {
console.log(props)
return (
<div style={{ backgroundColor: "skyblue", margin: 10 }}>
<h1> Hello {props.name}</h1>
<h2> Email : {props.email}</h2>
<h3> Adress : {props.other.adress}</h3>
</div>
)
}
export default Student
in App.Js
import Student from './Student'
function App() {
return (
<div className="App"
<h1>Props in react :)</h1>
<Student name={'anil'} email="jnu.prepare@gmail.com" />
<Student name={'Joseph'} email="Aut.design@gmail.com" />
<Student name={'Huion'} email="gop.fox@gmail.com" />
</div>
);
}
export default App;
To update data
we can use this Syntax
function App() {
const [name,setName]=useState("Anil")
return ()
<div className="App">
<h1>Props in React :)</h1>
<Student name={name}/>
<button onClick={()=>{setName("sidhu")}} >Update Name</button>
</div>
);
}
export default App;
}
Life cycle Methods:
Mounting Birth lena
Updating LIfe CHange
Unmounting End
Load Product
Update Product
Remove Product
Cycle will change every time
Mounting:
first constructor bntha hai before rendring
after that render hotha hai
Phir component DidMount call hoga
Constructor me
hum props ko use krskthy hai
Render method class me bntha hai
Render method state or props ko update krny kay lye use hotha hai and jb component bntha hai by default atha hai
render me state update nhi hogi
Component DidMount:
Use for API and hide show krwana hai or html pr depend ho
INterview QUESTION:
STATE UPDATE krwa skty hai
Component DidUpdate
past state ya current state similar hai ya dfifrent hai
we can put the condition also
API call krskthy hai conditonal hogi
without conditon degyyy toh infinite loop me chla jaye ga
Should Component Update: unique conmponent
agar hum chathy hai render method dobara call na ho
application ki perfomace enhance hogi cause of rendering method brr brr ni call hoga
agar ye true hoga then componentDidUpdate chlyy ga agar false hoga to nhi chlyy ga
Component willUnmount: we need two components
remove ko visible kyy ga ya visible ko remove kryy ga
Parent component me se child component render hoga ComponentWillUnmount wala bs Class component hoga
Hooks:
hm isliye use krsthy hai because lifecycle me hmmm function component use nhi krksty
Javascript:
Basic Syntax
UPPER CASE
l ower case
Datatypes
1) String var x = "Hello World"
2) Number var x = 25
3) Boolean var x = true
4) Array vare x = [14,15,16]
5) Object var x = {First: "Jane", Second: "Hassan", Last: "Asim"}
6) Null
7) Undefined
J.s String Methods
Length
toLowerCase()
toUpperCase()
Includes()
Forloop:
for(var a = 0; a <=4; a++)