-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunction-class.html
53 lines (45 loc) · 1.18 KB
/
function-class.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>My Second React App</title>
</head>
<body>
<div id="app"></div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/16.1.0/umd/react.development.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.1.0/umd/react-dom.development.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.8.34/browser.min.js"></script>
<script type="text/babel">
const elementFun = (
<h1>
This is a functional component.
</h1>
);
function TypeFun() {
return elementFun;
}
class TypeCla extends React.Component {
render() {
const headStyle = {
color:"green"
}
return <h1 style={headStyle}>This is a class component.</h1>;
}
}
class App extends React.Component {
render() {
return (
<div>
<TypeFun />
<TypeCla />
</div>
);
}
}
ReactDOM.render(
<App />,
document.getElementById('app')
);
</script>
</body>
</html>