-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
53 lines (51 loc) · 1.96 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
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>React Tutorial</title>
<script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
<script crossorigin src="https://unpkg.com/react@16/umd/react.development.js"></script>
<script crossorigin src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"></script>
</head>
<body>
<div id="app">
</div>
<script type="text/babel">
class App extends React.Component{
state = {
name: 'Ceci',
age: 25
}
handleClick = (e) => {
//arrow funtions takes the value of this to be the component it is in and bind it
//this will also let you change the state inside these type of functions
// console.log(e.target);
this.setState({
name: 'yoshi'
});
console.log(this.state);
}
handleMouseOver = (e) =>{
console.log(e.target, e.pageX);
}
handleCopy = (e) =>{
console.log('Try being original for once');
}
render(){
return (
<div className="app-content">
<h1>Hi</h1>
<p>My name is: { this.state.name }</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>
)
}
}
ReactDOM.render(
<App />, document.getElementById("app")
)
</script>
</body>
</html>