Skip to content

Commit e09099e

Browse files
Add files via upload
1 parent 786e8d5 commit e09099e

9 files changed

+136
-5
lines changed

Lab2(JsxAndBabel).html

+5-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@
1212
<div id="app"></div>
1313
<script type="text/babel">
1414
ReactDOM.render(
15-
<h1>Hello world, this is written is JSX!</h1>,
15+
<div>
16+
<h1>Hello world, this is written is JSX!</h1>
17+
<p> Hello </p>
18+
</div>
19+
,
1620
document.getElementById('app')
1721
);
1822
</script>

Lab21.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Deloyment

Lab22.txt

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
import logo from './logo.svg';
2+
import './App.css';
3+
import React, { useState } from "react";
4+
5+
function App() {
6+
const [customer, _setCustomer] = useState({ name: "", code: "" });
7+
const [customers, _setCustomers] = useState([]);
8+
9+
const setCustomer = e => {
10+
_setCustomer(prevState => ({
11+
...prevState,
12+
[e.target.name]: e.target.value
13+
}));
14+
};
15+
const setCustomers = e => {
16+
_setCustomers(prevState => (
17+
[...prevState, customer]
18+
));
19+
20+
_setCustomer(prevState => ({
21+
...prevState,
22+
name: "", code: ""
23+
}));
24+
25+
fetch('https://localhost:44393/Home/Submit', {
26+
method: 'POST',
27+
headers: {
28+
'Accept': 'application/json',
29+
'Content-Type': 'application/json',
30+
},
31+
body: JSON.stringify(customer)
32+
})
33+
};
34+
return (
35+
<div className="App">
36+
{customer.name} {customer.code}
37+
<input value={customer.name} onChange={setCustomer} type="text" name="name"/>
38+
<input value={customer.code} onChange={setCustomer} type="text" name="code"/>
39+
<input value="Add" type="button" onClick={setCustomers}/><br>
40+
</br>
41+
<table>
42+
<thead>
43+
<tr>
44+
<td>Name</td>
45+
<td>code</td>
46+
</tr>
47+
</thead>
48+
<tbody>
49+
{customers.map((x,index) => (
50+
<tr key={index}>
51+
<td>{x.name}</td>
52+
<td>{x.code}</td>
53+
</tr>
54+
))}
55+
</tbody>
56+
</table>
57+
</div>
58+
);
59+
}
60+
61+
export default App;

Lab4(FunctionalComponents).html

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
class ClassComponent extends React.Component {
1515
CallMe(){
1616
alert("Hello");
17+
1718
}
1819
render()
1920
{
@@ -40,7 +41,6 @@ <h1> Functions </h1>
4041
</div>
4142
);
4243
}
43-
4444
ReactDOM.render(
4545
<FirstComponent />,
4646
document.getElementById('app')

Lab6(LambdaExpressions).html

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<body>
99
<script>
1010
var arr = [1,2,3,4];
11-
var t1 = arr.filter(value => value > 3);
11+
var t1 = arr.filter((value) => value > 3);
1212

1313
console.log(t1);
1414
</script>

Lab7(FunctionStatesandProps).html

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212

1313
<script type="text/babel">
1414
function FirstComponent(props){
15-
const [counter, increment] = React.useState(0);
15+
const [counter, increment] = React.useState(10);
1616
const increm = event => increment(counter + 1);
17-
17+
// props.name = "hello";
1818
return(
1919
<div>
2020
<p>{props.name}</p>

Lab9(LifeCyclewithFunctions).html

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="UTF-8" />
5+
<title>React tutorial</title>
6+
<script src="https://unpkg.com/react@17/umd/react.development.js" crossorigin></script>
7+
<script src="https://unpkg.com/react-dom@17/umd/react-dom.development.js" crossorigin></script>
8+
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.8.2/browser.min.js"></script>
9+
</head>
10+
<body>
11+
<a href="SomePage.html">Some page</a><br>
12+
<div id="app"></div><br>
13+
14+
<script type="text/babel">
15+
function FirstComponent(props){
16+
const [counter, increment] = React.useState(0);
17+
const increm = event => increment(counter+1);
18+
19+
React.useEffect(() => {
20+
console.log("Component loaded");
21+
}, []);
22+
23+
React.useEffect(() => {
24+
console.log("Any change....");
25+
});
26+
27+
React.useEffect(() => {
28+
console.log("Only conter value changed");
29+
}, [counter]);
30+
31+
React.useEffect(() => {
32+
return () => {
33+
alert("Component unloaded");
34+
}
35+
}, []);
36+
37+
return(
38+
<div>
39+
<p>{props.name}</p>
40+
<p>{counter}</p>
41+
<button onClick={increm}>Click</button>
42+
</div>
43+
)
44+
}
45+
ReactDOM.render(
46+
<FirstComponent name="Shiv"/>,
47+
document.getElementById('app')
48+
);
49+
50+
</script>
51+
</body>
52+
</html>

SomePage.html

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="UTF-8" />
5+
<title>React tutorial</title>
6+
<script src="https://unpkg.com/react@17/umd/react.development.js" crossorigin></script>
7+
<script src="https://unpkg.com/react-dom@17/umd/react-dom.development.js" crossorigin></script>
8+
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.8.2/browser.min.js"></script>
9+
</head>
10+
<body>
11+
Some page
12+
</body>
13+
</html>

my-app.zip

428 KB
Binary file not shown.

0 commit comments

Comments
 (0)