-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
78 lines (67 loc) · 1.62 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
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>React tutorial </title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.14.7/react.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.14.7/react-dom.js"></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">
var FirstComponent = React.createClass({
render: function(){
return (
<div>
<h1>This is our first component </h1>
<h2>Hello again!</h2>
</div>
)
}
});
var SecondComponent = React.createClass({
// propTypes funkar bara i development mode men inte prodution mode.
propTypes:{
name: React.PropTypes.string.isRequired,
location: React.PropTypes.string.isRequired
},
getDefaultProps: function(){
return {
name: 'Peter',
location: 'New York'
}
},
render: function(){
let name = this.props.name;
let location = this.props.location;
return (
<div>
<p>Hello {name}!</p>
<p>I live in {location}</p>
</div>
);
}
});
/* SecondComponent.propTypes = {
name: React.PropTypes.number
} */
ReactDOM.render(
<SecondComponent location="Cambridge"/>,
document.getElementById('app')
);
// ReactDOM.render(
// <h1>Hello world, this is written is JSX!</h1>,
// document.getElementById('app')
// );
// ReactDOM.render(
// React.createElement(
// 'h1',
// null,
// 'Hello World!'
// ),
// document.getElementById('app')
// );
</script>
</body>
</html>