-
Notifications
You must be signed in to change notification settings - Fork 4
/
Lab6(StatesAndProps).html
51 lines (48 loc) · 1.34 KB
/
Lab6(StatesAndProps).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
<!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>
<script type="text/babel">
class FirstComponent extends React.Component {
constructor() {
super();
this.state = {
count: 0,
customer : {
name:"",
address:""
}
};
}
updateCount() {
this.setState((prevState, props) => {
return {
count: prevState.count + 1
}
});
}
render() {
return (
<div>
<button onClick={() => this.updateCount()}>
Clicked {this.state.count} times
</button><br/>
<h1> Comp1 {this.props.name}</h1>
</div>
);
}
}
ReactDOM.render(
<FirstComponent name="dddddd"/>,
document.getElementById('app')
);
</script>
</body>
</html>