-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
83 lines (75 loc) · 2.79 KB
/
index.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
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
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- https://babeljs.io/setup#installation -->
<script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
<!-- https://reactjs.org/docs/cdn-links.html -->
<script crossorigin src="https://unpkg.com/react@17/umd/react.development.js"></script>
<script crossorigin src="https://unpkg.com/react-dom@17/umd/react-dom.development.js"></script>
<title>Hello World!</title>
</head>
<!--
Browser Plugin: React Developer Tools
NEXT: https://github.com/facebook/create-react-app
-->
<body>
<div id="app"></div>
<script type="text/babel">
class App extends React.Component {
state = {
name: 'Sudhu',
age: 35
}
handleClick = (e) => {
// console.log(e.target);
console.log(this.state)
// this.state.name = "Don't Do THIS!"
this.setState({
name: 'Manjunath',
age: 18
})
}
handleMouseOver(e) {
console.log(e);
console.log(e.target, e.pageX);
}
handleCopy(e) {
console.log('Try being original for once!');
}
handleChange = (e) => {
this.setState({
name: e.target.value
})
}
handleSubmit = (e) => {
e.preventDefault()
console.log("Form Submitted", this.state.name)
}
render() {
return (
<div className="app-content">
<h1>Hello world!</h1>
<p>Random Number: {Math.random() * 10}</p>
<p>My name is {this.state.name} and I'm {this.state.age}</p>
<div>
<p>Click Event</p>
<button onClick={this.handleClick}>Click Me</button>
<button onMouseOver={this.handleMouseOver}>Hover Me</button>
<p onCopy={this.handleCopy}>What we think, we become.</p>
</div>
<div>
<form onSubmit={this.handleSubmit}>
<input type="text" onChange={this.handleChange} />
<button>Submit</button>
</form>
</div>
</div>
);
}
}
ReactDOM.render(<App />, document.getElementById('app'));
</script>
</body>
</html>