-
Notifications
You must be signed in to change notification settings - Fork 4
/
Lab4(FunctionalComponents).html
54 lines (53 loc) · 1.36 KB
/
Lab4(FunctionalComponents).html
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
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>React tutorial</title>
<script src="https://unpkg.com/react@17/umd/react.development.js" crossorigin></script>
<script src="https://unpkg.com/react-dom@17/umd/react-dom.development.js" crossorigin></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.8.2/browser.min.js"></script>
</head>
<body>
<div id="app"></div><br>
<div id="app1"></div><br>
<script type="text/babel">
class ClassComponent extends React.Component {
CallMe(){
alert("Hello");
}
render()
{
return(
<div>
<button onClick={this.CallMe}>
Class calls
</button>
<h1> class </h1>
</div>
);
}
}
function FirstComponent() {
function CallMe(){
alert("Hello");
}
return(
<div>
<button onClick={CallMe}>
Functions call
</button>
<h1> Functions </h1>
</div>
);
}
ReactDOM.render(
<FirstComponent />,
document.getElementById('app')
);
ReactDOM.render(
<ClassComponent />,
document.getElementById('app1')
);
</script>
</body>
</html>