-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path09.jsx.html.html
More file actions
84 lines (77 loc) · 2.05 KB
/
09.jsx.html.html
File metadata and controls
84 lines (77 loc) · 2.05 KB
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
84
<!DOCTYPE html>
<html>
<head>
<title>HTML vs JSX</title>
<meta charset="utf-8" />
<style>
body {
font-family: -apple-system, sans-serif;
}
a {
cursor: pointer;
}
</style>
</head>
<body>
<div id="app1"></div>
<div id="app2"></div>
<div id="app3"></div>
<div id="app4"></div>
<script src="react/react.js"></script>
<script src="react/react-dom.js"></script>
<script src="react/babel.js"></script>
<script type="text/babel">
function InvalidExample() {
const em = <em class="important" />;
const label = <label for="thatInput" />;
return (
<div>
{em}
{label}
</div>
);
}
function Example() {
const em = <em className="important" />;
const label = <label htmlFor="thatInput" />;
return (
<div>
{em}
{label}
</div>
);
}
function InvalidStyle() {
return <em style="font-size: 2em; line-height: 1.6" />;
}
function ValidStyle() {
const styles = {
fontSize: "2em",
lineHeight: "1.6",
};
return <em style={styles}>Valid style</em>;
}
function InlineStyle() {
return <em style={{ fontSize: "2em", lineHeight: "1.6" }}>Inline style</em>;
}
function reticulateSplines() {
alert("Will do!");
}
function Camel() {
const invalid = <a onclick="reticulateSplines()">nothing happens</a>;
const valid = <a onClick={reticulateSplines}>something happens</a>;
return (
<span>
{invalid}
<br />
{valid}
</span>
);
}
ReactDOM.render(<Example />, document.getElementById("app1"));
ReactDOM.render(<ValidStyle />, document.getElementById("app2"));
ReactDOM.render(<InlineStyle />, document.getElementById("app3"));
ReactDOM.render(<Camel />, document.getElementById("app4"));
</script>
</body>
</html>